Class DockableComponentWrapper

  • All Implemented Interfaces:
    java.util.EventListener, Dockable, DockingListener, DockingMonitor

    public class DockableComponentWrapper
    extends java.lang.Object
    implements Dockable
    This class models a 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
    • Method Detail

      • create

        public static DockableComponentWrapper create​(java.awt.Component src,
                                                      java.lang.String id,
                                                      java.lang.String desc)
        Creates a DockableComponentWrapper instance using the specified source component, persistent ID, and docking description. This method is used to create Dockable instances for simple Components where the drag source and drag initiator are the same Component.

        If src or id are null, then this method returns a null reference.

        src will be the Component returned by invoking getComponent() on the resulting Dockable and will be included in the List returned by getDragSources(). id will be the value returned by invoking getPersistentId() on the resulting Dockable. desc may be used by the Dockable for descriptive purposes (such as tab-text in a tabbed layout). It is not recommended to supply a null value for desc, but doing so is not illegal.

        Parameters:
        src - the source component
        id - the persistent ID for the Dockable instance
        desc - the docking description
        Returns:
        a new DockableComponentWrapper instance
        See Also:
        Dockable.getComponent(), Dockable.getDragSources(), Dockable.getPersistentId(), DockingManager.registerDockable(Component, String)
      • getFrameDragSources

        public java.util.Set getFrameDragSources()
        Returns a HashSet of Components used as frame drag sources when this Dockable is floating in a non-decorated external dialog. The HashSet returned by this method is initially empty. Because it is mutable, however, new Components may be added to it.
        Specified by:
        getFrameDragSources in interface Dockable
        Returns:
        a HashSet of Components used as frame drag sources when this Dockable is floating in a non-decorated external dialog.
        See Also:
        Dockable.getFrameDragSources()
      • getClientProperty

        public java.lang.Object getClientProperty​(java.lang.Object key)
        Returns the value of the property with the specified key. Only properties added with putClientProperty will return a non-null value. If key is null, a null reference is returned.

        If the Component returned by getComponent() is an instance of JComponent, then this method will dispatch to that JComponent's getClientProperty(Object, Object) method. Otherwise, this DockableComponentWrapper will provide its own internal mapping of client properties.

        Specified by:
        getClientProperty in interface Dockable
        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 this Dockable. null values are allowed. If key is null, then no action is taken.

        If the Component returned by getComponent() is an instance of JComponent, then this method will dispatch to that JComponent's putClientProperty(Object, Object) method. Otherwise, this DockableComponentWrapper will provide its own internal mapping of client properties.

        Specified by:
        putClientProperty in interface Dockable
        Parameters:
        key - the new client property key
        value - the new client property value; if null this method will remove the property
        See Also:
        Dockable.putClientProperty(Object, Object), JComponent.putClientProperty(java.lang.Object, java.lang.Object)
      • dock

        public boolean dock​(Dockable dockable)
        Provides the default Dockable implementation of dock(Dockable dockable) by calling and returning DockingManager.dock(Dockable dockable, Dockable parent). 'this' is passed as the parent parameter.
        Specified by:
        dock in interface Dockable
        Parameters:
        dockable - the Dockable to dock relative to this Dockable
        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 default Dockable implementation of dock(Dockable dockable, String relativeRegion) by calling and returning DockingManager.dock(Dockable dockable, Dockable parent, String region). 'this' is passed as the parent parameter.
        Specified by:
        dock in interface Dockable
        Parameters:
        dockable - the Dockable to dock relative to this Dockable
        relativeRegion - the docking region into which to dock the specified Dockable
        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 default Dockable implementation of dock(Dockable dockable, String relativeRegion, float ratio) by calling and returning DockingManager.dock(Dockable dockable, Dockable parent, String region, float proportion). 'this' is passed as the parent parameter.
        Specified by:
        dock in interface Dockable
        Parameters:
        dockable - the Dockable to dock relative to this Dockable
        relativeRegion - the docking region into which to dock the specified Dockable
        ratio - the proportion of available space in the resulting layout to allot to the new sibling Dockable.
        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 interface Dockable
        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 interface Dockable
        Parameters:
        listener - the PropertyChangeListener to be removed
        See Also:
        Dockable.addPropertyChangeListener(java.beans.PropertyChangeListener)