Interface CDockable
- All Known Subinterfaces:
MultipleCDockable,SingleCDockable
- All Known Implementing Classes:
AbstractCDockable,AbstractDockableCStation,CGridArea,CWorkingArea,DefaultCDockable,DefaultMultipleCDockable,DefaultSingleCDockable,ExternalizingCGridArea
A basic element representing some
Note: This interface is not intended to be implemented by clients. Clients should either extend the class
Component and a wrapper
around a Dockable.Note: This interface is not intended to be implemented by clients. Clients should either extend the class
AbstractCDockable or use
one of DefaultSingleCDockable or DefaultMultipleCDockable.- Author:
- Benjamin Sigg
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringKey for an action ofgetAction(String).static final StringKey for an action ofgetAction(String).static final StringKey for an action ofgetAction(String).static final StringKey for an action ofgetAction(String).static final StringKey for an action ofgetAction(String).static final StringKey for an action ofgetAction(String).static final StringKey for an action ofgetAction(String).static final StringKey for an action ofgetAction(String). -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a listener to this dockable which gets informed if the location or the visibility changes.voidAdds a property listener to this dockable, the listener will be informed of changes of this dockable.voidAdds a state listener to this dockable, the listener will be informed of changes of this dockable.voidaddDoubleClickListener(CDoubleClickListener listener) Adds a new listener to this dockable.voidaddFocusListener(CFocusListener listener) Adds a focus listener to this dockable.voidaddKeyboardListener(CKeyboardListener listener) Adds a keyboard listener to this dockable.voidaddVetoClosingListener(CVetoClosingListener listener) Adds a veto-listener to this dockable, the listener will be informed before this dockable gets closed and can issue a veto.CStation<?>Gets an action which is not added to the title by thisCDockableput by another module.Gets the preferred size of thisCDockable.getAutoBaseLocation(boolean noBackwardsTransformation) Tries to find out at which location thisCDockablemay appear if it would be made visible.Gets the location of thisCDockable.Gets a mutable map of colors.Gets the control which is responsible for this dockable.Gets the control which is responsible for this dockable.Gets the size and location of thisCDockable.Gets theComponentwhich should receive the focus once thisCDockableis focused.getFonts()Gets a mutable map of fonts.Gets the size which is used when thisCDockableis minimized and on a popup window.CStation<?>CStation<?>Gets the parent of thisCDockable, this should be the same as set by the last call ofsetWorkingArea(CStation).booleanTells whether thisCDockablehas a root station as parent.intern()Gets the intern representation of thisCDockable.booleanTells whether thisCDockablecan be closed by the user.booleanDeprecated.booleanisEnabled(EnableableItem item) Tells whether a part of this dockable is enabled.booleanTells whether thisCDockablecan be externalized by the user.booleanTells whether thisCDockablecan be maximized by the user.booleanTells whether thisCDockablecan be minimized by the user.booleanTells whether thisCDockablecan be normalized by the user.booleanTells whether the width of thisCDockableshould remain the same when its parent changes the size.booleanTells whether the height of thisCDockableshould remain the same when its parent changes the size.booleanTells whether thisCDockableis currently visible to the user.booleanTells whether a single tab should be shown for thisCDockable.booleanTells whether thisCDockablecan be combined with anotherDockableto create a stack.booleanisSticky()Tells whether thisCDockableremains visible when minimized and without focus.booleanTells whether theisSticky()property can be changed by the user by clicking a button that is displayed on theFlapDockStation.booleanTells whether thisCDockableshows its title or not.booleanTells whether thisCDockableis currently visible or not.voidRemoveslistenerfrom this dockablevoidRemoves a property listener from this dockable.voidRemoves a state listener from this dockable.voidRemoves a listener from this dockable.voidremoveFocusListener(CFocusListener listener) Removes a focus listener from this dockable.voidremoveKeyboardListener(CKeyboardListener listener) Removes a listener from this dockable.voidRemoveslistenerfrom thisCDockable.voidsetControlAccess(CControlAccess control) Sets theCControlwhich is responsible for thisCDockable.voidsetExtendedMode(ExtendedMode extendedMode) Sets how and where thisCDockableshould be shown.voidsetLocation(CLocation location) Sets the location of thisCDockable.voidsetLocationsAside(CDockable dockable) booleansetLocationsAside(Filter<CDockable> filter) Traverses the history of focusedCDockables, and selects the newest item with focus and matchingfilterfor callingsetLocationsAside(CDockable).booleanSearches for the last focusedCDockablewith the sameworking areaasthis, and callssetLocationsAside(CDockable)with it.
Note that if thisdockableis visible, then it may or may not change its location.voidsetMinimizedSize(Dimension size) Sets the size of thisCDockablewhen thisCDockableis minimized and on a popup window.voidsetSticky(boolean sticky) Sets whether thisCDockableshould remain visible when minimized and without focus.voidsetStickySwitchable(boolean switchable) Sets whether the user can switch theisSticky()property by clicking on a button that is presented by theFlapDockStation.voidsetVisible(boolean visible) Shows or hides thisCDockable.voidsetWorkingArea(CStation<?> area) Sets the parent of thisCDockable.
-
Field Details
-
ACTION_KEY_MINIMIZE
Key for an action ofgetAction(String). The action behind this key should callsetExtendedMode(ExtendedMode)with an argument ofExtendedMode.MINIMIZED.- See Also:
-
ACTION_KEY_MAXIMIZE
Key for an action ofgetAction(String). The action behind this key should callsetExtendedMode(ExtendedMode)with an argument ofExtendedMode.MAXIMIZED.- See Also:
-
ACTION_KEY_NORMALIZE
Key for an action ofgetAction(String). The action behind this key should callsetExtendedMode(ExtendedMode)with an argument ofExtendedMode.NORMALIZED.- See Also:
-
ACTION_KEY_EXTERNALIZE
Key for an action ofgetAction(String). The action behind this key should callsetExtendedMode(ExtendedMode)with an argument ofExtendedMode.EXTERNALIZED.- See Also:
-
ACTION_KEY_UNEXTERNALIZE
Key for an action ofgetAction(String). The action behind this key should callsetExtendedMode(ExtendedMode)with an argument ofExtendedMode.NORMALIZED.- See Also:
-
ACTION_KEY_UNMAXIMIZE_EXTERNALIZED
Key for an action ofgetAction(String). The action behind this key should callsetExtendedMode(ExtendedMode)with an argument ofExtendedMode.EXTERNALIZED.- See Also:
-
ACTION_KEY_CLOSE
Key for an action ofgetAction(String). The action behind this key should callsetVisible(boolean)with the argumentfalse.- See Also:
-
ACTION_KEY_MINIMIZE_HOLD
Key for an action ofgetAction(String). The action behind this key should toggle CDockable.setMinimizedHold(boolean). TODO: setMinimizedHold no longer exists; update- See Also:
-
-
Method Details
-
addCDockableStateListener
Adds a state listener to this dockable, the listener will be informed of changes of this dockable.- Parameters:
listener- the new listener
-
addCDockablePropertyListener
Adds a property listener to this dockable, the listener will be informed of changes of this dockable.- Parameters:
listener- the new listener
-
addCDockableLocationListener
Adds a listener to this dockable which gets informed if the location or the visibility changes.- Parameters:
listener- the new listener
-
removeCDockableStateListener
Removes a state listener from this dockable.- Parameters:
listener- the listener to remove
-
removeCDockablePropertyListener
Removes a property listener from this dockable.- Parameters:
listener- the listener to remove
-
removeCDockableLocationListener
Removeslistenerfrom this dockable- Parameters:
listener- the listener to remove
-
addFocusListener
Adds a focus listener to this dockable. The focus listener gets informed when this dockable gains or loses the focus.- Parameters:
listener- the new listener
-
removeFocusListener
Removes a focus listener from this dockable.- Parameters:
listener- the listener to remove
-
addKeyboardListener
Adds a keyboard listener to this dockable. The listener gets informed when a key is pressed or released on this dockable.- Parameters:
listener- the new listener
-
removeKeyboardListener
Removes a listener from this dockable.- Parameters:
listener- the listener to remove
-
addDoubleClickListener
Adds a new listener to this dockable. The listener gets informed when the mouse is clicked twice on this dockable.- Parameters:
listener- the new listener
-
removeDoubleClickListener
Removes a listener from this dockable.- Parameters:
listener- the listener to remove
-
addVetoClosingListener
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 aCVetoClosingEventwhich contains only thisCDockable(even if other dockables are closed at the same time).
CVetoClosingListeners added to theCControlare invoked before listeners that are added to aCDockable.- Parameters:
listener- the new listener- See Also:
-
removeVetoClosingListener
Removeslistenerfrom thisCDockable.- Parameters:
listener- the listener to remove
-
isMinimizable
boolean isMinimizable()Tells whether thisCDockablecan be minimized by the user.- Returns:
trueif this element can be minimized
-
isMaximizable
boolean isMaximizable()Tells whether thisCDockablecan be maximized by the user.- Returns:
trueif this element can be maximized
-
isExternalizable
boolean isExternalizable()Tells whether thisCDockablecan be externalized by the user.- Returns:
trueif this element can be externalized
-
isNormalizeable
boolean isNormalizeable()Tells whether thisCDockablecan be normalized by the user. Usually this method should returntruefor any dockable, as "normalizing" is the default mode.
Clients should not override this method.- Returns:
true, unless a subclass requires very special behavior.
-
isStackable
boolean isStackable()Tells whether thisCDockablecan be combined with anotherDockableto create a stack.- Returns:
trueif this element can be combined with anotherDockable, normallytrueshould be the answer.
-
isCloseable
boolean isCloseable()Tells whether thisCDockablecan be closed by the user. A close-button has to be provided by theCDockableitself. The best way to do that is to instantiate aCloseActionSourceand include this source in the array that is returned byCommonDockable.getSources().- Returns:
trueif this element can be closed
-
isResizeLockedVertically
boolean isResizeLockedVertically()Tells whether the height of thisCDockableshould 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 thisCDockable.- Returns:
trueif the height of thisCDockableshould remain the same during resize events of the parent.
-
isResizeLockedHorizontally
boolean isResizeLockedHorizontally()Tells whether the width of thisCDockableshould 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 thisCDockable.- Returns:
trueif the width of thisCDockableshould remain the same during resize events of the parent.
-
getAndClearResizeRequest
RequestDimension getAndClearResizeRequest()Gets the preferred size of thisCDockable. The preferred size will be used to resize thisCDockablewhenCControl.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 timenullis returned.- Returns:
- the next requested size or
null
-
setVisible
void setVisible(boolean visible) Shows or hides thisCDockable. If thisCDockableis not visible and is made visible, then the framework tries to set its location at the last known position.
Subclasses should callCControlAccess.show(CDockable)orCControlAccess.hide(CDockable).- Parameters:
visible- the new visibility state- Throws:
IllegalStateException- if this dockable can't be made visible- See Also:
-
isVisible
boolean isVisible()Tells whether thisCDockableis currently visible or not. Visibility means that thisCDockableis in the tree structure of DockingFrames and has a parent. Being in the structure does not imply being visible on the screen: If someJFrameis not shown, or someDockStationnot properly added to a parent component, then a visibleCDockablecan be invisible for the user. ForCDockables that are also root-CStationthis method will always returntrue.
Clients interested in whether the user can actually see this dockable should callisShowing().
Subclasses should return the result ofCControlAccess.isVisible(CDockable).- Returns:
trueif thisCDockablecan be accessed by the user through a graphical user interface.- See Also:
-
hasParent
boolean hasParent()Tells whether thisCDockablehas a root station as parent. Having a root station as parent impliesisVisible(). For root-CStationthis method will returnfalseif they do not have a parent, they are not considered to be parents of themselves.
Subclasses should return the result ofCControlAccess.hasParent(CDockable).- Returns:
trueif this dockable has a parent and is in the tree
-
isDockableVisible
@Deprecated @Todo(compatibility=BREAK_MAJOR, priority=ENHANCEMENT, target=VERSION_1_1_3, description="remove this method") boolean isDockableVisible()Deprecated.this method gets replaced byisShowing(), which offers the exact same information. This method will be removed in a future releaseTells whether thisCDockableis currently visible to the user. ACDockablewhich is notvisible, is notdockable visibleeither. The method does not take into account that a frame may be positioned such that it is not entirely visible on the screen. Neither does the method take into account, that a frame may be minimized.- Returns:
trueif the user should be able to see this item
-
isShowing
boolean isShowing()Tells whether thisCDockableis currently visible to the user. ACDockablewhich is notvisible, is notshowingeither. The method does not take into account that a frame may be positioned such that it is not entirely visible on the screen. The method may or may not take into account, that a frame may be minimized.
Clients interested in monitoring this property can add aCDockableLocationListenerto this dockable.- Returns:
trueif the user should be able to see this item- See Also:
-
setLocation
Sets the location of thisCDockable. If thisCDockableis visible, than this method will take immediately effect. Otherwise the location will be stored in a cache and read as soon as thisCDockableis 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 callCControlAccess.getLocationManager()andCLocationModeManager.setLocation(bibliothek.gui.Dockable, CLocation).- Parameters:
location- the new location,nullis possible, but will not move theCDockableimmediately- See Also:
-
setLocationsAside
Sets the location of thisCDockableasidedockablein allExtendedModes. If thisDockableis visible, then it may or may not change its location andExtendedMode. Note thatdockableandthismust not be the same object, and that bothCDockables must beregisteredat aCControl.- Parameters:
dockable- the item whose locations should be copied- Throws:
IllegalArgumentException- ifdockableisnull, not registered, the same asthis, or has a differentworking areaIllegalStateException- ifthisis not registered at the sameCControlasdockable
-
setLocationsAside
Traverses the history of focusedCDockables, and selects the newest item with focus and matchingfilterfor callingsetLocationsAside(CDockable). -
setLocationsAsideFocused
boolean setLocationsAsideFocused()Searches for the last focusedCDockablewith the sameworking areaasthis, and callssetLocationsAside(CDockable)with it.
Note that if thisdockableis visible, then it may or may not change its location. This method should be called before making thedockablevisible.- Returns:
trueif the last focusedCDockablewas found,falseotherwise. Iffalsethen no action was performed
-
getBaseLocation
CLocation getBaseLocation()Gets the location of thisCDockable. If thisCDockableis visible, then a location will always be returned. Otherwise a location will only be returned if it just was set usingsetLocation(CLocation).- Returns:
- the location or
null
-
getAutoBaseLocation
Tries to find out at which location thisCDockablemay appear if it would be made visible. The default implementation of this method has severe limitations:- Random placements are not considered and the result will be
null - Placeholders are not considered, if this
CDockableis associated with a placeholder, then the placeholder information will be completely lost. - This
CDockablemust not be visible and it must be registered at aCControl.
Clients can make use of this method in two ways:- They can find out whether the dockable has a location, or will be placed randomly (in which case the result
of this method is
null) - They can override this method in which case the
CDockablewill appear at the exact location that is returned by this method ignoring any other settings.
- Parameters:
noBackwardsTransformation- iftrue, then this method should not convert anyDockablePropertyback to aCLocation, instead it should returnnullif such a conversion would be necessary. This way the method does returnnullin any case where information (e.g. placeholders) could be lost due to the limitations ofCLocation- Returns:
- The expected location of this invisible
CDockable, this may either be the location that was set by callingsetLocation(CLocation), the last location of this dockable when it was visible, thedefault locationof theCControlor the default location for thenormalized extended mode. A value ofnullis returned if thisCDockablewould appear at a random location, is not registered at aCControlor is already visible.
- Random placements are not considered and the result will be
-
setExtendedMode
Sets how and where thisCDockableshould be shown. Conflicts withisExternalizable(),isMaximizable()andisMinimizable()will just be ignored. Implementations should callLocationModeManager.setMode(Dockable, ExtendedMode).
If this dockable is not visible, then it will be made visible in order to apply theextendedMode.- Parameters:
extendedMode- the size and location
-
getExtendedMode
ExtendedMode getExtendedMode()Gets the size and location of thisCDockable. Implementations should returnLocationModeManager.getMode(Dockable).- Returns:
- the size and location or
nullif thisCDockableis not part of anCControl. May benullif this dockable is not visible.
-
getGrouping
DockableGrouping getGrouping()Gets an algorithm that tells how thisCDockableattempts to group itself automatically with otherDockables. The algorithm is able to rewrite the location of thisCDockableevery time when it is moved to a new location, assuming that no stronger mechanism, or the user, already defined a location.- Returns:
- the grouping behavior, or
null
-
setWorkingArea
Sets the parent of thisCDockable. This method can be called by the client or indirectly throughsetLocation(CLocation).- Parameters:
area- the new parent ornull
-
getWorkingArea
CStation<?> getWorkingArea()Gets the parent of thisCDockable, this should be the same as set by the last call ofsetWorkingArea(CStation).- Returns:
- the parent or
null
-
setMinimizedSize
Sets the size of thisCDockablewhen thisCDockableis minimized and on a popup window.- Parameters:
size- the size
-
getMinimizedSize
Dimension getMinimizedSize()Gets the size which is used when thisCDockableis minimized and on a popup window. If a value below 0 is set, then the default size is used.- Returns:
- the size
-
setSticky
void setSticky(boolean sticky) Sets whether thisCDockableshould remain visible when minimized and without focus.- Parameters:
sticky- whether to remain visible
-
isSticky
boolean isSticky()Tells whether thisCDockableremains visible when minimized and without focus.- Returns:
trueif this remains visible,falseotherwise
-
setStickySwitchable
void setStickySwitchable(boolean switchable) Sets whether the user can switch theisSticky()property by clicking on a button that is presented by theFlapDockStation.- Parameters:
switchable- whether the user is able to switch the hold property
-
isStickySwitchable
boolean isStickySwitchable()Tells whether theisSticky()property can be changed by the user by clicking a button that is displayed on theFlapDockStation.- Returns:
trueif the user is able to switch the property,falseotherwise
-
isTitleShown
boolean isTitleShown()Tells whether thisCDockableshows its title or not. Note that someDockThemes might override this setting.- Returns:
trueif the title is shown,falseotherwise.
-
isSingleTabShown
boolean isSingleTabShown()Tells whether a single tab should be shown for thisCDockable. SomeDockThemes might ignore this setting.- Returns:
trueif a single tab should be shown,falseif not
-
isEnabled
Tells whether a part of this dockable is enabled.- Parameters:
item- the part to check- Returns:
- whether
itemis enabled, the default result should betrue
-
getFocusComponent
Component getFocusComponent()Gets theComponentwhich should receive the focus once thisCDockableis focused.- Returns:
- the element which should receive the focus, can be
null
-
intern
CommonDockable intern()Gets the intern representation of thisCDockable.- Returns:
- the intern representation.
-
asStation
CStation<?> asStation()- Returns:
- this as station or
null
-
setControlAccess
Sets theCControlwhich is responsible for thisCDockable. Subclasses must callCControlAccess.link(CDockable, CDockableAccess)to grant theCControlaccess to the internal properties of thisCDockable.linkcan also be used to revoke access.- Parameters:
control- the new control ornull
-
getControlAccess
Gets the control which is responsible for this dockable. Clients should not use this method unless they know exactly what they are doing.- Returns:
- the control
-
getControl
CControl getControl()Gets the control which is responsible for this dockable. This property is set as long as thisCDockableis registered at aCControl.- Returns:
- the control in whose realm this dockable is used, can be
null
-
getParentStation
CStation<?> getParentStation()- Returns:
- the closest station, may be
null
-
getAction
Gets an action which is not added to the title by thisCDockableput by another module.- Parameters:
key- the name of the action- Returns:
- an action or
null
-
getColors
ColorMap getColors()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.- Returns:
- the map, this has always to be the same object
-
getFonts
FontMap getFonts()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.- Returns:
- the map, this has always to be the same object
-
isShowing(), which offers the exact same information.