public class FeatureSettings extends JPanel
implements FeatureSettingsControllerI
{
+ private static final String COLON = ":";
+
private static final int MIN_WIDTH = 400;
private static final int MIN_HEIGHT = 400;
* look up attributes known for feature type
*/
String selectedType = (String) filteredFeatureChoice.getSelectedItem();
- List<String> attNames = FeatureAttributes.getInstance().getAttributes(
- selectedType);
+ List<String[]> attNames = FeatureAttributes.getInstance()
+ .getAttributes(selectedType);
/*
* if this feature type has filters set, load them first
/*
* and an empty filter for the user to populate (add)
*/
- KeyedMatcherI noFilter = new KeyedMatcher("", Condition.values()[0], "");
+ KeyedMatcherI noFilter = new KeyedMatcher(Condition.values()[0], "",
+ (String) null);
filters.add(noFilter);
/*
int filterIndex = 0;
for (KeyedMatcherI filter : filters)
{
- String key = filter.getKey();
+ String[] attName = filter.getKey();
Condition condition = filter.getMatcher()
.getCondition();
String pattern = filter.getMatcher().getPattern();
- JPanel row = addFilter(key, attNames, condition, pattern, filterIndex);
+ JPanel row = addFilter(attName, attNames, condition, pattern, filterIndex);
row.setBorder(BorderFactory.createLineBorder(debugBorderColour));
chooseFiltersPanel.add(row);
filterIndex++;
* <li>a text field for input of a match pattern</li>
* <li>optionally, a 'remove' button</li>
* </ul>
- * If attribute, condition or pattern are not null, they are set as defaults
- * for the input fields. The 'remove' button is added unless the pattern is
- * null or empty (incomplete filter condition).
+ * If attribute, condition or pattern are not null, they are set as defaults for
+ * the input fields. The 'remove' button is added unless the pattern is null or
+ * empty (incomplete filter condition).
*
- * @param attribute
+ * @param attName
* @param attNames
* @param cond
* @param pattern
* @param filterIndex
* @return
*/
- protected JPanel addFilter(String attribute, List<String> attNames,
+ protected JPanel addFilter(String[] attName, List<String[]> attNames,
Condition cond, String pattern, int filterIndex)
{
JPanel filterRow = new JPanel(new FlowLayout(FlowLayout.LEFT));
}
};
- if ("".equals(attribute))
+ if (attName == null) // the 'add a condition' row
{
attCombo.setSelectedItem(null);
}
else
{
- attCombo.setSelectedItem(attribute);
+ attCombo.setSelectedItem(String.join(COLON, attName));
}
attCombo.addItemListener(itemListener);
* @param attNames
*/
protected JComboBox<String> populateAttributesDropdown(
- String featureType, List<String> attNames)
+ String featureType, List<String[]> attNames)
{
+ List<String> displayNames = new ArrayList<>();
List<String> tooltips = new ArrayList<>();
FeatureAttributes fa = FeatureAttributes.getInstance();
- for (String attName : attNames)
+ for (String[] attName : attNames)
{
String desc = fa.getDescription(featureType, attName);
if (desc != null && desc.length() > MAX_TOOLTIP_LENGTH)
{
desc = desc.substring(0, MAX_TOOLTIP_LENGTH) + "...";
}
+ displayNames.add(String.join(COLON, attName));
tooltips.add(desc == null ? "" : desc);
}
JComboBox<String> attCombo = JvSwingUtils.buildComboWithTooltips(
- attNames, tooltips);
+ displayNames, tooltips);
if (attNames.isEmpty())
{
attCombo.setToolTipText(MessageManager
String attName = (String) attCombo.getSelectedItem();
Condition cond = (Condition) condCombo.getSelectedItem();
String pattern = valueField.getText();
- KeyedMatcherI km = new KeyedMatcher(attName, cond, pattern);
+ KeyedMatcherI km = new KeyedMatcher(cond, pattern,
+ attName.split(COLON));
filters.set(filterIndex, km);
}
if (gcol.isColourByAttribute())
{
- tx.append(gcol.getAttributeName());
+ tx.append(String.join(":", gcol.getAttributeName()));
}
else if (!gcol.isColourByLabel())
{