in progress
[jalview.git] / forester / java / src / org / forester / archaeopteryx / ControlPanel.java
index 419f2c5..5495b9e 100644 (file)
@@ -134,6 +134,7 @@ final class ControlPanel extends JPanel implements ActionListener {
     private int                  _paste_subtree_item;
     private int                  _add_new_node_item;
     private int                  _edit_node_data_item;
+    private int                  _get_ext_desc_data;
     private int                  _blast_item;
     // zooming and quick tree manipulation buttons:
     private JButton              _zoom_in_x;
@@ -254,7 +255,7 @@ final class ControlPanel extends JPanel implements ActionListener {
                     _order_of_appearance = !_order_of_appearance;
                     tp.setNodeInPreorderToNull();
                     tp.getPhylogeny().externalNodesHaveChanged();
-                    tp.getPhylogeny().hashIDs();
+                    tp.getPhylogeny().clearHashIdToNodeMap();
                     tp.getPhylogeny().recalculateNumberOfExternalDescendants( true );
                     tp.resetNodeIdToDistToLeafMap();
                     tp.setEdited( true );
@@ -625,7 +626,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();
             }
@@ -1162,9 +1164,7 @@ final class ControlPanel extends JPanel implements ActionListener {
             setActionWhenNodeClicked( NodeClickAction.SORT_DESCENDENTS );
         }
         else if ( action == _blast_item ) {
-            if ( !Constants.__RELEASE && !Constants.__SNAPSHOT_RELEASE ) {
-                setActionWhenNodeClicked( NodeClickAction.BLAST );
-            }
+            setActionWhenNodeClicked( NodeClickAction.BLAST );
         }
         else if ( action == _open_tax_web_item ) {
             setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
@@ -1187,6 +1187,9 @@ final class ControlPanel extends JPanel implements ActionListener {
         else if ( action == _edit_node_data_item ) {
             setActionWhenNodeClicked( NodeClickAction.EDIT_NODE_DATA );
         }
+        else if ( action == _get_ext_desc_data ) {
+            setActionWhenNodeClicked( NodeClickAction.GET_EXT_DESC_DATA );
+        }
         else {
             throw new RuntimeException( "unknown action: " + action );
         }
@@ -1368,6 +1371,23 @@ final class ControlPanel extends JPanel implements ActionListener {
             }
             cb_index++;
         }
+        if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
+            _blast_item = cb_index;
+            addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
+            if ( default_option == Configuration.blast ) {
+                selected_index = cb_index;
+            }
+            cb_index++;
+        }
+        if ( _configuration.doDisplayClickToOption( Configuration.get_ext_desc_data ) ) {
+            _get_ext_desc_data = cb_index;
+            addClickToOption( Configuration.get_ext_desc_data,
+                              _configuration.getClickToTitle( Configuration.get_ext_desc_data ) );
+            if ( default_option == Configuration.get_ext_desc_data ) {
+                selected_index = cb_index;
+            }
+            cb_index++;
+        }
         if ( getOptions().isEditable() ) {
             if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
                 _cut_subtree_item = cb_index;
@@ -1422,16 +1442,6 @@ final class ControlPanel extends JPanel implements ActionListener {
                 }
                 cb_index++;
             }
-            if ( !Constants.__RELEASE && !Constants.__SNAPSHOT_RELEASE ) {
-                if ( _configuration.doDisplayClickToOption( Configuration.blast ) ) {
-                    _blast_item = cb_index;
-                    addClickToOption( Configuration.blast, _configuration.getClickToTitle( Configuration.blast ) );
-                    if ( default_option == Configuration.blast ) {
-                        selected_index = cb_index;
-                    }
-                    cb_index++;
-                }
-            }
         }
         // Set default selection and its action
         _click_to_combobox.setSelectedIndex( selected_index );
@@ -1716,10 +1726,11 @@ 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;
         }
-        displayedPhylogenyMightHaveChanged( false );
+        getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
+        displayedPhylogenyMightHaveChanged( true );
         _mainpanel.getCurrentTreePanel().updateOvSettings();
         _mainpanel.getCurrentTreePanel().validate();
         _mainpanel.validate();
@@ -1819,10 +1830,10 @@ final class ControlPanel extends JPanel implements ActionListener {
                 node.setCollapse( false );
             }
             tp.resetNodeIdToDistToLeafMap();
-            tp.updateSetOfCollapsedExternalNodes( t );
+            tp.updateSetOfCollapsedExternalNodes();
             t.recalculateNumberOfExternalDescendants( false );
             tp.setNodeInPreorderToNull();
-            t.hashIDs();
+            t.clearHashIdToNodeMap();
             showWhole();
         }
     }
@@ -1959,6 +1970,7 @@ final class ControlPanel extends JPanel implements ActionListener {
         ADD_NEW_NODE,
         EDIT_NODE_DATA,
         SORT_DESCENDENTS,
+        GET_EXT_DESC_DATA,
         BLAST;
     }
 }