X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FFeatureTypeSettings.java;h=fa9833b0250870ea410ea98caa5616dde1bbc4db;hb=d43e766fa05058226c417d214e0b8d83294ec6e2;hp=89c693f1352295fa60747ae93767c893a9bdd8d3;hpb=11e8324f332f5648ba0f13b902621dc7a20137e4;p=jalview.git diff --git a/src/jalview/gui/FeatureTypeSettings.java b/src/jalview/gui/FeatureTypeSettings.java index 89c693f..fa9833b 100644 --- a/src/jalview/gui/FeatureTypeSettings.java +++ b/src/jalview/gui/FeatureTypeSettings.java @@ -58,17 +58,16 @@ import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JColorChooser; import javax.swing.JComboBox; +import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JSlider; import javax.swing.JTabbedPane; import javax.swing.JTextField; -import javax.swing.SwingConstants; import javax.swing.border.LineBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import javax.swing.plaf.basic.BasicArrowButton; /** * A dialog where the user can configure colour scheme, and any filters, for one @@ -835,17 +834,38 @@ public class FeatureTypeSettings extends JalviewDialog return colourByPanel; } + /** + * Shows a colour chooser dialog, and if a selection is made, updates the + * colour of the given panel + * + * @param colourPanel + * the panel whose background colour is being picked + * @param key + * message bundle key for the dialog title + */ private void showColourChooser(JPanel colourPanel, String key) { - Color col = JColorChooser.showDialog(this, - MessageManager.getString(key), colourPanel.getBackground()); - if (col != null) + // TODO 'final' is (currently) required here for SwingJS to work + JColorChooser colorChooser = new JColorChooser(); + colorChooser.setColor(colourPanel.getBackground()); + + ActionListener listener = new ActionListener() { - colourPanel.setBackground(col); - colourPanel.setForeground(col); - } - colourPanel.repaint(); - colourChanged(true); + @Override + public void actionPerformed(ActionEvent e) + { + Color col = colorChooser.getColor(); + colourPanel.setBackground(col); + colourPanel.setForeground(col); + colourPanel.repaint(); + colourChanged(true); + } + }; + + JDialog dialog = JColorChooser.createDialog(this, + MessageManager.getString(key), true, colorChooser, listener, + null); + dialog.setVisible(true); } /** @@ -942,7 +962,7 @@ public class FeatureTypeSettings extends JalviewDialog */ float minValue = min; float maxValue = max; - final int thresholdOption = threshold.getSelectedIndex(); + int thresholdOption = threshold.getSelectedIndex(); if (thresholdIsMin.isSelected() && thresholdOption == ABOVE_THRESHOLD_OPTION) { @@ -1242,7 +1262,12 @@ public class FeatureTypeSettings extends JalviewDialog { orFilters.setSelected(true); } - featureFilters.getMatchers().forEach(matcher -> filters.add(matcher)); + // avoid use of lambda expression to keep SwingJS happy + // featureFilters.getMatchers().forEach(item -> filters.add(item)); + for (FeatureMatcherI matcher : featureFilters.getMatchers()) + { + filters.add(matcher); + } } /* @@ -1320,7 +1345,7 @@ public class FeatureTypeSettings extends JalviewDialog * drop-down choice of attribute, with description as a tooltip * if we can obtain it */ - final JComboBox attCombo = populateAttributesDropdown(attNames, + JComboBox attCombo = populateAttributesDropdown(attNames, true, true); String filterBy = setSelectedAttribute(attCombo, filter); @@ -1422,8 +1447,8 @@ public class FeatureTypeSettings extends JalviewDialog if (!patternField.isEnabled() || (pattern != null && pattern.trim().length() > 0)) { - // todo: gif for button drawing '-' or 'x' - JButton removeCondition = new BasicArrowButton(SwingConstants.WEST); + JButton removeCondition = new JButton("\u2717"); // Dingbats cursive x + removeCondition.setPreferredSize(new Dimension(23, 17)); removeCondition .setToolTipText(MessageManager.getString("label.delete_row")); removeCondition.addActionListener(new ActionListener() @@ -1551,7 +1576,7 @@ public class FeatureTypeSettings extends JalviewDialog condCombo.removeAllItems(); for (Condition c : Condition.values()) { - if ((c.isNumeric() && type != Datatype.Character) + if ((c.isNumeric() && type == Datatype.Number) || (!c.isNumeric() && type != Datatype.Number)) { condCombo.addItem(c);