|
||||||||||
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.
The frontend has a list of Dockables. It assumes that these Dockables never
changes. The frontend can add a "close"-button to these Dockables. The location
of these Dockables is stored as well. Dockables which are not added
to this frontend, are just ignored.
Note: Clients must provide a set of root stations
(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).
Clients must also provide some 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. |
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(Dockable dockable,
DockSituationIgnore ignore)
Removes dockable from its parent, but only if
it is not filtered by ignore . |
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 neither the station nor its children are 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 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 |
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 |
fireLoaded(String name)
Invokes the method DockFrontendListener.loaded(DockFrontend, String)
on all listeners. |
protected void |
fireSaved(String name)
Invokes the method DockFrontendListener.saved(DockFrontend, String)
on all listeners. |
protected void |
fireShowed(Dockable dockable)
Invokes the method DockFrontendListener.showed(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. |
Set<String> |
getSettings()
Gets a set of the names of all known settings. |
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. |
protected void |
load(DataInputStream in,
boolean entry)
Reads a setting that was earlier converted into a byte-stream. |
void |
load(String name)
Loads a setting of this frontend. |
void |
read(DataInputStream in)
Reads the settings of this frontend from in . |
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 . |
protected void |
save(DataOutputStream out,
boolean entry)
Writes the current layout as byte-stream into out . |
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 |
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 . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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 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 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
IllegalArgumentException
- if dockable
is not known
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 hidden
IllegalArgumentException
- if dockable
is not knownpublic void save()
current setting
.
IllegalStateException
- if the name of the current setting is null
public void save(String name)
name
- the name for the settingprotected void save(DataOutputStream out, boolean entry) throws IOException
out
.
out
- the stream to write intoentry
- true
if just an ordinary setting should be written,
false
if the final setting should be written.
IOException
- if there are any problemspublic void load(String name)
name
- the name of the setting
IllegalArgumentException
- if no setting name
could be foundpublic 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 load(DataInputStream in, boolean entry) throws IOException
in
- the stream to readentry
- true
if the setting is just an ordinary setting,
false
if a final setting is read.
IOException
- if there are any problemsprotected void clean(DockSituationIgnore ignore)
ignore
.
ignore
- a filter, never null
protected void clean(DockStation station, DockSituationIgnore ignore)
station
, but only
if neither the station nor its children are filtered by ignore
.
station
- a station to cleanignore
- a filterprotected void clean(Dockable dockable, DockSituationIgnore ignore)
dockable
from its parent, but only if
it is not filtered by ignore
. If dockable
is
a station, clean(DockStation, DockSituationIgnore)
should also
be called.
dockable
- the element to remove from its parent.ignore
- 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 problemspublic 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 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()
public DockFrontend.Hider getHider()
protected DockFrontendListener[] listeners()
protected void fireHidden(Dockable dockable)
DockFrontendListener.hidden(DockFrontend, Dockable)
on all listeners.
dockable
- the hidden elementprotected void fireShowed(Dockable dockable)
DockFrontendListener.showed(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 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 |