|
org.openide.explorer 6.5.31 1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.openide.explorer.propertysheet.PropertyEnv
public class PropertyEnv
PropertyEnv is a class which allows an object (such as a
Node.Property instance) to communicate hints to property
editor instances that affect the behavior or visual
rendering of the property in a PropertySheet
or PropertyPanel
component. An instance of
PropertyEnv is passed to the attachEnv()
method of property editors implementing ExPropertyEditor.
Such property editors may then call
env.getFeatureDescriptor().get("someHintString")
to retrieve hints that affect their behavior from the
Node.Property object whose properties they are displaying.
The other purpose of the of this interface is to
enable communication between the PropertyEditor
and
the PropertySheet
or PropertyPanel
.
The custom property editor can get into a state when the visual state
does not represent valid value and in such case needs to disable OK button.
To handle that the property editor has to keep reference to its associated
PropertyEnv
and switch it into invalid state by calling
setState(
as soon as the content of the custom property editor is invalid and then
back by
STATE_INVALID
)setState(
when the custom property editor becomes valid once again. As a reaction
to these calls the displayer of the custom property editor (for example
dialog with OK button) is supposed to disable and re-enable the button.
STATE_VALID
)
Also it can happen that the property editor is complex and cannot decide whether
the value is valid quickly. Just knows that it needs to be validated.
For that purpose it wants to be informed when user presses the OK button and
do the complex validation then. For that purpose there is the STATE_NEEDS_VALIDATION
state. The property editor needs to use it and attach a listener to
be notified when the user presses the OK button:
class Validate implements VetoableChangeListener { public void vetoableChange(VetoableChangeEvent ev) throws PropertyVetoException { if (PROP_STATE.equals(ev.getPropertyName())) { if (!doTheComplexValidationOk()) { throw new PropertyVetoException(...); } } // otherwise allow the switch to ok state } } Validate v = new Validate(); env.setState(STATE_NEEDS_VALIDATION); env.addVetoableChangeListener(v);When the state is
STATE_NEEDS_VALIDATION
the OK button
of the surrounding dialog shall be enabled and when pressed the vetoable
listener notified about the expected change from
STATE_NEEDS_VALIDATION
to STATE_VALID
which can either be accepted or vetoed.
Field Summary | |
---|---|
static String |
PROP_STATE
Name of the state property. |
static Object |
STATE_INVALID
One possible value for the setState/getState methods. |
static Object |
STATE_NEEDS_VALIDATION
One possible value for the setState/getState methods. |
static Object |
STATE_VALID
One possible value for the setState/getState methods. |
Method Summary | |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener l)
Property change listener: listenning here you will be notified when the state of the environment is has been changed. |
void |
addVetoableChangeListener(VetoableChangeListener l)
Vetoable change listener: listenning here you will be notified when the state of the environment is being changed (when the setState method is being called). |
Object[] |
getBeans()
Array of beans that the edited property belongs to. |
FeatureDescriptor |
getFeatureDescriptor()
Feature descritor that describes the property. |
Object |
getState()
A getter for the current state of the environment. |
void |
registerInplaceEditorFactory(InplaceEditor.Factory factory)
Register a factory for InplaceEditor instances that the property sheet should use as an inline editor for the property. |
void |
removePropertyChangeListener(PropertyChangeListener l)
Removes Property change listener. |
void |
removeVetoableChangeListener(VetoableChangeListener l)
Vetoable change listener removal. |
void |
setState(Object newState)
A setter that should be used by the property editor to change the state of the environment. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String PROP_STATE
public static final Object STATE_VALID
public static final Object STATE_NEEDS_VALIDATION
public static final Object STATE_INVALID
Method Detail |
---|
public Object[] getBeans()
public FeatureDescriptor getFeatureDescriptor()
public void setState(Object newState)
public Object getState()
public void addVetoableChangeListener(VetoableChangeListener l)
public void addPropertyChangeListener(PropertyChangeListener l)
public void removeVetoableChangeListener(VetoableChangeListener l)
public void removePropertyChangeListener(PropertyChangeListener l)
public void registerInplaceEditorFactory(InplaceEditor.Factory factory)
getValue(String)
.
Node.Property
,
InplaceEditor
public String toString()
|
org.openide.explorer 6.5.31 1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |