|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object bibliothek.gui.dock.support.mode.ModeManager<H,M>
H
- the kind of properties that are to be stored in this managerM
- the kind of Mode
s used by this managerpublic abstract class ModeManager<H,M extends Mode<H>>
Associates Dockable
s with one Mode
out of a set
of modes. This manager remembers in which order the modes were applied
to a Dockable
.
Constructor Summary | |
---|---|
ModeManager(DockController controller)
Creates a new manager. |
Method Summary | ||
---|---|---|
void |
add(String key,
Dockable dockable)
Registers a new Dockable at this manager. |
|
void |
addAffected(Iterable<Dockable> dockables)
Adds all elements of dockables to the current
AffectedSet . |
|
void |
addEmpty(String key)
Adds an empty entry to this manager. |
|
void |
addModeManagerListener(ModeManagerListener<? super H,? super M> listener)
Adds a listener to this manager, the listener will be informed about changes in this manager. |
|
void |
apply(Dockable dockable,
M mode,
AffectedSet set,
boolean force)
Alters the mode of dockable to mode . |
|
void |
apply(Dockable dockable,
M mode,
boolean force)
Alters the mode of dockable to mode . |
|
void |
apply(Dockable dockable,
M mode,
H history,
AffectedSet set)
Alters the mode of dockable to be mode . |
|
boolean |
apply(Dockable dockable,
Path mode,
AffectedSet set,
boolean force)
Alters the mode of dockable to mode . |
|
boolean |
apply(Dockable dockable,
Path mode,
boolean force)
Alters the mode of dockable to mode . |
|
boolean |
apply(Dockable dockable,
Path mode,
H history,
AffectedSet set)
Alters the mode of dockable to be mode . |
|
protected abstract void |
applyDuringRead(String key,
Path old,
Path current,
Dockable dockable)
Called while reading modes in readSettings(ModeSettings) . |
|
protected boolean |
createEntryDuringRead(String key)
Tells whether an entry for a missing Dockable should be created. |
|
protected
|
createModeSettings(ModeSettingsConverter<H,B> converter)
Creates the empty set of settings for this ModeManager . |
|
|
createSettings(ModeSettingsConverter<H,B> converter)
Creates a new ModeSetting which is configured to transfer data from
this ModeManager to persistent storage or the other way. |
|
void |
destroy()
Unregisters listeners which this manager added to the DockController and
other components. |
|
protected void |
fireAdded(Dockable dockable)
Calls ModeManagerListener.dockableAdded(ModeManager, Dockable)
on all listeners that are currently registered |
|
protected void |
fireAdded(M mode)
Calls ModeManagerListener.modeAdded(ModeManager, Mode) on
all listeners that are currently registered. |
|
protected void |
fireModeChanged(Dockable dockable,
M oldMode,
M newMode)
Calls ModeManagerListener.modeChanged(ModeManager, Dockable, Mode, Mode)
on all listeners that are currently registered. |
|
protected void |
fireRemoved(Dockable dockable)
Calls ModeManagerListener.dockableRemoved(ModeManager, Dockable)
on all listeners that are currently registered. |
|
protected void |
fireRemoved(M mode)
Calls ModeManagerListener.modeRemoved(ModeManager, Mode) on
all listeners that are currently registered. |
|
DockController |
getController()
Gets the controller in whose realm this manager works. |
|
M |
getCurrentMode(Dockable dockable)
Tries to find the mode dockable is currently in. |
|
protected M |
getDefaultMode(Dockable dockable)
Gets the default mode of dockable , the mode
dockable is in if nothing else is specified. |
|
Dockable |
getDoubleClickTarget(Dockable target)
Given some Dockable on which an event was registered, searches a
registered dockable that is a child of target or
target itself. |
|
String |
getKey(Dockable dockable)
Gets the unique identifier which is used for dockable . |
|
M |
getMode(Path path)
Searches and returns the mode with given unique identifier path . |
|
List<M> |
getModeHistory(Dockable dockable)
Gets the history which modes dockable
used in the past. |
|
M |
getPreviousMode(Dockable dockable)
Reading the history this method tells which mode dockable was in before the current mode. |
|
protected H |
getProperties(M mode,
Dockable dockable)
Gets the properties which correspond to dockable
and mode . |
|
List<H> |
getPropertyHistory(Dockable dockable)
Gets the history which properties dockable
used in the past. |
|
boolean |
isEmpty(String key)
Tells whether information about dockable key gets
stored indefinitely or not. |
|
boolean |
isOnContinuous()
Tells whether this manager currently runs a continuous transaction. |
|
boolean |
isOnTransaction()
Tells whether this manager is currently changing the Mode of a Dockable . |
|
boolean |
isRegistered(Dockable dockable)
Tells whether this ModeManager knows dockable
and can handle a call to any of the apply methods. |
|
Set<Dockable> |
listDockables()
Returns a set containing all Dockable s that are currently
registered at this manager. |
|
protected ModeManagerListener<? super H,? super M>[] |
listeners()
Gets all the listeners that are currently registered in this manager. |
|
Iterable<M> |
modes()
Returns an iteration of all modes that are stored in this manager. |
|
void |
put(String key,
Dockable dockable)
Registers a new Dockable at this manager. |
|
void |
putFactory(ModeSettingFactory<H> factory)
Adds a factory to this ModeManager . |
|
void |
putMode(M mode)
Puts a new mode in this manager. |
|
void |
readSettings(ModeSettings<H,?> settings)
|
|
protected void |
rebuild(Dockable dockable)
Rebuilds the action sources of dockable . |
|
protected void |
rebuildAll()
Rebuilds the actions sources for all Dockable s. |
|
void |
reduceToEmpty(Dockable dockable)
Removes dockable itself, put the properties of
dockable remain in the system. |
|
void |
refresh()
Updates the modes of all Dockable s that
are registered at this ModeManager . |
|
void |
refresh(Dockable dockable,
boolean recursive)
Updates the mode of dockable and updates the actions
associated with dockable . |
|
void |
remove(Dockable dockable)
Removes the properties that belong to dockable . |
|
void |
removeEmpty(String name)
Removes the entry for name but only if the entry is not
associated with any Dockable . |
|
void |
removeMode(M mode)
Removes mode from this manager. |
|
void |
removeModeManagerListener(ModeManagerListener<? super H,? super M> listener)
Removes listener from this manager. |
|
void |
runTransaction(AffectingRunnable runnable)
Runs an algorithm which affects the mode of some Dockable s. |
|
void |
runTransaction(AffectingRunnable run,
boolean continuous)
Runs an algorithm which affects the mode of some Dockable s. |
|
void |
runTransaction(Runnable run)
Runs run as transaction, the DockRegister is stalled
and isOnTransaction() returns true while
run runs. |
|
void |
runTransaction(Runnable run,
boolean continuous)
Runs run as transaction, the DockRegister is stalled
and isOnTransaction() returns true while
run runs. |
|
protected void |
setProperties(M mode,
Dockable dockable,
H property)
Stores a property for dockable if in mode mode . |
|
void |
store(Dockable dockable)
Stores the current location of dockable and all its children in respect
to their current Mode . |
|
protected void |
store(M mode,
Dockable dockable)
Stores the location of dockable under the key mode . |
|
String |
toString()
|
|
void |
writeSettings(ModeSettings<H,?> setting)
Writes all the information stored in this ModeManager to
setting . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ModeManager(DockController controller)
controller
- the controller in whose realm this manager will workMethod Detail |
---|
public void destroy()
DockController
and
other components.
public DockController getController()
public void addModeManagerListener(ModeManagerListener<? super H,? super M> listener)
listener
- the new listener, not null
public void removeModeManagerListener(ModeManagerListener<? super H,? super M> listener)
listener
from this manager.
listener
- the listener to removepublic void putMode(M mode)
mode
- the new modepublic void putFactory(ModeSettingFactory<H> factory)
ModeManager
. The factory will be used by the
ModeSettings
to read and write data of the mode with the same identifier
as factory
persistently.Mode
might also provide a ModeSettingFactory
, if
there is a collision of unique identifiers the factory of the mode is used.
factory
- the new factorypublic void removeMode(M mode)
mode
from this manager. Note that history information
about the mode remains.
mode
- the mode to removepublic M getMode(Path path)
path
.
path
- some unique identifier
null
protected ModeManagerListener<? super H,? super M>[] listeners()
protected void fireAdded(Dockable dockable)
ModeManagerListener.dockableAdded(ModeManager, Dockable)
on all listeners that are currently registered
dockable
- the new elementprotected void fireRemoved(Dockable dockable)
ModeManagerListener.dockableRemoved(ModeManager, Dockable)
on all listeners that are currently registered.
dockable
- the removed elementprotected void fireModeChanged(Dockable dockable, M oldMode, M newMode)
ModeManagerListener.modeChanged(ModeManager, Dockable, Mode, Mode)
on all listeners that are currently registered.
dockable
- the element whose mode changedoldMode
- its old modenewMode
- its new modeprotected void fireAdded(M mode)
ModeManagerListener.modeAdded(ModeManager, Mode)
on
all listeners that are currently registered.
mode
- the added modeprotected void fireRemoved(M mode)
ModeManagerListener.modeRemoved(ModeManager, Mode)
on
all listeners that are currently registered.
mode
- the removed modepublic void add(String key, Dockable dockable)
Dockable
at this manager. If there is already
mode-information for key
present, then dockable
inherits this information.
key
- the unique key of dockable
dockable
- the new element
NullPointerException
- if either key
or dockable
is null
IllegalArgumentException
- if there is already a dockable registered
with key
public void put(String key, Dockable dockable)
Dockable
at this manager. This method works
like add(String, Dockable)
but does not throw an exception
if another Dockable
is already registered with key
.
Instead the other Dockable
is unregistered and docakble
inherits its mode-information.
key
- the unique identifier of dockable
dockable
- some new element
NullPointerException
- if either key
or dockable
is null
public String getKey(Dockable dockable)
dockable
.
dockable
- some element
null
if dockable
is not registeredpublic boolean isRegistered(Dockable dockable)
ModeManager
knows dockable
and can handle a call to any of the apply
methods.
dockable
- the element to check
true
if the element is known, false
otherwisepublic Set<Dockable> listDockables()
Dockable
s that are currently
registered at this manager.
public void runTransaction(AffectingRunnable runnable)
Dockable
s.
runnable
- the algorithm, null
will be ignoredpublic void runTransaction(AffectingRunnable run, boolean continuous)
Dockable
s.
run
- the algorithm, null
will be ignoredcontinuous
- if set to true
the transaction should run without changing
the internal cache storing the position of all Dockable
s. This can be important
if an operation runs an apply
method and additional work will change
the position of some elements again. Clients should call store(Dockable)
afterwards.public void runTransaction(Runnable run)
run
as transaction, the DockRegister
is stalled
and isOnTransaction()
returns true
while
run
runs.
run
- the runnable to executepublic void runTransaction(Runnable run, boolean continuous)
run
as transaction, the DockRegister
is stalled
and isOnTransaction()
returns true
while
run
runs.
run
- the runnable to executecontinuous
- if set to true
the transaction should run without changing
the internal cache storing the position of all Dockable
s. This can be important
if an operation runs an apply
method and additional work will change
the position of some elements again. Clients should call store(Dockable)
afterwards.public boolean apply(Dockable dockable, Path mode, boolean force)
dockable
to mode
.
This method just calls apply(Dockable, Mode, boolean)
.
dockable
- the element whose mode is going to be changedmode
- the new modeforce
- if true
dockable
is relocated even if the
current mode already is mode
true
if mode
was found, false
otherwise
IllegalArgumentException
- if dockable
is null
,
mode
is null
or dockable
is not
registered.public void apply(Dockable dockable, M mode, boolean force)
dockable
to mode
.
This method just calls apply(Dockable, Mode, AffectedSet, boolean)
.
dockable
- the element whose mode is going to be changedmode
- the new modeforce
- if true
dockable
is relocated even if the
current mode already is mode
IllegalArgumentException
- if dockable
is null
,
mode
is null
or dockable
is not
registered.public boolean apply(Dockable dockable, Path mode, AffectedSet set, boolean force)
dockable
to mode
.
This method just calls apply(Dockable, Mode, AffectedSet, boolean)
.
dockable
- the element whose mode is going to be changedmode
- the new modeset
- to store all dockables whose mode might have been changedforce
- if true
dockable
is relocated even if the
current mode already is mode
true
if mode
was found,
false
otherwise
IllegalArgumentException
- if dockable
is null
,
mode
is null
, set
is null
,
or dockable
is not registered.public void apply(Dockable dockable, M mode, AffectedSet set, boolean force)
dockable
to mode
. This
method does nothing if the current mode of dockable
already is mode
.apply(Dockable, Mode, Object, AffectedSet)
.
dockable
- the element whose mode is going to be changedmode
- the new modeset
- to store all dockables whose mode might have been changedforce
- if true
dockable
is relocated even if the
current mode already is mode
IllegalArgumentException
- if dockable
is null
,
mode
is null
, set
is null
,
or dockable
is not registered.public boolean apply(Dockable dockable, Path mode, H history, AffectedSet set)
dockable
to be mode
.
This method just calls apply(Dockable, Mode, Object, AffectedSet)
.
dockable
- the element whose mode is changedmode
- the new mode of dockable
history
- history information for Mode.apply(Dockable, Object, AffectedSet)
,
can be null
set
- to store elements that have changed
true
if mode
was found, false
otherwise
IllegalArgumentException
- if either dockable
, mode
or set
is null
public void apply(Dockable dockable, M mode, H history, AffectedSet set)
dockable
to be mode
.
This method does not alter the modes of other dockables, notice however
that the methods Mode.apply(Dockable, Object, AffectedSet)
may
trigger additional mode-changes.
dockable
- the element whose mode is changedmode
- the new mode of dockable
history
- history information for Mode.apply(Dockable, Object, AffectedSet)
,
can be null
set
- to store elements that have changed
IllegalArgumentException
- if either dockable
, mode
or set
is null
protected void setProperties(M mode, Dockable dockable, H property)
dockable
if in mode mode
. This
method does not trigger any version of the apply
methods.
mode
- the mode which is affecteddockable
- the dockables whose property is changedproperty
- the new property, can be null
protected H getProperties(M mode, Dockable dockable)
dockable
and mode
.
mode
- the first part of the keydockable
- the second part of the key
null
public boolean isOnTransaction()
Mode
of a Dockable
.
true
if a mode is currently workingpublic boolean isOnContinuous()
public void refresh()
Dockable
s that
are registered at this ModeManager
.
public void refresh(Dockable dockable, boolean recursive)
dockable
and updates the actions
associated with dockable
. This method is intended to be
called by any code that changes the mode in a way that is not automatically
registered by this ModeManager
.
dockable
- the element whose mode might have changedrecursive
- if set, then the children of dockable
are refreshed as well.public void remove(Dockable dockable)
dockable
.
dockable
- the element to removepublic void reduceToEmpty(Dockable dockable)
dockable
itself, put the properties of
dockable
remain in the system.
dockable
- the element to reduceprotected abstract void applyDuringRead(String key, Path old, Path current, Dockable dockable)
readSettings(ModeSettings)
.
Subclasses might change the mode according to newMode
.
key
- the identifier of dockable
old
- the mode dockable
is currently incurrent
- the mode dockable
is going to bedockable
- the element that changes its mode, might be null
protected boolean createEntryDuringRead(String key)
Dockable
should be created.
This will result in a call to addEmpty(String)
during
readSettings(ModeSettings)
.
The default implementation returns always false
.
key
- the key for which to create a new entry
true
if an entry should be createdpublic void addEmpty(String key)
Dockable
that has not yet been created. It is
helpful if the client intends to load first its properties and create
only those Dockable
s which are visible.removeEmpty(String)
is called.
key
- the name of the empty entry
NullPointerException
- if key
is null
public void removeEmpty(String name)
name
but only if the entry is not
associated with any Dockable
.
name
- the name of the entry which might be empty
NullPointerException
- if key
is null
public boolean isEmpty(String key)
key
gets
stored indefinitely or not.
key
- the key to check
true
if the key is never removed automatically
false
otherwisepublic Dockable getDoubleClickTarget(Dockable target)
Dockable
on which an event was registered, searches a
registered dockable that is a child of target
or
target
itself.
target
- the target whose registered child is searched
target
, a child of target
, or null
protected M getDefaultMode(Dockable dockable)
dockable
, the mode
dockable
is in if nothing else is specified. This method checks
Mode.isDefaultMode(Dockable)
and returns the first
Mode
where the answer was true
.
dockable
- some dockable, not null
ModeManager
and not be null
public M getCurrentMode(Dockable dockable)
dockable
is currently in. This method
calls Mode.isCurrentMode(Dockable)
and returns the first
Mode
where the answer was true
.
dockable
- some dockable, not null
null
if not foundpublic M getPreviousMode(Dockable dockable)
dockable
was in before the current mode.
dockable
- some element
null
if this
information is not availablepublic List<M> getModeHistory(Dockable dockable)
dockable
used in the past. The older entries are at the beginning
of the list. The current mode may or may not be included
in the list.
dockable
- the element whose history is asked
public List<H> getPropertyHistory(Dockable dockable)
dockable
used in the past. Entries of value null
are ignored.
The older entries are at the beginning of the list.
dockable
- the element whose history is asked
public void store(Dockable dockable)
dockable
and all its children in respect
to their current Mode
. Dockables that are not registered at this manager
are ignored.isOnContinuous()
returns true
dockable
- a root of a treeprotected void store(M mode, Dockable dockable)
dockable
under the key mode
.isOnContinuous()
returns true
mode
- the mode dockable
is currently indockable
- the element whose location will be storedpublic Iterable<M> modes()
protected void rebuildAll()
Dockable
s.
protected void rebuild(Dockable dockable)
dockable
.
dockable
- the element whose actions are to be updatedpublic <B> ModeSettings<H,B> createSettings(ModeSettingsConverter<H,B> converter)
ModeSetting
which is configured to transfer data from
this ModeManager
to persistent storage or the other way. The new setting
contains all the ModeSettingFactory
s which are currently known to this manager.
B
- the intermediate formatconverter
- conversion tool from this managers meta-data format to the intermediate
format.
protected <B> ModeSettings<H,B> createModeSettings(ModeSettingsConverter<H,B> converter)
ModeManager
. Subclasses
may override this method to use another set of settings. This method does
not need to call ModeSettings.addFactory(ModeSettingFactory)
.
B
- the intermediate formatconverter
- converstion tool from this managers meta-data format to the
intermediate format.
public void writeSettings(ModeSettings<H,?> setting)
ModeManager
to
setting
.
setting
- the settings to fillpublic void readSettings(ModeSettings<H,?> settings)
public void addAffected(Iterable<Dockable> dockables)
dockables
to the current
AffectedSet
.
dockables
- the elements to addpublic String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |