KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > suberic > pooka > gui > filter > FlagFilterEditor


1 package net.suberic.pooka.gui.filter;
2 import net.suberic.pooka.Pooka;
3 import javax.swing.*;
4 import java.util.Vector JavaDoc;
5 import java.util.Properties JavaDoc;
6
7 /**
8  * This is a class that lets you choose your filter actions.
9  */

10 public class FlagFilterEditor extends FilterEditor {
11   JComboBox flagBox;
12   JComboBox trueFalseBox;
13
14   public static String JavaDoc FILTER_CLASS = "net.suberic.pooka.filter.FlagFilterAction";
15
16   /**
17    * Configures the given FilterEditor from the given VariableBundle and
18    * property.
19    */

20   public void configureEditor(net.suberic.util.gui.propedit.PropertyEditorManager newManager, String JavaDoc propertyName) {
21     property = propertyName;
22     manager = newManager;
23
24     Vector JavaDoc flagNames = Pooka.getSearchManager().getFlagLabels();
25     flagBox = new JComboBox(flagNames);
26
27     this.add(flagBox);
28
29     Vector JavaDoc trueFalse = new Vector JavaDoc();
30     trueFalse.add(Pooka.getProperty("label.true", "True"));
31     trueFalse.add(Pooka.getProperty("label.false", "False"));
32
33     trueFalseBox = new JComboBox(trueFalse);
34
35     this.add(trueFalseBox);
36   }
37
38   /**
39    * Gets the values that would be set by this FilterEditor.
40    */

41   public java.util.Properties JavaDoc getValue() {
42     Properties JavaDoc props = new Properties JavaDoc();
43     String JavaDoc oldFlag = manager.getProperty(property + ".flag", "");
44     if (! oldFlag.equals((String JavaDoc) flagBox.getSelectedItem()))
45       props.setProperty(property + ".flag", (String JavaDoc) flagBox.getSelectedItem());
46
47     String JavaDoc oldValue = manager.getProperty(property + ".value", "");
48     if (! oldFlag.equals((String JavaDoc) trueFalseBox.getSelectedItem()))
49       props.setProperty(property + ".value", (String JavaDoc) trueFalseBox.getSelectedItem());
50
51     String JavaDoc oldClassName = manager.getProperty(property + ".class", "");
52     if (!oldClassName.equals(FILTER_CLASS))
53       props.setProperty(property + ".class", FILTER_CLASS);
54
55     return props;
56   }
57
58   /**
59    * Sets the values represented by this FilterEditor in the manager.
60    */

61   public void setValue() {
62     String JavaDoc oldFlag = manager.getProperty(property + ".flag", "");
63     if (! oldFlag.equals((String JavaDoc) flagBox.getSelectedItem()))
64       manager.setProperty(property + ".flag", (String JavaDoc) flagBox.getSelectedItem());
65
66     String JavaDoc oldValue = manager.getProperty(property + ".value", "");
67     if (! oldFlag.equals((String JavaDoc) trueFalseBox.getSelectedItem()))
68       manager.setProperty(property + ".value", (String JavaDoc) trueFalseBox.getSelectedItem());
69
70     String JavaDoc oldClassName = manager.getProperty(property + ".class", "");
71     if (!oldClassName.equals(FILTER_CLASS))
72       manager.setProperty(property + ".class", FILTER_CLASS);
73   }
74
75   /**
76    * Returns the class that will be set for this FilterEditor.
77    */

78   public String JavaDoc getFilterClassValue() {
79     return FILTER_CLASS;
80   }
81
82
83 }
84
Popular Tags