T
- the kind of tabs this pane supportsM
- the kind of menus this pane supportsI
- the kind of info panel this pane supportspublic abstract class AbstractTabPane<T extends Tab,M extends TabMenu,I extends LonelyTabPaneComponent> extends Object implements TabPane
TabPane
. This class handles creation,
storage and destruction of Tab
s and TabMenu
s, it also stores
a list of currently visible Dockable
s.setController(DockController)
to make sure
this pane can use all available information.LAYOUT_MANAGER, USE_SMALL_MINIMUM_SIZE
Constructor and Description |
---|
AbstractTabPane() |
Modifier and Type | Method and Description |
---|---|
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 |
protected void |
clearTabs()
Removes all tabs from the internal data structure.
Subclasses may override this method to be informed about the exact time when a tab changes, but the overriden method must call the original method. |
TabMenu |
createMenu()
Creates a new menu for this pane.
|
void |
destroyMenu(TabMenu menu)
Destroys
menu which was created by
this pane. |
void |
discardComponentsAndRebuild()
|
void |
doLayout()
Updates the layout of this pane, assuming a
TabLayoutManager
is installed. |
protected void |
fireAdded(Dockable dockable)
Informs all
TabPaneListener s that dockable
has been added. |
protected void |
fireControllerChanged()
Informs all
TabPaneListener that the current DockController changed. |
protected void |
fireInfoComponentChanged(I oldInfo,
I newInfo)
Informs all
TabPaneListener s that the info component has been
replaced. |
protected void |
fireRemoved(Dockable dockable)
Informs all
TabPaneListener s that dockable
has been removed. |
protected void |
fireSelectionChanged()
Informs all
TabPaneListener s 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
Dockable s that are stored on this pane. |
TabPlacement |
getDockTabPlacement()
Tells at which side tabs are to be displayed.
|
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 required to have a big enough
TabPane.getAvailableArea() to show
all content. |
T |
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 required to have a big enough
TabPane.getAvailableArea() to show
all content. |
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 . |
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
TabPaneListener s 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)
|
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. |
protected T |
putTab(Dockable dockable,
T tab)
Associates
tab with dockable . |
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 . |
protected T |
removeTab(Dockable dockable)
Removes the tab of
dockable from the internal data structure. |
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 |
setDockTabPlacement(TabPlacement tabPlacement)
Tells this pane where to paint the tabs.
|
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. |
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. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAvailableArea, getMinimumSize, getPreferredSize, getSelectedBounds, setSelectedBounds
public void setController(DockController controller)
controller
.controller
- the realm in which this pane works, may be null
public DockController getController()
TabPane
DockController
this pane is associated with.getController
in interface TabPane
null
public void setDockTabPlacement(TabPlacement tabPlacement)
tabPlacement
- a side, not null
public TabPlacement getDockTabPlacement()
TabPane
TabLayoutManager
, but may be ignored.getDockTabPlacement
in interface TabPane
null
public void doLayout()
TabLayoutManager
is installed.public Dimension getMinimumSize()
TabPane.getAvailableArea()
to show
all content.public Dimension getPreferredSize()
TabPane.getAvailableArea()
to show
all content.public void revalidate()
doLayout()
. Subclasses may override to
update the layout lazily.public void addTabPaneListener(TabPaneListener listener)
TabPane
addTabPaneListener
in interface TabPane
listener
- the new listenerpublic void removeTabPaneListener(TabPaneListener listener)
TabPane
removeTabPaneListener
in interface TabPane
listener
- the listener to removeprotected TabPaneListener[] listeners()
TabPaneListener
s that are known to this TabPane
protected void fireSelectionChanged()
TabPaneListener
s that the selection changed.protected void fireAdded(Dockable dockable)
TabPaneListener
s that dockable
has been added.dockable
- the new childprotected void fireRemoved(Dockable dockable)
TabPaneListener
s that dockable
has been removed.dockable
- the removed childprotected void fireInfoComponentChanged(I oldInfo, I newInfo)
TabPaneListener
s that the info component has been
replaced.oldInfo
- the old info componentnewInfo
- the new info componentprotected void fireControllerChanged()
TabPaneListener
that the current DockController
changed.public TabLayoutManager getLayoutManager()
null
public void setLayoutManager(TabLayoutManager layoutManager)
null
will reinstall the default layout manager.layoutManager
- the new manager, may be null
public void insert(int index, Dockable dockable)
dockable
as child to this tab-pane.index
- the index of the new childdockable
- the new childpublic void move(int source, int destination)
source
to destination
.source
- where to find the element to movedestination
- the target locationpublic void remove(int index)
index
'th element of this pane.index
- the index of the element to removepublic void removeAll()
public void discardComponentsAndRebuild()
public Dockable getSelectedDockable()
TabPane
Dockable
on this pane (this
is the one child that is visible).getSelectedDockable
in interface TabPane
null
unless there are no
children at allpublic void setSelectedDockable(Dockable dockable)
dockable
of this pane as the one visible
element.setSelectedDockable
in interface TabPane
dockable
- the newly selected element, can be null
public Dockable[] getDockables()
TabPane
Dockable
s that are stored on this pane. The list
should be ordered.getDockables
in interface TabPane
null
but maybe emptypublic int getDockableCount()
public Dockable getDockable(int index)
index
'th element of this pane.index
- the index of an elementindex
public int indexOf(Dockable dockable)
dockable
on this pane.dockable
- the element to searchdockable
was not foundpublic Tab[] getTabs()
TabPane
getTabs
in interface TabPane
null
but maybe empty. Note
that the size of this array must be smaller or equal to the array returned
by TabPane.getDockables()
.public int indexOfVisible(Tab tab)
tab
following the indices of
Dockables
but ignoring invisible tabs.tab
- the tab to searchpublic T getVisibleTab(int index)
index
- the index of some visible tabnull
if index
is too big.IllegalArgumentException
- if index
is smaller than 0
.indexOfVisible(Tab)
public int getVisibleTabCount()
getVisibleTab(int)
public List<T> getTabsList()
public T getTab(Dockable dockable)
dockable
.dockable
- the element to searchnull
public T putOnTab(Dockable dockable)
TabPane
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.dockable
already is on a tab then this tab should be reused.public T getOnTab(Dockable dockable)
TabPane
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
.public void setInfoComponent(I info)
info
- the new component, can be null
getInfoComponent()
public I getInfoComponent()
TabPane
getInfoComponent
in interface TabPane
null
public List<M> getMenuList()
public TabMenu[] getMenus()
public M getMenu(Dockable dockable)
dockable
is shown.dockable
- some child of this panenull
public void putInMenu(TabMenu menu, Dockable dockable)
TabPane
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.putInMenu
in interface TabPane
menu
- a menu created by this TabPane
dockable
- some child of thisTabPane.putOnTab(Dockable)
public TabMenu createMenu()
TabPane
createMenu
in interface TabPane
public void destroyMenu(TabMenu menu)
TabPane
menu
which was created
by
this pane.destroyMenu
in interface TabPane
menu
- a menu to destroyprotected abstract void addToMenu(M menu, Dockable dockable)
dockable
somewhere to menu
menu
- a menu of this panedockable
- a new child of menu
protected abstract void removeFromMenu(M menu, Dockable dockable)
dockable
from menu
.menu
- some menu of this panedockable
- a child of menu
protected T putTab(Dockable dockable, T tab)
tab
with dockable
. this method
modifies the internal data structure in order to store the change.dockable
- the key for the tab-maptab
- the value for the tab-mapdockable
protected T removeTab(Dockable dockable)
dockable
from the internal data structure.dockable
- the key of the element to be removed from the tab-mapprotected void clearTabs()
protected abstract T newTab(Dockable dockable)
Tab
that has this
as parent and
represents dockable
. The new tab should not be stored in
any collection.dockable
- the element for which a new tab is requiredpublic abstract M newMenu()
TabMenu
that has this
as parent.protected abstract void tabRemoved(T tab)
tab
will never be used again and
all resources associated with tab
should be freed. This
method is only called if tab
is invisible.tab
- the tab to destroyprotected abstract void menuRemoved(M menu)
menu
will never be used again and
all resources associated with menu
should be freed. This
method is only called if menu
is invisible.menu
- the destroyed menu