|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbibliothek.gui.DockFrontend
public class DockFrontend
A DockFrontend provides some methods to handle the storage of various layouts.
The frontend can save the current layout (the location of all Dockables) and
later restore it. Each set of properties is stored in a Setting
. Subclasses
might override the following methods to store additional information:
createSetting()
getSetting(boolean)
and setSetting(Setting, boolean)
write(Setting, boolean, DataOutputStream)
and read(boolean, DataInputStream)
or
Setting.write(DockSituation, PropertyTransformer, boolean, DataOutputStream)
and
Setting.read(DockSituation, PropertyTransformer, boolean, DataInputStream)
writeXML(Setting, boolean, XElement)
and readXML(boolean, XElement)
or
Setting.writeXML(DockSituation, PropertyTransformer, boolean, XElement)
and
Setting.readXML(DockSituation, PropertyTransformer, boolean, XElement)
added
to this frontend, are just ignored.addRoot
). The frontend will only
store the locations of children of these roots. The frontend adds these
roots also to its controller
, but the frontend does
not observe the controller, and so all changes must be applied directly
on the frontend (on the other hand, clients may use more than one frontend).factories
to allow the storage of their elements. The default-factories are already
installed.
Nested Class Summary | |
---|---|
class |
DockFrontend.Hider
An object which is action and ActionGuard at the same time. |
Field Summary | |
---|---|
static PropertyKey<KeyStroke> |
HIDE_ACCELERATOR
|
Constructor Summary | |
---|---|
DockFrontend()
Constructs a new frontend, creates a new controller. |
|
DockFrontend(DockController controller)
Constructs a new frontend. |
|
DockFrontend(DockController controller,
Window owner)
Constructs a new frontend, tries to set up a ScreenDockStationFactory . |
|
DockFrontend(Window owner)
Constructs a new frontend, creates a new controller. |
Method Summary | |
---|---|
void |
add(Dockable dockable,
String name)
Adds a Dockable to this frontend. |
void |
addFrontendListener(DockFrontendListener listener)
Adds a listener to this frontend. |
void |
addRoot(DockStation station,
String name)
Adds a root to this frontend. |
protected void |
clean(DockSituationIgnore ignore)
Removes all child-parent relations expect the ones filtered out by ignore . |
protected void |
clean(DockStation station,
DockSituationIgnore ignore)
Removes all recursively all children from station , but only
if the children are not filtered by ignore . |
protected DockFrontend.Hider |
createHider()
Creates the action that is added to all known dockables, and which is called the "close"-action. |
protected Setting |
createSetting()
Creates a bag that contains all information needed to describe the current set of properties. |
protected DockSituation |
createSituation(boolean entry)
Invoked every time before the current setting is written into a stream. |
protected PropertyTransformer |
createTransformer()
Invoked every time before properties are written or read. |
boolean |
delete(String name)
Deletes the setting with the given name . |
protected void |
fireAdded(Dockable dockable)
Invokes the method DockFrontendListener.added(DockFrontend, Dockable)
on all listeners. |
protected void |
fireAllHidden(Dockable dockable,
Set<Dockable> processed)
Invokes the method DockFrontendListener.hidden(DockFrontend, Dockable)
on all listeners for dockable and all its children. |
protected void |
fireAllShown(Dockable dockable,
Set<Dockable> processed)
Invokes the method DockFrontendListener.shown(DockFrontend, Dockable)
on all listeners for dockable and all its children. |
protected void |
fireDeleted(String name)
Invokes the method DockFrontendListener.deleted(DockFrontend, String)
on all listeners. |
protected void |
fireHidden(Dockable dockable)
Invokes the method DockFrontendListener.hidden(DockFrontend, Dockable)
on all listeners. |
protected void |
fireHideable(Dockable dockable,
boolean value)
Invokes the method DockFrontendListener.hideable(DockFrontend, Dockable, boolean)
on all listeners. |
protected void |
fireLoaded(String name)
Invokes the method DockFrontendListener.loaded(DockFrontend, String)
on all listeners. |
protected void |
fireRead(String name)
Invokes the method DockFrontendListener.read(DockFrontend, String)
on all listeners. |
protected void |
fireRemoved(Dockable dockable)
Invokes the method DockFrontendListener.removed(DockFrontend, Dockable)
on all listeners. |
protected void |
fireSaved(String name)
Invokes the method DockFrontendListener.saved(DockFrontend, String)
on all listeners. |
protected void |
fireShown(Dockable dockable)
Invokes the method DockFrontendListener.shown(DockFrontend, Dockable)
on all listeners. |
DockController |
getController()
Gets the controller which is used by this frontend. |
String |
getCurrentSetting()
Gets the name of the setting which was loaded or saved the last time. |
DockStation |
getDefaultStation()
Gets the default station of this frontend. |
Collection<Dockable> |
getDockables()
Gets the list of Dockables which are added to this frontend. |
DockProperties |
getDockProperties()
Gets the set of properties which have a controller-global influence. |
DockFrontend.Hider |
getHider()
Gets the action which is added to all known Dockables, and which is called the "close"-action. |
DockSituationIgnore |
getIgnoreForEntry()
Gets the filter which is used when saving or loading a normal entry. |
DockSituationIgnore |
getIgnoreForFinal()
Gets the filter which is applied when saving or loading the final layout at the startup or shutdown of the application. |
Map<String,Dockable> |
getNamedDockables()
Gets an independent map containing all Dockables registered to this frontend. |
DockStation |
getRoot(String name)
Gets the root with the designated name. |
DockStation[] |
getRoots()
Gets a modifiable array containing all DockStation s which are
registered as root. |
Setting |
getSetting(boolean entry)
Creates a new Setting which describes the current set of
properties of this frontend. |
Set<String> |
getSettings()
Gets a set of the names of all known settings. |
boolean |
hasLocation(Dockable dockable)
Tells whether this DockFrontend currently knows where to
put dockable . |
void |
hide(Dockable dockable)
Makes dockable invisible. |
boolean |
isHidden(Dockable dockable)
Tells whether dockable is hidden or not. |
boolean |
isHideable(Dockable dockable)
Tells whether there is a "close"-action for dockable or not. |
boolean |
isShowHideAction()
Tells whether the hide-action is shown or not. |
boolean |
isShown(Dockable dockable)
Tells whether dockable is visible or not. |
List<Dockable> |
listDockables()
Gets a list of all Dockable s which are registered at this
frontend. |
protected DockFrontendListener[] |
listeners()
Gets an independent array containing all currently registered listeners. |
Set<Dockable> |
listShownDockables()
Gets a set of all Dockable which are known to this frontend
and which are visible. |
void |
load(String name)
Loads a setting of this frontend. |
protected Setting |
read(boolean entry,
DataInputStream in)
Calls first createSetting() and then
Setting.read(DockSituation, PropertyTransformer, boolean, DataInputStream) . |
void |
read(DataInputStream in)
Reads the settings of this frontend from in . |
protected Setting |
readXML(boolean entry,
XElement element)
Calls createSetting() and then
Setting.readXML(DockSituation, PropertyTransformer, boolean, XElement) . |
void |
readXML(XElement element)
Reads the contents of this frontend from an xml element. |
void |
registerFactory(DockablePropertyFactory factory)
Registers a factory to write and read properties. |
void |
registerFactory(DockFactory<? extends DockElement,?> factory)
Registers a factory to write and read Dockables and
DockStations |
void |
remove(Dockable dockable)
Removes a Dockable which was earlier added to this frontend. |
void |
removeFrontendListener(DockFrontendListener listener)
Removes an earlier added listener from this frontend. |
void |
removeRoot(DockStation station)
Removes a root from this frontend. |
void |
save()
Saves the current layout under the name of the current setting . |
void |
save(String name)
Saves the current layout with the specified name. |
void |
setCurrentSetting(String setting)
Sets the name of the current setting. |
void |
setDefaultStation(DockStation defaultStation)
Sets the default station of this frontend. |
void |
setHideable(Dockable dockable,
boolean hideable)
Sets whether to show add a close-action or not to dockable . |
void |
setIgnoreForEntry(DockSituationIgnore ignoreForEntry)
Sets a filter which is applied when saving or loading a normal entry. |
void |
setIgnoreForFinal(DockSituationIgnore ignoreForFinal)
Sets the filter which is applied when saving or loading the final layout at the startup or shutdown of the application. |
void |
setSetting(Setting setting,
boolean entry)
Changes the content of all root-stations according to setting . |
void |
setShowHideAction(boolean show)
Sets whether to show the hide-action or not. |
void |
show(Dockable dockable)
Ensures that dockable is child of a root known to this
frontend. |
void |
write(DataOutputStream out)
Writes all settings of this frontend, including the current layout, into out . |
protected void |
write(Setting setting,
boolean entry,
DataOutputStream out)
Calls Setting.write(DockSituation, PropertyTransformer, boolean, DataOutputStream) |
protected void |
writeXML(Setting setting,
boolean entry,
XElement element)
Calls Setting.writeXML(DockSituation, PropertyTransformer, boolean, XElement) . |
void |
writeXML(XElement element)
Writes all properties of this frontend into an xml element. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final PropertyKey<KeyStroke> HIDE_ACCELERATOR
Constructor Detail |
---|
public DockFrontend()
public DockFrontend(Window owner)
ScreenDockStationFactory
, which can only be created if the owner
of the dialogs is known.
owner
- the owner of the dialogs of a ScreenDockStationFactory
,
may be null
public DockFrontend(DockController controller)
controller
- the controller used to store root stationspublic DockFrontend(DockController controller, Window owner)
ScreenDockStationFactory
.
controller
- the controller used to store the root stationsowner
- the owner of the dialog of a ScreenDockStation
,
may be null
Method Detail |
---|
public DockController getController()
public Collection<Dockable> getDockables()
Dockables
which are added to this frontend.
public void addFrontendListener(DockFrontendListener listener)
listener
- the observerpublic void removeFrontendListener(DockFrontendListener listener)
listener
- the observer which will be removedpublic void registerFactory(DockFactory<? extends DockElement,?> factory)
Dockables
and
DockStations
factory
- the new factorypublic void registerFactory(DockablePropertyFactory factory)
DockStation
.
factory
- the new factorypublic void add(Dockable dockable, String name)
dockable
. The frontend also assumes that dockable
can be reused when reading a setting. That means, that the factory which
matches the key of dockable
does not create a new instance
when reading the preferences of dockable
. You should note that
the frontend does not support Dockables
whose lifespan
ends when they are made invisible.
dockable
- the new Dockablename
- the unique name of the Dockable
IllegalArgumentException
- if either of dockable
or
name
is null
, or if name
is not
unique.public Map<String,Dockable> getNamedDockables()
public void addRoot(DockStation station, String name)
Dockables
which are
children of a root can be stored. The frontend forwards the roots to
its controller
(through the add
-method). Note
that the frontend does not observ its controller and therefore does not
know whether there are other roots registered at the controller.default station
.
station
- the new stationname
- the unique name of the station
IllegalArgumentException
- if station
or name
is null
, or if name
is not unique.public DockStation getRoot(String name)
name
- the name of the root
null
public DockStation[] getRoots()
DockStation
s which are
registered as root.
public void setDefaultStation(DockStation defaultStation)
Dockables
whose location could not be stored
earlier or whose location has become invalid.
defaultStation
- the default station, can be null
public DockStation getDefaultStation()
setDefaultStation(DockStation)
or a root picked at random.
null
public void remove(Dockable dockable)
Dockable
which was earlier added to this frontend.
dockable
- the element to removepublic void removeRoot(DockStation station)
default station
, then the
default station is set to null
.
station
- the root to removepublic boolean hasLocation(Dockable dockable)
DockFrontend
currently knows where to
put dockable
.
dockable
- the element whose location might be known
true
if the location of dockable
is knownpublic void setIgnoreForEntry(DockSituationIgnore ignoreForEntry)
ignoreForEntry
- the filter, can be null
public DockSituationIgnore getIgnoreForEntry()
null
public void setIgnoreForFinal(DockSituationIgnore ignoreForFinal)
ignoreForFinal
- the filter, can be null
public DockSituationIgnore getIgnoreForFinal()
null
public DockProperties getDockProperties()
public Set<String> getSettings()
public String getCurrentSetting()
null
if no setting was saved yetpublic void setCurrentSetting(String setting)
setting
- the name of the new settingpublic boolean isHideable(Dockable dockable)
dockable
or not.
dockable
- the element whose state is asked, must be known to this
frontend.
true
if dockable
has a close-actionpublic boolean isHidden(Dockable dockable)
dockable
is hidden or not.
dockable
- the element whose state is asked
true
if dockable
is not visiblepublic boolean isShown(Dockable dockable)
dockable
is visible or not.
dockable
- the element whose state is asked
true
if dockable
is visiblepublic void setHideable(Dockable dockable, boolean hideable)
dockable
.
Changes are affected immediately.
dockable
- the element whose state will be changedhideable
- the new state
IllegalArgumentException
- if dockable
is not known
to this frontendpublic void setShowHideAction(boolean show)
hide
).
show
- whether to show the actionsetHideable(Dockable, boolean)
public boolean isShowHideAction()
true
if the action is shown on
hideable
dockables or false
otherwisepublic void show(Dockable dockable)
dockable
is child of a root known to this
frontend.
dockable
- the element which should be made visible
IllegalStateException
- if the default station
is
needed but can't be foundpublic void hide(Dockable dockable)
dockable
invisible. The location of dockable
is saved, and if made visible again, it will reappear at its old location.
dockable
- the element which should be hiddenpublic void save()
current setting
.
IllegalStateException
- if the name of the current setting is null
public void save(String name)
name
- the name for the settingpublic void load(String name)
name
- the name of the setting
IllegalArgumentException
- if no setting name
could be foundpublic Setting getSetting(boolean entry)
Setting
which describes the current set of
properties of this frontend. The setting contains information about
the location of each Dockable
.
entry
- true
if only the information for an ordinary
entry should be stored, false
if the setting should contain
as much information as possible.
createSetting()
public void setSetting(Setting setting, boolean entry)
setting
.
setting
- a new set of propertiesentry
- true
if only information for an ordinary
entry should be extracted, false
if as much information
as possible should be extracted. The value of this argument should
be the same as was used when getSetting(boolean)
was called.public Set<Dockable> listShownDockables()
Dockable
which are known to this frontend
and which are visible.
public List<Dockable> listDockables()
Dockable
s which are registered at this
frontend.
protected void clean(DockSituationIgnore ignore)
ignore
.
ignore
- a filter, never null
protected void clean(DockStation station, DockSituationIgnore ignore)
station
, but only
if the children are not filtered by ignore
.
station
- a station to cleanignore
- a filterpublic boolean delete(String name)
name
.
name
- the name of the setting to delete
true
if the setting was deleted, false
if the setting was unknown anyway.public void write(DataOutputStream out) throws IOException
out
.
out
- the stream to write into
IOException
- if there are any problemsprotected void write(Setting setting, boolean entry, DataOutputStream out) throws IOException
Setting.write(DockSituation, PropertyTransformer, boolean, DataOutputStream)
setting
- the setting which will be writtenentry
- whether setting
is an ordinary entry, or
the finall setting that contains more data.out
- the stream to write into
IOException
- if an I/O-error occurspublic void read(DataInputStream in) throws IOException
in
. The layout
will be changed according to the contents that are read.
in
- the stream to read from
IOException
- if there are any problemsprotected Setting read(boolean entry, DataInputStream in) throws IOException
createSetting()
and then
Setting.read(DockSituation, PropertyTransformer, boolean, DataInputStream)
.
entry
- whether the set of properties is used as ordinary entry,
or contains more data than usuall.in
- the stream to read from
IOException
- if an I/O-error occurscreateSetting()
public void writeXML(XElement element)
element
- the element to write into, this method will not
change the attributes of element
protected void writeXML(Setting setting, boolean entry, XElement element)
Setting.writeXML(DockSituation, PropertyTransformer, boolean, XElement)
.
setting
- the setting to writeentry
- whether setting
is an ordinary entry, or
the finall setting that contains more data.element
- the xml element to write into, this method does not
change the attributes of the entrypublic void readXML(XElement element)
element
- the element to readprotected Setting readXML(boolean entry, XElement element)
createSetting()
and then
Setting.readXML(DockSituation, PropertyTransformer, boolean, XElement)
.
entry
- whether the set of properties is used as ordinary entry,
or contains more data than usuall.element
- the xml element containg the data for the new setting
createSetting()
protected DockSituation createSituation(boolean entry)
entry
- true
if the situation is used for a regular setting,
false
if the situation is used as the final setting which will
be loaded the next time the application starts.
protected PropertyTransformer createTransformer()
protected DockFrontend.Hider createHider()
protected Setting createSetting()
public DockFrontend.Hider getHider()
protected DockFrontendListener[] listeners()
protected void fireAllHidden(Dockable dockable, Set<Dockable> processed)
DockFrontendListener.hidden(DockFrontend, Dockable)
on all listeners for dockable
and all its children.
dockable
- the hidden elementprocessed
- Set of Dockable
s for which the event is already fired,
will be modified by this method, can be null
protected void fireHidden(Dockable dockable)
DockFrontendListener.hidden(DockFrontend, Dockable)
on all listeners.
dockable
- the hidden elementprotected void fireAdded(Dockable dockable)
DockFrontendListener.added(DockFrontend, Dockable)
on all listeners.
dockable
- the added elementprotected void fireHideable(Dockable dockable, boolean value)
DockFrontendListener.hideable(DockFrontend, Dockable, boolean)
on all listeners.
dockable
- the element whose state changedvalue
- the new stateprotected void fireRemoved(Dockable dockable)
DockFrontendListener.removed(DockFrontend, Dockable)
on all listeners.
dockable
- the removed elementprotected void fireAllShown(Dockable dockable, Set<Dockable> processed)
DockFrontendListener.shown(DockFrontend, Dockable)
on all listeners for dockable
and all its children.
dockable
- the shown elementprocessed
- Set of Dockable
s whose event is already fired,
will be modified by this method, can be null
protected void fireShown(Dockable dockable)
DockFrontendListener.shown(DockFrontend, Dockable)
on all listeners.
dockable
- the shown elementprotected void fireSaved(String name)
DockFrontendListener.saved(DockFrontend, String)
on all listeners.
name
- the name of the saved settingprotected void fireLoaded(String name)
DockFrontendListener.loaded(DockFrontend, String)
on all listeners.
name
- the name of the loaded settingprotected void fireRead(String name)
DockFrontendListener.read(DockFrontend, String)
on all listeners.
name
- the name of the read settingprotected void fireDeleted(String name)
DockFrontendListener.deleted(DockFrontend, String)
on all listeners.
name
- the name of the deleted setting
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |