From 2571c6d7548fcec3d02605644903ea13b78f0891 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Sun, 3 Jun 2018 08:33:29 +0100 Subject: [PATCH] JAL-3010 apply Visibility to sub-types if set in Summary View --- resources/lang/Messages.properties | 2 ++ src/jalview/gui/FeatureSettings.java | 37 +++++++++++++++++++++++++++--- src/jalview/gui/FeatureTypeSettings.java | 2 +- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index f6c3f8f..6d38b37 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -1364,3 +1364,5 @@ label.most_bound_molecules = Most Bound Molecules label.most_polymer_residues = Most Polymer Residues label.cached_structures = Cached Structures label.free_text_search = Free Text Search +label.summary_view = Summary View +label.summary_view_tip = Show only top level ontology terms \ No newline at end of file diff --git a/src/jalview/gui/FeatureSettings.java b/src/jalview/gui/FeatureSettings.java index cb571d8..f645d83 100644 --- a/src/jalview/gui/FeatureSettings.java +++ b/src/jalview/gui/FeatureSettings.java @@ -27,6 +27,7 @@ import jalview.datamodel.SequenceI; import jalview.datamodel.features.FeatureMatcherI; import jalview.datamodel.features.FeatureMatcherSet; import jalview.datamodel.features.FeatureMatcherSetI; +import jalview.datamodel.ontology.OntologyI; import jalview.gui.Help.HelpId; import jalview.io.JalviewFileChooser; import jalview.io.JalviewFileView; @@ -302,6 +303,9 @@ public class FeatureSettings extends JPanel switch (column) { case TYPE_COLUMN: + /* + * drag to reorder not enabled in Summary View + */ tip = summaryView.isSelected() ? MessageManager.getString( "label.feature_settings_select_columns") @@ -1357,8 +1361,9 @@ public class FeatureSettings extends JPanel } }); - summaryView = new JCheckBox("Summary view"); - summaryView.setToolTipText("Show only top level ontology terms"); + summaryView = new JCheckBox(MessageManager.getString("summary_view")); + summaryView + .setToolTipText(MessageManager.getString("summary_view_tip")); summaryView.addActionListener(new ActionListener() { @Override @@ -1712,17 +1717,43 @@ public class FeatureSettings extends JPanel return v == null ? null : v.getClass(); } + /** + * Answers true for all columns except Feature Type + */ @Override public boolean isCellEditable(int row, int col) { - return col == 0 ? false : true; + return col != TYPE_COLUMN; } + /** + * Sets the value in the model for a given row and column. If Visibility + * (Show/Hide) is being set, and the table is in Summary View, then it is + * set also on any sub-types of the row's feature type. + */ @Override public void setValueAt(Object value, int row, int col) { data[row][col] = value; 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++) + { + if (r != row) + { + String type2 = (String) data[r][TYPE_COLUMN]; + if (so.isA(type2, type)) + { + data[r][col] = value; + fireTableCellUpdated(r, col); + } + } + } + } + updateFeatureRenderer(data); } diff --git a/src/jalview/gui/FeatureTypeSettings.java b/src/jalview/gui/FeatureTypeSettings.java index 6bea16a..201ec44 100644 --- a/src/jalview/gui/FeatureTypeSettings.java +++ b/src/jalview/gui/FeatureTypeSettings.java @@ -262,6 +262,7 @@ public class FeatureTypeSettings extends JalviewDialog List types = fr.getRenderOrder(); subTypes = SequenceOntologyFactory.getInstance() .getChildTerms(this.featureType, types); + Collections.sort(subTypes); // sort for ease of reading in tooltip /* * save original colours and filters for this feature type @@ -1282,7 +1283,6 @@ public class FeatureTypeSettings extends JalviewDialog andOrPanel.add(panel2, BorderLayout.EAST); StringBuilder sb = new StringBuilder(20 * subTypes.size()); sb.append("Apply filters also to child terms" + ":"); // todo i18n - Collections.sort(subTypes); for (String child : subTypes) { sb.append("
").append(child); -- 1.7.10.2