bibliothek.gui.dock.common.intern
Class AbstractCDockable

java.lang.Object
  extended by bibliothek.gui.dock.common.intern.AbstractCDockable
All Implemented Interfaces:
CDockable
Direct Known Subclasses:
CWorkingArea, DefaultCDockable

public abstract class AbstractCDockable
extends Object
implements CDockable

An abstract implementation of CDockable. Contains methods to work with listeners and with CActions.

Author:
Benjamin Sigg

Nested Class Summary
 
Nested classes/interfaces inherited from interface bibliothek.gui.dock.common.intern.CDockable
CDockable.ExtendedMode
 
Constructor Summary
protected AbstractCDockable(CommonDockable dockable)
          Creates a new dockable
 
Method Summary
 void addCDockablePropertyListener(CDockablePropertyListener listener)
          Adds a property listener to this dockable, the listener will be informed of changes of this dockable.
 void addCDockableStateListener(CDockableStateListener listener)
          Adds a state listener to this dockable, the listener will be informed of changes of this dockable.
protected  CControlAccess control()
          Gets access to the controller.
 Dimension getAndClearResizeRequest()
          Gets the preferred size of this CDockable.
 DockActionSource getClose()
          Gets the source that contains the close-action.
 ColorMap getColors()
          Gets a mutable map of colors.
 CControlAccess getControl()
          Gets the control which is responsible for this dockable.
 CDockable.ExtendedMode getExtendedMode()
          Gets the size and location of this dockable.
 CLocation getLocation()
          Gets the location of this dockable.
 Dimension getMinimizedSize()
          Gets the size which is used when this dockable is minimzed and on a popup window.
 CWorkingArea getWorkingArea()
          Gets the parent of this dockable, this should be the same as set by the last call of CDockable.setWorkingArea(CWorkingArea).
protected  void init(CommonDockable dockable)
          Initializes this CDockable.
 CommonDockable intern()
          Gets the intern representation of this dockable.
 boolean isMinimizedHold()
          Tells whether this dockable remains visible when minimized and without focus.
 boolean isResizeLocked()
          Tells whether the size of this dockable should remain the same when its parent changes the size.
 boolean isVisible()
          Tells whether this dockable is currently visible or not.
protected  CDockablePropertyListener[] propertyListeners()
          Gets the list of property listeners.
 void removeCDockablePropertyListener(CDockablePropertyListener listener)
          Removes a property listener from this dockable.
 void removeCDockableStateListener(CDockableStateListener listener)
          Removes a state listener from this dockable.
 void setControl(CControlAccess control)
          Sets the CControl which is responsible for this dockable.
 void setExtendedMode(CDockable.ExtendedMode extendedMode)
          Sets how and where this dockable should be shown.
 void setLocation(CLocation location)
          Sets the location of this dockable.
 void setMinimizedHold(boolean hold)
          Sets whether this dockable should remain visible when minimized and without focus.
 void setMinimizedSize(Dimension size)
          Sets the size of this dockable when this dockable is minimized and on a popup window.
 void setResizeLocked(boolean resizeLocked)
          Sets whether this dockable likes to remain with the same size all the time.
 void setResizeRequest(Dimension size, boolean process)
          Tells this CDockable which size it should have.
 void setVisible(boolean visible)
          Shows or hides this dockable.
 void setWorkingArea(CWorkingArea area)
          Sets the parent of this dockable.
protected  CDockableStateListener[] stateListeners()
          Gets the list of state listeners.
 void toFront()
          Tries to focus this dockable.
protected  void updateClose()
          Ensures that close contains an action when necessary.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface bibliothek.gui.dock.common.intern.CDockable
isCloseable, isExternalizable, isMaximizable, isMinimizable, isStackable
 

Constructor Detail

AbstractCDockable

protected AbstractCDockable(CommonDockable dockable)
Creates a new dockable

Parameters:
dockable - the internal representation of this CDockable, can be null but then init(CommonDockable) should be called.
Method Detail

init

protected void init(CommonDockable dockable)
Initializes this CDockable.

Parameters:
dockable - the representation of this CDockable, not null

control

protected CControlAccess control()
Gets access to the controller.

Returns:
access or null

addCDockableStateListener

public void addCDockableStateListener(CDockableStateListener listener)
Description copied from interface: CDockable
Adds a state listener to this dockable, the listener will be informed of changes of this dockable.

Specified by:
addCDockableStateListener in interface CDockable
Parameters:
listener - the new listener

addCDockablePropertyListener

public void addCDockablePropertyListener(CDockablePropertyListener listener)
Description copied from interface: CDockable
Adds a property listener to this dockable, the listener will be informed of changes of this dockable.

Specified by:
addCDockablePropertyListener in interface CDockable
Parameters:
listener - the new listener

removeCDockableStateListener

public void removeCDockableStateListener(CDockableStateListener listener)
Description copied from interface: CDockable
Removes a state listener from this dockable.

Specified by:
removeCDockableStateListener in interface CDockable
Parameters:
listener - the listener to remove

removeCDockablePropertyListener

public void removeCDockablePropertyListener(CDockablePropertyListener listener)
Description copied from interface: CDockable
Removes a property listener from this dockable.

Specified by:
removeCDockablePropertyListener in interface CDockable
Parameters:
listener - the listener to remove

stateListeners

protected CDockableStateListener[] stateListeners()
Gets the list of state listeners.

Returns:
the stateListeners

propertyListeners

protected CDockablePropertyListener[] propertyListeners()
Gets the list of property listeners.

Returns:
the stateListeners

updateClose

protected void updateClose()
Ensures that close contains an action when necessary.


setVisible

public void setVisible(boolean visible)
Description copied from interface: CDockable
Shows or hides this dockable. If this dockable is not visible and is made visible, then the framework tries to set its location at the last known position.
Subclasses should call CControlAccess.show(CDockable) or CControlAccess.hide(CDockable).

Specified by:
setVisible in interface CDockable
Parameters:
visible - the new visibility state
See Also:
CDockable.isVisible()

isVisible

public boolean isVisible()
Description copied from interface: CDockable
Tells whether this dockable is currently visible or not. Visibility means that this dockable is in the tree structure of DockingFrames. Being in the structure does not imply being visible on the screen. If some JFrame is not shown, or some DockStation not properly added to a parent component, then a visible dockable can be invisible for the user.
Subclasses should return the result of CControlAccess.isVisible(CDockable).

Specified by:
isVisible in interface CDockable
Returns:
true if this dockable can be accessed by the user through a graphical user interface.

toFront

public void toFront()
Tries to focus this dockable. There are no guarantees that this dockabe really gets focused.


setLocation

public void setLocation(CLocation location)
Description copied from interface: CDockable
Sets the location of this dockable. If this dockable is visible, than this method will take immediately effect. Otherwise the location will be stored in a cache and read as soon as this dockable is made visible.
Note that the location can only be seen as a hint, the framework tries to fit the location as good as possible, but there are no guarantees.

Specified by:
setLocation in interface CDockable
Parameters:
location - the new location, null is possible, but will not move the dockable immediately

getLocation

public CLocation getLocation()
Description copied from interface: CDockable
Gets the location of this dockable. If this dockable is visible, then a location will always be returned. Otherwise a location will only be returned if it just was set using CDockable.setLocation(CLocation).

Specified by:
getLocation in interface CDockable
Returns:
the location or null

setExtendedMode

public void setExtendedMode(CDockable.ExtendedMode extendedMode)
Description copied from interface: CDockable
Sets how and where this dockable should be shown. Conflicts with CDockable.isExternalizable(), CDockable.isMaximizable() and CDockable.isMinimizable() will just be ignored.

Specified by:
setExtendedMode in interface CDockable
Parameters:
extendedMode - the size and location

getExtendedMode

public CDockable.ExtendedMode getExtendedMode()
Description copied from interface: CDockable
Gets the size and location of this dockable.

Specified by:
getExtendedMode in interface CDockable
Returns:
the size and location or null if this dockable is not part of an CControl.

setWorkingArea

public void setWorkingArea(CWorkingArea area)
Description copied from interface: CDockable
Sets the parent of this dockable. This method can be called by the client or indirectly through CDockable.setLocation(CLocation).

Specified by:
setWorkingArea in interface CDockable
Parameters:
area - the new parent or null

getWorkingArea

public CWorkingArea getWorkingArea()
Description copied from interface: CDockable
Gets the parent of this dockable, this should be the same as set by the last call of CDockable.setWorkingArea(CWorkingArea).

Specified by:
getWorkingArea in interface CDockable
Returns:
the parent or null

isResizeLocked

public boolean isResizeLocked()
Description copied from interface: CDockable
Tells whether the size of this dockable should remain the same when its parent changes the size. This has only effect if the parent can choose the size of its children. A lock is no guarantee for staying with the same size, the user still can resize this dockable.

Specified by:
isResizeLocked in interface CDockable
Returns:
true if the size of this dockable should remain the same during resize events of the parent.

setResizeRequest

public void setResizeRequest(Dimension size,
                             boolean process)
Tells this CDockable which size it should have. The size will be stored until it is read by getAndClearResizeRequest().
This method will call CControl.handleResizeRequests() in order to try to apply the requested size. However, there are no guarantees that the requested size can be matched, or that the request gets handled at all.
If this dockable is not registered at a CControl, then the request will remain unprocessed until this dockable is registered, and someone calls CControl.handleResizeRequests() on the new owner.

Parameters:
size - the new preferred size, can be null to cancel an earlier request
process - whether to process all pending requests of all CDockable registered at the CControl which is the owner of this. Clients can set this parameter to false and call CControl.handleResizeRequests() manually to process all pending requests.

getAndClearResizeRequest

public Dimension getAndClearResizeRequest()
Description copied from interface: CDockable
Gets the preferred size of this CDockable. The preferred size will be used to resize this CDockable when CControl.handleResizeRequests() is called. There are no guarantees that the request can be granted, or will be handled at all.
Calling this method should delete the request, so calling this method twice should have the effect, that the second time null is returned.

Specified by:
getAndClearResizeRequest in interface CDockable
Returns:
the next requested size or null

setResizeLocked

public void setResizeLocked(boolean resizeLocked)
Sets whether this dockable likes to remain with the same size all the time.

Parameters:
resizeLocked - true if the size of this dockable should be kept as long as possible.

setMinimizedHold

public void setMinimizedHold(boolean hold)
Description copied from interface: CDockable
Sets whether this dockable should remain visible when minimized and without focus.

Specified by:
setMinimizedHold in interface CDockable
Parameters:
hold - whether to remain visible

isMinimizedHold

public boolean isMinimizedHold()
Description copied from interface: CDockable
Tells whether this dockable remains visible when minimized and without focus.

Specified by:
isMinimizedHold in interface CDockable
Returns:
true if this remains visible, false otherwise

setMinimizedSize

public void setMinimizedSize(Dimension size)
Description copied from interface: CDockable
Sets the size of this dockable when this dockable is minimized and on a popup window.

Specified by:
setMinimizedSize in interface CDockable
Parameters:
size - the size

getMinimizedSize

public Dimension getMinimizedSize()
Description copied from interface: CDockable
Gets the size which is used when this dockable is minimzed and on a popup window. If a value below 0 is set, then the default size is used.

Specified by:
getMinimizedSize in interface CDockable
Returns:
the size

intern

public CommonDockable intern()
Gets the intern representation of this dockable.

Specified by:
intern in interface CDockable
Returns:
the intern representation.

setControl

public void setControl(CControlAccess control)
Sets the CControl which is responsible for this dockable.

Specified by:
setControl in interface CDockable
Parameters:
control - the new control

getClose

public DockActionSource getClose()
Gets the source that contains the close-action.

Specified by:
getClose in interface CDockable
Returns:
the source

getColors

public ColorMap getColors()
Description copied from interface: CDockable
Gets a mutable map of colors. Clients can put colors into this map, and the colors will be presented on the screen by various effects.

Specified by:
getColors in interface CDockable
Returns:
the map, this has always to be the same object

getControl

public CControlAccess getControl()
Gets the control which is responsible for this dockable.

Specified by:
getControl in interface CDockable
Returns:
the control