{
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);
JComboBox<Condition> condCombo)
{
Datatype type = FeatureAttributes.getInstance().getDatatype(featureType,
- attName);
+ fromAttributeDisplayName(attName));
if (MessageManager.getString("label.label").equals(attName))
{
type = Datatype.Character;
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);
+ if (c == cond)
+ {
+ condIsValid = true;
+ }
}
}
/*
* set the selected condition (does nothing if not in the list)
*/
- if (cond != null)
+ if (condIsValid)
{
condCombo.setSelectedItem(cond);
}
+ else
+ {
+ condCombo.setSelectedIndex(0);
+ }
+
+ condCombo.addItemListener(listener);
}
/**