From: gmungoc Date: Fri, 11 Oct 2019 10:52:03 +0000 (+0100) Subject: JAL-3458 redraw alignment and Overview on Cancel in Feature Settings X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=05951a61acec617599e9a92828b8a498fab6ae32;p=jalview.git JAL-3458 redraw alignment and Overview on Cancel in Feature Settings --- diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index 2f5d83b..72a074d 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -842,7 +842,6 @@ public class AlignmentPanel extends GAlignmentPanel implements } if (updateOverview) { - if (overviewPanel != null) { overviewPanel.updateOverviewImage(); diff --git a/src/jalview/gui/FeatureSettings.java b/src/jalview/gui/FeatureSettings.java index f81ecce..ddadd6d 100644 --- a/src/jalview/gui/FeatureSettings.java +++ b/src/jalview/gui/FeatureSettings.java @@ -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