Class DefaultDockingPort
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,EventListener,Accessible,DockingConstants,DockingPort,DockingListener,DockingMonitor
- Direct Known Subclasses:
FloatingDockingPort,Viewport
Container that implements the DockingPort
interface. It provides a default implementation of DockingPort to
allow ease of development within docking-enabled applications.
The DefaultDockingPort handles docking in one of three ways. If the
port is empty, then all incoming Dockables are docked to the CENTER
region. If the port is not empty, then all incoming Dockables docked
to the CENTER region are embedded within a JTabbedPane. All incoming
Dockables docked to an outer region (NORTH, SOUTH, EAST, and WEST) of
a non-empty port are placed into a split layout using a JSplitPane.
For centrally docked Components, the immediate child of the
DefaultDockingPort may or may not be a JTabbedPane. If
isSingleTabAllowed() returns true for the current
DefaultDockingPort, then the immediate child returned by
getDockedComponent() will return a JTabbedPane instance even
if there is only one Dockable embedded within the port. If there is a
single Dockable in the port, but isSingleTabAllowed() returns
false, then getDockedComponent() will return the
Component that backs the currently docked Dockable, returned
by the Dockable's getComponent() method.
isSingleTabAllowed() is a scoped property that may apply to this
port, all ports across the JVM, or all ports within a user defined scope.
getDockedComponent() will return a JTabbedPane at all times
if there is more than one centrally docked Dockable within the port,
and all docked Components will reside within the tabbed pane.
Components that are docked in the NORTH, SOUTH, EAST, or WEST regions are
placed in a JSplitPane splitting the layout of the
DockingPort between child components. Each region of the
JSplitPane contains a new DefaultDockingPort, which, in
turn, contains the docked components. In this situation,
getDockedComponent() will return a JSplitPane reference.
A key concept that drives the DefaultDockingPort, then, is the
notion that this DockingPort implementation may only ever have one
single child component, which may or may not be a wrapper for other child
components. Because JSplitPane contains child
DefaultDockingPorts, each of those DefaultDockingPorts is
available for further sub-docking operations.
Since a DefaultDockingPort may only contain one child component,
there is a container hierarchy to manage tabbed interfaces, split layouts,
and sub-docking. As components are removed from this hierarchy, the hierarchy
itself must be reevaluated. Removing a component from a child
DefaultDockingPort within a JSplitPane renders the child
DefaultDockingPort unnecessary, which, in turn, renders the notion of
splitting the layout with a JSplitPane unnecessary (since there are
no longer two components to split the layout between). Likewise, removing a
child component from a JTabbedPane such that there is only one child
left within the JTabbedPane removes the need for a tabbed interface
to begin with.
When the DockingManager removes a component from a
DockingPort via DockingManager.undock(Dockable dockable) it
uses a call to undock() on the current DockingPort.
undock() automatically handles the reevaluation of the container
hierarchy to keep wrapper-container usage at a minimum. Since
DockingManager makes this callback automatic, developers normally
will not need to call this method explicitly. However, when removing a
component from a DefaultDockingPort using application code,
developers should keep in mind to use undock() instead of
remove().
Border management after docking and undocking operations are accomplished
using a BorderManager. setBorderManager() may be used to set
the border manager instance and customize border management.
- Author:
- Christopher Butler
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategyNested classes/interfaces inherited from interface org.flexdock.docking.event.DockingListener
DockingListener.Stub -
Field Summary
FieldsFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface org.flexdock.docking.DockingConstants
ACTIVE_WINDOW, BOTTOM, CENTER, CENTER_REGION, CLOSE_ACTION, DEFAULT_PERSISTENCE_KEY, DOCKING_ID, EAST_REGION, HEAVYWEIGHT_DOCKABLES, HORIZONTAL, LEFT, MOUSE_PRESSED, NORTH_REGION, PERMANENT_FOCUS_OWNER, PIN_ACTION, REGION, RIGHT, SOUTH_REGION, TOP, UNINITIALIZED, UNINITIALIZED_RATIO, UNKNOWN_REGION, UNSPECIFIED_SIBLING_PREF, VERTICAL, WEST_REGIONFields inherited from interface org.flexdock.docking.DockingPort
INITIAL_TAB_POSITIONFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newDefaultDockingPortwith a persistent ID equal to theStringvalue of this a random UUID.Creates a newDefaultDockingPortwith the specified persistent ID. -
Method Summary
Modifier and TypeMethodDescriptionOverridden to set the currently docked component.Overridden to set the currently docked component.voidOverridden to set the currently docked component.voidOverridden to set the currently docked component.Overridden to set the currently docked component.voidaddDockingListener(DockingListener listener) Adds aDockingListenerto observe docking events for thisDockingPort.voidclear()Removes allDockablesfrom thisDockingPort.protected BorderManagerCreates a standard border manager for this docking port.protected LayoutManagerprotected JTabbedPaneIf this method returnsnull, implementations may throw NullPointerExceptions.booleanDocks the specified component within the specified region.booleanDocks the specifiedDockablewithin the specified region.voidNo operation.voidRequests activation for the newly docked Dockable.voiddragStarted(DockingEvent evt) No operation.voiddropStarted(DockingEvent evt) No operation.Returns aLayoutNodecontaining metadata that describes the current layout contained within thisDefaultDockingPort.Returns the currently intalledBorderManager.protected DockablegetComponent(String region) Returns theComponentcurrently docked within the specifiedregion.getDockable(String region) Returns theDockablecurrently docked within the specifiedregion.getDockableAt(Point location) Returns the direct childDockablelocated at the specifiedPoint.Returns allDockablesdocked within thisDockingPortand all sub-DockingPorts.protected SetgetDockableSet(int depth, int level, Class desiredClass) Returns the childComponentcurrently embedded within withDockingPort.Returns an array of allDockingListenersadded to thisDockingPort.Returns aDockingPortPropertySetinstance associated with thisDockingPort.Returns theDockingStrategyused by thisDockingPort.protected intReturns aStringidentifier that is unique toDockingPortswithin a JVM instance, but persistent across JVM instances.Returns the docking region within thisDockingPortthat contains the specifiedPoint.Returns theRegionCheckercurrently used by thisDockingPort.voidimportLayout(LayoutNode node) Clears out the existing layout within thisDockingPortand reconstructs a new layout based upon the specifiedLayoutNode.voidinstallMaximizedDockable(Dockable dockable) Asks thisDockingPortto temporarily install the specifiedDockableand maximize its component.booleanisDockingAllowed(Component comp, String region) Returnstrueif docking is allowed for the specifiedComponentwithin the suppliedregion,falseotherwise.booleanisParentDockingPort(Component comp) Indicates whether or not the specified component is docked somewhere within thisDefaultDockingPort.booleanisRoot()Returns a boolean indicating whether or not thisDockingPortis nested within anotherDockingPort.booleanReturnstrueif single tabs are allowed within thisDockingPort,falseotherwise.booleanReturnstrueif drag-to-dock support is enabled for tabs and their associatedDockables,falseotherwise.protected booleanisValidDockableChild(Component c, Class desiredClass) protected booleanisValidDockingRegion(String region) voidOverridden to provide enhancements during drag operations.voidreleaseForMaximization(Dockable dockable) Asks thisDockingPortto temporarily release its childDockablefor use by anotherDockingPortto achieve maximization.voidremove(int index) Overridden to decorate superclass method, keeping track of internal docked-component reference.voidOverridden to decorate superclass method, keeping track of internal docked-component reference.voidremoveDockingListener(DockingListener listener) Removes the specifiedDockingListenerfrom thisDockingPort.voidNotifies thisDockingPortthat theDockablepreviously released for maximization via a call toDockingPort.releaseForMaximization(Dockable)is now ready to be returned to its original state inside thisDockingPort.voidSets the currently installedBorderManager.voidsetDragInProgress(boolean inProgress) This method is used internally by the framework to notifyDefaultDockingPortswhether a drag operation is or is not currently in progress and should not be called by application-level developers.voidSets the persisent ID to be used for thisDockingPort.voidsetRoot(boolean root) This method is used internally by the framework to notifyDefaultDockingPortswhether they are "root"DockingPortsaccording to the rules specified byisRoot()on theDockingPortinterface.voidsetSingleTabAllowed(boolean allowed) Sets the "single tab" property for thisDockingPort, allowing or disallowing a singleDockablewithin theDockingPortto appear within a tabbed layout.voidsetTabsAsDragSource(boolean enabled) Enables or disables drag support for docking operations on the tabs used within an embedded tabbed layout.booleanUndocks the specifiedComponentand returns a boolean indicating the success of the operation.voidNo operation.voidNo operation.voidNotifies thisDockingPortthat theDockablepreviously installed for maximization via a call toDockingPort.installMaximizedDockable(Dockable)should now be returned to its originalDockingPortand that thisDockingPortshould return to its original state from before the call toDockingPort.installMaximizedDockable(Dockable).protected voidMethods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods inherited from class java.awt.Container
addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.flexdock.docking.DockingPort
getClientProperty, putClientProperty
-
Field Details
-
dockingListeners
-
-
Constructor Details
-
DefaultDockingPort
public DefaultDockingPort()Creates a newDefaultDockingPortwith a persistent ID equal to theStringvalue of this a random UUID.- See Also:
-
DefaultDockingPort
Creates a newDefaultDockingPortwith the specified persistent ID. Ifidisnull, then theStringvalue of thisObject'shash code is used. The persistent ID will be the same value returned by invokinggetPersistentId()for thisDefaultDockingPort.- Parameters:
id- the persistent ID for the newDefaultDockingPortinstance.
-
-
Method Details
-
createLayout
-
createBorderManager
Creates a standard border manager for this docking port.This method is called from the constructor.
- Returns:
- the border manager for this docking port.
-
add
Overridden to set the currently docked component. Should not be called by application code. -
add
Overridden to set the currently docked component. Should not be called by application code. -
add
Overridden to set the currently docked component. Should not be called by application code. -
add
Overridden to set the currently docked component. Should not be called by application code. -
add
Overridden to set the currently docked component. Should not be called by application code. -
isDockingAllowed
Returnstrueif docking is allowed for the specifiedComponentwithin the suppliedregion,falseotherwise. It is important to note that success of a docking operation relies on many factors and a return value oftruefrom this method does not necessarily guarantee that a call todock()will succeed. This method merely indicates that the currentDockingPortdoes not have any outstanding reason to block a docking operation with respect to the specifiedComponentandregion.If
compisnullorregionis invalid according toDockingManager.isValidDockingRegion(String region), then this method returnsfalse.If this
DockingPortis not already the parentDockingPortfor the specifiedComponent, then this method returnstrue.If this
DockingPortis already the parentDockingPortfor the specifiedComponent, then a check is performed to see if there is a tabbed layout. Tabbed layouts may contain multipleDockables, and thus the tab ordering may be rearranged, or shifted into a split layout. Ifcompis the only dockedComponentwithin thisDockingPort, then this method returnsfalsesince the layout cannot be rearranged. Otherwise, this method returnstrue.- Specified by:
isDockingAllowedin interfaceDockingPort- Parameters:
comp- theComponentwhose docking availability is to be checkedregion- the region to be checked for docking availability for the specifiedComponent.- Returns:
trueif docking is allowed for the specifiedComponentwithin the suppliedregion,falseotherwise.- See Also:
-
getRegion
Returns the docking region within thisDockingPortthat contains the specifiedPoint. Valid return values are those regions defined inDockingConstantsand includeNORTH_REGION,SOUTH_REGION,EAST_REGION,WEST_REGION,CENTER_REGION, andUNKNOWN_REGION.If
locationisnull, thenUNKNOWN_REGIONis returned.This method gets the
RegionCheckerfor thisDockingPortby callinggetRegionChecker(). It then attempts to locate theDockableat the specifiedlocationby callinggetDockableAt(Point location).This method defers processing to
getRegion(Component c, Point p)for the currentRegionChecker. If aDockablewas found at the specifiedPoint, then the location of thePointis translated to the coordinate system of theComponentfor the embeddedDockableand thatComponentand modifiedPointare passed intogetRegion(Component c, Point p)} for the currentRegionChecker. If noDockablewas found, then the specifiedPointis left unmodified and thisDockingPortand the suppliedPointare passed togetRegion(Component c, Point p)} for the currentRegionChecker.- Specified by:
getRegionin interfaceDockingPort- Parameters:
location- the location within thisDockingPortto examine for a docking region.- Returns:
- the docking region within this
DockingPortthat contains the specifiedPoint - See Also:
-
getRegionChecker
Returns theRegionCheckercurrently used by thisDockingPort. This method retrieves theDockingPortPropertySetinstance for thisDockingPortby callinggetDockingProperties(). It then returns by invokinggetRegionChecker()on the resolvedDockingPortPropertySet.- Returns:
- the
RegionCheckercurrently used by thisDockingPort. - See Also:
-
getDockableAt
Returns the direct childDockablelocated at the specifiedPoint. Iflocationisnull, or thisDockingPortis empty, then anullreference is returned.If this
DockingPortcontains a split layout, then any nestedDockableswill be within a sub-DockingPortand not a direct child of thisDockingPort. Therefore, ifgetDockedComponent()returns aJSplitPane, then this method will return anullreference.If this
DockingPortcontains a tabbed layout, then theJTabbedPanereturned bygetDockedComponent()will be checked for aDockableat the specifiedPoint.- Parameters:
location- the location within theDockingPortto test for aDockable.- Returns:
- the direct child
Dockablelocated at the specifiedPoint. - See Also:
-
getComponent
Returns theComponentcurrently docked within the specifiedregion.If this
DockingPorthas either a single childDockableor a tabbed layout, then the supplied region must beCENTER_REGIONor this method will return anullreference. If there is a single childDockable, then this method will return the sameComponentas returned bygetDockedComponent(). If there is a tabbed layout, then this method will return theComponentin the currently selected tab.If this
DockingPorthas a split layout, then a check forCENTER_REGIONwill return anullreference. For outer regions (NORTH_REGION,SOUTH_REGION,EAST_REGION, orWEST_REGION), the supplied region parameter must match the orientation of the embeddedJSplitPane. Thus for a vertically oriented split pane, checks forEAST_REGIONandWEST_REGIONwill return anullreference. Likewise, for a horizontally oriented split pane, checks forNORTH_REGIONandSOUTH_REGIONwill return anullreference.Outer regions are mapped to corresponding split pane regions.
NORTH_REGIONmaps to the split pane's top component,SOUTH_REGIONmaps to the bottom,EAST_REGIONmaps to the right, andWEST_REGIONmaps to the left. The sub-DockingPortfor the split pane region that corresponds to the specifiedregionparameter will be resolved and this method will return thatComponentretrieved by calling itsgetDockedComponent()method. Note that thegetDockedComponent()call to a sub-DockingPortimplies that theJTabbedPaneorJSplitPanefor the sub-port may be returned if the sub-port contains multipleDockables.If this
DockingPortis empty, then this method returns anullreference.- Specified by:
getComponentin interfaceDockingPort- Parameters:
region- the region to be checked for a dockedComponent- Returns:
- the
Componentdocked within the specified region. - See Also:
-
getDockable
Returns theDockablecurrently docked within the specifiedregion. This method dispatches togetComponent(String region)to retrieve theComponentdocked within the specified region and returns its associatedDockableviaDockingManager.getDockable(Component comp).There are somewhat strict semantics associated with retrieving the
Componentin a particular docking region. API documentation forgetComponent(String region)should be referenced for a listing of the rule set. Ifregionis invalid according toDockingManager.isValidDockingRegion(String region), then this method returns anullreference.- Specified by:
getDockablein interfaceDockingPort- Parameters:
region- the region to be checked for a dockedDockable- Returns:
- the
Dockabledocked within the specified region. - See Also:
-
createTabbedPane
If this method returnsnull, implementations may throw NullPointerExceptions. Do not expect NPE checking.- Returns:
- a valid JTabbedPane.
-
updateTab
-
getDockingStrategy
Returns theDockingStrategyused by thisDockingPort. This method dispatches togetDockingStrategy(Object obj), passingthisas an argument. By default,DefaultDockingStrategyis used unless a differentDockingStrategyhas been assigned by the end user forDefaultDockingPort.- Specified by:
getDockingStrategyin interfaceDockingPort- Returns:
- the
DockingStrategyused by thisDockingPort. - See Also:
-
clear
public void clear()Removes allDockablesfrom thisDockingPort. Internally, this method dispatches toremoveAll(). This ensures that not only dockedComponentsare removed, that that all wrapper containers such asJTabbedPanes,JSplitPanes, and sub-DockingPortsare removed as well.- Specified by:
clearin interfaceDockingPort- See Also:
-
dock
Docks the specified component within the specified region. This method attempts to resolve theDockableassociated with the specifiedComponentby invokingDockingManager.getDockable(Component comp). Processing is then dispatched todock(Dockable dockable, String region).If no
Dockableis resolved for the specifiedComponent, then this method attempts to register theComponentas aDockableautomatically by callingDockingManager.registerDockable(Component comp).If either
comporregionregion arenull, then this method returnsfalse. Otherwise, this method returns a boolean indicating the success of the docking operation based upondock(Dockable dockable, String region).- Specified by:
dockin interfaceDockingPort- Parameters:
comp- theComponentto be docked within thisDockingPortregion- the region within thisDockingPortto dock the specifiedComponent- Returns:
trueif the docking operation was successful,falseotherwise.- See Also:
-
dock
Docks the specifiedDockablewithin the specified region. TheComponentused for docking is returned by callinggetComponent()on the specifiedDockable. This method returnsfalseimmediately if the specifiedDockableisnullor ifisDockingAllowed(Component comp, String region)returnsfalse.If this
DockingPortis currently empty, then theDockableis docked into theCENTER_REGION, regardless of the suppliedregionparameter's value.If
isSingleTabAllowed()returnsfalseand theDockingPortis emtpy, then theDockablewill be added directly to theDockingPortand will take up all available space within theDockingPort. In this case, subsequent calls togetDockedComponent()will return the dockableComponent.If
isSingleTabAllowed()returnstrueand theDockingPortis emtpy, then aJTabbedPanewill be added directly to theDockingPortand will take up all available space within theDockingPort. The dockableComponentwill be added as a tab within the tabbed pane. In this case, subsequent calls togetDockedComponent()will return theJTabbedPane.If the
DockingPortis not empty, and the specified region isCENTER_REGION, then the dockableComponentwill be added to theJTabbedPanereturned bygetDockedComponent(). If thisDockingPortonly contained a single dockableComponentwithout a tabbed pane, then the currently dockedComponentis removed, aJTabbedPaneis created and added, and both the oldComponentand the new one are added to theJTabbedPane. In this case, subsequent calls togetDockedComponent()will return theJTabbedPane.If the
DockingPortis not empty, and the specified region isNORTH_REGION,SOUTH_REGION,EAST_REGION, orWEST_REGION, then the currently dockedComponentis removed and replaced with aJSplitPane. Two newDefaultDockingPortsare created as sub-ports and are added to each side of theJSplitPane. The previously dockedComponentis docked to the CENTER_REGION of one of the sub-ports and the newComponentis added to the other. In this case, subsequent calls togetDockedComponent()will return theJSplitPane. In this fasion, the sub-ports will now be capable of handling further sub-docking within the layout.JSplitPaneand sub-DockingPortcreation are delegated to theDockingStrategyreturned bygetDockingStrategy(). Initial splitpane divider location is also controlled by thisDockingStrategy.- Specified by:
dockin interfaceDockingPort- Parameters:
dockable- theDockableto be docked within thisDockingPortregion- the region within thisDockingPortto dock the specifiedDockable- Returns:
trueif the docking operation was successful,falseotherwise.- See Also:
-
getDockedComponent
Returns the childComponentcurrently embedded within withDockingPort. If theDockingPortis empty, then this method returns anullreference. If there is a singleDockabledocked within it with no tabbed layout, then theComponentfor thatDockableis returned per itsgetComponent()method. If there is a tabbed layout present, then aJTabbedPaneis returned. If there is a split layout present, then aJSplitPaneis returned.- Specified by:
getDockedComponentin interfaceDockingPort- See Also:
-
getPersistentId
Returns aStringidentifier that is unique toDockingPortswithin a JVM instance, but persistent across JVM instances. This is used for configuration mangement, allowing the JVM to recognize aDockingPortinstance within an application instance, persist the ID, and recall it in later application instances. The ID should be unique within an appliation instance so that there are no collisions with otherDockingPortinstances, but it should also be consistent from JVM to JVM so that the association between aDockingPortinstance and its ID can be remembered from session to session.The value returned by this method will come from the most recent call to
setPersistentId(String id). IfsetPersistentId(String id)was invoked with anullargument, then theStringverion of thisDockingPort'shash code is used. Therefore, this method will never return anullreference.- Specified by:
getPersistentIdin interfaceDockingPort- Returns:
- the persistent ID for this
DockingPort - See Also:
-
setPersistentId
Sets the persisent ID to be used for thisDockingPort. Ifidisnull, then theStringvalue of thisDockingPort'shash code is used.DockingPortsare tracked by persistent ID withinDockingManager. Whenever this method is called, theDockingManager'stracking mechanism is automatically upated for thisDockingPort.- Specified by:
setPersistentIdin interfaceDockingPort- Parameters:
id- the persistent ID to be used for thisDockingPort- See Also:
-
isSingleTabAllowed
public boolean isSingleTabAllowed()Returnstrueif single tabs are allowed within thisDockingPort,falseotherwise.Generally the tabbed interface does not appear until two or more
Dockablesare docked to theCENTER_REGIONof theDockingPortand tabs are required to switch between them. When there is only a singleDockablewithin theDockingPort, the default behavior for the dockableComponentto take up all of the space within theDockingPort.If this method returns
true, then a singleDockablewithin thisDockingPortwill reside within a tabbed layout that contains only one tab.The value returned by this method is a scoped property. This means there may be many different "scopes" at which the single-tab property may be set. For instance, a "global" setting may override the individual setting for this
DockingPort, and thisDockingPort'sparticular setting may override the global default setting.org.flexdock.docking.props.PropertyManagershould be referenced for further information on scoped properties.- Returns:
trueif single tabs are allowed within thisDockingPort,falseotherwise.- See Also:
-
setSingleTabAllowed
public void setSingleTabAllowed(boolean allowed) Sets the "single tab" property for thisDockingPort, allowing or disallowing a singleDockablewithin theDockingPortto appear within a tabbed layout.Generally the tabbed interface does not appear until two or more
Dockablesare docked to theCENTER_REGIONof theDockingPortand tabs are required to switch between them. When there is only a singleDockablewithin theDockingPort, the default behavior for the dockableComponentto take up all of the space within theDockingPort.If the single tab property is set to
true, then a singleDockablewithin thisDockingPortwill reside within a tabbed layout that contains only one tab.The single tab property is a scoped property. This means there may be many different "scopes" at which the single-tab property may be set. For instance, a "global" setting may override the individual setting for this
DockingPort, and thisDockingPort'sparticular setting may override the global default setting. This method applied a value only to the local scope for this particularDockingPort.org.flexdock.docking.props.PropertyManagershould be referenced for further information on scoped properties.- Parameters:
allowed-trueif a single-tabbed layout should be allowed,falseotherwise- See Also:
-
isParentDockingPort
Indicates whether or not the specified component is docked somewhere within thisDefaultDockingPort. This method returnstrueif the specifiedComponentis a direct child of theDefaultDockingPortor is a direct child of aJTabbedPaneorJSplitPanethat is currently theDefaultDockingPort'sdocked component. Otherwise, this method returnsfalse. Ifcompisnull, then then this method returnfalse- Specified by:
isParentDockingPortin interfaceDockingPort- Parameters:
comp- the Component to be tested.- Returns:
- a boolean indicating whether or not the specified component is
docked somewhere within this
DefaultDockingPort. - See Also:
-
isValidDockingRegion
-
getCenterDockable
-
remove
public void remove(int index) Overridden to decorate superclass method, keeping track of internal docked-component reference. -
removeAll
public void removeAll()Overridden to decorate superclass method, keeping track of internal docked-component reference. -
setBorderManager
Sets the currently installedBorderManager. This method provides a means of customizing border managment following any successful call todock(Dockable dockable, String region)orundock(Component comp), allowing cleanup of borders for nestedComponentswithin the docking layout.nullvalues are allowed.- Parameters:
mgr- theBorderManagerassigned to to manage docked component borders.- See Also:
-
getBorderManager
Returns the currently intalledBorderManager. TheBorderManageris used any time a successful call todock(Dockable dockable, String region)orundock(Component comp)has been issued to clean up borders for nestedComponentswithin the docking layout. This method will return anullreference if there is noBorderManagerinstalled.- Returns:
- the currently installed
BorderManager. - See Also:
-
undock
Undocks the specifiedComponentand returns a boolean indicating the success of the operation.Since
DefaultDockingPortmay only contain one child component, there i s a container hierarchy to manage tabbed interfaces, split layouts, and sub-docking. As components are removed from this hierarchy, the hierarchy itself must be reevaluated. Removing a component from a child code>DefaultDockingPort} within aJSplitPanerenders the childDefaultDockingPortunnecessary, which, in turn, renders the notion of splitting the layout with aJSplitPaneunnecessary (since there are no longer two components to split the layout between). Likewise, removing a child component from aJTabbedPanesuch that there is only one child left within theJTabbedPaneremoves the need for a tabbed interface to begin with.This method automatically handles the reevaluation of the container hierarchy to keep wrapper-container usage at a minimum. Since
DockingManagermakes this callback automatic, developers normally will not need to call this method explicitly. However, when removing a component from aDefaultDockingPortusing application code, developers should keep in mind to use this method instead ofremove().- Specified by:
undockin interfaceDockingPort- Parameters:
comp- theComponentto be undocked.- Returns:
- a boolean indicating the success of the operation
- See Also:
-
getDockables
Returns allDockablesdocked within thisDockingPortand all sub-DockingPorts. The returnedSetwill containDockableinstances. If there are noDockablespresent, an emptySetwill be returned. This method will never return anullreference.- Specified by:
getDockablesin interfaceDockingPort- Returns:
- all
Dockablesdocked within thisDockingPortand all sub-DockingPorts. - See Also:
-
getDockableSet
-
isValidDockableChild
-
addDockingListener
Adds aDockingListenerto observe docking events for thisDockingPort.nullarguments are ignored.- Specified by:
addDockingListenerin interfaceDockingMonitor- Parameters:
listener- theDockingListenerto add to thisDockingPort.- See Also:
-
getDockingListeners
Returns an array of allDockingListenersadded to thisDockingPort. If there are no listeners present for thisDockingPort, then a zero-length array is returned.- Specified by:
getDockingListenersin interfaceDockingMonitor- Returns:
- an array of all
DockingListenersadded to thisDockingPort. - See Also:
-
removeDockingListener
Removes the specifiedDockingListenerfrom thisDockingPort. If the specifiedDockingListenerisnull, or the listener has not previously been added to thisDockingPort, then noExceptionis thrown and no action is taken.- Specified by:
removeDockingListenerin interfaceDockingMonitor- Parameters:
listener- theDockingListenerto remove from thisDockingPort- 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
Requests activation for the newly docked Dockable.- Specified by:
dockingCompletein 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:
-
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:
-
getDockingProperties
Returns aDockingPortPropertySetinstance associated with thisDockingPort. This method returns the default implementation supplied by the framework by invokinggetDockingPortPropertySet(DockingPort port)onorg.flexdock.docking.props.PropertyManagerand supplying an argument ofthis.- Specified by:
getDockingPropertiesin interfaceDockingPort- Returns:
- the
DockingPortPropertySetassociated with thisDockingPort. This method will not return anullreference. - See Also:
-
setTabsAsDragSource
public void setTabsAsDragSource(boolean enabled) Enables or disables drag support for docking operations on the tabs used within an embedded tabbed layout. If tab-drag-source is enabled, then the tab that corresponds to aDockablewithin an embedded tabbed layout will respond to drag events as if the tab were a component included within theListreturned by callinggetDragSources()on theDockable. This allows dragging a tab to initiate drag-to-dock operations.- Parameters:
enabled-trueif drag-to-dock support should be enabled for tabs and their associatedDockables,falseotherwise.- See Also:
-
isTabsAsDragSource
public boolean isTabsAsDragSource()Returnstrueif drag-to-dock support is enabled for tabs and their associatedDockables,falseotherwise. If tab-drag-source is enabled, then the tab that corresponds to aDockablewithin an embedded tabbed layout will respond to drag events as if the tab were a component included within theListreturned by callinggetDragSources()on theDockable. This allows dragging a tab to initiate drag-to-dock operations.- Returns:
trueif drag-to-dock support is enabled for tabs and their associatedDockables,falseotherwise.- See Also:
-
getInitTabPlacement
protected int getInitTabPlacement() -
isRoot
public boolean isRoot()Returns a boolean indicating whether or not thisDockingPortis nested within anotherDockingPort. If there are no otherDockingPortswithin thisDockingPort'scontainer ancestor hierarchy, then this method will returntrue. Otherwise, this method will returnfalse. If the thisDockingPortis not validated and/or is not part of a container hierarchy, this method should returntrue.- Specified by:
isRootin interfaceDockingPort- Returns:
falseif thisDockingPortis nested within anotherDockingPort,trueotherwise.- See Also:
-
setRoot
public void setRoot(boolean root) This method is used internally by the framework to notifyDefaultDockingPortswhether they are "root"DockingPortsaccording to the rules specified byisRoot()on theDockingPortinterface. This method should not be called by application-level developers. It will most likely be removed in future versions and the logic contained herein will be managed by some type of change listener.- Parameters:
root-trueif this is a "root"DockingPort,falseotherwise.- See Also:
-
setDragInProgress
public void setDragInProgress(boolean inProgress) This method is used internally by the framework to notifyDefaultDockingPortswhether a drag operation is or is not currently in progress and should not be called by application-level developers. It will most likely be removed in future versions and the logic contained herein will be managed by some type of change listener.- Parameters:
inProgress-trueif a drag operation involving thisDockingPortis currently in progress,falseotherwise.
-
paint
Overridden to provide enhancements during drag operations. SomeDragPreviewimplementations may by able to supply aBufferedImagefor thisDockingPortto use for painting operations. This may be useful for cases in which the dimensions of dockedComponentsare altered in realtime during the drag operation to provide a "ghost" image for theDragPreview. In this case, visual feedback for altered subcomponents within thisDockingPortmay be blocked in favor of a temporaryBufferedImagefor the life of the drag operation.- Overrides:
paintin classJComponent- Parameters:
g- theGraphicscontext in which to paint- See Also:
-
exportLayout
Returns aLayoutNodecontaining metadata that describes the current layout contained within thisDefaultDockingPort. TheLayoutNodereturned by this method will be aDockingPortNodethat constitutes the root of a tree structure containing variousDockingNodeimplementations; specificallySplitNode,DockableNode, andDockingPortNode. Each of these nodes isSerializable, implying theLayoutNodeitself may be written to external storage and later reloaded into thisDockingPortviaimportLayout(LayoutNode node).- Specified by:
exportLayoutin interfaceDockingPort- Returns:
- a
LayoutNoderepresenting the current layout state within thisDockingPort - See Also:
-
importLayout
Clears out the existing layout within thisDockingPortand reconstructs a new layout based upon the specifiedLayoutNode.At present, this method can only handle
LayoutNodesthat have been generated byDefaultDockingPort'sexportLayout()method. If the specifiedLayoutNodeisnullor is otherwise not an instance ofDockingPortNode, then this method returns immediately with no action taken.Otherwise, the necessary
Dockablesare docked within thisDockingPortand all subsequently generated sub-DockingPortsin a visual configuration mandated by the tree structure modeled by the specifiedLayoutNode.- Specified by:
importLayoutin interfaceDockingPort- Parameters:
node- theLayoutNodewhose layout is to be instantiated within thisDockingPort- See Also:
-
installMaximizedDockable
Description copied from interface:DockingPortAsks thisDockingPortto temporarily install the specifiedDockableand maximize its component. This method is called byDockingManagerin the course of maximizing aDockable. Client code should not call this method directly.This
DockingPortis expected to display the specified dockable's component such that it occupies all (or the majority) of its screen resources. Also, thisDockingPortis expected to internally store enough information to restore its current state after a subsequent call toDockingPort.uninstallMaximizedDockable().- Specified by:
installMaximizedDockablein interfaceDockingPort- Parameters:
dockable- theDockablethat is requested to be maximized- See Also:
-
uninstallMaximizedDockable
public void uninstallMaximizedDockable()Description copied from interface:DockingPortNotifies thisDockingPortthat theDockablepreviously installed for maximization via a call toDockingPort.installMaximizedDockable(Dockable)should now be returned to its originalDockingPortand that thisDockingPortshould return to its original state from before the call toDockingPort.installMaximizedDockable(Dockable). This method is called byDockingManagerin the course of restoring a maximizedDockable. Client code should not call this method directly.This
DockingPortis expected to remove the maximized dockable's component from its swing container hierarchy.- Specified by:
uninstallMaximizedDockablein interfaceDockingPort- See Also:
-
releaseForMaximization
Description copied from interface:DockingPortAsks thisDockingPortto temporarily release its childDockablefor use by anotherDockingPortto achieve maximization. This method is called byDockingManagerin the course of maximizing aDockable. Client code should not call this method directly.This
DockingPortis expected to remove the specified dockable's component from its swing container hierarchy. Also, thisDockingPortis expected to internally store enough information to restore its current state after a subsequent call toDockingPort.returnFromMaximization().- Specified by:
releaseForMaximizationin interfaceDockingPort- Parameters:
dockable- theDockablethat is requested to be maximized- See Also:
-
returnFromMaximization
public void returnFromMaximization()Description copied from interface:DockingPortNotifies thisDockingPortthat theDockablepreviously released for maximization via a call toDockingPort.releaseForMaximization(Dockable)is now ready to be returned to its original state inside thisDockingPort. This method is called byDockingManagerin the course of restoring a maximizedDockable. Client code should not call this method directly.- Specified by:
returnFromMaximizationin interfaceDockingPort- See Also:
-