|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.vaadin.ui.AbstractComponent
com.vaadin.ui.AbstractComponentContainer
com.vaadin.ui.TabSheet
public class TabSheet
TabSheet component.
Tabs are typically identified by the component contained on the tab (see
ComponentContainer
), and tab metadata (including caption, icon,
visibility, enabledness, closability etc.) is kept in separate TabSheet.Tab
instances.
Tabs added with addComponent(Component)
get the caption and the icon
of the component at the time when the component is created, and these are not
automatically updated after tab creation.
A tab sheet can have multiple tab selection listeners and one tab close
handler (TabSheet.CloseHandler
), which by default removes the tab from the
TabSheet.
The TabSheet
can be styled with the .v-tabsheet, .v-tabsheet-tabs and
.v-tabsheet-content styles. Themes may also have pre-defined variations of
the tab sheet presentation, such as Reindeer.TABSHEET_BORDERLESS
,
Runo.TABSHEET_SMALL
and several other styles in Reindeer
.
The current implementation does not load the tabs to the UI before the first
time they are shown, but this may change in future releases.
Nested Class Summary | |
---|---|
static interface |
TabSheet.CloseHandler
CloseHandler is used to process tab closing events. |
class |
TabSheet.SelectedTabChangeEvent
Selected tab change event. |
static interface |
TabSheet.SelectedTabChangeListener
Selected tab change event listener. |
static interface |
TabSheet.Tab
Tab meta-data for a component in a TabSheet . |
class |
TabSheet.TabSheetTabImpl
TabSheet's implementation of TabSheet.Tab - tab metadata. |
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractComponent |
---|
AbstractComponent.ComponentErrorEvent, AbstractComponent.ComponentErrorHandler |
Nested classes/interfaces inherited from interface com.vaadin.ui.Component |
---|
Component.ErrorEvent, Component.ErrorListener, Component.Event, Component.Focusable, Component.Listener |
Nested classes/interfaces inherited from interface com.vaadin.terminal.Paintable |
---|
Paintable.RepaintRequestEvent, Paintable.RepaintRequestListener |
Nested classes/interfaces inherited from interface com.vaadin.ui.ComponentContainer |
---|
ComponentContainer.ComponentAttachEvent, ComponentContainer.ComponentAttachListener, ComponentContainer.ComponentDetachEvent, ComponentContainer.ComponentDetachListener |
Field Summary |
---|
Fields inherited from interface com.vaadin.terminal.Sizeable |
---|
SIZE_UNDEFINED, UNIT_SYMBOLS, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS |
Constructor Summary | |
---|---|
TabSheet()
Constructs a new Tabsheet. |
Method Summary | |
---|---|
void |
addComponent(Component c)
Adds a new tab into TabSheet. |
void |
addListener(FieldEvents.BlurListener listener)
Adds a BlurListener to the Component which gets fired
when a Field loses keyboard focus. |
void |
addListener(FieldEvents.FocusListener listener)
Adds a FocusListener to the Component which gets fired
when a Field receives keyboard focus. |
void |
addListener(TabSheet.SelectedTabChangeListener listener)
Adds a tab selection listener |
TabSheet.Tab |
addTab(Component c)
Adds a new tab into TabSheet. |
TabSheet.Tab |
addTab(Component c,
int position)
Adds a new tab into TabSheet. |
TabSheet.Tab |
addTab(Component c,
String caption)
Adds a new tab into TabSheet. |
TabSheet.Tab |
addTab(Component c,
String caption,
Resource icon)
Adds a new tab into TabSheet. |
TabSheet.Tab |
addTab(Component c,
String caption,
Resource icon,
int position)
Adds a new tab into TabSheet. |
boolean |
areTabsHidden()
Are the tab selection parts ("tabs") hidden. |
void |
changeVariables(Object source,
Map<String,Object> variables)
Called when one or more variables handled by the implementing class are changed. |
protected void |
fireSelectedTabChange()
Sends an event that the currently selected tab has changed. |
void |
focus()
Sets the focus for this component if the component is Focusable . |
int |
getComponentCount()
Gets the number of contained components (tabs). |
Iterator<Component> |
getComponentIterator()
Gets the component container iterator for going through all the components (tab contents). |
Component |
getSelectedTab()
Gets the selected tab content component. |
TabSheet.Tab |
getTab(Component c)
Returns the TabSheet.Tab (metadata) for a component. |
TabSheet.Tab |
getTab(int position)
Returns the TabSheet.Tab (metadata) for a component. |
String |
getTabCaption(Component c)
Deprecated. Use getTab(Component) and TabSheet.Tab.getCaption()
instead. |
Resource |
getTabIcon(Component c)
Deprecated. Use getTab(Component) and TabSheet.Tab.getIcon()
instead. |
int |
getTabIndex()
Gets the tabulator index of the Focusable component. |
int |
getTabPosition(TabSheet.Tab tab)
Gets the position of the tab |
void |
hideTabs(boolean tabsHidden)
Hides or shows the tab selection parts ("tabs"). |
void |
moveComponentsFrom(ComponentContainer source)
Moves all components from another container to this container. |
void |
paintContent(PaintTarget target)
Paints the content of this component. |
void |
removeComponent(Component c)
Removes a component and its corresponding tab. |
void |
removeListener(FieldEvents.BlurListener listener)
Removes a BlurListener from the Component. |
void |
removeListener(FieldEvents.FocusListener listener)
Removes a FocusListener from the Component. |
void |
removeListener(Paintable.RepaintRequestListener listener)
Removes repaint request listener. |
void |
removeListener(TabSheet.SelectedTabChangeListener listener)
Removes a tab selection listener |
void |
removeTab(TabSheet.Tab tab)
Removes a TabSheet.Tab and the component associated with it, as previously
added with addTab(Component) ,
addTab(Component, String, Resource) or
addComponent(Component) . |
void |
replaceComponent(Component oldComponent,
Component newComponent)
Replaces a component (tab content) with another. |
void |
setCloseHandler(TabSheet.CloseHandler handler)
Provide a custom TabSheet.CloseHandler for this TabSheet if you wish to
perform some additional tasks when a user clicks on a tabs close button,
e.g. |
void |
setSelectedTab(Component c)
Sets the selected tab. |
void |
setSelectedTab(int position)
Sets the selected tab, identified by its position. |
void |
setSelectedTab(TabSheet.Tab tab)
Sets the selected tab. |
void |
setTabCaption(Component c,
String caption)
Deprecated. Use getTab(Component) and
TabSheet.Tab.setCaption(String) instead. |
void |
setTabIcon(Component c,
Resource icon)
Deprecated. Use getTab(Component) and
TabSheet.Tab.setIcon(Resource) instead. |
void |
setTabIndex(int tabIndex)
Sets the tabulator index of the Focusable component. |
void |
setTabPosition(TabSheet.Tab tab,
int position)
Sets the position of the tab. |
Methods inherited from class com.vaadin.ui.AbstractComponentContainer |
---|
addListener, addListener, attach, detach, fireComponentAttachEvent, fireComponentDetachEvent, removeAllComponents, removeListener, removeListener, requestRepaintAll, setEnabled, setHeight, setWidth |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.vaadin.ui.Component |
---|
addListener, addStyleName, attach, childRequestedRepaint, detach, getApplication, getCaption, getIcon, getLocale, getParent, getStyleName, getWindow, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setCaption, setEnabled, setIcon, setParent, setReadOnly, setStyleName, setVisible |
Methods inherited from interface com.vaadin.terminal.Paintable |
---|
addListener, getDebugId, paint, requestRepaint, requestRepaintRequests, setDebugId |
Methods inherited from interface com.vaadin.terminal.VariableOwner |
---|
isImmediate |
Methods inherited from interface com.vaadin.terminal.Sizeable |
---|
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeight, setHeightUnits, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidth, setWidthUnits |
Constructor Detail |
---|
public TabSheet()
Method Detail |
---|
public Iterator<Component> getComponentIterator()
getComponentIterator
in interface ComponentContainer
public int getComponentCount()
getComponentIterator()
.
public void removeComponent(Component c)
removeComponent
in interface ComponentContainer
removeComponent
in class AbstractComponentContainer
c
- the component to be removed.ComponentContainer.removeComponent(Component)
public void removeTab(TabSheet.Tab tab)
TabSheet.Tab
and the component associated with it, as previously
added with addTab(Component)
,
addTab(Component, String, Resource)
or
addComponent(Component)
.
If the tab was selected, the first eligible (visible and enabled) remaining tab is selected.
tab
- the Tab to removeaddTab(Component)
,
addTab(Component, String, Resource)
,
addComponent(Component)
,
removeComponent(Component)
public void addComponent(Component c)
addComponent
in interface ComponentContainer
addComponent
in class AbstractComponentContainer
c
- the component to be added.addTab(Component)
public TabSheet.Tab addTab(Component c, String caption)
c
- the component to be added onto tab - should not be null.caption
- the caption to be set for the component and used rendered in
tab bar
TabSheet.Tab
public TabSheet.Tab addTab(Component c, String caption, Resource icon)
c
- the component to be added onto tab - should not be null.caption
- the caption to be set for the component and used rendered in
tab baricon
- the icon to be set for the component and used rendered in tab
bar
TabSheet.Tab
public TabSheet.Tab addTab(Component c, String caption, Resource icon, int position)
c
- the component to be added onto tab - should not be null.caption
- the caption to be set for the component and used rendered in
tab baricon
- the icon to be set for the component and used rendered in tab
barposition
- the position at where the the tab should be added.
TabSheet.Tab
public TabSheet.Tab addTab(Component c)
c
- the component to be added onto tab - should not be null.
TabSheet.Tab
public TabSheet.Tab addTab(Component c, int position)
c
- the component to be added onto tab - should not be null.position
- The position where the tab should be added
TabSheet.Tab
public void moveComponentsFrom(ComponentContainer source)
TabSheet
, component captions and
icons are copied from it.
moveComponentsFrom
in interface ComponentContainer
moveComponentsFrom
in class AbstractComponentContainer
source
- the container components are removed from.public void paintContent(PaintTarget target) throws PaintException
paintContent
in class AbstractComponent
target
- the paint target
PaintException
- if the paint operation failed.public boolean areTabsHidden()
public void hideTabs(boolean tabsHidden)
tabsHidden
- true if the tabs should be hidden@Deprecated public String getTabCaption(Component c)
getTab(Component)
and TabSheet.Tab.getCaption()
instead.
c
- the component in the tab@Deprecated public void setTabCaption(Component c, String caption)
getTab(Component)
and
TabSheet.Tab.setCaption(String)
instead.
c
- the component in the tabcaption
- the caption to set.@Deprecated public Resource getTabIcon(Component c)
getTab(Component)
and TabSheet.Tab.getIcon()
instead.
c
- the component in the tab@Deprecated public void setTabIcon(Component c, Resource icon)
getTab(Component)
and
TabSheet.Tab.setIcon(Resource)
instead.
c
- the component in the tabicon
- the icon to setpublic TabSheet.Tab getTab(Component c)
TabSheet.Tab
(metadata) for a component. The TabSheet.Tab
object can be used for setting caption,icon, etc for the tab.
c
- the component
public TabSheet.Tab getTab(int position)
TabSheet.Tab
(metadata) for a component. The TabSheet.Tab
object can be used for setting caption,icon, etc for the tab.
position
- the position of the tab
public void setSelectedTab(Component c)
c
- public void setSelectedTab(TabSheet.Tab tab)
Tab
instance. Does nothing if the tabsheet doesn't contain
the given tab.
tab
- public void setSelectedTab(int position)
position
- public Component getSelectedTab()
public void changeVariables(Object source, Map<String,Object> variables)
VariableOwner
changeVariables
in interface VariableOwner
changeVariables
in class AbstractComponent
source
- the Source of the variable change. This is the origin of the
event. For example in Web Adapter this is the request.variables
- the Mapping from variable names to new variable values.public void replaceComponent(Component oldComponent, Component newComponent)
TabSheet
.
If the oldComponent is not present in the tab sheet, the new one is added
at the end.
If the oldComponent is already in the tab sheet but the newComponent
isn't, the old tab is replaced with a new one, and the caption and icon
of the old one are copied to the new tab.
If both old and new components are present, their positions are swapped.
Replaces the component in the container with another one without changing
position.
This method replaces component with another one is such way that the new component overtakes the position of the old component. If the old component is not in the container, the new component is added to the container. If the both component are already in the container, their positions are swapped. Component attach and detach events should be taken care as with add and remove.
replaceComponent
in interface ComponentContainer
oldComponent
- the old component that will be replaced.newComponent
- the new component to be replaced.public void addListener(TabSheet.SelectedTabChangeListener listener)
listener
- the Listener to be added.public void removeListener(TabSheet.SelectedTabChangeListener listener)
listener
- the Listener to be removed.protected void fireSelectedTabChange()
public void removeListener(Paintable.RepaintRequestListener listener)
Paintable
removeListener
in interface Paintable
removeListener
in class AbstractComponent
listener
- the listener to be removed.public void setCloseHandler(TabSheet.CloseHandler handler)
TabSheet.CloseHandler
for this TabSheet if you wish to
perform some additional tasks when a user clicks on a tabs close button,
e.g. show a confirmation dialogue before removing the tab.
To remove the tab, if you provide your own close handler, you must call
removeComponent(Component)
yourself.
The default CloseHandler for TabSheet will only remove the tab.
handler
- public void setTabPosition(TabSheet.Tab tab, int position)
tab
- The tabposition
- The new position of the tabpublic int getTabPosition(TabSheet.Tab tab)
tab
- The tab
public void focus()
AbstractComponent
Focusable
.
focus
in interface Component.Focusable
focus
in class AbstractComponent
FieldEvents
,
FieldEvents.FocusEvent
,
FieldEvents.FocusListener
,
FieldEvents.BlurEvent
,
FieldEvents.BlurListener
public int getTabIndex()
Component.Focusable
Focusable
component.
getTabIndex
in interface Component.Focusable
Focusable
componentComponent.Focusable.setTabIndex(int)
public void setTabIndex(int tabIndex)
Component.Focusable
Focusable
component.
The tab index property is used to specify the order in which the
fields are focused when the user presses the Tab key. Components with
a defined tab index are focused sequentially first, and then the
components with no tab index.
Form loginBox = new Form(); loginBox.setCaption("Login"); layout.addComponent(loginBox); // Create the first field which will be focused TextField username = new TextField("User name"); loginBox.addField("username", username); // Set focus to the user name username.focus(); TextField password = new TextField("Password"); loginBox.addField("password", password); Button login = new Button("Login"); loginBox.getFooter().addComponent(login); // An additional component which natural focus order would // be after the button. CheckBox remember = new CheckBox("Remember me"); loginBox.getFooter().addComponent(remember); username.setTabIndex(1); password.setTabIndex(2); remember.setTabIndex(3); // Different than natural place login.setTabIndex(4);
After all focusable user interface components are done, the browser can begin again from the component with the smallest tab index, or it can take the focus out of the page, for example, to the location bar.
If the tab index is not set (is set to zero), the default tab order is used. The order is somewhat browser-dependent, but generally follows the HTML structure of the page.
A negative value means that the component is completely removed from the tabulation order and can not be reached by pressing the Tab key at all.
setTabIndex
in interface Component.Focusable
tabIndex
- the tab order of this component. Indexes usually start
from 1. Zero means that default tab order should be used.
A negative value means that the field should not be
included in the tabbing sequence.Component.Focusable.getTabIndex()
public void addListener(FieldEvents.BlurListener listener)
FieldEvents.BlurNotifier
BlurListener
to the Component which gets fired
when a Field
loses keyboard focus.
addListener
in interface FieldEvents.BlurNotifier
FieldEvents.BlurListener
public void removeListener(FieldEvents.BlurListener listener)
FieldEvents.BlurNotifier
BlurListener
from the Component.
removeListener
in interface FieldEvents.BlurNotifier
FieldEvents.BlurListener
public void addListener(FieldEvents.FocusListener listener)
FieldEvents.FocusNotifier
FocusListener
to the Component which gets fired
when a Field
receives keyboard focus.
addListener
in interface FieldEvents.FocusNotifier
FieldEvents.FocusListener
public void removeListener(FieldEvents.FocusListener listener)
FieldEvents.FocusNotifier
FocusListener
from the Component.
removeListener
in interface FieldEvents.FocusNotifier
FieldEvents.FocusListener
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |