org.araneaframework.uilib.tab
Class TabContainerWidget

java.lang.Object
  extended by org.araneaframework.core.BaseComponent
      extended by org.araneaframework.core.BaseService
          extended by org.araneaframework.core.BaseWidget
              extended by org.araneaframework.core.BaseApplicationWidget
                  extended by org.araneaframework.uilib.tab.TabContainerWidget
All Implemented Interfaces:
Serializable, Component, Composite, Composite.CompositeComponent, Composite.CompositeService, Composite.CompositeWidget, ApplicationComponent, ApplicationService, ApplicationWidget, Service, TabContainerContext, TabRegistrationContext, Viewable, Viewable.ViewableComponent, Viewable.ViewableService, Viewable.ViewableWidget, Widget

public class TabContainerWidget
extends BaseApplicationWidget
implements TabContainerContext, TabRegistrationContext

This class represents a UI widget that contains tabs (TabWidget)s. Only one tab can be selected (active) at a time, such tab is specified with selectTab(String). When on creation the selected tab is not specified, the first tab is marked as selected. Tabs are added with addTab(String, String, Widget), removed with removeTab(String) and disabled (user cannot select them) with disableTab(String). By default tabs preserve the addition order and are also presented in that order. When this TabContainerWidget has a Comparator set, it will sort and present the tabs in an order specified by that Comparator.

Since:
1.1
Author:
Taimo Peelo (taimo@araneaframework.org)
See Also:
Serialized Form

Nested Class Summary
protected  class TabContainerWidget.ComponentImpl
           
protected  class TabContainerWidget.SelectionEventListener
          Tab selection listener.
 class TabContainerWidget.TabSwitchClosure
          This closure handles tab switching of this instance of TabContainerWidget.
 
Nested classes/interfaces inherited from class org.araneaframework.core.BaseApplicationWidget
BaseApplicationWidget.CompositeImpl, BaseApplicationWidget.ViewableImpl, BaseApplicationWidget.ViewModel
 
Nested classes/interfaces inherited from class org.araneaframework.core.BaseWidget
BaseWidget.WidgetImpl
 
Nested classes/interfaces inherited from class org.araneaframework.core.BaseService
BaseService.ServiceImpl
 
Nested classes/interfaces inherited from interface org.araneaframework.uilib.tab.TabContainerContext
TabContainerContext.TabSwitchListener
 
Nested classes/interfaces inherited from interface org.araneaframework.core.ApplicationWidget
ApplicationWidget.WidgetViewModel
 
Nested classes/interfaces inherited from interface org.araneaframework.core.ApplicationService
ApplicationService.ServiceViewModel
 
Nested classes/interfaces inherited from interface org.araneaframework.core.ApplicationComponent
ApplicationComponent.ComponentViewModel
 
Nested classes/interfaces inherited from interface org.araneaframework.Composite
Composite.CompositeComponent, Composite.CompositeService, Composite.CompositeWidget
 
Nested classes/interfaces inherited from interface org.araneaframework.Viewable
Viewable.ViewableComponent, Viewable.ViewableService, Viewable.ViewableWidget
 
Nested classes/interfaces inherited from interface org.araneaframework.Widget
Widget.Interface
 
Field Summary
protected  String defaultSelectedTabId
           
protected  boolean dying
          This is just to make sure that we do not initialize ANY tabs after destroying process has already begun.
protected  TabWidget selected
           
static String TAB_SELECT_EVENT_ID
           
protected  Map tabs
           
protected  TabContainerContext.TabSwitchListener tabSwitchListener
           
 
Fields inherited from class org.araneaframework.core.BaseService
currentInputData, currentOutputData
 
Fields inherited from interface org.araneaframework.core.ApplicationWidget
EVENT_HANDLER_ID_KEY, EVENT_PARAMETER_KEY, EVENT_PATH_KEY
 
Fields inherited from interface org.araneaframework.core.ApplicationService
ACTION_HANDLER_ID_KEY, ACTION_PARAMETER_KEY, ACTION_PATH_KEY
 
Constructor Summary
TabContainerWidget()
           
TabContainerWidget(Comparator comparator)
           
 
Method Summary
 Component.Interface _getComponent()
          The factory method returning the implementation of the Component.
 void addTab(String id, String labelId, Widget contentWidget)
          Adds the stateful tab with specified identifier.
 void addTab(String id, String labelId, WidgetFactory contentWidgetFactory)
          Adds the stateless (content widget is destroyed when tab is deselected) tab with specified identifier.
 void addTab(String id, Widget labelWidget, Widget contentWidget)
          Adds the stateful tab with specified identifier.
 void addTab(String id, Widget labelWidget, WidgetFactory contentWidgetFactory)
          Adds the stateless (content widget is destroyed when tab is deselected) tab with specified identifier.
 boolean disableTab(String id)
          Disables the tab with given id — the label be shown but tab cannot be selected before it is enabled again.
 void disableWidget(Object key)
          Overrides for disableWidget()/enableWidget()
 boolean enableTab(String id)
          Enables the tab with the id that previously was disabled.
 void enableWidget(Object key)
          Enables the widget with the specified key.
protected  Environment getChildWidgetEnvironment()
          Returns the widget's Environment by default.
 String getDefaultSelectedTabId()
          Provides the current default ID of a tab that will be automatically selected once added.
 TabContext getSelectedTab()
          Returns the currently selected tab widget, which is the container for the widget that was added using the addTab(..) method.
 Map getTabs()
          Returns all the tabs present in this TabContainerContext.
 TabContainerContext.TabSwitchListener getTabSwitchListener()
          Returns the current listener for tab switch events.
 boolean isTabSelected(String id)
          Specifies whether the specified tab is currently active (selected).
 TabWidget registerTab(TabWidget tabWidget)
          Invoked by TabWidget when it is initialized.
 boolean removeTab(String id)
          Removes tab with given id.
protected  void selectFirst()
           
 boolean selectTab(String id)
          Switches selected tab to one identified by id.
 void setDefaultSelectedTabId(String defaultSelectedTabId)
          Sets a default ID of a tab that will be automatically selected once added.
 void setTabSwitchListener(TabContainerContext.TabSwitchListener tabSwitchListener)
          Sets the listener for tab switch events.
 TabWidget unregisterTab(TabWidget tabWidget)
          Invoked by TabWidget when it is destroyed.
 
Methods inherited from class org.araneaframework.core.BaseApplicationWidget
_getComposite, _getViewable, action, addActionListener, addEventListener, addWidget, addWidget, clearActionListeners, clearEventlisteners, clearGlobalEventListener, event, getActionId, getChildEnvironment, getChildren, getEnvironment, getEventId, getViewModel, getWidget, handleAction, handleEvent, handleUpdate, propagate, putViewData, putViewDataOnce, removeActionListener, removeEventListener, removeViewData, removeWidget, render, setGlobalEventListener, update
 
Methods inherited from class org.araneaframework.core.BaseWidget
_getWidget, getInputData, getOutputData, handleWidgetException
 
Methods inherited from class org.araneaframework.core.BaseService
_getService, handleServiceException
 
Methods inherited from class org.araneaframework.core.BaseComponent
_addComponent, _addComponent, _checkCall, _disableComponent, _enableComponent, _endCall, _endWaitingCall, _getChildren, _getDisabledChildren, _propagate, _relocateComponent, _removeComponent, _setEnvironment, _setScope, _startCall, _startWaitingCall, _strictCheckCall, _strictStartCall, _waitNoCall, destroy, disable, enable, getScope, handleException, init, isAlive, isDead, isInitialized
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.araneaframework.Widget
_getWidget
 
Methods inherited from interface org.araneaframework.Service
_getService
 
Methods inherited from interface org.araneaframework.Component
getScope, isAlive
 

Field Detail

TAB_SELECT_EVENT_ID

public static final String TAB_SELECT_EVENT_ID
See Also:
Constant Field Values

tabs

protected Map tabs

selected

protected TabWidget selected

defaultSelectedTabId

protected String defaultSelectedTabId

tabSwitchListener

protected TabContainerContext.TabSwitchListener tabSwitchListener

dying

protected transient boolean dying
This is just to make sure that we do not initialize ANY tabs after destroying process has already begun.

Constructor Detail

TabContainerWidget

public TabContainerWidget()

TabContainerWidget

public TabContainerWidget(Comparator comparator)
Method Detail

getChildWidgetEnvironment

protected Environment getChildWidgetEnvironment()
                                         throws Exception
Description copied from class: BaseApplicationWidget
Returns the widget's Environment by default. Usually overridden.

Overrides:
getChildWidgetEnvironment in class BaseApplicationWidget
Throws:
Exception

selectFirst

protected void selectFirst()

addTab

public void addTab(String id,
                   String labelId,
                   Widget contentWidget)
Description copied from interface: TabContainerContext
Adds the stateful tab with specified identifier.

Specified by:
addTab in interface TabContainerContext
Parameters:
id - tab identifier
labelId - key to resource text to be used as tab label
contentWidget - tab's content widget

addTab

public void addTab(String id,
                   String labelId,
                   WidgetFactory contentWidgetFactory)
Description copied from interface: TabContainerContext
Adds the stateless (content widget is destroyed when tab is deselected) tab with specified identifier.

Specified by:
addTab in interface TabContainerContext
Parameters:
id - tab identifier
labelId - key to resource text to be used as tab label
contentWidgetFactory - WidgetFactory that produces tab's contents.

addTab

public void addTab(String id,
                   Widget labelWidget,
                   Widget contentWidget)
Description copied from interface: TabContainerContext
Adds the stateful tab with specified identifier.

Specified by:
addTab in interface TabContainerContext
Parameters:
id - tab identifier
labelWidget - tab's label widget
contentWidget - tab's content widget

addTab

public void addTab(String id,
                   Widget labelWidget,
                   WidgetFactory contentWidgetFactory)
Description copied from interface: TabContainerContext
Adds the stateless (content widget is destroyed when tab is deselected) tab with specified identifier.

Specified by:
addTab in interface TabContainerContext
Parameters:
id - tab identifier
labelWidget - tab's label widget

disableTab

public boolean disableTab(String id)
Description copied from interface: TabContainerContext
Disables the tab with given id — the label be shown but tab cannot be selected before it is enabled again.

Specified by:
disableTab in interface TabContainerContext
Returns:
whether tab with given id existed

enableTab

public boolean enableTab(String id)
Description copied from interface: TabContainerContext
Enables the tab with the id that previously was disabled.

Specified by:
enableTab in interface TabContainerContext
Returns:
whether the tab with given id existed.

removeTab

public boolean removeTab(String id)
Description copied from interface: TabContainerContext
Removes tab with given id.

Specified by:
removeTab in interface TabContainerContext
Returns:
whether the tab existed and was really removed

selectTab

public boolean selectTab(String id)
Description copied from interface: TabContainerContext
Switches selected tab to one identified by id.

Specified by:
selectTab in interface TabContainerContext
Returns:
whether tab with given id existed.

isTabSelected

public boolean isTabSelected(String id)
Description copied from interface: TabContainerContext
Specifies whether the specified tab is currently active (selected).

Specified by:
isTabSelected in interface TabContainerContext
Returns:
whether the specified tab is currently active (selected).

getSelectedTab

public TabContext getSelectedTab()
Description copied from interface: TabContainerContext
Returns the currently selected tab widget, which is the container for the widget that was added using the addTab(..) method.

Specified by:
getSelectedTab in interface TabContainerContext
Returns:
The currently selected TabContext.

getTabs

public Map getTabs()
Description copied from interface: TabContainerContext
Returns all the tabs present in this TabContainerContext. Keys in the map are tab identifiers, values are implementation dependent structures that hold tab information. Returned Map must be unmodifiable.

Specified by:
getTabs in interface TabContainerContext
Returns:
A map of tabs.

getDefaultSelectedTabId

public String getDefaultSelectedTabId()
Provides the current default ID of a tab that will be automatically selected once added. A null value means that no default ID is used.

Returns:
The ID of the tab that will be auomatically selected.
Since:
1.2.1

setDefaultSelectedTabId

public void setDefaultSelectedTabId(String defaultSelectedTabId)
Sets a default ID of a tab that will be automatically selected once added. A null value means that no default ID is used. Should be called before tabs are added.

Parameters:
defaultSelectedTabId -
Since:
1.2.1
See Also:
selectTab(String)

setTabSwitchListener

public void setTabSwitchListener(TabContainerContext.TabSwitchListener tabSwitchListener)
Description copied from interface: TabContainerContext
Sets the listener for tab switch events. There can be only one listener per tab container. The tabSwitchListener parameter cannot be null. Tab switch occurs when the currently selected tab changes.

Specified by:
setTabSwitchListener in interface TabContainerContext
Parameters:
tabSwitchListener - A listener for listening tab switch events.

getTabSwitchListener

public TabContainerContext.TabSwitchListener getTabSwitchListener()
Description copied from interface: TabContainerContext
Returns the current listener for tab switch events.

Specified by:
getTabSwitchListener in interface TabContainerContext
Returns:
the current listener for tab switch events.

registerTab

public TabWidget registerTab(TabWidget tabWidget)
Description copied from interface: TabRegistrationContext
Invoked by TabWidget when it is initialized.

Specified by:
registerTab in interface TabRegistrationContext
See Also:
TabRegistrationContext.registerTab(org.araneaframework.uilib.tab.TabWidget)

unregisterTab

public TabWidget unregisterTab(TabWidget tabWidget)
Description copied from interface: TabRegistrationContext
Invoked by TabWidget when it is destroyed.

Specified by:
unregisterTab in interface TabRegistrationContext
See Also:
TabRegistrationContext.unregisterTab(org.araneaframework.uilib.tab.TabWidget)

disableWidget

public void disableWidget(Object key)
Overrides for disableWidget()/enableWidget()

Overrides:
disableWidget in class BaseApplicationWidget

enableWidget

public void enableWidget(Object key)
Description copied from class: BaseApplicationWidget
Enables the widget with the specified key. Only a disabled widgets can be enabled.

Overrides:
enableWidget in class BaseApplicationWidget

_getComponent

public Component.Interface _getComponent()
Description copied from interface: Component
The factory method returning the implementation of the Component.

Specified by:
_getComponent in interface Component
Overrides:
_getComponent in class BaseComponent
Returns:
the implementation of the Component.