001: package org.netbeans.spi.options;
002:
003: import java.beans.PropertyChangeListener;
004: import javax.swing.JComponent;
005: import org.openide.util.HelpCtx;
006: import org.openide.util.Lookup;
007:
008: /**
009: * PanelController creates visual representation of one Options Dialog
010: * category, and manages communication between Options Dialog and this
011: * panel.
012: */
013: public abstract class OptionsPanelController {
014:
015: /**
016: * Property name constant.
017: */
018: public static final String PROP_VALID = "valid";
019:
020: /**
021: * Property name constant.
022: */
023: public static final String PROP_CHANGED = "changed";
024:
025: /**
026: * Property name constant.
027: */
028: public static final String PROP_HELP_CTX = "helpCtx";
029:
030: /**
031: * Component should load its data here. You should not do any
032: * time-consuming operations inside the constructor, because it
033: * blocks initialization of OptionsDialog. Initialization
034: * should be implemented in update method.
035: * This method is called after {@link #getComponent} method.
036: * Update method can be called more than one time for the same instance
037: * of JComponent obtained from {@link #getComponent} call.
038: */
039: public abstract void update();
040:
041: /**
042: * This method is called when Options Dialog "OK" button is pressed.
043: */
044: public abstract void applyChanges();
045:
046: /**
047: * This method is called when Options Dialog "Cancel" button is pressed.
048: */
049: public abstract void cancel();
050:
051: /**
052: * Should return <code>true</code> if some option value in this
053: * category is valid.
054: *
055: *
056: * @return <code>true</code> if some option value in this
057: * category is valid
058: */
059: public abstract boolean isValid();
060:
061: /**
062: * Should return <code>true</code> if some option value in this
063: * category has been changed.
064: *
065: *
066: * @return <code>true</code> if some option value in this
067: * category has been changed
068: */
069: public abstract boolean isChanged();
070:
071: /**
072: * Each option category can provide some lookup. Options Dialog master
073: * lookup is composed from these individual lookups. Master lookup
074: * can be obtained from {@link #getComponent} call. This lookup is designed
075: * to support communication anong individual panels in one Options
076: * Dialog.
077: *
078: * There is no guarantee that this method will be called from AWT thread.
079: *
080: * @return lookup provided by this Options Dialog panel
081: */
082: public Lookup getLookup() {
083: return Lookup.EMPTY;
084: }
085:
086: /**
087: * Returns visual component representing this options category.
088: * This method is called before {@link #update} method.
089: *
090: * @param masterLookup master lookup composed from lookups provided by
091: * individual OptionsPanelControllers
092: * - {@link OptionsPanelController#getLookup}
093: * @return visual component representing this options category
094: */
095: public abstract JComponent getComponent(Lookup masterLookup);
096:
097: /**
098: *
099: * Get current help context asociated with this panel.
100: *
101: *
102: * @return current help context
103: */
104: public abstract HelpCtx getHelpCtx();
105:
106: /**
107: * Registers new listener.
108: *
109: *
110: * @param l a new listener
111: */
112: public abstract void addPropertyChangeListener(
113: PropertyChangeListener l);
114:
115: /**
116: * Unregisters given listener.
117: *
118: *
119: * @param l a listener to be removed
120: */
121: public abstract void removePropertyChangeListener(
122: PropertyChangeListener l);
123: }
|