JAL-3010 method extracted for setSubtypesVisibility
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Sun, 3 Jun 2018 07:43:15 +0000 (08:43 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Sun, 3 Jun 2018 07:43:15 +0000 (08:43 +0100)
src/jalview/gui/FeatureSettings.java

index f645d83..fe905c0 100644 (file)
@@ -1361,9 +1361,11 @@ public class FeatureSettings extends JPanel
       }
     });
 
-    summaryView = new JCheckBox(MessageManager.getString("summary_view"));
+    summaryView = new JCheckBox(
+            MessageManager.getString("label.summary_view"));
     summaryView
-            .setToolTipText(MessageManager.getString("summary_view_tip"));
+            .setToolTipText(
+                    MessageManager.getString("label.summary_view_tip"));
     summaryView.addActionListener(new ActionListener()
     {
       @Override
@@ -1738,23 +1740,35 @@ public class FeatureSettings extends JPanel
       fireTableCellUpdated(row, col);
       if (summaryView.isSelected() && col == SHOW_COLUMN)
       {
-        String type = (String) data[row][TYPE_COLUMN];
-        OntologyI so = SequenceOntologyFactory.getInstance();
-        for (int r = 0; r < data.length; r++)
+        setSubtypesVisibility(row, (Boolean) value);
+      }
+      updateFeatureRenderer(data);
+    }
+
+    /**
+     * Sets the visibility of any feature types which are sub-types of the type
+     * in the given row of the table
+     * 
+     * @param row
+     * @param value
+     */
+    protected void setSubtypesVisibility(int row, Boolean value)
+    {
+      String type = (String) data[row][TYPE_COLUMN];
+      OntologyI so = SequenceOntologyFactory.getInstance();
+
+      for (int r = 0; r < data.length; r++)
+      {
+        String type2 = (String) data[r][TYPE_COLUMN];
+        if (!type2.equals(type))
         {
-          if (r != row)
+          if (so.isA(type2, type))
           {
-            String type2 = (String) data[r][TYPE_COLUMN];
-            if (so.isA(type2, type))
-            {
-              data[r][col] = value;
-              fireTableCellUpdated(r, col);
-            }
+            data[r][SHOW_COLUMN] = value;
+            fireTableCellUpdated(r, SHOW_COLUMN);
           }
         }
       }
-
-      updateFeatureRenderer(data);
     }
 
   }