net.xoetrope.swing.docking
Class XDockingPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by net.xoetrope.swing.docking.XDockingPanel
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible
Direct Known Subclasses:
XDockableFrame

public class XDockingPanel
extends javax.swing.JPanel

A panel for use in a docking framework. The panel is an area into which various content panels may be docked. These docked panels are displayed with a header containing a title and a dock/minimize button. Clicking on the minimize button caused the panel to hide itself within the MultiSplitPane's layout and add a button to the side bar if one has been specified. Double clicking the header causes the panel to occupy the full area of its parent

An individual XDockingPanel can contain multiple child panels, each of which is given a separate header, similar to a tab in a tab pane. The header contains a button, which when clicked docks the panel to a sidebar. The header may also contain a highlight to indicate that it is selected/active

The dockable components are managed via the XDockable object which contains a collection of the participating objects, including the XDockingPanel, the XDockingSidebar that holds the minimized panel and the XDockableHeader that is used within this panel. The value of the dockable object's fields are set as the dockable panel's state is changed.

In docking a panel the panel is hidden and the sidebar is informed that it should assume ownership of the dockable. However the content/panel remains a child of this docking panel unless shown in a preview panel. In the preview the content is 'borrowed' by the preview panel, but when the preview panel is dismissed the content is restored to this instance of the docking panel.

Copyright: (c) Xoetrope Ltd., 1998-2006
License: see license.txt

See Also:
Serialized Form

Nested Class Summary
 class XDockingPanel.XDockableProxy
          A proxy for hidden panels.
 
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
protected  XDockableHeader activeHeader
           
static int CLOSED
           
protected  javax.swing.JPanel contentPane
           
protected  java.awt.Dimension defSize
           
protected  javax.swing.JPanel headerPanel
           
protected  java.util.ArrayList listeners
           
static int MAXIMIZED
           
static int MINIMIZED
           
static int PREVIEW_CLOSED
           
static int PREVIEW_OPENED
           
static int RESTORED
           
protected  org.jdesktop.swingx.MultiSplitPane splitPane
           
static boolean USE_REMOVE_STRATEGY
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, 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
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
XDockingPanel(java.lang.String constraint)
          Creates a new instance of XDockingPanel
 
Method Summary
 void addDockable(XDockable dockable, java.awt.Color[] colors, java.lang.String[] tooltips)
          Add a panel to this container.
 void addDockingPanelListener(XDockingPanelListener l)
          Add a listener to this panel
 void dock()
          Dock this panel
 void fireDockingPanelListeners(int state)
          Invoke a dockingpanel listener method
 java.lang.String getConstraint()
          Get the constraint used by this docking panel.
 java.awt.Container getContentPane()
          Get the container into which the content should be added
 java.awt.Dimension getPreferredSize()
          Get the preferred size of the component.
 java.lang.String getTitle()
          Get the window title of teh active header
 void removeDockable(XDockable dockable, boolean addToSidebar)
          Remove the content referred to by the dockable from this docking panel
 void removeDockable(XDockable dockable, boolean addToSidebar, boolean removeDocked)
          Remove the content referred to by the dockable from this docking panel
 void removeDockingPanelListener(XDockingPanelListener l)
          Remove a listener from this panel
 void restoreContent(XDockable dockable)
          Dock the content of the dockable object back into this container.
 void setActivateHeader(XDockableHeader dh)
          Set the active header
 void setConstraint(java.lang.String c)
          Set the constraint used by this docking panel.
 void setTitle(java.lang.String title)
          Set the window title of the active header
 
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, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, 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, transferFocusBackward, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

USE_REMOVE_STRATEGY

public static final boolean USE_REMOVE_STRATEGY
See Also:
Constant Field Values

CLOSED

public static final int CLOSED
See Also:
Constant Field Values

MAXIMIZED

public static final int MAXIMIZED
See Also:
Constant Field Values

MINIMIZED

public static final int MINIMIZED
See Also:
Constant Field Values

PREVIEW_CLOSED

public static final int PREVIEW_CLOSED
See Also:
Constant Field Values

PREVIEW_OPENED

public static final int PREVIEW_OPENED
See Also:
Constant Field Values

RESTORED

public static final int RESTORED
See Also:
Constant Field Values

activeHeader

protected XDockableHeader activeHeader

contentPane

protected javax.swing.JPanel contentPane

headerPanel

protected javax.swing.JPanel headerPanel

defSize

protected java.awt.Dimension defSize

splitPane

protected org.jdesktop.swingx.MultiSplitPane splitPane

listeners

protected java.util.ArrayList listeners
Constructor Detail

XDockingPanel

public XDockingPanel(java.lang.String constraint)
Creates a new instance of XDockingPanel

Parameters:
constraint - the name/constraint by which this panel is known. Note that this name is not displayed to the user and is instead used programatically
Method Detail

addDockingPanelListener

public void addDockingPanelListener(XDockingPanelListener l)
Add a listener to this panel


removeDockingPanelListener

public void removeDockingPanelListener(XDockingPanelListener l)
Remove a listener from this panel


fireDockingPanelListeners

public void fireDockingPanelListeners(int state)
Invoke a dockingpanel listener method

Parameters:
state - a flasg indicating the new state and hence the method to invoke

getConstraint

public java.lang.String getConstraint()
Get the constraint used by this docking panel.


setConstraint

public void setConstraint(java.lang.String c)
Set the constraint used by this docking panel.

Parameters:
c - the new layout constraint

getContentPane

public java.awt.Container getContentPane()
Get the container into which the content should be added

Returns:
the content pane

restoreContent

public void restoreContent(XDockable dockable)
Dock the content of the dockable object back into this container. The dockable object is updated in the process to refelct its new ownership.

Parameters:
dockable - the object being docked.

addDockable

public void addDockable(XDockable dockable,
                        java.awt.Color[] colors,
                        java.lang.String[] tooltips)
Add a panel to this container. The panel will have a tab showing the title. The dockable object is updated to reflect its new ownership

Parameters:
dockable - the object being docked.
colors - the header colors: background, text color, active background, active text color
tooltips - the tooltip text for the minimize and close buttons

setActivateHeader

public void setActivateHeader(XDockableHeader dh)
Set the active header

Parameters:
dh - the new active header

removeDockable

public void removeDockable(XDockable dockable,
                           boolean addToSidebar,
                           boolean removeDocked)
Remove the content referred to by the dockable from this docking panel

Parameters:
dockable - the object being docked.
addToSideBar - true to add the content to the dockable's sidebar
removeDocked - true to remove a docked component from the sidebar if the component is already minimized and docked

removeDockable

public void removeDockable(XDockable dockable,
                           boolean addToSidebar)
Remove the content referred to by the dockable from this docking panel

Parameters:
dockable - the object being docked.
addToSideBar - true to add the content to the dockable's sidebar

dock

public void dock()
Dock this panel


getTitle

public java.lang.String getTitle()
Get the window title of teh active header

Returns:
the title

setTitle

public void setTitle(java.lang.String title)
Set the window title of the active header

Parameters:
title - the new title

getPreferredSize

public java.awt.Dimension getPreferredSize()
Get the preferred size of the component. The

Overrides:
getPreferredSize in class javax.swing.JComponent
Returns:
the size of the panel or 0x0 if the panel is docked