* if a numeric condition is selected, show the value range
* as a tooltip on the value input field
*/
- setPatternTooltip(filterBy, selectedCondition, patternField);
+ setNumericHints(filterBy, selectedCondition, patternField);
/*
* add remove button if filter is populated (non-empty pattern)
}
/**
- * If a numeric comparison condition is selected, retrieve the min-max range for
- * the value (score or attribute), and set it as a tooltip on the value file
+ * If a numeric comparison condition is selected, retrieves the min-max range
+ * for the value (score or attribute), and sets it as a tooltip on the value
+ * field. If the field is currently empty, then pre-populates it with
+ * <ul>
+ * <li>the minimum value, if condition is > or >=</li>
+ * <li>the maximum value, if condition is < or <=</li>
+ * </ul>
*
* @param attName
* @param selectedCondition
* @param patternField
*/
- private void setPatternTooltip(String attName,
+ private void setNumericHints(String attName,
Condition selectedCondition, JTextField patternField)
{
patternField.setToolTipText("");
float[] minMax = getMinMax(attName);
if (minMax != null)
{
- String tip = String.format("(%s - %s)",
- DECFMT_2_2.format(minMax[0]), DECFMT_2_2.format(minMax[1]));
+ String minFormatted = DECFMT_2_2.format(minMax[0]);
+ String maxFormatted = DECFMT_2_2.format(minMax[1]);
+ String tip = String.format("(%s - %s)", minFormatted, maxFormatted);
patternField.setToolTipText(tip);
+ if (patternField.getText().isEmpty())
+ {
+ if (selectedCondition == Condition.GE
+ || selectedCondition == Condition.GT)
+ {
+ patternField.setText(minFormatted);
+ }
+ else
+ {
+ if (selectedCondition == Condition.LE
+ || selectedCondition == Condition.LT)
+ {
+ patternField.setText(maxFormatted);
+ }
+ }
+ }
}
}
}
ItemListener listener = condCombo.getItemListeners()[0];
condCombo.removeItemListener(listener);
boolean condIsValid = false;
+
condCombo.removeAllItems();
for (Condition c : Condition.values())
{
condCombo.setSelectedIndex(0);
}
- condCombo.addItemListener(listener);
-
/*
* clear pattern if it is now invalid for condition
*/
patternField.setText("");
}
}
+
+ /*
+ * restore the listener
+ */
+ condCombo.addItemListener(listener);
}
/**
Condition cond = (Condition) condCombo.getSelectedItem();
String pattern = valueField.getText().trim();
- setPatternTooltip(attName, cond, valueField);
+ setNumericHints(attName, cond, valueField);
if (pattern.length() == 0 && cond.needsAPattern())
{