X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fext%2Farchaeopteryx%2FAptxInit.java;h=b9a2266f49651437ac5f250513c4246e232b66b3;hb=ccbd3e0bfd34533d8e98b7ef9a6cb48d9684b3da;hp=da18a60a2dab8c4b0627dc3c1da59b7d33f6df28;hpb=66bafd3a951e3365d766726c1a59a2bbff15e8f1;p=jalview.git diff --git a/src/jalview/ext/archaeopteryx/AptxInit.java b/src/jalview/ext/archaeopteryx/AptxInit.java index da18a60..b9a2266 100644 --- a/src/jalview/ext/archaeopteryx/AptxInit.java +++ b/src/jalview/ext/archaeopteryx/AptxInit.java @@ -24,7 +24,6 @@ import org.forester.archaeopteryx.Configuration; import org.forester.archaeopteryx.MainFrame; import org.forester.archaeopteryx.webservices.PhylogeniesWebserviceClient; import org.forester.archaeopteryx.webservices.WebserviceUtil; -import org.forester.archaeopteryx.webservices.WebservicesManager; import org.forester.io.parsers.PhylogenyParser; import org.forester.io.parsers.nexus.NexusPhylogeniesParser; import org.forester.io.parsers.nhx.NHXParser; @@ -47,9 +46,9 @@ import org.forester.util.ForesterUtil; */ public final class AptxInit { - private final static Configuration APTX_CONFIG = new Configuration( - "_aptx_jalview_configuration_file", false, false, false); + "_aptx_jalview_configuration_file", + false, false, false); private final static boolean VALIDATE_PHYLOXML_XSD = APTX_CONFIG .isValidatePhyloXmlAgainstSchema(); @@ -130,12 +129,11 @@ public final class AptxInit } else if (parser instanceof PhyloXmlParser) { - if ( VALIDATE_PHYLOXML_XSD ) { - JvOptionPane.showInternalMessageDialog( null, - ForesterUtil.wordWrap( - "phyloXML XSD-based validation is turned off [enable with line 'validate_against_phyloxml_xsd_schem: true' in configuration file]", - 80 ), - "Warning", + if (VALIDATE_PHYLOXML_XSD == false) + { + JvOptionPane.showInternalMessageDialog(Desktop.desktop, + MessageManager.getString("error.phyloxml_validation"), + MessageManager.getString("label.file_open_error"), JvOptionPane.WARNING_MESSAGE ); } } @@ -202,21 +200,13 @@ public final class AptxInit * @param viewport * @return */ - public static MainFrame[] createInstancesFromDb(int databaseIndex, + public static MainFrame[] createInstancesFromDb( + PhylogeniesWebserviceClient treeDbClient, String identifier, AlignmentViewport viewport) { URL url = null; Phylogeny[] trees = null; - final WebservicesManager webservices_manager = WebservicesManager - .getInstance(); - final PhylogeniesWebserviceClient client = webservices_manager - .getAvailablePhylogeniesWebserviceClient(databaseIndex); - String identifier = JvOptionPane.showInternalInputDialog( - Desktop.desktop, - client.getInstructions() + "\n(Reference: " - + client.getReference() + ")", - client.getDescription(), JvOptionPane.QUESTION_MESSAGE); if ((identifier != null) && (identifier.trim().length() > 0)) { @@ -226,7 +216,7 @@ public final class AptxInit } identifier = identifier.trim(); - if (client.isQueryInteger()) + if (treeDbClient.isQueryInteger()) { identifier = identifier.replaceAll("^\\D+", ""); @@ -237,8 +227,11 @@ public final class AptxInit } catch (final NumberFormatException e) { JvOptionPane.showInternalMessageDialog(Desktop.desktop, - "Identifier is expected to be a number", - "Can not open URL", JvOptionPane.ERROR_MESSAGE); + MessageManager.formatMessage( + "error.database_id_has_letters", new String[] + { identifier }), + MessageManager.getString("label.invalid_url"), + JvOptionPane.ERROR_MESSAGE); return new MainFrame[0]; } identifier = id + ""; @@ -246,12 +239,12 @@ public final class AptxInit boolean exception = false; try { - String url_str = client.getUrl(); + String url_str = treeDbClient.getUrl(); url_str = url_str.replaceFirst( PhylogeniesWebserviceClient.QUERY_PLACEHOLDER, identifier); url = new URL(url_str); PhylogenyParser parser = null; - switch (client.getReturnFormat()) + switch (treeDbClient.getReturnFormat()) { case TOL_XML_RESPONSE: parser = new TolParser(); @@ -305,7 +298,7 @@ public final class AptxInit break; default: throw new IllegalArgumentException( - "unknown format: " + client.getReturnFormat()); + "unknown format: " + treeDbClient.getReturnFormat()); } // // if (_main_frame.getMainPanel().getCurrentTreePanel() != null) @@ -321,26 +314,32 @@ public final class AptxInit { exception = true; JvOptionPane.showInternalMessageDialog(Desktop.desktop, - "Malformed URL: " + url + "\n" + e.getLocalizedMessage(), - "Malformed URL", JvOptionPane.ERROR_MESSAGE); + MessageManager.formatMessage( + "exception.unable_to_launch_url", new String[] + { url.toString() }), + MessageManager.getString("label.invalid_url"), + JvOptionPane.ERROR_MESSAGE); + System.err.println(e.getLocalizedMessage()); } catch (final IOException e) { exception = true; JvOptionPane.showInternalMessageDialog(Desktop.desktop, "Could not read from " + url + "\n" + e.getLocalizedMessage(), - "Failed to read tree from " + client.getName() + " for " + "Failed to read tree from " + treeDbClient.getName() + " for " + identifier, JvOptionPane.ERROR_MESSAGE); + System.err.println(e.getLocalizedMessage()); } catch (final NumberFormatException e) { exception = true; JvOptionPane.showInternalMessageDialog(Desktop.desktop, "Could not read from " + url + "\n" + e.getLocalizedMessage(), - "Failed to read tree from " + client.getName() + " for " + "Failed to read tree from " + treeDbClient.getName() + " for " + identifier, JvOptionPane.ERROR_MESSAGE); + System.err.println(e.getLocalizedMessage()); } catch (final Exception e) { exception = true; @@ -348,16 +347,7 @@ public final class AptxInit JvOptionPane.showInternalMessageDialog(Desktop.desktop, e.getLocalizedMessage(), "Unexpected Exception", JvOptionPane.ERROR_MESSAGE); - } finally - { - // if (_main_frame.getCurrentTreePanel() != null) - // { - // _main_frame.getCurrentTreePanel().setArrowCursor(); - // } - // else - // { - // _main_frame.getMainPanel().setArrowCursor(); - // } + System.err.println(e.getLocalizedMessage()); } if ((trees != null) && (trees.length > 0)) { @@ -365,16 +355,16 @@ public final class AptxInit { if (!phylogeny.isEmpty()) { - if (client.getName().equals(WebserviceUtil.TREE_FAM_NAME)) + if (treeDbClient.getName().equals(WebserviceUtil.TREE_FAM_NAME)) { phylogeny.setRerootable(false); phylogeny.setRooted(true); } - if (client.getProcessingInstructions() != null) + if (treeDbClient.getProcessingInstructions() != null) { try { - WebserviceUtil.processInstructions(client, phylogeny); + WebserviceUtil.processInstructions(treeDbClient, phylogeny); } catch (final PhyloXmlDataFormatException e) { JvOptionPane.showInternalMessageDialog(Desktop.desktop, @@ -382,12 +372,12 @@ public final class AptxInit JvOptionPane.ERROR_MESSAGE); } } - if (client.getNodeField() != null) + if (treeDbClient.getNodeField() != null) { try { PhylogenyMethods.transferNodeNameToField(phylogeny, - client.getNodeField(), false); + treeDbClient.getNodeField(), false); } catch (final PhyloXmlDataFormatException e) { JvOptionPane.showInternalMessageDialog(Desktop.desktop, @@ -396,7 +386,7 @@ public final class AptxInit } } phylogeny.setIdentifier( - new Identifier(identifier, client.getName())); + new Identifier(identifier, treeDbClient.getName())); // _main_frame.getJMenuBar().remove(_main_frame.getHelpMenu()); // _main_frame.getMenuBarOfMainFrame() // .add(_main_frame.getHelpMenu()); @@ -425,8 +415,8 @@ public final class AptxInit my_name_for_file = new String( sb.toString().replaceAll(" ", "_")); } - // _main_frame.getMainPanel().getCurrentTreePanel() - // .setTreeFile(new File(my_name_for_file)); + aptxApp.getMainPanel().getCurrentTreePanel() + .setTreeFile(new File(my_name_for_file)); AptxUtil.lookAtSomeTreePropertiesForAptxControlSettings( phylogeny, aptxApp.getMainPanel().getControlPanel(), APTX_CONFIG); @@ -436,7 +426,7 @@ public final class AptxInit } } } - else if (!exception) + else if (!exception) // ..what? { JvOptionPane.showMessageDialog(null, ForesterUtil.wordWrap( @@ -480,6 +470,23 @@ public final class AptxInit final Phylogeny aptxTree, final AlignmentViewport jalviewAlignport, String treeTitle) { + if (APTX_CONFIG == null || APTX_CONFIG.isCouldReadConfigFile() == false) + { + int keepGoing = JvOptionPane.showConfirmDialog(Desktop.desktop, + MessageManager.getString("label.aptx_config_not_found"), + MessageManager.formatMessage("label.couldnt_locate", + new String[] + { "_aptx_jalview_configuration_file" }), + JvOptionPane.YES_NO_CANCEL_OPTION); + + if (keepGoing == JvOptionPane.CANCEL_OPTION + || keepGoing == JvOptionPane.CLOSED_OPTION + || keepGoing == JvOptionPane.NO_OPTION) + { + return null; + } + + } MainFrame aptxApp = Archaeopteryx.createApplication(aptxTree, APTX_CONFIG, treeTitle); @@ -495,12 +502,6 @@ public final class AptxInit return aptxApp; } - // private static void addPartitioningSlider(MainFrame aptxFrame) - // { - // JSlider slider = new JSlider(); - // - // - // } public static ExternalTreeViewerBindingI bindNodesToJalviewSequences( final MainFrame aptxApp, @@ -544,5 +545,8 @@ public final class AptxInit return activeAptx; } + private static void disableRedundantGuiMenus() + { + } }