import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.Date;
import javax.swing.JOptionPane;
import org.forester.phylogeny.Phylogeny;
import org.forester.phylogeny.PhylogenyMethods;
import org.forester.phylogeny.data.Identifier;
-import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
-import org.forester.phylogeny.factories.PhylogenyFactory;
import org.forester.util.ForesterUtil;
public class UrlTreeReader implements Runnable {
}
synchronized void readPhylogeniesFromWebservice() {
- final long start_time = new Date().getTime();
URL url = null;
Phylogeny[] trees = null;
final WebservicesManager webservices_manager = WebservicesManager.getInstance();
final PhylogeniesWebserviceClient client = webservices_manager
.getAvailablePhylogeniesWebserviceClient( _webservice_client_index );
- String identifier = JOptionPane.showInputDialog( _main_frame, client.getInstructions() + "\n(Reference: "
+ String identifier = JOptionPane.showInputDialog( _main_frame.getThisFrame(), client.getInstructions() + "\n(Reference: "
+ client.getReference() + ")", client.getDescription(), JOptionPane.QUESTION_MESSAGE );
if ( ( identifier != null ) && ( identifier.trim().length() > 0 ) ) {
identifier = identifier.trim();
id = -1;
}
if ( id < 1 ) {
- JOptionPane.showMessageDialog( _main_frame,
+ JOptionPane.showMessageDialog( _main_frame.getThisFrame(),
"Identifier is expected to be a number",
"Can not open URL",
JOptionPane.ERROR_MESSAGE );
case PFAM:
parser = new NHXParser();
( ( NHXParser ) parser )
- .setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
+ .setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
( ( NHXParser ) parser ).setReplaceUnderscores( false );
( ( NHXParser ) parser ).setGuessRootedness( true );
break;
else {
_main_frame.getMainPanel().setWaitCursor();
}
- final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
- trees = factory.create( url.openStream(), parser );
+ trees = ForesterUtil.readPhylogeniesFromUrl( url, parser );
}
catch ( final MalformedURLException e ) {
exception = true;
- JOptionPane.showMessageDialog( _main_frame,
+ JOptionPane.showMessageDialog( _main_frame.getThisFrame(),
"Malformed URL: " + url + "\n" + e.getLocalizedMessage(),
"Malformed URL",
JOptionPane.ERROR_MESSAGE );
}
catch ( final IOException e ) {
exception = true;
- JOptionPane.showMessageDialog( _main_frame,
+ JOptionPane.showMessageDialog( _main_frame.getThisFrame(),
"Could not read from " + url + "\n" + e.getLocalizedMessage(),
"Failed to read tree from " + client.getName() + " for " + identifier,
JOptionPane.ERROR_MESSAGE );
}
catch ( final NumberFormatException e ) {
exception = true;
- JOptionPane.showMessageDialog( _main_frame,
+ JOptionPane.showMessageDialog( _main_frame.getThisFrame(),
"Could not read from " + url + "\n" + e.getLocalizedMessage(),
"Failed to read tree from " + client.getName() + " for " + identifier,
JOptionPane.ERROR_MESSAGE );
catch ( final Exception e ) {
exception = true;
e.printStackTrace();
- JOptionPane.showMessageDialog( _main_frame,
+ JOptionPane.showMessageDialog( _main_frame.getThisFrame(),
e.getLocalizedMessage(),
"Unexpected Exception",
JOptionPane.ERROR_MESSAGE );
WebserviceUtil.processInstructions( client, phylogeny );
}
catch ( final PhyloXmlDataFormatException e ) {
- JOptionPane.showMessageDialog( _main_frame,
+ JOptionPane.showMessageDialog( _main_frame.getThisFrame(),
"Error:\n" + e.getLocalizedMessage(),
"Error",
JOptionPane.ERROR_MESSAGE );
PhylogenyMethods.transferNodeNameToField( phylogeny, client.getNodeField(), false );
}
catch ( final PhyloXmlDataFormatException e ) {
- JOptionPane.showMessageDialog( _main_frame,
+ JOptionPane.showMessageDialog( _main_frame.getThisFrame(),
"Error:\n" + e.getLocalizedMessage(),
"Error",
JOptionPane.ERROR_MESSAGE );
}
_main_frame.getMainPanel().getCurrentTreePanel().setTreeFile( new File( my_name_for_file ) );
AptxUtil.lookAtSomeTreePropertiesForAptxControlSettings( phylogeny, _main_frame.getMainPanel()
- .getControlPanel(), _main_frame.getConfiguration() );
+ .getControlPanel(), _main_frame.getConfiguration() );
_main_frame.getMainPanel().getControlPanel().showWhole();
}
}
}
else if ( !exception ) {
JOptionPane.showMessageDialog( null, ForesterUtil.wordWrap( "Failed to read in tree(s) from [" + url
- + "]", 80 ), "Error", JOptionPane.ERROR_MESSAGE );
+ + "]", 80 ), "Error", JOptionPane.ERROR_MESSAGE );
}
_main_frame.getContentPane().repaint();
if ( ( trees != null ) && ( trees.length > 0 ) ) {
try {
JOptionPane.showMessageDialog( null,
ForesterUtil.wordWrap( "Successfully read in " + trees.length
- + " tree(s) from [" + url + "]", 80 ),
- "Success",
- JOptionPane.INFORMATION_MESSAGE );
+ + " tree(s) from [" + url + "]", 80 ),
+ "Success",
+ JOptionPane.INFORMATION_MESSAGE );
}
catch ( final Exception e ) {
// Not important if this fails, do nothing.