Class DockableComponentWrapper
- All Implemented Interfaces:
EventListener,Dockable,DockingListener,DockingMonitor
Dockable implementation for wrapping a
Component. It is essentially the simplest means to turning a generic
Component into a Dockable instance. Compound
Dockables may have separate child components that are responsible for
drag initiation, whereas another component is the actual drag source. This is
shown in the manner that a JInternalFrame would be a draggable
component, while the frame's title pane is the actual drag initiator.
The class, conversely, deals with the simple case, where a
Component itself must be docking-enabled.
DockableComponentWrapper wraps a Component and implements the
Dockable interface. Since the Component itself is being
docking-enabled, it serves as both the drag source and drag initiator. Thus,
getComponent() will return a reference to 'this' and
getDragSources() return a List containing the same
self-reference Component.
This class may be used by application code to enable docking capabilities on
a given Component. However, it is recommended that
DockingManager.registerDockable(Component evtSrc, String desc) be
used as a more automated, less invasive means of enabling docking on a
component.
DockingManager.registerDockable(Component evtSrc, String desc) will
automatically create a DockableComponentWrapper instance and register
the required drag listeners.
- Author:
- Chris Butler
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.flexdock.docking.event.DockingListener
DockingListener.Stub -
Field Summary
Fields inherited from interface org.flexdock.docking.Dockable
DOCKABLE_INDICATOR -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDockingListener(DockingListener listener) Adds aDockingListenerto observe docking events for thisDockable.voidAdds a PropertyChangeListener to the listener list.static DockableComponentWrapperCreates aDockableComponentWrapperinstance using the specified source component, persistent ID, and docking description.static DockableComponentWrappercreate(DockingAdapter adapter) static DockableComponentWrappercreate(DockingStub stub) booleanProvides the defaultDockableimplementation ofdock(Dockable dockable)by calling and returningDockingManager.dock(Dockable dockable, Dockable parent).booleanProvides the defaultDockableimplementation ofdock(Dockable dockable, String relativeRegion)by calling and returningDockingManager.dock(Dockable dockable, Dockable parent, String region).booleanProvides the defaultDockableimplementation ofdock(Dockable dockable, String relativeRegion, float ratio)by calling and returningDockingManager.dock(Dockable dockable, Dockable parent, String region, float proportion).voidNo operation.voidNo operation.voiddragStarted(DockingEvent evt) No operation.voiddropStarted(DockingEvent evt) No operation.getClientProperty(Object key) Returns the value of the property with the specified key.Returns theComponentused to create thisDockableComponentWrapperinstance.Returns an array of allDockingListenersadded to thisDockable.Returns theDockingPortwithin which thisDockableis currently docked.Returns aDockablePropertySetinstance associated with thisDockable.Returns aListofComponentsused to initiate drag-to-dock operation.Returns aHashSetofComponentsused as frame drag sources when thisDockableis floating in a non-decorated external dialog.Returns the persistent ID of thisDockableComponentWrapperinstance provided when this object was instantiated.voidputClientProperty(Object key, Object value) Adds an arbitrary key/value "client property" to thisDockable.voidremoveDockingListener(DockingListener listener) Removes the specifiedDockingListenerfrom thisDockable.voidRemoves a PropertyChangeListener from the listener list.voidNo operation.voidNo operation.
-
Method Details
-
create
Creates aDockableComponentWrapperinstance using the specified source component, persistent ID, and docking description. This method is used to createDockableinstances for simpleComponentswhere the drag source and drag initiator are the sameComponent.If
srcoridarenull, then this method returns anullreference.srcwill be theComponentreturned by invokinggetComponent()on the resultingDockableand will be included in theListreturned bygetDragSources().idwill be the value returned by invokinggetPersistentId()on the resultingDockable.descmay be used by theDockablefor descriptive purposes (such as tab-text in a tabbed layout). It is not recommended to supply anullvalue fordesc, but doing so is not illegal.- Parameters:
src- the source componentid- the persistent ID for the Dockable instancedesc- the docking description- Returns:
- a new
DockableComponentWrapperinstance - See Also:
-
create
-
create
-
getComponent
Returns theComponentused to create thisDockableComponentWrapperinstance.- Specified by:
getComponentin interfaceDockable- Returns:
- the
Componentused to create thisDockableComponentWrapperinstance. - See Also:
-
getDragSources
Returns aListofComponentsused to initiate drag-to-dock operation. By default, the returnedListcontains theComponentreturned bygetComponent().- Specified by:
getDragSourcesin interfaceDockable- Returns:
- a
ListofComponentsused to initiate drag-to-dock operation. - See Also:
-
getPersistentId
Returns the persistent ID of thisDockableComponentWrapperinstance provided when this object was instantiated.- Specified by:
getPersistentIdin interfaceDockable- Returns:
- the persistent ID of this
DockableComponentWrapper - See Also:
-
getFrameDragSources
Returns aHashSetofComponentsused as frame drag sources when thisDockableis floating in a non-decorated external dialog. TheHashSetreturned by this method is initially empty. Because it is mutable, however, newComponentsmay be added to it.- Specified by:
getFrameDragSourcesin interfaceDockable- Returns:
- a
HashSetofComponentsused as frame drag sources when thisDockableis floating in a non-decorated external dialog. - See Also:
-
addDockingListener
Adds aDockingListenerto observe docking events for thisDockable.nullarguments are ignored.- Specified by:
addDockingListenerin interfaceDockingMonitor- Parameters:
listener- theDockingListenerto add to thisDockable.- See Also:
-
getDockingListeners
Returns an array of allDockingListenersadded to thisDockable. If there are no listeners present for thisDockable, then a zero-length array is returned.- Specified by:
getDockingListenersin interfaceDockingMonitor- Returns:
- an array of all
DockingListenersadded to thisDockable. - See Also:
-
removeDockingListener
Removes the specifiedDockingListenerfrom thisDockable. If the specifiedDockingListenerisnull, or the listener has not previously been added to thisDockable, then noExceptionis thrown and no action is taken.- Specified by:
removeDockingListenerin interfaceDockingMonitor- Parameters:
listener- theDockingListenerto remove from thisDockable- See Also:
-
dockingCanceled
No operation. Provided as a method stub to fulfull theDockingListenerinterface contract.- Specified by:
dockingCanceledin interfaceDockingListener- Parameters:
evt- theDockingEventto respond to.- See Also:
-
dockingComplete
No operation. Provided as a method stub to fulfull theDockingListenerinterface contract.- Specified by:
dockingCompletein interfaceDockingListener- Parameters:
evt- theDockingEventto respond to.- See Also:
-
undockingComplete
No operation. Provided as a method stub to fulfull theDockingListenerinterface contract.- Specified by:
undockingCompletein interfaceDockingListener- Parameters:
evt- theDockingEventto respond to.- See Also:
-
undockingStarted
No operation. Provided as a method stub to fulfull theDockingListenerinterface contract.- Specified by:
undockingStartedin interfaceDockingListener- Parameters:
evt- theDockingEventto respond to.- See Also:
-
dragStarted
No operation. Provided as a method stub to fulfull theDockingListenerinterface contract.- Specified by:
dragStartedin interfaceDockingListener- Parameters:
evt- theDockingEventto respond to.- See Also:
-
dropStarted
No operation. Provided as a method stub to fulfull theDockingListenerinterface contract.- Specified by:
dropStartedin interfaceDockingListener- Parameters:
evt- theDockingEventto respond to.- See Also:
-
getClientProperty
Returns the value of the property with the specified key. Only properties added withputClientPropertywill return a non-nullvalue. Ifkeyisnull, anullreference is returned.If the
Componentreturned bygetComponent()is an instance ofJComponent, then this method will dispatch to thatJComponent'sgetClientProperty(Object, Object)method. Otherwise, thisDockableComponentWrapperwill provide its own internal mapping of client properties.- Specified by:
getClientPropertyin interfaceDockable- Parameters:
key- the key that is being queried- Returns:
- the value of this property or
null - See Also:
-
putClientProperty
Adds an arbitrary key/value "client property" to thisDockable.nullvalues are allowed. Ifkeyisnull, then no action is taken.If the
Componentreturned bygetComponent()is an instance ofJComponent, then this method will dispatch to thatJComponent'sputClientProperty(Object, Object)method. Otherwise, thisDockableComponentWrapperwill provide its own internal mapping of client properties.- Specified by:
putClientPropertyin interfaceDockable- Parameters:
key- the new client property keyvalue- the new client property value; ifnullthis method will remove the property- See Also:
-
getDockingProperties
Returns aDockablePropertySetinstance associated with thisDockable. This method returns the default implementation supplied by the framework by invokinggetDockablePropertySet(Dockable dockable)onorg.flexdock.docking.props.PropertyManagerand supplying an argument ofthis.- Specified by:
getDockingPropertiesin interfaceDockable- Returns:
- the
DockablePropertySetassociated with thisDockable. This method will not return anullreference. - See Also:
-
getDockingPort
Returns theDockingPortwithin which thisDockableis currently docked. If not currently docked, this method will returnnull.This method defers processing to
getDockingPort(Dockable dockable), passing an argument ofthis.- Specified by:
getDockingPortin interfaceDockable- Returns:
- the
DockingPortwithin which thisDockableis currently docked. - See Also:
-
dock
Provides the defaultDockableimplementation ofdock(Dockable dockable)by calling and returningDockingManager.dock(Dockable dockable, Dockable parent).'this'is passed as theparentparameter. -
dock
Provides the defaultDockableimplementation ofdock(Dockable dockable, String relativeRegion)by calling and returningDockingManager.dock(Dockable dockable, Dockable parent, String region).'this'is passed as theparentparameter. -
dock
Provides the defaultDockableimplementation ofdock(Dockable dockable, String relativeRegion, float ratio)by calling and returningDockingManager.dock(Dockable dockable, Dockable parent, String region, float proportion).'this'is passed as theparentparameter.- Specified by:
dockin interfaceDockable- Parameters:
dockable- theDockableto dock relative to thisDockablerelativeRegion- the docking region into which to dock the specifiedDockableratio- the proportion of available space in the resulting layout to allot to the new siblingDockable.- Returns:
trueif the docking operation was successful;falseotherwise.- See Also:
-
addPropertyChangeListener
Description copied from interface:DockableAdds a PropertyChangeListener to the listener list. The listener is registered for all bound properties of this class. Note that if this Dockable is inheriting a bound property, then no event will be fired in response to a change in the inherited property.If listener is null, no exception is thrown and no action is performed.
- Specified by:
addPropertyChangeListenerin interfaceDockable- Parameters:
listener- the PropertyChangeListener to be added- See Also:
-
removePropertyChangeListener
Description copied from interface:DockableRemoves a PropertyChangeListener from the listener list. This method should be used to remove PropertyChangeListeners that were registered for all bound properties of this class.If listener is null, no exception is thrown and no action is performed.
- Specified by:
removePropertyChangeListenerin interfaceDockable- Parameters:
listener- the PropertyChangeListener to be removed- See Also:
-