01: package net.suberic.util.gui.propedit;
02:
03: import javax.swing.*;
04: import java.util.Vector;
05: import java.util.List;
06:
07: /**
08: * This will make an editor for a list of properties.
09: */
10: public abstract class CompositeSwingPropertyEditor extends
11: SwingPropertyEditor {
12: protected List editors;
13:
14: /**
15: * This writes the currently configured values in the PropertyEditorUI
16: * to the source VariableBundle.
17: */
18: public void setValue() throws PropertyValueVetoException {
19: if (isEnabled()) {
20: for (int i = 0; i < editors.size(); i++) {
21: ((PropertyEditorUI) editors.get(i)).setValue();
22: }
23: }
24: }
25:
26: /**
27: * This resets the editor to the original (or latest set, if setValue()
28: * has been called) value of the edited property.
29: */
30: public void resetDefaultValue() throws PropertyValueVetoException {
31: if (isEnabled()) {
32: for (int i = 0; i < editors.size(); i++) {
33: ((PropertyEditorUI) editors.get(i)).resetDefaultValue();
34: }
35: }
36: }
37:
38: /**
39: * Returns the current values of the edited properties as a
40: * java.util.Properties object.
41: */
42: public java.util.Properties getValue() {
43: java.util.Properties currentRetValue = new java.util.Properties();
44: java.util.Iterator iter = editors.iterator();
45: while (iter.hasNext()) {
46: currentRetValue.putAll(((SwingPropertyEditor) iter.next())
47: .getValue());
48: }
49:
50: return currentRetValue;
51: }
52:
53: /**
54: * Sets the enabled property of the PropertyEditorUI. Disabled
55: * editors should not be able to do setValue() calls.
56: */
57: public void setEnabled(boolean newValue) {
58: for (int i = 0; i < editors.size(); i++) {
59: ((PropertyEditorUI) editors.get(i)).setEnabled(newValue);
60: }
61: enabled = newValue;
62: }
63: }
|