buoyx.docking
Class DockingContainer

java.lang.Object
  extended by buoy.event.EventSource
      extended by buoy.widget.Widget
          extended by buoy.widget.WidgetContainer
              extended by buoyx.docking.DockingContainer

public class DockingContainer
extends WidgetContainer

A DockingContainer contains a single content Widget, plus any number of DockableWidgets. The DockableWidgets are arranged along one edge of the content Widget, divided into a set of tabs. The number of tabs, the set of DockableWidgets in each tab, and the order in which they appear are all configurable.

Once you create one or more DockingContainers and add DockableWidgets to them, the user is free to rearrange them by dragging them with the mouse. This includes reordering the Widgets in a tab, moving them between tabs, moving a Widget from one DockingContainer to a different DockingContainer in the same window, and detaching a Widget so that it appears in a separate dialog.

Whenever the user performs a drag, a DockingEvent is dispatched to report the event. When the drag is from one DockingContainer to another one, both the source and target containers will dispatch events. For drags within a single container, only one event is generated.

Author:
Peter Eastman

Constructor Summary
DockingContainer()
          Create a DockingContainer with no children and tabs along its top edge.
DockingContainer(Widget content, BTabbedPane.TabPosition tabPosition)
          Create a DockingContainer.
 
Method Summary
 void addDockableWidget(DockableWidget widget)
          Add a DockableWidget to this container.
 void addDockableWidget(DockableWidget widget, int tab, int indexInTab)
          Add a new DockableWidget to this container.
 DockableWidget getChild(int tab, int index)
          Get a DockableWidget contained in this container.
 int getChildCount()
          Get the number of children in this container.
 int getChildIndexInTab(DockableWidget widget)
          Get the position within its tab at which a DockableWidget appears.
 java.util.Collection<Widget> getChildren()
          Get a Collection containing all child Widgets of this container.
 int getChildTabIndex(DockableWidget widget)
          Get the index of the tab in which a DockableWidget appears.
 Widget getContent()
          Get the content Widget.
 boolean getHideSingleTab()
          When all DockableWidgets are grouped into a single tab, it is possible to save space by hiding the tab.
 java.awt.Dimension getMinimumSize()
          Get the smallest size at which this Widget can reasonably be drawn.
 java.awt.Dimension getPreferredSize()
          Get the preferred size at which this Widget will look best.
 int getSelectedTab()
          Get which tab is currently displayed.
 BSplitPane getSplitPane()
          Get the BSplitPane which separates the content Widget from the DockableWidgets.
 int getTabChildCount(int tabIndex)
          Get the number of DockableWidgets within a particular tab.
 int getTabCount()
          Get the number of tabs in this container.
 BTabbedPane.TabPosition getTabPosition()
          Get which side of the content Widget the DockableWidgets appear on.
 void layoutChildren()
          Layout the child Widgets.
 void remove(Widget widget)
          Remove a child Widget from this container.
 void removeAll()
          Remove all child Widgets from this container.
 void resetToPreferredSizes(int tabIndex)
          Reset the positions of the dividers within a single tab based on the preferred sizes of the DockableWidgets it contains.
 void setContent(Widget widget)
          Set the content Widget.
 void setHideSingleTab(boolean hide)
          When all DockableWidgets are grouped into a single tab, it is possible to save space by hiding the tab.
 void setSelectedTab(int index)
          Set which tab is currently displayed.
 void setTabPosition(BTabbedPane.TabPosition position)
          Set which side of the content Widget the DockableWidgets appear on.
 
Methods inherited from class buoy.widget.WidgetContainer
isOpaque, setOpaque
 
Methods inherited from class buoy.widget.Widget
addEventLink, dispatchEvent, getBackground, getBounds, getComponent, getCursor, getFont, getMaximumSize, getName, getParent, hasFocus, isEnabled, isFocusable, isVisible, repaint, requestFocus, setBackground, setCursor, setEnabled, setFocusable, setFont, setName, setVisible
 
Methods inherited from class buoy.event.EventSource
addEventLink, addEventLink, removeEventLink
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DockingContainer

public DockingContainer()
Create a DockingContainer with no children and tabs along its top edge.


DockingContainer

public DockingContainer(Widget content,
                        BTabbedPane.TabPosition tabPosition)
Create a DockingContainer.

Parameters:
content - the content Widget
tabPosition - this specifies which side of the content Widget the DockableWidgets will be placed on
Method Detail

getContent

public Widget getContent()
Get the content Widget.


setContent

public void setContent(Widget widget)
Set the content Widget.


addDockableWidget

public void addDockableWidget(DockableWidget widget)
Add a DockableWidget to this container. It will be placed in a new tab.


addDockableWidget

public void addDockableWidget(DockableWidget widget,
                              int tab,
                              int indexInTab)
Add a new DockableWidget to this container.

Parameters:
widget - the Widget to add
tab - the index of the tab in which to place the Widget
indexInTab - the position within the tab at which the Widget should appear

getChildTabIndex

public int getChildTabIndex(DockableWidget widget)
Get the index of the tab in which a DockableWidget appears. If it is not a child of this container, -1 is returned.


getChildIndexInTab

public int getChildIndexInTab(DockableWidget widget)
Get the position within its tab at which a DockableWidget appears. If it is not a child of this container, -1 is returned.


getTabCount

public int getTabCount()
Get the number of tabs in this container.


getTabChildCount

public int getTabChildCount(int tabIndex)
Get the number of DockableWidgets within a particular tab.


getTabPosition

public BTabbedPane.TabPosition getTabPosition()
Get which side of the content Widget the DockableWidgets appear on.


setTabPosition

public void setTabPosition(BTabbedPane.TabPosition position)
Set which side of the content Widget the DockableWidgets appear on.


getSelectedTab

public int getSelectedTab()
Get which tab is currently displayed.


setSelectedTab

public void setSelectedTab(int index)
Set which tab is currently displayed.


getHideSingleTab

public boolean getHideSingleTab()
When all DockableWidgets are grouped into a single tab, it is possible to save space by hiding the tab. This method gets whether that option is enabled.


setHideSingleTab

public void setHideSingleTab(boolean hide)
When all DockableWidgets are grouped into a single tab, it is possible to save space by hiding the tab. This method sets whether that option is enabled.


resetToPreferredSizes

public void resetToPreferredSizes(int tabIndex)
Reset the positions of the dividers within a single tab based on the preferred sizes of the DockableWidgets it contains.


getChildCount

public int getChildCount()
Description copied from class: WidgetContainer
Get the number of children in this container.

Specified by:
getChildCount in class WidgetContainer

getChildren

public java.util.Collection<Widget> getChildren()
Description copied from class: WidgetContainer
Get a Collection containing all child Widgets of this container.

Specified by:
getChildren in class WidgetContainer

getChild

public DockableWidget getChild(int tab,
                               int index)
Get a DockableWidget contained in this container.

Parameters:
tab - the index of the tab in which the Widget appears
index - the index of the Widget within its tab

remove

public void remove(Widget widget)
Description copied from class: WidgetContainer
Remove a child Widget from this container.

Specified by:
remove in class WidgetContainer

removeAll

public void removeAll()
Description copied from class: WidgetContainer
Remove all child Widgets from this container.

Specified by:
removeAll in class WidgetContainer

layoutChildren

public void layoutChildren()
Description copied from class: WidgetContainer
Layout the child Widgets. This may be invoked whenever something has changed (the size of this WidgetContainer, the preferred size of one of its children, etc.) that causes the layout to no longer be correct. If a child is itself a WidgetContainer, its layoutChildren() method will be called in turn.

Specified by:
layoutChildren in class WidgetContainer

getMinimumSize

public java.awt.Dimension getMinimumSize()
Description copied from class: Widget
Get the smallest size at which this Widget can reasonably be drawn. When a WidgetContainer lays out its contents, it will attempt never to make this Widget smaller than its minimum size.

Overrides:
getMinimumSize in class Widget

getPreferredSize

public java.awt.Dimension getPreferredSize()
Description copied from class: Widget
Get the preferred size at which this Widget will look best. When a WidgetContainer lays out its contents, it will attempt to make this Widget as close as possible to its preferred size.

Overrides:
getPreferredSize in class Widget

getSplitPane

public BSplitPane getSplitPane()
Get the BSplitPane which separates the content Widget from the DockableWidgets.



Written by Peter Eastman.