bibliothek.gui.dock.station.stack.tab
Class AbstractTabPane<T extends Tab,M extends TabMenu,I extends LonelyTabPaneComponent>

java.lang.Object
  extended by bibliothek.gui.dock.station.stack.tab.AbstractTabPane<T,M,I>
Type Parameters:
T - the kind of tabs this pane supports
M - the kind of menus this pane supports
I - the kind of info panel this pane supports
All Implemented Interfaces:
TabPane
Direct Known Subclasses:
CombinedStackDockComponent

public abstract class AbstractTabPane<T extends Tab,M extends TabMenu,I extends LonelyTabPaneComponent>
extends Object
implements TabPane

An abstract implementation of TabPane. This class handles creation, storage and destruction of Tabs and TabMenus, it also stores a list of currently visible Dockables.
Subclasses should call setController(DockController) to make sure this pane can use all available information.

Author:
Benjamin Sigg

Field Summary
 
Fields inherited from interface bibliothek.gui.dock.station.stack.tab.TabPane
LAYOUT_MANAGER
 
Constructor Summary
AbstractTabPane()
           
 
Method Summary
 void addTabPaneListener(TabPaneListener listener)
          Adds a listener to this pane, the listener has to be informed when elements are added or removed, and when the selection changes.
protected abstract  void addToMenu(M menu, Dockable dockable)
          Adds dockable somewhere to menu
 TabMenu createMenu()
          Creates a new menu for this pane.
 void destroyMenu(TabMenu menu)
          Destroys menu which was created by this pane.
 void discardComponentsAndRebuild()
          Deletes all Tabs and TabMenus of this TabPane and rebuilds them.
 void doLayout()
          Updates the layout of this pane, assuming a TabLayoutManager is installed.
protected  void fireAdded(Dockable dockable)
          Informs all TabPaneListeners that dockable has been added.
protected  void fireInfoComponentChanged(I oldInfo, I newInfo)
          Informs all TabPaneListeners that the info component has been replaced.
protected  void fireRemoved(Dockable dockable)
          Informs all TabPaneListeners that dockable has been removed.
protected  void fireSelectionChanged()
          Informs all TabPaneListeners that the selection changed.
 DockController getController()
          Gets the DockController this pane is associated with.
 Dockable getDockable(int index)
          Gets the index'th element of this pane.
 int getDockableCount()
          Gets the number of elements that are displayed on this pane.
 Dockable[] getDockables()
          Gets a list of all Dockables that onto this pane.
 I getInfoComponent()
          Gets the info component, the info component shows some additional information.
 TabLayoutManager getLayoutManager()
          Gets the layout manager that is currently used to layout the contents of this pane.
 M getMenu(Dockable dockable)
          Gets the menu on which dockable is shown.
 List<M> getMenuList()
          Gets a list of all the menus of this pane, includes visible and invisible menus
 TabMenu[] getMenus()
          Gets all the menus of this pane, visible and invisible
 Dimension getMinimumSize()
          Gets the minimal size that TabPane.getAvailableArea() should return.
 Tab getOnTab(Dockable dockable)
          Gets the tab-button for dockable, if no tab-button for dockable exists a new button should be created.
 Dimension getPreferredSize()
          Gets the preferred size that TabPane.getAvailableArea() should return.
 Dockable getSelectedDockable()
          Gets the currently selected Dockable on this pane (this is the one child that is visible).
 T getTab(Dockable dockable)
          Gets the tab that is used to display dockable.
 TabPlacement getTabPlacement()
          Tells at which side tabs are to be displayed.
 Tab[] getTabs()
          Gets all the tabs that are currently visible on this pane.
 List<T> getTabsList()
          Gets all known tabs of this pane, including invisible tabs.
 T getVisibleTab(int index)
          Gets the index'th visible tab.
 int getVisibleTabCount()
          Gets the number of tabs that are currently visible.
 int indexOf(Dockable dockable)
          Gets the index of dockable on this pane.
 int indexOfVisible(Tab tab)
          Returns the index of tab following the indices of Dockables but ignoring invisible tabs.
 void insert(int index, Dockable dockable)
          Adds dockable as child to this tab-pane.
protected  TabPaneListener[] listeners()
          Gets all the TabPaneListeners that are known to this TabPane
protected abstract  void menuRemoved(M menu)
          Informs this pane that menu will never be used again and all resources associated with menu should be freed.
 void move(int source, int destination)
          Moves the element at location source to destination.
abstract  M newMenu()
          Creates a new TabMenu that has this as parent.
protected abstract  T newTab(Dockable dockable)
          Creates a new Tab that has this as parent and represents dockable.
 void putInMenu(TabMenu menu, Dockable dockable)
          Adds dockable somewhere on menu.
 T putOnTab(Dockable dockable)
          Informs this pane that its child dockable should have a tab-button.
 void remove(int index)
          Removes the index'th element of this pane.
 void removeAll()
          Removes all elements from this pane.
protected abstract  void removeFromMenu(M menu, Dockable dockable)
          Removes dockable from menu.
 void removeTabPaneListener(TabPaneListener listener)
          Removes a listener from this pane.
 void revalidate()
          Called when the layout of this pane has become invalid, the default behavior is to call doLayout().
 void setController(DockController controller)
          Connects this pane with controller.
 void setInfoComponent(I info)
          Sets the info component.
 void setLayoutManager(TabLayoutManager layoutManager)
          Sets the layout manager that will layout the contents of this pane, a value of null will reinstall the default layout manager.
 void setSelectedDockable(Dockable dockable)
          Selects the child dockable of this pane as the one visible element.
 void setTabPlacement(TabPlacement tabPlacement)
          Tells this pane where to paint the tabs.
protected abstract  void tabRemoved(T tab)
          Informs this pane that tab will never be used again and all resources associated with tab should be freed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface bibliothek.gui.dock.station.stack.tab.TabPane
getAvailableArea, getSelectedBounds, setSelectedBounds
 

Constructor Detail

AbstractTabPane

public AbstractTabPane()
Method Detail

setController

public void setController(DockController controller)
Connects this pane with controller.

Parameters:
controller - the realm in which this pane works, may be null

getController

public DockController getController()
Description copied from interface: TabPane
Gets the DockController this pane is associated with.

Specified by:
getController in interface TabPane
Returns:
the controller, might be null

setTabPlacement

public void setTabPlacement(TabPlacement tabPlacement)
Tells this pane where to paint the tabs.

Parameters:
tabPlacement - a side, not null

getTabPlacement

public TabPlacement getTabPlacement()
Description copied from interface: TabPane
Tells at which side tabs are to be displayed. This property is intended for a TabLayoutManager, but may be ignored.

Specified by:
getTabPlacement in interface TabPane
Returns:
the side, not null

doLayout

public void doLayout()
Updates the layout of this pane, assuming a TabLayoutManager is installed.


getMinimumSize

public Dimension getMinimumSize()
Gets the minimal size that TabPane.getAvailableArea() should return.

Returns:
the minimal size

getPreferredSize

public Dimension getPreferredSize()
Gets the preferred size that TabPane.getAvailableArea() should return.

Returns:
the preferred size

revalidate

public void revalidate()
Called when the layout of this pane has become invalid, the default behavior is to call doLayout(). Subclasses may override to update the layout lazily.


addTabPaneListener

public void addTabPaneListener(TabPaneListener listener)
Description copied from interface: TabPane
Adds a listener to this pane, the listener has to be informed when elements are added or removed, and when the selection changes.

Specified by:
addTabPaneListener in interface TabPane
Parameters:
listener - the new listener

removeTabPaneListener

public void removeTabPaneListener(TabPaneListener listener)
Description copied from interface: TabPane
Removes a listener from this pane.

Specified by:
removeTabPaneListener in interface TabPane
Parameters:
listener - the listener to remove

listeners

protected TabPaneListener[] listeners()
Gets all the TabPaneListeners that are known to this TabPane

Returns:
an array of listeners

fireSelectionChanged

protected void fireSelectionChanged()
Informs all TabPaneListeners that the selection changed.


fireAdded

protected void fireAdded(Dockable dockable)
Informs all TabPaneListeners that dockable has been added.

Parameters:
dockable - the new child

fireRemoved

protected void fireRemoved(Dockable dockable)
Informs all TabPaneListeners that dockable has been removed.

Parameters:
dockable - the removed child

fireInfoComponentChanged

protected void fireInfoComponentChanged(I oldInfo,
                                        I newInfo)
Informs all TabPaneListeners that the info component has been replaced.

Parameters:
oldInfo - the old info component
newInfo - the new info component

getLayoutManager

public TabLayoutManager getLayoutManager()
Gets the layout manager that is currently used to layout the contents of this pane.

Returns:
the layout manager, may be null

setLayoutManager

public void setLayoutManager(TabLayoutManager layoutManager)
Sets the layout manager that will layout the contents of this pane, a value of null will reinstall the default layout manager.

Parameters:
layoutManager - the new manager, may be null

insert

public void insert(int index,
                   Dockable dockable)
Adds dockable as child to this tab-pane.

Parameters:
index - the index of the new child
dockable - the new child

move

public void move(int source,
                 int destination)
Moves the element at location source to destination.

Parameters:
source - where to find the element to move
destination - the target location

remove

public void remove(int index)
Removes the index'th element of this pane.

Parameters:
index - the index of the element to remove

removeAll

public void removeAll()
Removes all elements from this pane.


discardComponentsAndRebuild

public void discardComponentsAndRebuild()
Deletes all Tabs and TabMenus of this TabPane and rebuilds them.


getSelectedDockable

public Dockable getSelectedDockable()
Description copied from interface: TabPane
Gets the currently selected Dockable on this pane (this is the one child that is visible).

Specified by:
getSelectedDockable in interface TabPane
Returns:
the selection, not null unless there are no children at all

setSelectedDockable

public void setSelectedDockable(Dockable dockable)
Selects the child dockable of this pane as the one visible element.

Parameters:
dockable - the newly selected element, can be null

getDockables

public Dockable[] getDockables()
Description copied from interface: TabPane
Gets a list of all Dockables that onto this pane. The list should be ordered.

Specified by:
getDockables in interface TabPane
Returns:
the list of children, not null but maybe empty

getDockableCount

public int getDockableCount()
Gets the number of elements that are displayed on this pane.

Returns:
the number of elements

getDockable

public Dockable getDockable(int index)
Gets the index'th element of this pane.

Parameters:
index - the index of an element
Returns:
element at position index

indexOf

public int indexOf(Dockable dockable)
Gets the index of dockable on this pane.

Parameters:
dockable - the element to search
Returns:
the index or -1 if dockable was not found

getTabs

public Tab[] getTabs()
Description copied from interface: TabPane
Gets all the tabs that are currently visible on this pane.

Specified by:
getTabs in interface TabPane
Returns:
the current tabs, not null but maybe empty. Note that the size of this array must be smaller or equal to the array returned by TabPane.getDockables().

indexOfVisible

public int indexOfVisible(Tab tab)
Returns the index of tab following the indices of Dockables but ignoring invisible tabs.

Parameters:
tab - the tab to search
Returns:
its index or -1 if not found or invisible

getVisibleTab

public T getVisibleTab(int index)
Gets the index'th visible tab.

Parameters:
index - the index of some visible tab
Returns:
the visible tab or null if index is too big.
Throws:
IllegalArgumentException - if index is smaller than 0.
See Also:
indexOfVisible(Tab)

getVisibleTabCount

public int getVisibleTabCount()
Gets the number of tabs that are currently visible.

Returns:
the number of visible tabs
See Also:
getVisibleTab(int)

getTabsList

public List<T> getTabsList()
Gets all known tabs of this pane, including invisible tabs.

Returns:
the tabs of this pane

getTab

public T getTab(Dockable dockable)
Gets the tab that is used to display dockable.

Parameters:
dockable - the element to search
Returns:
the tab or null

putOnTab

public T putOnTab(Dockable dockable)
Description copied from interface: TabPane
Informs this pane that its child dockable should have a tab-button. This TabPane may create a new Tab or reuse an existing Tab. Reusing an existing tab is recommended. If dockable was part of a TabMenu, then it should be removed from that menu.
If dockable already is on a tab then this tab should be reused.

Specified by:
putOnTab in interface TabPane
Parameters:
dockable - the element which needs a tab-button
Returns:
a Tab that is only used for dockable

getOnTab

public Tab getOnTab(Dockable dockable)
Description copied from interface: TabPane
Gets the tab-button for dockable, if no tab-button for dockable exists a new button should be created. Reusing existing tabs is recommended. Other than TabPane.putOnTab(Dockable) this method must not affect any TabMenu showing Dockable.

Specified by:
getOnTab in interface TabPane
Parameters:
dockable - the element whose tab is requested
Returns:
the tab matching dockable

setInfoComponent

public void setInfoComponent(I info)
Sets the info component.

Parameters:
info - the new component, can be null
See Also:
getInfoComponent()

getInfoComponent

public I getInfoComponent()
Description copied from interface: TabPane
Gets the info component, the info component shows some additional information. E.g. the info component may show information about the current selection.

Specified by:
getInfoComponent in interface TabPane
Returns:
Gets the current info component, may be null

getMenuList

public List<M> getMenuList()
Gets a list of all the menus of this pane, includes visible and invisible menus

Returns:
the list of menus

getMenus

public TabMenu[] getMenus()
Gets all the menus of this pane, visible and invisible

Returns:
all the menus

getMenu

public M getMenu(Dockable dockable)
Gets the menu on which dockable is shown.

Parameters:
dockable - some child of this pane
Returns:
the menu or null

putInMenu

public void putInMenu(TabMenu menu,
                      Dockable dockable)
Description copied from interface: TabPane
Adds dockable somewhere on menu. If dockable is already shown on another menu or Tab, then it has to be removed from that other menu or tab.

Specified by:
putInMenu in interface TabPane
Parameters:
menu - a menu created by this TabPane
dockable - some child of this
See Also:
TabPane.putOnTab(Dockable)

createMenu

public TabMenu createMenu()
Description copied from interface: TabPane
Creates a new menu for this pane.

Specified by:
createMenu in interface TabPane
Returns:
the new menu

destroyMenu

public void destroyMenu(TabMenu menu)
Description copied from interface: TabPane
Destroys menu which was created by this pane.

Specified by:
destroyMenu in interface TabPane
Parameters:
menu - a menu to destroy

addToMenu

protected abstract void addToMenu(M menu,
                                  Dockable dockable)
Adds dockable somewhere to menu

Parameters:
menu - a menu of this pane
dockable - a new child of menu

removeFromMenu

protected abstract void removeFromMenu(M menu,
                                       Dockable dockable)
Removes dockable from menu.

Parameters:
menu - some menu of this pane
dockable - a child of menu

newTab

protected abstract T newTab(Dockable dockable)
Creates a new Tab that has this as parent and represents dockable. The new tab should not be stored in any collection.

Parameters:
dockable - the element for which a new tab is required
Returns:
the new tab

newMenu

public abstract M newMenu()
Creates a new TabMenu that has this as parent.

Returns:
the new menu

tabRemoved

protected abstract void tabRemoved(T tab)
Informs this pane that tab will never be used again and all resources associated with tab should be freed. This method is only called if tab is invisible.

Parameters:
tab - the tab to destroy

menuRemoved

protected abstract void menuRemoved(M menu)
Informs this pane that menu will never be used again and all resources associated with menu should be freed. This method is only called if menu is invisible.

Parameters:
menu - the destroyed menu