|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbibliothek.gui.dock.support.action.ModeTransitionManager<A>
A
- the type of properties that has to be stored for every
dockable-mode relationpublic abstract class ModeTransitionManager<A>
A set of modes. Adds some ButtonDockAction
s to Dockable
s,
and when the user clicks on one of these actions, then the Dockable
goes into another mode.
Subclasses can assign some properties that connect mode and Dockable
.
This class is an ActionGuard
and will only have an influence if
it is added to the DockController
through DockController.addActionGuard(ActionGuard)
Constructor Summary | |
---|---|
ModeTransitionManager(String... modes)
Creates a new manager |
Method Summary | ||
---|---|---|
void |
add(String name,
Dockable dockable)
Makes an entry for dockable and adds actions to its
global DockActionSource . |
|
protected abstract String[] |
availableModes(String current,
Dockable dockable)
Makes a list of all modes dockable can be going into. |
|
protected
|
createSetting(ModeTransitionConverter<A,B> converter)
Creates a new, empty setting. |
|
protected abstract String |
currentMode(Dockable dockable)
Gets the mode dockable is currently into. |
|
protected abstract String |
getDefaultMode(Dockable dockable)
Gets the mode dockable should be go to if no other
mode is preferred. |
|
List<Dockable> |
getDockables()
Gets a list that contains all Dockable s that are currently
known to this manager. |
|
SimpleButtonAction |
getIngoingAction(String mode)
Gets the action that is displayed on Dockable s which might
go into the mode mode . |
|
String |
getName(Dockable dockable)
Searches the name of dockable . |
|
SimpleButtonAction |
getOutgoingAction(String mode)
Gets the action that is displayed on Dockable s which are
currently in the mode mode . |
|
protected A |
getProperties(String mode,
Dockable dockable)
Gets the properties which correspond to dockable
and mode . |
|
|
getSetting(ModeTransitionConverter<A,B> converter)
Gets the current set or properties. |
|
DockActionSource |
getSource(Dockable dockable)
Gets a list of actions for the Dockable |
|
protected void |
goIn(String mode,
Dockable dockable)
Called when the button to go into mode is pressed. |
|
protected void |
goOut(String mode,
Dockable dockable)
Called when the button to go out of mode is pressed. |
|
protected String[] |
history(Dockable dockable)
Gets the history of modes dockable was into. |
|
protected String |
previousMode(Dockable dockable)
Gets the mode in which Dockable was previously |
|
void |
put(String name,
Dockable dockable)
Ensures that dockable is registered under name
and that dockable has an entry. |
|
protected void |
putIngoingAction(String mode,
SimpleButtonAction action)
Sets the action that is displayed on Dockable s which might
go into the mode mode . |
|
protected void |
putMode(Dockable dockable,
String mode)
Stores mode as new mode of dockable , put
does not call transition(String, String, Dockable) . |
|
protected void |
putOutgoingAction(String mode,
SimpleButtonAction action)
Sets the action that is displayed on Dockable s which might
go out of the mode mode . |
|
boolean |
react(Dockable dockable)
Tests the given Dockable and tells whether this
ActionGuard is interested in it and wants to add some additional
actions to it, or if this guard
is not made for the dockable . |
|
|
read(ModeTransitionConverter<A,B> converter,
DataInputStream in)
Reads the properties of this manager. |
|
protected void |
rebuild(Dockable dockable)
Called when the list of actions for dockable has to be
rebuild. |
|
protected void |
rebuildAll()
Called when the list of actions has to be rebuilt for each Dockable . |
|
void |
remove(Dockable dockable)
Removes the properties that belong to dockable . |
|
void |
setMode(Dockable dockable,
String mode)
Sets the mode of dockable to mode . |
|
protected void |
setProperties(String mode,
Dockable dockable,
A properties)
Sets the properties which correspond to dockable
and mode . |
|
void |
setSetting(ModeTransitionSetting<A,?> setting)
Sets all properties of this manager. |
|
protected abstract void |
transition(String oldMode,
String newMode,
Dockable dockable)
Called when a Dockable has to change from one mode to another mode.Subclasses might use getProperties(String, Dockable) and
setProperties(String, Dockable, Object) to get or store
properties associated with the mode. |
|
protected abstract void |
transitionDuringRead(String oldMode,
String newMode,
Dockable dockable)
Called while reading modes in setSetting(ModeTransitionSetting) . |
|
|
write(ModeTransitionConverter<A,B> converter,
DataOutputStream out)
Writes the properties of this manager into out . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ModeTransitionManager(String... modes)
modes
- the list of modes in which a Dockable
might
go intoMethod Detail |
---|
public boolean react(Dockable dockable)
ActionGuard
Dockable
and tells whether this
ActionGuard is interested in it and wants to add some additional
actions
to it, or if this guard
is not made for the dockable
.
react
in interface ActionGuard
dockable
- The Dockable
to test
true
if the ActionGuard.getSource(Dockable)
-method
should be invoked, false
otherwisepublic DockActionSource getSource(Dockable dockable)
ActionGuard
Dockable
getSource
in interface ActionGuard
dockable
- The Dockable
for which ActionGuard.react(Dockable)
is true
dockable
.public void add(String name, Dockable dockable)
dockable
and adds actions to its
global DockActionSource
.
name
- a unique name for dockable
dockable
- the element to addpublic void put(String name, Dockable dockable)
dockable
is registered under name
and that dockable
has an entry. If there is already a
Dockable
known under name
, then this other
Dockable
is replaced by dockable
.
name
- the name of dockable
dockable
- the new Dockable
public void remove(Dockable dockable)
dockable
.
dockable
- the element to removepublic List<Dockable> getDockables()
Dockable
s that are currently
known to this manager.
Dockable
s, the list can be modified
without disturbing this manager.public String getName(Dockable dockable)
dockable
.
dockable
- an element whose name is searched
null
public SimpleButtonAction getOutgoingAction(String mode)
Dockable
s which are
currently in the mode mode
.
mode
- the mode whose outgoing action is searched
null
if mode
is unknownprotected void putOutgoingAction(String mode, SimpleButtonAction action)
Dockable
s which might
go out of the mode mode
.
mode
- some mode whose action should be exchangedaction
- the new action, can be null
IllegalArgumentException
- if mode
is unknownpublic SimpleButtonAction getIngoingAction(String mode)
Dockable
s which might
go into the mode mode
.
mode
- the mode whose ingoing action is searched
null
if mode
is unknownprotected void putIngoingAction(String mode, SimpleButtonAction action)
Dockable
s which might
go into the mode mode
.
mode
- some mode whose action should be exchangedaction
- the new action, can be null
IllegalArgumentException
- if mode
is unknownprotected abstract String currentMode(Dockable dockable)
dockable
is currently into. This method
must also work if dockable
is not registered at this
ModeTransitionManager
.
dockable
- the element whose mode is searched
dockable
is, null
is not valid.protected abstract String[] availableModes(String current, Dockable dockable)
dockable
can be going into.
current
- the mode dockable
is currently indockable
- the element whose available modes are searched
protected abstract String getDefaultMode(Dockable dockable)
dockable
should be go to if no other
mode is preferred.
dockable
- the element whose default mode is asked
protected abstract void transition(String oldMode, String newMode, Dockable dockable)
Dockable
has to change from one mode to another mode.getProperties(String, Dockable)
and
setProperties(String, Dockable, Object)
to get or store
properties associated with the mode.
oldMode
- the mode dockable
is currently innewMode
- the mode dockable
is going to bedockable
- the element that changes its modeprotected abstract void transitionDuringRead(String oldMode, String newMode, Dockable dockable)
setSetting(ModeTransitionSetting)
.
Subclasses might change the mode according to newMode
.
oldMode
- the mode dockable
is currently innewMode
- the mode dockable
is going to bedockable
- the element that changes its modeprotected String[] history(Dockable dockable)
dockable
was into. The history
contains every mode at most once, beginning with oldest mode.
dockable
- the element whose history is searched
null
if dockable
is
not known. Modifications of the array will not have any sideeffects.protected void goOut(String mode, Dockable dockable)
mode
is pressed.
mode
- the mode to leavedockable
- the affected elementprotected void goIn(String mode, Dockable dockable)
mode
is pressed.
mode
- the mode to go intodockable
- the affected elementpublic void setMode(Dockable dockable, String mode)
dockable
to mode
.
dockable
- the element to set the modemode
- the new mode of dockable
protected void rebuildAll()
Dockable
.
protected void rebuild(Dockable dockable)
dockable
has to be
rebuild.
dockable
- the element whose actions are searchedprotected A getProperties(String mode, Dockable dockable)
dockable
and mode
.
mode
- the first part of the keydockable
- the second part of the key
null
protected void setProperties(String mode, Dockable dockable, A properties)
dockable
and mode
. Does nothing if dockable
is
unknown.
mode
- the first part of the keydockable
- the second part of the keyproperties
- the things to store or null
to delete
the entryprotected void putMode(Dockable dockable, String mode)
mode
as new mode of dockable
, put
does not call transition(String, String, Dockable)
.
dockable
- the element whose mode changesmode
- the new modeprotected String previousMode(Dockable dockable)
Dockable
was previously
dockable
- the element whose mode is searched
null
public <B> ModeTransitionSetting<A,B> getSetting(ModeTransitionConverter<A,B> converter)
B
- the type of the internal representation of the propertiesconverter
- converts the properties into the internal representation
public void setSetting(ModeTransitionSetting<A,?> setting)
setting
will not be affected by this method.
setting
- the set of propertiesprotected <B> ModeTransitionSetting<A,B> createSetting(ModeTransitionConverter<A,B> converter)
B
- the type of properties stored in the settingconverter
- used to convert properties of this manager to the properties of the setting
public <B> void write(ModeTransitionConverter<A,B> converter, DataOutputStream out) throws IOException
out
.
converter
- a converter that can write the properties of this manager.out
- the stream to write into
IOException
- if an I/O-error occurspublic <B> void read(ModeTransitionConverter<A,B> converter, DataInputStream in) throws IOException
ModeTransitionSetting setting = createSetting( converter ); setting.read( in ); setSetting( setting );
converter
- a converter that can read the propertiesin
- the stream to read from
IOException
- if the stream can't be read
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |