JAL-3458 redraw alignment and Overview on Cancel in Feature Settings
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 11 Oct 2019 10:52:03 +0000 (11:52 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 11 Oct 2019 10:52:03 +0000 (11:52 +0100)
src/jalview/gui/AlignmentPanel.java
src/jalview/gui/FeatureSettings.java

index 2f5d83b..72a074d 100644 (file)
@@ -842,7 +842,6 @@ public class AlignmentPanel extends GAlignmentPanel implements
     }
     if (updateOverview)
     {
-
       if (overviewPanel != null)
       {
         overviewPanel.updateOverviewImage();
index f81ecce..ddadd6d 100644 (file)
@@ -379,7 +379,7 @@ public class FeatureSettings extends JPanel
                       javax.swing.event.InternalFrameEvent evt)
               {
                 fr.removePropertyChangeListener(change);
-              };
+              }
             });
     frame.setLayer(JLayeredPane.PALETTE_LAYER);
     inConstruction = false;
@@ -1148,26 +1148,38 @@ public class FeatureSettings extends JPanel
 
   }
 
-  public void updateFeatureRenderer(Object[][] data)
+  /**
+   * Update the priority order of features; only repaint if this changed the
+   * order of visible features. Any newly discovered feature types are set to
+   * visible. Returns true if repaint was requested, false if not.
+   * 
+   * @param data
+   * @return
+   */
+  public boolean updateFeatureRenderer(Object[][] data)
   {
-    updateFeatureRenderer(data, true);
+    return updateFeatureRenderer(data, true);
   }
 
   /**
    * Update the priority order of features; only repaint if this changed the
-   * order of visible features
+   * order of visible features. Returns true if repaint was requested, false if
+   * not.
    * 
    * @param data
    * @param visibleNew
+   * @return
    */
-  void updateFeatureRenderer(Object[][] data, boolean visibleNew)
+  boolean updateFeatureRenderer(Object[][] data, boolean visibleNew)
   {
     FeatureSettingsBean[] rowData = getTableAsBeans(data);
 
     if (fr.setFeaturePriority(rowData, visibleNew))
     {
       af.alignPanel.paintAlignment(true, true);
+      return true;
     }
+    return false;
   }
 
   /**
@@ -1272,10 +1284,7 @@ public class FeatureSettings extends JPanel
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        fr.setTransparency(originalTransparency);
-        fr.setFeatureFilters(originalFilters);
-        updateFeatureRenderer(originalData);
-        close();
+        cancel();
       }
     });
 
@@ -1358,6 +1367,27 @@ public class FeatureSettings extends JPanel
   }
 
   /**
+   * On Cancel, restore settings as they were when the dialog was opened (or
+   * possibly with any new features added while the dialog was open)
+   */
+  void cancel()
+  {
+    fr.setTransparency(originalTransparency);
+    fr.setFeatureFilters(originalFilters);
+    boolean repainted = updateFeatureRenderer(originalData);
+
+    /*
+     * ensure alignment (and Overview if visible) are redrawn
+     */
+    if (!repainted)
+    {
+      af.alignPanel.paintAlignment(true, true);
+    }
+
+    close();
+  }
+
+  /**
    * Answers a suitable tooltip to show on the colour cell of the table
    * 
    * @param fcol