git://source.jalview.org
/
jalview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a81d34b
)
JAL-2808 update conditions list on change of attribute (safely)
author
gmungoc
<g.m.carstairs@dundee.ac.uk>
Wed, 22 Nov 2017 16:56:35 +0000
(16:56 +0000)
committer
gmungoc
<g.m.carstairs@dundee.ac.uk>
Wed, 22 Nov 2017 16:56:35 +0000
(16:56 +0000)
src/jalview/gui/FeatureTypeSettings.java
patch
|
blob
|
history
diff --git
a/src/jalview/gui/FeatureTypeSettings.java
b/src/jalview/gui/FeatureTypeSettings.java
index
e280091
..
372234a
100644
(file)
--- a/
src/jalview/gui/FeatureTypeSettings.java
+++ b/
src/jalview/gui/FeatureTypeSettings.java
@@
-1330,7
+1330,20
@@
public class FeatureTypeSettings extends JalviewDialog
{
attCombo.setSelectedItem(toAttributeDisplayName(attName));
}
{
attCombo.setSelectedItem(toAttributeDisplayName(attName));
}
- attCombo.addItemListener(itemListener);
+ attCombo.addItemListener(new ItemListener()
+ {
+ @Override
+ public void itemStateChanged(ItemEvent e)
+ {
+ /*
+ * on change of attribute, refresh the conditions list to
+ * ensure it is appropriate for the attribute datatype
+ */
+ populateConditions((String) attCombo.getSelectedItem(),
+ (Condition) condCombo.getSelectedItem(), condCombo);
+ actionListener.actionPerformed(null);
+ }
+ });
filterRow.add(attCombo);
filterRow.add(attCombo);
@@
-1395,7
+1408,7
@@
public class FeatureTypeSettings extends JalviewDialog
JComboBox<Condition> condCombo)
{
Datatype type = FeatureAttributes.getInstance().getDatatype(featureType,
JComboBox<Condition> condCombo)
{
Datatype type = FeatureAttributes.getInstance().getDatatype(featureType,
- attName);
+ fromAttributeDisplayName(attName));
if (MessageManager.getString("label.label").equals(attName))
{
type = Datatype.Character;
if (MessageManager.getString("label.label").equals(attName))
{
type = Datatype.Character;
@@
-1405,22
+1418,39
@@
public class FeatureTypeSettings extends JalviewDialog
type = Datatype.Number;
}
type = Datatype.Number;
}
+ /*
+ * remove itemListener before starting
+ */
+ ItemListener listener = condCombo.getItemListeners()[0];
+ condCombo.removeItemListener(listener);
+ boolean condIsValid = false;
+ condCombo.removeAllItems();
for (Condition c : Condition.values())
{
if ((c.isNumeric() && type != Datatype.Character)
|| (!c.isNumeric() && type != Datatype.Number))
{
condCombo.addItem(c);
for (Condition c : Condition.values())
{
if ((c.isNumeric() && type != Datatype.Character)
|| (!c.isNumeric() && type != Datatype.Number))
{
condCombo.addItem(c);
+ if (c == cond)
+ {
+ condIsValid = true;
+ }
}
}
/*
* set the selected condition (does nothing if not in the list)
*/
}
}
/*
* set the selected condition (does nothing if not in the list)
*/
- if (cond != null)
+ if (condIsValid)
{
condCombo.setSelectedItem(cond);
}
{
condCombo.setSelectedItem(cond);
}
+ else
+ {
+ condCombo.setSelectedIndex(0);
+ }
+
+ condCombo.addItemListener(listener);
}
/**
}
/**