JAL-4317 enable display of feature when showing its colour or filter settings dialog... patch/JAL-4317_enablefeaturewhenadjustingstyle
authorJames Procter <j.procter@dundee.ac.uk>
Mon, 30 Oct 2023 12:14:20 +0000 (12:14 +0000)
committerJames Procter <j.procter@dundee.ac.uk>
Mon, 30 Oct 2023 12:14:26 +0000 (12:14 +0000)
src/jalview/gui/FeatureEditor.java
src/jalview/gui/FeatureSettings.java
src/jalview/gui/FeatureTypeSettings.java

index 7117508..606d843 100644 (file)
@@ -253,7 +253,7 @@ public class FeatureEditor
            */
           final String ft = features.get(featureIndex).getType();
           final String type = ft == null ? lastFeatureAdded : ft;
-          FeatureTypeSettings fcc = new FeatureTypeSettings(fr, type);
+          FeatureTypeSettings fcc = new FeatureTypeSettings(fr, type,true);
           fcc.setRequestFocusEnabled(true);
           fcc.requestFocus();
           fcc.addActionListener(new ActionListener()
index 4d31805..34c1db0 100644 (file)
@@ -1885,6 +1885,8 @@ public class FeatureSettings extends JPanel
            */
           String ttl = MessageManager
                   .formatMessage("label.select_colour_for", type);
+          Object last=(Boolean)table.getValueAt(selectedRow, SHOW_COLUMN);
+          table.setValueAt(Boolean.TRUE, selectedRow, SHOW_COLUMN);
           ColourChooserListener listener = new ColourChooserListener()
           {
             @Override
@@ -1892,12 +1894,14 @@ public class FeatureSettings extends JPanel
             {
               currentColor = new FeatureColour(c);
               table.setValueAt(currentColor, rowSelected, COLOUR_COLUMN);
+              table.setValueAt(Boolean.TRUE, selectedRow, SHOW_COLUMN);
               fireEditingStopped();
             }
 
             @Override
             public void cancel()
             {
+              table.setValueAt(last, selectedRow, SHOW_COLUMN);
               fireEditingStopped();
             }
           };
@@ -1909,7 +1913,9 @@ public class FeatureSettings extends JPanel
           /*
            * variable colour and filters dialog
            */
-          chooser = new FeatureTypeSettings(fr, type);
+          boolean last=(Boolean)table.getValueAt(selectedRow, SHOW_COLUMN);
+          table.setValueAt(Boolean.TRUE, selectedRow, SHOW_COLUMN);
+          chooser = new FeatureTypeSettings(fr, type,last);
           if (!Platform.isJS())
           /**
            * Java only
@@ -2035,7 +2041,9 @@ public class FeatureSettings extends JPanel
     {
       if (button == e.getSource())
       {
-        FeatureTypeSettings chooser = new FeatureTypeSettings(fr, type);
+        boolean last = fr.getFeaturesDisplayed().isVisible(type);
+        ((FeatureTableModel) table.getModel()).setValueAt(Boolean.TRUE, rowSelected, SHOW_COLUMN);
+        FeatureTypeSettings chooser = new FeatureTypeSettings(fr, type,last);
         chooser.addActionListener(this);
         chooser.setRequestFocusEnabled(true);
         chooser.requestFocus();
@@ -2067,6 +2075,8 @@ public class FeatureSettings extends JPanel
                 .getData()[rowSelected];
         data[COLOUR_COLUMN] = currentColor;
         data[FILTER_COLUMN] = currentFilter;
+        data[SHOW_COLUMN] = fr.getFeaturesDisplayed().isVisible(type);
+                
         fireEditingStopped();
         // SwingJS needs an explicit repaint() here,
         // rather than relying upon no validation having
index 327f6ca..79f4c88 100644 (file)
@@ -204,20 +204,23 @@ public class FeatureTypeSettings extends JalviewDialog
 
   private JPanel chooseFiltersPanel;
 
+  public boolean originalDisplay;
+
   /**
    * Constructor
    * 
    * @param frender
    * @param theType
+   * @param last - visibility of feature prior to adjustment
    */
-  public FeatureTypeSettings(FeatureRenderer frender, String theType)
+  public FeatureTypeSettings(FeatureRenderer frender, String theType, boolean last)
   {
     this.fr = frender;
     this.featureType = theType;
     ap = fr.ap;
     originalFilter = fr.getFeatureFilter(theType);
     originalColour = fr.getFeatureColours().get(theType);
-
+    originalDisplay = last;
     adjusting = true;
 
     try
@@ -1032,6 +1035,9 @@ public class FeatureTypeSettings extends JalviewDialog
   {
     fr.setColour(featureType, originalColour);
     fr.setFeatureFilter(featureType, originalFilter);
+    if (!originalDisplay) { 
+      fr.getFeaturesDisplayed().setHidden(featureType);
+    }
     refreshDisplay(true);
   }