(no commit message)
authorcmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Fri, 1 Jun 2012 19:28:08 +0000 (19:28 +0000)
committercmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Fri, 1 Jun 2012 19:28:08 +0000 (19:28 +0000)
forester/java/src/org/forester/archaeopteryx/ControlPanel.java
forester/java/src/org/forester/archaeopteryx/MainFrame.java
forester/java/src/org/forester/archaeopteryx/TreePanel.java
forester/java/src/org/forester/archaeopteryx/tools/RunnableProcess.java
forester/java/src/org/forester/archaeopteryx/tools/TaxonomyDataObtainer.java

index b58411b..233952e 100644 (file)
@@ -625,7 +625,8 @@ final class ControlPanel extends JPanel implements ActionListener {
     }
 
     void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
-        if ( ( _mainpanel != null ) && ( _mainpanel.getCurrentPhylogeny() != null ) ) {
+        if ( ( _mainpanel != null )
+                && ( _mainpanel.getCurrentPhylogeny() != null && !_mainpanel.getCurrentPhylogeny().isEmpty() ) ) {
             if ( getOptions().isShowOverview() ) {
                 _mainpanel.getCurrentTreePanel().updateOvSizes();
             }
@@ -1712,7 +1713,7 @@ final class ControlPanel extends JPanel implements ActionListener {
      * Fit entire tree into window.
      */
     void showWhole() {
-        if ( _mainpanel.getCurrentScrollPane() == null ) {
+        if ( _mainpanel.getCurrentScrollPane() == null || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) {
             return;
         }
         getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
index 3fe5714..35ba34a 100644 (file)
@@ -43,6 +43,7 @@ import javax.swing.JMenuBar;
 import javax.swing.JMenuItem;
 import javax.swing.JOptionPane;
 import javax.swing.JRadioButtonMenuItem;
+import javax.swing.SwingUtilities;
 
 import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
 import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION;
@@ -545,8 +546,18 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         _jmenubar.add( _help_jmenu );
     }
 
-    public synchronized void updateProcessMenu() {
-        System.out.println( "pool size " + _process_pool.size() );
+    public void updateProcessMenu() {
+        // In general Swing is not thread safe.
+        // See "Swing's Threading Policy".
+        SwingUtilities.invokeLater( new Runnable() {
+
+            public void run() {
+                doUpdateProcessMenu();
+            }
+        } );
+    }
+
+    private void doUpdateProcessMenu() {
         if ( _process_pool.size() > 0 ) {
             if ( _process_menu == null ) {
                 _process_menu = createMenu( "", getConfiguration() );
@@ -570,22 +581,6 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         _jmenubar.validate();
         _jmenubar.repaint();
         repaint();
-        //        _help_jmenu.add( _help_item = new JMenuItem( "Help" ) );
-        //        _help_jmenu.add( _website_item = new JMenuItem( "Archaeopteryx Home" ) );
-        //        _aptx_ref_item = new JMenuItem( "Archaeopteryx Reference" );
-        //        _help_jmenu.add( _phyloxml_website_item = new JMenuItem( "phyloXML Home" ) );
-        //        _help_jmenu.add( _phyloxml_ref_item = new JMenuItem( "phyloXML Reference" ) );
-        //        _help_jmenu.addSeparator();
-        //        _help_jmenu.add( _about_item = new JMenuItem( "About" ) );
-        //        customizeJMenuItem( _help_item );
-        //        customizeJMenuItem( _website_item );
-        //        customizeJMenuItem( _phyloxml_website_item );
-        //        customizeJMenuItem( _aptx_ref_item );
-        //        customizeJMenuItem( _phyloxml_ref_item );
-        //        customizeJMenuItem( _about_item );
-        //        _phyloxml_ref_item.setToolTipText( PHYLOXML_REF_TOOL_TIP );
-        //        _aptx_ref_item.setToolTipText( APTX_REF_TOOL_TIP );
-        //        _jmenubar.add( _help_jmenu );
     }
 
     void buildTypeMenu() {
index b245183..096c8d5 100644 (file)
@@ -3670,6 +3670,9 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                                final int graphics_file_height,
                                final int graphics_file_x,
                                final int graphics_file_y ) {
+        if ( _phylogeny == null || _phylogeny.isEmpty() ) {
+            return;
+        }
         if ( _control_panel.isShowSequenceRelations() ) {
             _query_sequence = _control_panel.getSelectedQuerySequence();
         }
index b559fba..0a5504c 100644 (file)
@@ -18,7 +18,6 @@ public abstract class RunnableProcess implements Runnable {
     }
 
     void start( final MainFrame mf, final String name ) {
-        //mf.getMainPanel().getCurrentTreePanel().setWaitCursor();
         setProcessId( mf.getProcessPool().addProcess( name ) );
         mf.updateProcessMenu();
     }
@@ -29,7 +28,6 @@ public abstract class RunnableProcess implements Runnable {
             ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not remove process " + getProcessId()
                     + " from process pool" );
         }
-        //mf.getMainPanel().getCurrentTreePanel().setArrowCursor();
         mf.updateProcessMenu();
     }
 }
index 819466e..a6d814b 100644 (file)
@@ -74,7 +74,6 @@ public class TaxonomyDataObtainer extends RunnableProcess {
             not_found = AncestralTaxonomyInference.obtainDetailedTaxonomicInformation( _phy, _delete );
         }
         catch ( final UnknownHostException e ) {
-            _mf.getMainPanel().getCurrentTreePanel().setArrowCursor();
             JOptionPane.showMessageDialog( _mf,
                                            "Could not connect to \"" + getBaseUrl() + "\"",
                                            "Network error during taxonomic information gathering",
@@ -82,7 +81,6 @@ public class TaxonomyDataObtainer extends RunnableProcess {
             return;
         }
         catch ( final IOException e ) {
-            _mf.getMainPanel().getCurrentTreePanel().setArrowCursor();
             e.printStackTrace();
             JOptionPane.showMessageDialog( _mf,
                                            e.toString(),
@@ -91,7 +89,6 @@ public class TaxonomyDataObtainer extends RunnableProcess {
             return;
         }
         catch ( final AncestralTaxonomyInferenceException e ) {
-            _mf.getMainPanel().getCurrentTreePanel().setArrowCursor();
             e.printStackTrace();
             JOptionPane.showMessageDialog( _mf,
                                            e.toString(),
@@ -102,6 +99,18 @@ public class TaxonomyDataObtainer extends RunnableProcess {
         finally {
             end( _mf );
         }
+        if ( _phy == null || _phy.isEmpty() ) {
+            try {
+                JOptionPane.showMessageDialog( _mf,
+                                               "None of the external node taxonomies could be resolved",
+                                               "Taxonomy Tool Failed",
+                                               JOptionPane.WARNING_MESSAGE );
+            }
+            catch ( final Exception e ) {
+                // Not important if this fails, do nothing. 
+            }
+            return;
+        }
         _treepanel.setTree( _phy );
         _mf.showWhole();
         _treepanel.setEdited( true );