public abstract class AbstractState extends java.lang.Object implements State
Modifier and Type | Field and Description |
---|---|
protected StateManager |
manager
The state manager where we are registered.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
properties
Property list.
|
protected java.beans.PropertyChangeSupport |
propertyChangeSupport
Property change support for standard handling of property changes.
|
ACTIVATION_PROPERTY, ACTIVE_ICON_PROPERTY, DISABLED_ICON_PROPERTY, ENABLE_PROPERTY, INACTIVE_ICON_PROPERTY, LABEL_TEXT_PROPERTY, POPUP_PROPERTY, TOOLTIP_TEXT_PROPERTY
Constructor and Description |
---|
AbstractState()
Create a new abstract state.
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent e)
An action is performed.
|
boolean |
activate()
Activate this state.
|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a property change listener.
|
void |
addPropertyChangeListener(java.lang.String property,
java.beans.PropertyChangeListener listener)
Add a property change listener for a special property.
|
javax.swing.JComponent[] |
addToToolBar(javax.swing.JToolBar toolBar)
Add this element to the toolbar.
|
javax.swing.JComponent[] |
addToToolBar(javax.swing.JToolBar toolBar,
int index)
Add this element to the toolbar.
|
void |
deactivate()
Deactivate this state.
|
java.lang.Object |
getValue(java.lang.String name)
Get the value of a given property.
|
boolean |
isActivated()
Is this state activated?
|
boolean |
isEnabled()
Is this state enabled?
|
boolean |
isToggleEnabled()
Is it possible to switch this state off by clicking on it with the mouse?
|
void |
putValue(java.lang.String key,
java.lang.Object value)
Set the value of a given property,
|
void |
refresh()
Refresh state.
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a property change listener.
|
void |
removePropertyChangeListener(java.lang.String property,
java.beans.PropertyChangeListener listener)
Remove a property change listener for a special property.
|
void |
setEnabled(boolean state)
Enable or disable this state.
|
void |
setManager(StateManager stateManager)
Set the state manager which handles this state.
|
protected void |
setProperty(java.lang.String name,
java.lang.Object value)
Set a property to a new value.
|
void |
showPopup(java.awt.Component comp,
int x,
int y)
Show a popup menu.
|
protected final java.beans.PropertyChangeSupport propertyChangeSupport
protected final java.util.Map<java.lang.String,java.lang.Object> properties
protected StateManager manager
public void setManager(@NotNull StateManager stateManager)
setManager
in interface State
stateManager
- state managerpublic void addPropertyChangeListener(@NotNull java.beans.PropertyChangeListener listener)
addPropertyChangeListener
in interface javax.swing.Action
listener
- listener to addpublic void addPropertyChangeListener(@NotNull java.lang.String property, @NotNull java.beans.PropertyChangeListener listener)
addPropertyChangeListener
in interface State
property
- property identifierlistener
- listener to addpublic void removePropertyChangeListener(@NotNull java.beans.PropertyChangeListener listener)
removePropertyChangeListener
in interface javax.swing.Action
listener
- listener to removepublic void removePropertyChangeListener(@NotNull java.lang.String property, @NotNull java.beans.PropertyChangeListener listener)
removePropertyChangeListener
in interface State
property
- property identifierlistener
- listener to removepublic boolean activate()
public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener
e
- unusedpublic boolean isActivated()
isActivated
in interface State
public void deactivate()
deactivate
in interface State
public void setEnabled(boolean state)
setEnabled
in interface javax.swing.Action
state
- if true
enable this state, otherwise disable itpublic boolean isEnabled()
isEnabled
in interface javax.swing.Action
public java.lang.Object getValue(@NotNull java.lang.String name)
getValue
in interface javax.swing.Action
name
- property namepublic void putValue(@NotNull java.lang.String key, java.lang.Object value)
putValue
in interface javax.swing.Action
key
- property keyvalue
- new value of propertyprotected void setProperty(@NotNull java.lang.String name, java.lang.Object value)
name
- property namevalue
- new valuepublic void showPopup(@NotNull java.awt.Component comp, int x, int y)
showPopup
in interface State
comp
- component where to show the popup menux
- x position in componenty
- y position in componentState.hasPopup()
@NotNull public javax.swing.JComponent[] addToToolBar(@NotNull javax.swing.JToolBar toolBar)
addToToolBar
in interface ToolBarElement
toolBar
- toolbar to add to@NotNull public javax.swing.JComponent[] addToToolBar(@NotNull javax.swing.JToolBar toolBar, int index)
addToToolBar
in interface ToolBarElement
toolBar
- toolbar to add toindex
- position where to add the itempublic boolean isToggleEnabled()
isToggleEnabled
in interface State