Package org.eclipse.core.commands
Class State
java.lang.Object
org.eclipse.core.commands.common.EventManager
org.eclipse.core.commands.State
- Direct Known Subclasses:
PersistentState
A piece of state information that can be shared between objects, and might be persisted between sessions. This can be used for commands that toggle between two states and wish to pass this state information between different handlers.
This state object can either be used as a single state object shared between several commands, or one state object per command -- depending on the needs of the application.
Clients may instantiate or extend this class.
- Since:
- 3.2
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(IStateListener listener) Adds a listener to changes for this state.void
dispose()
Disposes of this state.protected final void
fireStateChanged
(Object oldValue) Notifies listeners to this state that it has changed in some way.final String
getId()
Returns the identifier for this state.getValue()
The current value associated with this state.void
removeListener
(IStateListener listener) Removes a listener to changes from this state.void
Sets the identifier for this object.void
Sets the value for this state object.Methods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
-
Constructor Details
-
State
public State()
-
-
Method Details
-
addListener
Adds a listener to changes for this state.- Parameters:
listener
- The listener to add; must not benull
.
-
dispose
public void dispose()Disposes of this state. This allows the state to unregister itself with any managers or as a listener. -
fireStateChanged
Notifies listeners to this state that it has changed in some way.- Parameters:
oldValue
- The old value; may be anything.
-
getId
Returns the identifier for this state.- Returns:
- The id; may be
null
.
-
getValue
The current value associated with this state. This can be any type of object, but implementations will usually restrict this value to a particular type.- Returns:
- The current value; may be anything.
-
removeListener
Removes a listener to changes from this state.- Parameters:
listener
- The listener to remove; must not benull
.
-
setId
Sets the identifier for this object. This method should only be called by the command framework. Clients should not call this method.- Parameters:
id
- The id; must not benull
.
-
setValue
Sets the value for this state object.- Parameters:
value
- The value to set; may be anything.
-