Class JDockingPanel

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

    public class JDockingPanel
    extends javax.swing.JPanel
    implements java.awt.event.ActionListener
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class javax.swing.JPanel

        javax.swing.JPanel.AccessibleJPanel
      • Nested classes/interfaces inherited from class javax.swing.JComponent

        javax.swing.JComponent.AccessibleJComponent
      • Nested classes/interfaces inherited from class java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int ALLOWED_DRAG_DROP_ACTIONS  
      static int DOCK_BOTTOM  
      static int DOCK_CENTER  
      static int DOCK_LEFT  
      static int DOCK_RIGHT  
      static int DOCK_TOP  
      • Fields inherited from class javax.swing.JComponent

        listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
      • Fields inherited from class java.awt.Component

        accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
      • Fields inherited from interface java.awt.image.ImageObserver

        ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
    • Constructor Summary

      Constructors 
      Constructor Description
      JDockingPanel()
      Creates a docking panel to which any Dockables may be added by the respective dock methods.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void actionPerformed​(java.awt.event.ActionEvent e)  
      void addDividerChangeLister​(DividerChangeListener l)  
      boolean changeTitle​(java.lang.String oldTitle, java.lang.String newTitle)
      changes a title of a docked Dockable
      void dock​(Dockable dockable)
      Dock the dockable to the center of the selected view.
      void dock​(Dockable dockable, int position)
      Dock the Dockable at the given position to the selected view.
      void dock​(Dockable dockable, java.lang.String dockInfo)
      Dock the dockable either as a new root dockable or to the treeElement that contains dockable specified as part dockInfo.
      protected void fireDockableSelected​(Dockable dockable)
      Sends ActionEvent to listeners when the user interactively selected another dockable
      java.awt.Rectangle getAbsoluteBounds​(java.awt.Component jc)
      Calculates bounds of the dockable relative to this JDockingPanel
      Dockable getDockable​(java.awt.Component content)
      Returns the Dockable that contains the given content.
      Dockable getDockable​(java.lang.String title)  
      int getDockableCount()  
      java.util.Collection<Dockable> getDockables()  
      java.util.Set<java.lang.String> getDockableTitles()  
      java.lang.String[] getDockInfoSequence()
      returns the persistence information necessary to recreate the current docking state.
      Dockable getDraggedDockable​(java.awt.dnd.DropTargetDragEvent dtde)  
      Dockable getSelectedDockable()
      Returns the currently active Dockable, i.e.
      java.lang.String getTitle​(Dockable dockable)  
      boolean isInFrontInTabbedPane​(java.lang.String title)  
      boolean isMaximized()  
      boolean isVisibleInSplitPane​(java.lang.String title, boolean left)
      Checks, whether a dockable with the given title exists, and whether it is visible (selected if in a JTabbedPane) and whether it is in the left or right branch (depending on parameter left) of a JSplitPane.
      void maximize​(java.lang.String title, javax.swing.JToolBar maximizeToolBar)
      Toggle the maximization state of the dockable in the docking panel.
      void paint​(java.awt.Graphics g)  
      void redistribute()  
      void relocateView​(java.lang.String movedDockableName, java.lang.String targetDockableName, int targetPosition, float dividerPosition)
      May be overriden to catch user initiated drag&drop
      void removeDividerChangeLister​(DividerChangeListener l)  
      void selectDockable​(Dockable dockable)  
      void setToFrontInTabbedPane​(java.lang.String title)  
      void undock​(java.lang.String title)  
      void undock​(java.lang.String title, boolean isDragging)  
      void undockAll()  
      void visibilityChanged​(Dockable dockable, boolean isVisible)
      This is called when a Dockable's visibility changes, i.e.
      - when a new Dockable is docked
      - when a new Dockable is undocked
      - when the user drags & docks a Dockable
      - when the user actively switches tabs in a tabbed pane
      It may be overridden in order to react on a visibility change due to the user selecting a different tab of dragging & docking a Dockable.
      • Methods inherited from class javax.swing.JPanel

        getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
      • Methods 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, update
      • Methods inherited from class java.awt.Container

        add, add, add, add, add, 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, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
      • Methods 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, transferFocusUpCycle
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • JDockingPanel

        public JDockingPanel()
        Creates a docking panel to which any Dockables may be added by the respective dock methods.
    • Method Detail

      • actionPerformed

        public void actionPerformed​(java.awt.event.ActionEvent e)
        Specified by:
        actionPerformed in interface java.awt.event.ActionListener
      • maximize

        public void maximize​(java.lang.String title,
                             javax.swing.JToolBar maximizeToolBar)
        Toggle the maximization state of the dockable in the docking panel. If it is maximizing, then a toolbar may be provided that is shown in the maximized state. Note that a null toolbar causes the maximized state to use the default toolbar with maximize and close buttons only.
        Parameters:
        maximizeToolBar - null for default or toolbar that shall be shown in maximized state
      • fireDockableSelected

        protected void fireDockableSelected​(Dockable dockable)
        Sends ActionEvent to listeners when the user interactively selected another dockable
        Parameters:
        dockable -
      • getAbsoluteBounds

        public java.awt.Rectangle getAbsoluteBounds​(java.awt.Component jc)
        Calculates bounds of the dockable relative to this JDockingPanel
        Parameters:
        jc -
        Returns:
      • paint

        public void paint​(java.awt.Graphics g)
        Overrides:
        paint in class javax.swing.JComponent
      • relocateView

        public void relocateView​(java.lang.String movedDockableName,
                                 java.lang.String targetDockableName,
                                 int targetPosition,
                                 float dividerPosition)
        May be overriden to catch user initiated drag&drop
        Parameters:
        movedDockableName -
        targetDockableName -
        targetPosition -
      • dock

        public void dock​(Dockable dockable)
        Dock the dockable to the center of the selected view.
        Parameters:
        dockable -
      • dock

        public void dock​(Dockable dockable,
                         int position)
        Dock the Dockable at the given position to the selected view.
        Parameters:
        dockable -
        position -
      • dock

        public void dock​(Dockable dockable,
                         java.lang.String dockInfo)
        Dock the dockable either as a new root dockable or to the treeElement that contains dockable specified as part dockInfo. The dockInfo parameter is either "root" or has the following format: "title[\tposition[\tdividerlocation]]" with position is one of center,top,left,bottom,right and dividerlocation is between 0.0 and 1.0 giving the percentage of space given to the left/top element.
        Parameters:
        dockable -
        dockInfo - encoded position and parent obtainable by getDockInfo(title)
      • undock

        public void undock​(java.lang.String title)
      • undock

        public void undock​(java.lang.String title,
                           boolean isDragging)
      • undockAll

        public void undockAll()
      • getDockableTitles

        public java.util.Set<java.lang.String> getDockableTitles()
      • getDockables

        public java.util.Collection<Dockable> getDockables()
      • getDockable

        public Dockable getDockable​(java.lang.String title)
      • getTitle

        public java.lang.String getTitle​(Dockable dockable)
      • getDockableCount

        public int getDockableCount()
      • getDockInfoSequence

        public java.lang.String[] getDockInfoSequence()
        returns the persistence information necessary to recreate the current docking state. To recreate a docking state create an empty JDockingPanel and call dock(dockable, dockInfo) once for every dockable keeping the order of the title[] array and pass the respective dockInfo from the array returned by this function.
        Returns:
        dockInfo[] array with a docking instruction for every dockable
      • isInFrontInTabbedPane

        public boolean isInFrontInTabbedPane​(java.lang.String title)
        Parameters:
        title -
        Returns:
        true if a dockable with the given title exists and if it is the selected component of a tabbed pane
      • setToFrontInTabbedPane

        public void setToFrontInTabbedPane​(java.lang.String title)
        Parameters:
        title -
      • isVisibleInSplitPane

        public boolean isVisibleInSplitPane​(java.lang.String title,
                                            boolean left)
        Checks, whether a dockable with the given title exists, and whether it is visible (selected if in a JTabbedPane) and whether it is in the left or right branch (depending on parameter left) of a JSplitPane.
        Parameters:
        title -
        left - if true, then
        Returns:
        true the respective dockable is visible and in the left part of a JSplitPane
      • changeTitle

        public boolean changeTitle​(java.lang.String oldTitle,
                                   java.lang.String newTitle)
        changes a title of a docked Dockable
        Parameters:
        oldTitle - existing title
        newTitle - must be a unique title and must not contain a TAB
        Returns:
        true in case of success
      • getDockable

        public Dockable getDockable​(java.awt.Component content)
        Returns the Dockable that contains the given content.
        Parameters:
        content - the content to be looked for
        Returns:
        content owning Dockable or null if content is not found
      • getSelectedDockable

        public Dockable getSelectedDockable()
        Returns the currently active Dockable, i.e. the one with the highlighted header area.
        Returns:
        active Dockable or null if there are no Dockables
      • getDraggedDockable

        public Dockable getDraggedDockable​(java.awt.dnd.DropTargetDragEvent dtde)
      • visibilityChanged

        public void visibilityChanged​(Dockable dockable,
                                      boolean isVisible)
        This is called when a Dockable's visibility changes, i.e.
        - when a new Dockable is docked
        - when a new Dockable is undocked
        - when the user drags & docks a Dockable
        - when the user actively switches tabs in a tabbed pane
        It may be overridden in order to react on a visibility change due to the user selecting a different tab of dragging & docking a Dockable.
        Parameters:
        dockable -
        isVisible -
      • selectDockable

        public void selectDockable​(Dockable dockable)
      • isMaximized

        public boolean isMaximized()
        Returns:
        whether one of the dockable views is currently maximized
      • redistribute

        public void redistribute()