A desktop part of a workpace.
Use this object to define the layout of a DockingDesktop. This layout can be applied later
to that desktop through the Workspace.apply(DockingContext ctx) method.
The API is a subset of the one of DockingDesktop : limited to layout building.
you can addDockable(), split(), createTab(), addHiddenDockable(), addFloatingDockable(), see these
method description for further information.
Node : WSDesktop doens't support layout updates : you should use it to build a layout, but not to
move dockables around. (if you add a dockable somewhere, don't add it elsewhere later as removal isn't
fully implemented).
In a WSDesktop, dockables are identified by a WSDockKey (a limited version of DockKey) : this is to allow
you to create workspaces with dockables that haven't been constructed yet (lazy loading).
Example :
Workspace w = new Workspace();
WSDesktop desk = w.getDesktop(0); // gets the default (single) desktop
// define some dockable keys
WSDockKey editorKey = new WSDockKey("editor");
WSDockKey treeKey, tableKey, imgToolKey // other dockable keys
// now define a workspace layout
desk.addDockable(editorKey); // initial dockable
desk.split(editorKey, treeKey, DockingConstants.SPLIT_LEFT, 0.5); // splitted
desk.split(treeKey, tableKey, DockingConstants.SPLIT_TOP, 0.7); // tree is also splitted
desk.createTab(tableKey, imgToolsKey, 0); // tableKey is transformed into a tabbed container
// and that's it
// ...
// later
//
DockingContext ctx = ... // your real desktop
w.apply(ctx); // applies the workspace to this desktop
// now the dektops are loaded as specified in the 'w' workspace
addDockable
public void addDockable(WSDockKey key)
Adds the first dockable to this desktop. This method will fail if called more than once
addDockable
public void addDockable(WSDockKey compoundDockable,
WSDockKey childDockable)
Adds a dockable into a compound dockable
addHiddenDockable
public void addHiddenDockable(WSDockKey dockable,
RelativeDockablePosition dockedPosition)
Adds a new dockable (and stores its return-to-docked position)
addToTabbedGroup
public void addToTabbedGroup(WSDockKey base,
WSDockKey newTab)
Registers a dockable as belonging to a tab group.
It is used to have a memory of grouped (tabbed) dockables in order to keep the
group together when dockable are restored from auto-hide mode.
This method is generally called by the tabbed container management, and not directly
by the developper.
However, there is a case where calling this method can be usefull :
when, at startup, a desktop is built with multiple hidden dockables, and the developper wants
them to be grouped in a tab container when they are restored to the desktop.
base
- an already tabbed dockablenewTab
- a dockable to add to the tab group
clear
public void clear()
removes all information stored into this desktop, which becomes ready to
be reused.
createTab
public void createTab(WSDockKey baseTab,
WSDockKey newTab,
int order)
Creates a tab containing baseTab and newTab (if baseTab is already into a Tab, then
newTab will just be added at the "order" position.
getDesktopName
public String getDesktopName()
Returns the name of this desktop (which must match the name of a real desktop if more than one desktops are used )
setDesktopName
public void setDesktopName(String name)
Updates the name of this workspace desktop
setFloating
public void setFloating(WSDockKey dockable,
Rectangle windowRect,
RelativeDockablePosition returnPosition)
Adds a new floating dockable
dockable
- the dockable to add as floatingwindowRect
- rectangle defining the window (relative to screen) of the floating dockablereturnPosition
- where to put the dockable when returning to the desktop
setMaximizedDockable
public void setMaximizedDockable(WSDockKey max)
Sets the maximized dockable of this desktop, (or null if no dockable maximized).
Don't forget that this dockable MUST ALSO BE in the DOCKED state (added to the desktop
in a split, tab or compound node) otherwise the missing restore information will cause
unwanted behaviour, or exceptions.
split
public void split(WSDockKey base,
WSDockKey newDockable,
DockingConstants.Split split,
double splitLocation)
Splits a dockable (with a given split location)
base
- the dockable to be splittednewDockable
- the new dockablesplit
- the orientation of splitsplitLocation
- where the split divisor is (always relative from the top/left dockable, so
split(a, b, SPLIT_TOP, 0.1f) and split(a, b, SPLIT_BOTTOM, 0.1f) have the same dividor location (somewhere near
the top of the split).