KickJava   Java API By Example, From Geeks To Geeks.

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


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

11 public class MoveFilterEditor extends FilterEditor {
12   String JavaDoc originalFolderName;
13
14   FolderSelectorPane fsp;
15
16   public static String JavaDoc FILTER_CLASS = "net.suberic.pooka.filter.MoveFilterAction";
17
18   /**
19    * Configures the given FilterEditor from the given VariableBundle and
20    * property.
21    */

22   public void configureEditor(net.suberic.util.gui.propedit.PropertyEditorManager newManager, String JavaDoc propertyName) {
23     property = propertyName;
24     manager = newManager;
25
26     fsp = new FolderSelectorPane();
27     fsp.configureEditor(propertyName + ".targetFolder", manager);
28
29     SpringLayout JavaDoc layout = new SpringLayout JavaDoc();
30     this.setLayout(layout);
31
32     this.add(fsp.getLabelComponent());
33     this.add(fsp.getValueComponent());
34
35     layout.putConstraint(SpringLayout.NORTH, fsp.getLabelComponent(), 0, SpringLayout.NORTH, this);
36     layout.putConstraint(SpringLayout.WEST, fsp.getLabelComponent(), 0, SpringLayout.WEST, this);
37     layout.putConstraint(SpringLayout.SOUTH, this, 0, SpringLayout.SOUTH, fsp.getLabelComponent());
38     layout.putConstraint(SpringLayout.WEST, fsp.getValueComponent(), 5, SpringLayout.EAST, fsp.getLabelComponent());
39     layout.putConstraint(SpringLayout.EAST, this, 5, SpringLayout.EAST, fsp.getValueComponent());
40
41     this.setPreferredSize(new java.awt.Dimension JavaDoc(150, fsp.getLabelComponent().getMinimumSize().height));
42     this.setMaximumSize(new java.awt.Dimension JavaDoc(Integer.MAX_VALUE, fsp.getLabelComponent().getMinimumSize().height));
43
44   }
45
46   /**
47    * Gets the values that would be set by this FilterEditor.
48    */

49   public java.util.Properties JavaDoc getValue() {
50     Properties JavaDoc props = fsp.getValue();
51
52     String JavaDoc oldClassName = manager.getProperty(property + ".class", "");
53     if (!oldClassName.equals(FILTER_CLASS))
54       props.setProperty(property + ".class", FILTER_CLASS);
55
56     return props;
57   }
58
59   /**
60    * Sets the values represented by this FilterEditor in the manager.
61    */

62   public void setValue() throws PropertyValueVetoException {
63
64     fsp.setValue();
65
66     String JavaDoc oldClassName = manager.getProperty(property + ".class", "");
67     if (!oldClassName.equals(FILTER_CLASS))
68       manager.setProperty(property + ".class", FILTER_CLASS);
69   }
70
71   /**
72    * Returns the class that will be set for this FilterEditor.
73    */

74   public String JavaDoc getFilterClassValue() {
75     return FILTER_CLASS;
76   }
77
78 }
79
Popular Tags