com.vlsolutions.swing.docking

Class DockingContext


public class DockingContext
extends java.lang.Object

A context that can be shared by multiple docking desktops.

Keeps track of registered dockables and manages import export.

A DockingContext can be seen as the top-most grouping element of docking (as DockingDesktop can be contained is a context), and as such, all methods related to workspace management have been promoted to this class.

Since:
2.1

Field Summary

protected HashMap
dockableStates
inner state of the dockables
protected ArrayList
registeredDockables
All dockables must be registered (even if not shown) in order to be processed by the XML Parser or to be displayed in the DockingSelectorDialog

Constructor Summary

DockingContext()
Constructs a new DockingContext

Method Summary

void
addDesktop(DockingDesktop desktop)
Adds a desktop to this context
void
addDockableSelectionListener(DockableSelectionListener listener)
Adds a new DockableSelectionListener to this desktop.
void
addDockableStateChangeListener(DockableStateChangeListener listener)
Adds a new DockableStateChangeListener to this desktop.
void
addDockableStateWillChangeListener(DockableStateWillChangeListener listener)
Adds a new DockableStateWillChangeListener to this desktop.
void
addDockingActionListener(DockingActionListener listener)
void
close(Dockable dockable)
Close this dockable
ArrayList
getDesktopList()
Returns a list of the desktops sharing this context
Dockable
getDockableByKey(String dockKey)
Returns the (registered) dockable corresponding to the given key id, or null if not found

Note : since VLDocking 2.1.2, this method also tries to use its DockableResolver if null would have been returned.

DockableResolver
getDockableResolver()
Returns the dockable resolver used by this context (or null if none defined)
DockableState
getDockableState(Dockable dockable)
Returns the current state of a dockable (CLOSED, HIDDEN, DOCKED, MAXIMIZED, FLOATING)
DockableState[]
getDockables()
Creates and returns an array of all registered dockable with their current state.
ArrayList
getDockablesByState(DockingDesktop desktop, int state)
constructs and returns the list of dockables corresponding to a desktop, at a specific state
void
readXML(InputStream in)
Reads an XML encoded stream as the new desktop configuration.
void
registerDockable(Dockable dockable)
Every dockable must be registered in order to be managed by a DockingDesktop.
void
removeDesktop(DockingDesktop desktop)
Removes a desktop from this context
void
removeDockableSelectionListener(DockableSelectionListener listener)
Removes a DockableSelectionListener from this desktop.
void
removeDockableStateChangeListener(DockableStateChangeListener listener)
Removes a DockableStateChangeListener from this desktop.
void
removeDockableStateWillChangeListener(DockableStateWillChangeListener listener)
Removes a DockableStateWillChangeListener from this desktop.
void
removeDockingActionListener(DockingActionListener listener)
void
setDockableResolver(DockableResolver dockableResolver)
Updates the dockable resolver used by this context (can be set to null)
void
setDockableState(Dockable dockable, DockableState state)
Updates the current state of a dockable
void
unregisterDockable(Dockable dockable)
Unregisters the dockable, which can be garbage collected (no longer used by docking desktops.
void
writeXML(OutputStream stream)
Saves the current desktop configuration into an XML stream.

Field Details

dockableStates

protected HashMap dockableStates
inner state of the dockables

registeredDockables

protected ArrayList registeredDockables
All dockables must be registered (even if not shown) in order to be processed by the XML Parser or to be displayed in the DockingSelectorDialog

Constructor Details

DockingContext

public DockingContext()
Constructs a new DockingContext

Method Details

addDesktop

public void addDesktop(DockingDesktop desktop)
Adds a desktop to this context

addDockableSelectionListener

public void addDockableSelectionListener(DockableSelectionListener listener)
Adds a new DockableSelectionListener to this desktop.

DockableSelection Events are triggered when a dockable takes the focus.


addDockableStateChangeListener

public void addDockableStateChangeListener(DockableStateChangeListener listener)
Adds a new DockableStateChangeListener to this desktop.

DockableStateChange Events are triggered after the state change.

As of version 2.0 of the framework, this method can also be replaced by adding a propertychangeListener on the DockKey object (and react to its DockableState property).


addDockableStateWillChangeListener

public void addDockableStateWillChangeListener(DockableStateWillChangeListener listener)
Adds a new DockableStateWillChangeListener to this desktop.

DockableStateWillChange Events are triggered before the state change, and are vetoable.


addDockingActionListener

public void addDockingActionListener(DockingActionListener listener)

close

public void close(Dockable dockable)
Close this dockable

getDesktopList

public ArrayList getDesktopList()
Returns a list of the desktops sharing this context

getDockableByKey

public Dockable getDockableByKey(String dockKey)
Returns the (registered) dockable corresponding to the given key id, or null if not found

Note : since VLDocking 2.1.2, this method also tries to use its DockableResolver if null would have been returned.


getDockableResolver

public DockableResolver getDockableResolver()
Returns the dockable resolver used by this context (or null if none defined)
Since:
2.1.2

getDockableState

public DockableState getDockableState(Dockable dockable)
Returns the current state of a dockable (CLOSED, HIDDEN, DOCKED, MAXIMIZED, FLOATING)

getDockables

public DockableState[] getDockables()
Creates and returns an array of all registered dockable with their current state.

Visibility states are [DockableState.STATE_CLOSED, STATE_DOCKED, STATE_HIDDEN]

Returns:
an array of DockableState

getDockablesByState

public ArrayList getDockablesByState(DockingDesktop desktop,
                                     int state)
constructs and returns the list of dockables corresponding to a desktop, at a specific state

readXML

public void readXML(InputStream in)
            throws ParserConfigurationException,
                   IOException,
                   SAXException
Reads an XML encoded stream as the new desktop configuration.

When the method returns, the desktops associated to this context are totally reconfigured with posiibly different dockables at different positions.

Note : The DockKeys of the stream must be registered with the registerDockable method, prior readXML.
This is the case if the desktop is already open and dockables laid out, but might not be the case if this method is used at application startup to populate an empty desktop.

Note : altenatively (since 2.1.2) if a DockableResolver has been set, it will be use to auto-register the new dockables encountered along the stream.

Dismisses all visible dockables (docked and auto-hidden), and clear their DockableState.

The stream is not closed at the end of the operation.

Note : When multiple desktops are loaded from the stream, the context uses their "desktopName" property (desk.getDesktopName()) to identify them.


registerDockable

public void registerDockable(Dockable dockable)
Every dockable must be registered in order to be managed by a DockingDesktop.

if this method is invoked and the dockable is already registered, nothing happens. if the dockable is still unknown, it is added to the dockables set and (since 2.1.3) its state is set to CLOSED (prior 2.1.3, the state was null).


removeDesktop

public void removeDesktop(DockingDesktop desktop)
Removes a desktop from this context

removeDockableSelectionListener

public void removeDockableSelectionListener(DockableSelectionListener listener)
Removes a DockableSelectionListener from this desktop.

removeDockableStateChangeListener

public void removeDockableStateChangeListener(DockableStateChangeListener listener)
Removes a DockableStateChangeListener from this desktop.

removeDockableStateWillChangeListener

public void removeDockableStateWillChangeListener(DockableStateWillChangeListener listener)
Removes a DockableStateWillChangeListener from this desktop.

removeDockingActionListener

public void removeDockingActionListener(DockingActionListener listener)

setDockableResolver

public void setDockableResolver(DockableResolver dockableResolver)
Updates the dockable resolver used by this context (can be set to null)
Since:
2.1.2

setDockableState

public void setDockableState(Dockable dockable,
                             DockableState state)
Updates the current state of a dockable

unregisterDockable

public void unregisterDockable(Dockable dockable)
Unregisters the dockable, which can be garbage collected (no longer used by docking desktops.

writeXML

public void writeXML(OutputStream stream)
            throws IOException
Saves the current desktop configuration into an XML stream.

The workspace is composed of every desktop layouts associated with this context (desktops are identified by their 'desktopName' property).

The stream is not closed at the end of the operation.


© Copyright 2004-2006 VLSolutions. All Rights Reserved.
www.vlsolutions.com : Java Components - Smart Client Applications