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:
AbstractDockableCStation, 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

Field Summary
protected  CListenerCollection listenerCollection
          the listeners that were added to this dockable
 
Fields inherited from interface bibliothek.gui.dock.common.intern.CDockable
ACTION_KEY_CLOSE, ACTION_KEY_EXTERNALIZE, ACTION_KEY_MAXIMIZE, ACTION_KEY_MINIMIZE, ACTION_KEY_NORMALIZE, ACTION_KEY_UNEXTERNALIZE, ACTION_KEY_UNMAXIMIZE_EXTERNALIZED
 
Constructor Summary
protected AbstractCDockable()
          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.
 void addDoubleClickListener(CDoubleClickListener listener)
          Adds a new listener to this dockable.
 void addFocusListener(CFocusListener listener)
          Adds a focus listener to this dockable.
 void addKeyboardListener(CKeyboardListener listener)
          Adds a keyboard listener to this dockable.
 void addVetoClosingListener(CVetoClosingListener listener)
          Adds a veto-listener to this dockable, the listener will be informed before this dockable gets closed and can issue a veto.
protected  CControlAccess control()
          Gets access to the controller.
protected abstract  CommonDockable createCommonDockable()
          Creates the CommonDockable that is associated with this dockable, called the first time the CommonDockable is required for an operation.
 CAction getAction(String key)
          Gets an action which is not added to the title by this CDockable put by another module.
 RequestDimension getAndClearResizeRequest()
          Gets the preferred size of this CDockable.
 CLocation getBaseLocation()
          Gets the location of this CDockable.
protected  CloseActionSource getClose()
          Gets the action source which might show a single action that closes this dockable.
 ColorMap getColors()
          Gets a mutable map of colors.
 CControlAccess getControl()
          Gets the control which is responsible for this dockable.
 CLocation getDefaultLocation(ExtendedMode mode)
          Gets an earlier set value of setDefaultLocation(ExtendedMode, CLocation).
 ExtendedMode getExtendedMode()
          Gets the size and location of this CDockable.
 FontMap getFonts()
          Gets a mutable map of fonts.
 Dimension getMinimizedSize()
          Gets the size which is used when this CDockable is minimzed and on a popup window.
 CStation<?> getWorkingArea()
          Gets the parent of this CDockable, this should be the same as set by the last call of CDockable.setWorkingArea(CStation).
protected  void init(CommonDockable dockable)
          Initializes this CDockable.
 CommonDockable intern()
          Gets the intern representation of this dockable.
 boolean isMinimizedHold()
          Tells whether this CDockable remains visible when minimized and without focus.
 boolean isResizeLocked()
          Tells whether width and height are locked.
 boolean isResizeLockedHorizontally()
          Tells whether the width of this CDockable should remain the same when its parent changes the size.
 boolean isResizeLockedVertically()
          Tells whether the height of this CDockable should remain the same when its parent changes the size.
 boolean isSingleTabShown()
          Tells whether a single tab should be shown for this CDockable.
 boolean isTitleShown()
          Tells whether this CDockable shows its title or not.
 boolean isVisible()
          Tells whether this CDockable is currently visible or not.
protected  CDockablePropertyListener[] propertyListeners()
          Deprecated. subclasses should use CListenerCollection.getCDockablePropertyListener() of listenerCollection if they want to fire an event
 void putAction(String key, CAction action)
          Exchanges an action of this CDockable.
 void removeCDockablePropertyListener(CDockablePropertyListener listener)
          Removes a property listener from this dockable.
 void removeCDockableStateListener(CDockableStateListener listener)
          Removes a state listener from this dockable.
 void removeDoubleClickListener(CDoubleClickListener listener)
          Removes a listener from this dockable.
 void removeFocusListener(CFocusListener listener)
          Removes a focus listener from this dockable.
 void removeKeyboardListener(CKeyboardListener listener)
          Removes a listener from this dockable.
 void removeVetoClosingListener(CVetoClosingListener listener)
          Removes listener from this CDockable.
 void setControl(CControlAccess control)
          Sets the CControl which is responsible for this dockable.
 void setDefaultLocation(ExtendedMode mode, CLocation location)
          Sets the default location for mode mode for this dockable.
 void setExtendedMode(ExtendedMode extendedMode)
          Sets how and where this CDockable should be shown.
 void setLocation(CLocation location)
          Sets the location of this CDockable.
 void setMinimizedHold(boolean hold)
          Sets whether this CDockable should remain visible when minimized and without focus.
 void setMinimizedSize(Dimension size)
          Sets the size of this CDockable when this CDockable 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 setResizeLockedHorizontally(boolean resizeLockedHorizontally)
          Sets whether this dockable likes to remain with the same width all the time.
 void setResizeLockedVertically(boolean resizeLockedVertically)
          Sets whether this dockable likes to remain with the same height all the time.
 void setResizeRequest(Dimension size, boolean process)
          Tells this CDockable which size it should have.
 void setResizeRequest(RequestDimension size, boolean process)
          Tells this CDockable which size it should have.
 void setSingleTabShown(boolean singleTabShown)
          Tells this CDockable whether to show a single tab or not.
 void setTitleShown(boolean shown)
          Tells this CDockable whether to show or to hide its titles.
 void setVisible(boolean visible)
          Shows or hides this CDockable.
 void setWorkingArea(CStation<?> area)
          Sets the parent of this CDockable.
protected  CDockableStateListener[] stateListeners()
          Deprecated. subclasses should use CListenerCollection.getCDockableStateListener() of listenerCollection if they want to fire an event
 void toFront()
          Tries to focus this dockable.
 
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
 

Field Detail

listenerCollection

protected CListenerCollection listenerCollection
the listeners that were added to this dockable

Constructor Detail

AbstractCDockable

protected AbstractCDockable()
Creates a new dockable

Method Detail

createCommonDockable

protected abstract CommonDockable createCommonDockable()
Creates the CommonDockable that is associated with this dockable, called the first time the CommonDockable is required for an operation.

Returns:
the new dockable

init

protected void init(CommonDockable dockable)
Initializes this CDockable.

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

getClose

protected CloseActionSource getClose()
Gets the action source which might show a single action that closes this dockable.

Returns:
the close source

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

addFocusListener

public void addFocusListener(CFocusListener listener)
Description copied from interface: CDockable
Adds a focus listener to this dockable. The focus listener gets informed when this dockable gains or loses the focus.

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

removeFocusListener

public void removeFocusListener(CFocusListener listener)
Description copied from interface: CDockable
Removes a focus listener from this dockable.

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

addKeyboardListener

public void addKeyboardListener(CKeyboardListener listener)
Description copied from interface: CDockable
Adds a keyboard listener to this dockable. The listener gets informed when a key is pressed or released on this dockable.

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

removeKeyboardListener

public void removeKeyboardListener(CKeyboardListener listener)
Description copied from interface: CDockable
Removes a listener from this dockable.

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

addDoubleClickListener

public void addDoubleClickListener(CDoubleClickListener listener)
Description copied from interface: CDockable
Adds a new listener to this dockable. The listener gets informed when the mouse is clicked twice on this dockable.

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

removeDoubleClickListener

public void removeDoubleClickListener(CDoubleClickListener listener)
Description copied from interface: CDockable
Removes a listener from this dockable.

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

addVetoClosingListener

public void addVetoClosingListener(CVetoClosingListener listener)
Description copied from interface: CDockable
Adds a veto-listener to this dockable, the listener will be informed before this dockable gets closed and can issue a veto. The listener will receive a CVetoClosingEvent which contains only this CDockable (even if other dockables are closed at the same time).
CVetoClosingListeners added to the CControl are invoked before listeners that are added to a CDockable.

Specified by:
addVetoClosingListener in interface CDockable
Parameters:
listener - the new listener
See Also:
CControl.addVetoClosingListener(CVetoClosingListener)

removeVetoClosingListener

public void removeVetoClosingListener(CVetoClosingListener listener)
Description copied from interface: CDockable
Removes listener from this CDockable.

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

stateListeners

@Deprecated
protected CDockableStateListener[] stateListeners()
Deprecated. subclasses should use CListenerCollection.getCDockableStateListener() of listenerCollection if they want to fire an event

Gets the list of state listeners.

Returns:
the stateListeners

propertyListeners

@Deprecated
protected CDockablePropertyListener[] propertyListeners()
Deprecated. subclasses should use CListenerCollection.getCDockablePropertyListener() of listenerCollection if they want to fire an event

Gets the list of property listeners.

Returns:
the stateListeners

setVisible

public void setVisible(boolean visible)
Description copied from interface: CDockable
Shows or hides this CDockable. If this CDockable 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 CDockable is currently visible or not. Visibility means that this CDockable 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 CDockable 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 CDockable 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 CDockable. If this CDockable is visible, than this method will take immediately effect. Otherwise the location will be stored in a cache and read as soon as this CDockable 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.
Subclasses should call CControlAccess.getLocationManager() and CLocationModeManager.setLocation(bibliothek.gui.Dockable, CLocation).

Specified by:
setLocation in interface CDockable
Parameters:
location - the new location, null is possible, but will not move the CDockable immediately
See Also:
CDockable.getBaseLocation()

getBaseLocation

public CLocation getBaseLocation()
Description copied from interface: CDockable
Gets the location of this CDockable. If this CDockable 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:
getBaseLocation in interface CDockable
Returns:
the location or null

setExtendedMode

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

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

getExtendedMode

public ExtendedMode getExtendedMode()
Description copied from interface: CDockable
Gets the size and location of this CDockable. Implementations should return LocationModeManager.getMode(Dockable).

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

setWorkingArea

public void setWorkingArea(CStation<?> area)
Description copied from interface: CDockable
Sets the parent of this CDockable. 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 CStation<?> getWorkingArea()
Description copied from interface: CDockable
Gets the parent of this CDockable, this should be the same as set by the last call of CDockable.setWorkingArea(CStation).

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

isResizeLocked

public boolean isResizeLocked()
Tells whether width and height are locked.

Returns:
true if width and height are locked

isResizeLockedVertically

public boolean isResizeLockedVertically()
Description copied from interface: CDockable
Tells whether the height of this CDockable 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 CDockable.

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

isResizeLockedHorizontally

public boolean isResizeLockedHorizontally()
Description copied from interface: CDockable
Tells whether the width of this CDockable 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 CDockable.

Specified by:
isResizeLockedHorizontally in interface CDockable
Returns:
true if the width of this CDockable 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().
If process is true, then 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 CDockable is not registered at a CControl, then the request will remain unprocessed until this CDockable 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.
See Also:
setResizeRequest(RequestDimension, boolean)

setResizeRequest

public void setResizeRequest(RequestDimension size,
                             boolean process)
Tells this CDockable which size it should have. The size will be stored until it is read by getAndClearResizeRequest().
If process is true, then 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 CDockable is not registered at a CControl, then the request will remain unprocessed until this CDockable 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 RequestDimension 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
See Also:
setResizeLockedHorizontally(boolean), setResizeLockedVertically(boolean)

setResizeLockedHorizontally

public void setResizeLockedHorizontally(boolean resizeLockedHorizontally)
Sets whether this dockable likes to remain with the same width all the time.

Parameters:
resizeLockedHorizontally - true if the width of this dockable should be kept as long as possible

setResizeLockedVertically

public void setResizeLockedVertically(boolean resizeLockedVertically)
Sets whether this dockable likes to remain with the same height all the time.

Parameters:
resizeLockedVertically - true if the height of this dockable should be kept as long as possible

setMinimizedHold

public void setMinimizedHold(boolean hold)
Description copied from interface: CDockable
Sets whether this CDockable 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 CDockable 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 CDockable when this CDockable 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 CDockable 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

setTitleShown

public void setTitleShown(boolean shown)
Tells this CDockable whether to show or to hide its titles.

Parameters:
shown - true if titles should be shown, false if they should be hidden.

isTitleShown

public boolean isTitleShown()
Description copied from interface: CDockable
Tells whether this CDockable shows its title or not. Note that some DockThemes might override this setting.

Specified by:
isTitleShown in interface CDockable
Returns:
true if the title is shown, false otherwise.

setSingleTabShown

public void setSingleTabShown(boolean singleTabShown)
Tells this CDockable whether to show a single tab or not.

Parameters:
singleTabShown - true if a single tab should be shown, false otherwise
See Also:
isSingleTabShown()

isSingleTabShown

public boolean isSingleTabShown()
Description copied from interface: CDockable
Tells whether a single tab should be shown for this CDockable. Some DockThemes might ignore this setting.

Specified by:
isSingleTabShown in interface CDockable
Returns:
true if a single tab should be shown, false if not

intern

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

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

setDefaultLocation

public void setDefaultLocation(ExtendedMode mode,
                               CLocation location)
Sets the default location for mode mode for this dockable. Note that this location does not override any existing setting. This method can be called either before or after making this dockable visible. It is the client's responsibility to ensure that location is valid together with mode.

Parameters:
mode - the mode for which to store the default location
location - the default location or null

getDefaultLocation

public CLocation getDefaultLocation(ExtendedMode mode)
Gets an earlier set value of setDefaultLocation(ExtendedMode, CLocation).

Parameters:
mode - the mode for which to search the default location
Returns:
the location or null

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

putAction

public void putAction(String key,
                      CAction action)
Exchanges an action of this CDockable. The actions that are associated with this CDockable through this method are not necessarily shown on the title. They are used by other modules to create effects that are known only to them.

Parameters:
key - the key of the action, one of the ACTION_KEY_xzy-constants defined in CDockable
action - the new action, can be null which might force back a default action (that depends on the module that uses key)

getAction

public CAction getAction(String key)
Description copied from interface: CDockable
Gets an action which is not added to the title by this CDockable put by another module.

Specified by:
getAction in interface CDockable
Parameters:
key - the name of the action
Returns:
an action or null

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

getFonts

public FontMap getFonts()
Description copied from interface: CDockable
Gets a mutable map of fonts. Clients can put fonts into this map, and the fonts will be presented on the screen through various effects.

Specified by:
getFonts 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