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;
}
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 );
}
}
* @param viewport
* @return
*/
- public static MainFrame[] createInstancesFromDb(int databaseIndex,
- AlignmentViewport viewport, String defaultIdentifier)
+ 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, null,
- null, defaultIdentifier).toString();
if ((identifier != null) && (identifier.trim().length() > 0))
{
}
identifier = identifier.trim();
- if (client.isQueryInteger())
+ if (treeDbClient.isQueryInteger())
{
identifier = identifier.replaceAll("^\\D+", "");
} 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 + "";
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();
break;
default:
throw new IllegalArgumentException(
- "unknown format: " + client.getReturnFormat());
+ "unknown format: " + treeDbClient.getReturnFormat());
}
//
// if (_main_frame.getMainPanel().getCurrentTreePanel() != null)
{
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;
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))
{
{
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,
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,
}
}
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());
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);
}
}
}
- else if (!exception)
+ else if (!exception) // ..what?
{
JvOptionPane.showMessageDialog(null,
ForesterUtil.wordWrap(
return aptxApp;
}
- // private static void addPartitioningSlider(MainFrame aptxFrame)
- // {
- // JSlider slider = new JSlider();
- //
- //
- // }
public static ExternalTreeViewerBindingI<?> bindNodesToJalviewSequences(
final MainFrame aptxApp,
import javax.swing.SwingUtilities;
import org.forester.archaeopteryx.MainFrame;
+import org.forester.archaeopteryx.webservices.PhylogeniesWebserviceClient;
+import org.forester.archaeopteryx.webservices.WebservicesManager;
/**
* DOCUMENT ME!
protected void loadTreePfam_actionPerformed(ActionEvent e)
{
- // only DBRefs of first sequence are checked for matching DB for now
+ // only DBRefs of first sequence are checked for matching DB for now,
+ // iterating through them all seems excessive
SequenceI seq = viewport.getAlignment().getSequenceAt(0);
String dbId = null;
for (DBRefEntry pfamRef : DBRefUtils
*/
public void chooseTreeDb(int databaseIndex, String defaultIdentifier)
{
- AptxInit.createInstancesFromDb(databaseIndex, viewport,
- defaultIdentifier);
+ 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,
+ null, null, defaultIdentifier)
+ .toString();
+
+ AptxInit.createInstancesFromDb(client, identifier, viewport);
}
public TreePanel showNewickTree(NewickFile nf, String treeTitle)