public abstract class AbstractStateAdapter extends Object implements StateAdapter, ChangeListener
Constructor and Description |
---|
AbstractStateAdapter()
Creates a new adapter, that monitors no state and has an
empty string as its name.
|
AbstractStateAdapter(State pState)
Creates a new adapter, that monitors the handed state and has an
empty string as its name.
|
AbstractStateAdapter(State pState,
String pName)
Creates a new adapter, that monitors the handed state and uses
the handed string as its name.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Object pTarget)
Add a target object to our adapter.
|
void |
add(Object pTarget,
boolean pInvert)
Add a target object to our adapter.
|
void |
addInvert(Object pTarget)
Add a target object with inverted state change logic to our adapter.
|
protected abstract void |
adjustInitialState(Object pTarget,
boolean pEnabled)
Implement this method in a subclass to set the initial state
of a target object.
|
protected String |
getConsistencyCategory()
This implementation returns the full class name to be used
as a key in the
CONSISTENCY_MAP . |
String |
getName()
Return the name of the state adapter.
|
protected abstract void |
processStateChange(Object pTarget,
boolean pEnabled)
Implement this method in a subclass to set the state of a target
object after our monitored state changes.
|
void |
remove(Object pComponent)
Removes the handed object of our adapter.
|
void |
setName(String pName)
Set the name of the state adapter.
|
void |
setState(State pState)
Sets (or resets if pState=null) the state this adapter acts on.
|
void |
stateChanged(ChangeEvent pEvent)
Internal method to monitor our state, don't call this.
|
public AbstractStateAdapter()
public AbstractStateAdapter(State pState)
pState
- the state we adopt to, may be nullpublic AbstractStateAdapter(State pState, String pName)
pState
- the state we adopt to, may be nullpName
- our nameIllegalArgumentException
- if pName is nullpublic String getName()
StateAdapter
getName
in interface StateAdapter
public void setName(String pName)
StateAdapter
setName
in interface StateAdapter
pName
- the name of the state (must not be null)public void setState(State pState)
StateAdapter
setState
in interface StateAdapter
pState
- null or the state we act uponpublic void add(Object pTarget)
StateAdapter
add
in interface StateAdapter
pTarget
- target we should act on when our state changespublic void addInvert(Object pTarget)
StateAdapter
addInvert
in interface StateAdapter
pTarget
- target we should act on when our state changespublic void add(Object pTarget, boolean pInvert)
StateAdapter
add
in interface StateAdapter
pTarget
- target we should act on when our state changespInvert
- flag if we should invert the state changeprotected String getConsistencyCategory()
CONSISTENCY_MAP
.
Override to match if your implementation affects the same
property of a target as another implementation.CONSISTENCY_MAP
public void remove(Object pComponent)
StateAdapter
remove
in interface StateAdapter
pComponent
- target we should removepublic void stateChanged(ChangeEvent pEvent)
stateChanged
in interface ChangeListener
pEvent
- not usedprotected abstract void adjustInitialState(Object pTarget, boolean pEnabled)
pTarget
- target object, never nullpEnabled
- true if the target object should get "enabled"protected abstract void processStateChange(Object pTarget, boolean pEnabled)
pTarget
- target object, never nullpEnabled
- true if the target object should get "enabled"Copyright © 2017 Jürgen Zeller (privat). All rights reserved.