From: James Procter Date: Mon, 30 Oct 2023 12:14:20 +0000 (+0000) Subject: JAL-4317 enable display of feature when showing its colour or filter settings dialog... X-Git-Tag: Release_2_11_4_0~121^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fpatch%2FJAL-4317_enablefeaturewhenadjustingstyle;p=jalview.git JAL-4317 enable display of feature when showing its colour or filter settings dialog, and restore original visibility if cancel is pressed. --- diff --git a/src/jalview/gui/FeatureEditor.java b/src/jalview/gui/FeatureEditor.java index 7117508..606d843 100644 --- a/src/jalview/gui/FeatureEditor.java +++ b/src/jalview/gui/FeatureEditor.java @@ -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() diff --git a/src/jalview/gui/FeatureSettings.java b/src/jalview/gui/FeatureSettings.java index 4d31805..34c1db0 100644 --- a/src/jalview/gui/FeatureSettings.java +++ b/src/jalview/gui/FeatureSettings.java @@ -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 diff --git a/src/jalview/gui/FeatureTypeSettings.java b/src/jalview/gui/FeatureTypeSettings.java index 327f6ca..79f4c88 100644 --- a/src/jalview/gui/FeatureTypeSettings.java +++ b/src/jalview/gui/FeatureTypeSettings.java @@ -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); }