01: package net.suberic.pooka.gui.filter;
02:
03: import net.suberic.pooka.Pooka;
04: import javax.swing.*;
05: import java.util.Vector;
06: import java.util.Properties;
07:
08: /**
09: * This is a class that lets you choose your filter actions.
10: */
11: public class FlagFilterEditor extends FilterEditor {
12: JComboBox flagBox;
13: JComboBox trueFalseBox;
14:
15: public static String FILTER_CLASS = "net.suberic.pooka.filter.FlagFilterAction";
16:
17: /**
18: * Configures the given FilterEditor from the given VariableBundle and
19: * property.
20: */
21: public void configureEditor(
22: net.suberic.util.gui.propedit.PropertyEditorManager newManager,
23: String propertyName) {
24: property = propertyName;
25: manager = newManager;
26:
27: Vector flagNames = Pooka.getSearchManager().getFlagLabels();
28: flagBox = new JComboBox(flagNames);
29:
30: this .add(flagBox);
31:
32: Vector trueFalse = new Vector();
33: trueFalse.add(Pooka.getProperty("label.true", "True"));
34: trueFalse.add(Pooka.getProperty("label.false", "False"));
35:
36: trueFalseBox = new JComboBox(trueFalse);
37:
38: this .add(trueFalseBox);
39: }
40:
41: /**
42: * Gets the values that would be set by this FilterEditor.
43: */
44: public java.util.Properties getValue() {
45: Properties props = new Properties();
46: String oldFlag = manager.getProperty(property + ".flag", "");
47: if (!oldFlag.equals((String) flagBox.getSelectedItem()))
48: props.setProperty(property + ".flag", (String) flagBox
49: .getSelectedItem());
50:
51: String oldValue = manager.getProperty(property + ".value", "");
52: if (!oldFlag.equals((String) trueFalseBox.getSelectedItem()))
53: props.setProperty(property + ".value",
54: (String) trueFalseBox.getSelectedItem());
55:
56: String oldClassName = manager.getProperty(property + ".class",
57: "");
58: if (!oldClassName.equals(FILTER_CLASS))
59: props.setProperty(property + ".class", FILTER_CLASS);
60:
61: return props;
62: }
63:
64: /**
65: * Sets the values represented by this FilterEditor in the manager.
66: */
67: public void setValue() {
68: String oldFlag = manager.getProperty(property + ".flag", "");
69: if (!oldFlag.equals((String) flagBox.getSelectedItem()))
70: manager.setProperty(property + ".flag", (String) flagBox
71: .getSelectedItem());
72:
73: String oldValue = manager.getProperty(property + ".value", "");
74: if (!oldFlag.equals((String) trueFalseBox.getSelectedItem()))
75: manager.setProperty(property + ".value",
76: (String) trueFalseBox.getSelectedItem());
77:
78: String oldClassName = manager.getProperty(property + ".class",
79: "");
80: if (!oldClassName.equals(FILTER_CLASS))
81: manager.setProperty(property + ".class", FILTER_CLASS);
82: }
83:
84: /**
85: * Returns the class that will be set for this FilterEditor.
86: */
87: public String getFilterClassValue() {
88: return FILTER_CLASS;
89: }
90:
91: }
|