Class DockableComponentWrapper
- java.lang.Object
-
- org.flexdock.docking.defaults.DockableComponentWrapper
-
- All Implemented Interfaces:
java.util.EventListener
,Dockable
,DockingListener
,DockingMonitor
public class DockableComponentWrapper extends java.lang.Object implements Dockable
This class models aDockable
implementation for wrapping aComponent
. It is essentially the simplest means to turning a genericComponent
into aDockable
instance. CompoundDockables
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 aJInternalFrame
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 aComponent
and implements theDockable
interface. Since theComponent
itself is being docking-enabled, it serves as both the drag source and drag initiator. Thus,getComponent()
will return a reference to'this'
andgetDragSources()
return aList
containing the same self-referenceComponent
.This class may be used by application code to enable docking capabilities on a given
Component
. However, it is recommended thatDockingManager.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 aDockableComponentWrapper
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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDockingListener(DockingListener listener)
Adds aDockingListener
to observe docking events for thisDockable
.void
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list.static DockableComponentWrapper
create(java.awt.Component src, java.lang.String id, java.lang.String desc)
Creates aDockableComponentWrapper
instance using the specified source component, persistent ID, and docking description.static DockableComponentWrapper
create(DockingAdapter adapter)
static DockableComponentWrapper
create(DockingStub stub)
boolean
dock(Dockable dockable)
Provides the defaultDockable
implementation ofdock(Dockable dockable)
by calling and returningDockingManager.dock(Dockable dockable, Dockable parent)
.boolean
dock(Dockable dockable, java.lang.String relativeRegion)
Provides the defaultDockable
implementation ofdock(Dockable dockable, String relativeRegion)
by calling and returningDockingManager.dock(Dockable dockable, Dockable parent, String region)
.boolean
dock(Dockable dockable, java.lang.String relativeRegion, float ratio)
Provides the defaultDockable
implementation ofdock(Dockable dockable, String relativeRegion, float ratio)
by calling and returningDockingManager.dock(Dockable dockable, Dockable parent, String region, float proportion)
.void
dockingCanceled(DockingEvent evt)
No operation.void
dockingComplete(DockingEvent evt)
No operation.void
dragStarted(DockingEvent evt)
No operation.void
dropStarted(DockingEvent evt)
No operation.java.lang.Object
getClientProperty(java.lang.Object key)
Returns the value of the property with the specified key.java.awt.Component
getComponent()
Returns theComponent
used to create thisDockableComponentWrapper
instance.DockingListener[]
getDockingListeners()
Returns an array of allDockingListeners
added to thisDockable
.DockingPort
getDockingPort()
Returns theDockingPort
within which thisDockable
is currently docked.DockablePropertySet
getDockingProperties()
Returns aDockablePropertySet
instance associated with thisDockable
.java.util.List
getDragSources()
Returns aList
ofComponents
used to initiate drag-to-dock operation.java.util.Set
getFrameDragSources()
Returns aHashSet
ofComponents
used as frame drag sources when thisDockable
is floating in a non-decorated external dialog.java.lang.String
getPersistentId()
Returns the persistent ID of thisDockableComponentWrapper
instance provided when this object was instantiated.void
putClientProperty(java.lang.Object key, java.lang.Object value)
Adds an arbitrary key/value "client property" to thisDockable
.void
removeDockingListener(DockingListener listener)
Removes the specifiedDockingListener
from thisDockable
.void
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list.void
undockingComplete(DockingEvent evt)
No operation.void
undockingStarted(DockingEvent evt)
No operation.
-
-
-
Method Detail
-
create
public static DockableComponentWrapper create(java.awt.Component src, java.lang.String id, java.lang.String desc)
Creates aDockableComponentWrapper
instance using the specified source component, persistent ID, and docking description. This method is used to createDockable
instances for simpleComponents
where the drag source and drag initiator are the sameComponent
.If
src
orid
arenull
, then this method returns anull
reference.src
will be theComponent
returned by invokinggetComponent()
on the resultingDockable
and will be included in theList
returned bygetDragSources()
.id
will be the value returned by invokinggetPersistentId()
on the resultingDockable
.desc
may be used by theDockable
for descriptive purposes (such as tab-text in a tabbed layout). It is not recommended to supply anull
value 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
DockableComponentWrapper
instance - See Also:
Dockable.getComponent()
,Dockable.getDragSources()
,Dockable.getPersistentId()
,DockingManager.registerDockable(Component, String)
-
create
public static DockableComponentWrapper create(DockingStub stub)
-
create
public static DockableComponentWrapper create(DockingAdapter adapter)
-
getComponent
public java.awt.Component getComponent()
Returns theComponent
used to create thisDockableComponentWrapper
instance.- Specified by:
getComponent
in interfaceDockable
- Returns:
- the
Component
used to create thisDockableComponentWrapper
instance. - See Also:
Dockable.getComponent()
,create(Component, String, String)
-
getDragSources
public java.util.List getDragSources()
Returns aList
ofComponents
used to initiate drag-to-dock operation. By default, the returnedList
contains theComponent
returned bygetComponent()
.- Specified by:
getDragSources
in interfaceDockable
- Returns:
- a
List
ofComponents
used to initiate drag-to-dock operation. - See Also:
Dockable.getDragSources()
,getComponent()
,create(Component, String, String)
-
getPersistentId
public java.lang.String getPersistentId()
Returns the persistent ID of thisDockableComponentWrapper
instance provided when this object was instantiated.- Specified by:
getPersistentId
in interfaceDockable
- Returns:
- the persistent ID of this
DockableComponentWrapper
- See Also:
Dockable.getPersistentId()
,create(Component, String, String)
-
getFrameDragSources
public java.util.Set getFrameDragSources()
Returns aHashSet
ofComponents
used as frame drag sources when thisDockable
is floating in a non-decorated external dialog. TheHashSet
returned by this method is initially empty. Because it is mutable, however, newComponents
may be added to it.- Specified by:
getFrameDragSources
in interfaceDockable
- Returns:
- a
HashSet
ofComponents
used as frame drag sources when thisDockable
is floating in a non-decorated external dialog. - See Also:
Dockable.getFrameDragSources()
-
addDockingListener
public void addDockingListener(DockingListener listener)
Adds aDockingListener
to observe docking events for thisDockable
.null
arguments are ignored.- Specified by:
addDockingListener
in interfaceDockingMonitor
- Parameters:
listener
- theDockingListener
to add to thisDockable
.- See Also:
getDockingListeners()
,removeDockingListener(DockingListener)
-
getDockingListeners
public DockingListener[] getDockingListeners()
Returns an array of allDockingListeners
added to thisDockable
. If there are no listeners present for thisDockable
, then a zero-length array is returned.- Specified by:
getDockingListeners
in interfaceDockingMonitor
- Returns:
- an array of all
DockingListeners
added to thisDockable
. - See Also:
addDockingListener(DockingListener)
,removeDockingListener(DockingListener)
-
removeDockingListener
public void removeDockingListener(DockingListener listener)
Removes the specifiedDockingListener
from thisDockable
. If the specifiedDockingListener
isnull
, or the listener has not previously been added to thisDockable
, then noException
is thrown and no action is taken.- Specified by:
removeDockingListener
in interfaceDockingMonitor
- Parameters:
listener
- theDockingListener
to remove from thisDockable
- See Also:
addDockingListener(DockingListener)
,getDockingListeners()
-
dockingCanceled
public void dockingCanceled(DockingEvent evt)
No operation. Provided as a method stub to fulfull theDockingListener
interface contract.- Specified by:
dockingCanceled
in interfaceDockingListener
- Parameters:
evt
- theDockingEvent
to respond to.- See Also:
DockingListener.dockingCanceled(DockingEvent)
-
dockingComplete
public void dockingComplete(DockingEvent evt)
No operation. Provided as a method stub to fulfull theDockingListener
interface contract.- Specified by:
dockingComplete
in interfaceDockingListener
- Parameters:
evt
- theDockingEvent
to respond to.- See Also:
DockingListener.dockingComplete(DockingEvent)
-
undockingComplete
public void undockingComplete(DockingEvent evt)
No operation. Provided as a method stub to fulfull theDockingListener
interface contract.- Specified by:
undockingComplete
in interfaceDockingListener
- Parameters:
evt
- theDockingEvent
to respond to.- See Also:
DockingListener.undockingComplete(DockingEvent)
-
undockingStarted
public void undockingStarted(DockingEvent evt)
No operation. Provided as a method stub to fulfull theDockingListener
interface contract.- Specified by:
undockingStarted
in interfaceDockingListener
- Parameters:
evt
- theDockingEvent
to respond to.- See Also:
DockingListener.undockingStarted(DockingEvent)
-
dragStarted
public void dragStarted(DockingEvent evt)
No operation. Provided as a method stub to fulfull theDockingListener
interface contract.- Specified by:
dragStarted
in interfaceDockingListener
- Parameters:
evt
- theDockingEvent
to respond to.- See Also:
DockingListener.dragStarted(DockingEvent)
-
dropStarted
public void dropStarted(DockingEvent evt)
No operation. Provided as a method stub to fulfull theDockingListener
interface contract.- Specified by:
dropStarted
in interfaceDockingListener
- Parameters:
evt
- theDockingEvent
to respond to.- See Also:
DockingListener.dropStarted(DockingEvent)
-
getClientProperty
public java.lang.Object getClientProperty(java.lang.Object key)
Returns the value of the property with the specified key. Only properties added withputClientProperty
will return a non-null
value. Ifkey
isnull
, anull
reference is returned.If the
Component
returned bygetComponent()
is an instance ofJComponent
, then this method will dispatch to thatJComponent's
getClientProperty(Object, Object)
method. Otherwise, thisDockableComponentWrapper
will provide its own internal mapping of client properties.- Specified by:
getClientProperty
in interfaceDockable
- Parameters:
key
- the key that is being queried- Returns:
- the value of this property or
null
- See Also:
Dockable.getClientProperty(Object)
,JComponent.getClientProperty(java.lang.Object)
-
putClientProperty
public void putClientProperty(java.lang.Object key, java.lang.Object value)
Adds an arbitrary key/value "client property" to thisDockable
.null
values are allowed. Ifkey
isnull
, then no action is taken.If the
Component
returned bygetComponent()
is an instance ofJComponent
, then this method will dispatch to thatJComponent's
putClientProperty(Object, Object)
method. Otherwise, thisDockableComponentWrapper
will provide its own internal mapping of client properties.- Specified by:
putClientProperty
in interfaceDockable
- Parameters:
key
- the new client property keyvalue
- the new client property value; ifnull
this method will remove the property- See Also:
Dockable.putClientProperty(Object, Object)
,JComponent.putClientProperty(java.lang.Object, java.lang.Object)
-
getDockingProperties
public DockablePropertySet getDockingProperties()
Returns aDockablePropertySet
instance associated with thisDockable
. This method returns the default implementation supplied by the framework by invokinggetDockablePropertySet(Dockable dockable)
onorg.flexdock.docking.props.PropertyManager
and supplying an argument ofthis
.- Specified by:
getDockingProperties
in interfaceDockable
- Returns:
- the
DockablePropertySet
associated with thisDockable
. This method will not return anull
reference. - See Also:
Dockable.getDockingProperties()
,PropertyManager.getDockablePropertySet(Dockable)
-
getDockingPort
public DockingPort getDockingPort()
Returns theDockingPort
within which thisDockable
is currently docked. If not currently docked, this method will returnnull
.This method defers processing to
getDockingPort(Dockable dockable)
, passing an argument ofthis
.- Specified by:
getDockingPort
in interfaceDockable
- Returns:
- the
DockingPort
within which thisDockable
is currently docked. - See Also:
Dockable.getDockingPort()
,DockingManager.getDockingPort(Dockable)
-
dock
public boolean dock(Dockable dockable)
Provides the defaultDockable
implementation ofdock(Dockable dockable)
by calling and returningDockingManager.dock(Dockable dockable, Dockable parent)
.'this'
is passed as theparent
parameter.- Specified by:
dock
in interfaceDockable
- Parameters:
dockable
- theDockable
to dock relative to thisDockable
- Returns:
true
if the docking operation was successful;false
otherwise.- See Also:
Dockable.dock(Dockable)
,DockingManager.dock(Dockable, Dockable)
-
dock
public boolean dock(Dockable dockable, java.lang.String relativeRegion)
Provides the defaultDockable
implementation ofdock(Dockable dockable, String relativeRegion)
by calling and returningDockingManager.dock(Dockable dockable, Dockable parent, String region)
.'this'
is passed as theparent
parameter.- Specified by:
dock
in interfaceDockable
- Parameters:
dockable
- theDockable
to dock relative to thisDockable
relativeRegion
- the docking region into which to dock the specifiedDockable
- Returns:
true
if the docking operation was successful;false
otherwise.- See Also:
Dockable.dock(Dockable, String)
,DockingManager.dock(Dockable, Dockable, String)
-
dock
public boolean dock(Dockable dockable, java.lang.String relativeRegion, float ratio)
Provides the defaultDockable
implementation ofdock(Dockable dockable, String relativeRegion, float ratio)
by calling and returningDockingManager.dock(Dockable dockable, Dockable parent, String region, float proportion)
.'this'
is passed as theparent
parameter.- Specified by:
dock
in interfaceDockable
- Parameters:
dockable
- theDockable
to dock relative to thisDockable
relativeRegion
- the docking region into which to dock the specifiedDockable
ratio
- the proportion of available space in the resulting layout to allot to the new siblingDockable
.- Returns:
true
if the docking operation was successful;false
otherwise.- See Also:
DockingManager.dock(Dockable, Dockable, String, float)
-
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Description copied from interface:Dockable
Adds 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:
addPropertyChangeListener
in interfaceDockable
- Parameters:
listener
- the PropertyChangeListener to be added- See Also:
Dockable.removePropertyChangeListener(PropertyChangeListener)
-
removePropertyChangeListener
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Description copied from interface:Dockable
Removes 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:
removePropertyChangeListener
in interfaceDockable
- Parameters:
listener
- the PropertyChangeListener to be removed- See Also:
Dockable.addPropertyChangeListener(java.beans.PropertyChangeListener)
-
-