|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecteu.webtoolkit.jwt.WObject
eu.webtoolkit.jwt.WWidget
eu.webtoolkit.jwt.WCompositeWidget
eu.webtoolkit.jwt.WTabWidget
public class WTabWidget
A widget that organizes contents in tab panes.
This widget combines a horizontal WMenu with a WStackedWidget
, and a tab-like look.
A tab widget will place the tab bar on top of the contents, and fit the contents below it.
Usage example:
{
@code
WTabWidget examples = new WTabWidget(this);
examples.addTab(helloWorldExample(), "Hello World");
examples.addTab(chartExample(), "Charts");
examples.addTab(new WText("A WText"), "WText");
examples.currentChanged().addListener(this, new Signal.Listener() {
public void trigger() {
//custom code
}
});
examples.setInternalPathEnabled();
examples.setInternalBasePath("/examples");
}
The tab widget is styled by the current CSS theme. The look (of the header)
can be overridden using the Wt-tabs CSS class and the following
selectors:
.Wt-tabs ul : the list .Wt-tabs li : a list item .Wt-tabs span : outer span of a list item .Wt-span span span : inner span of a list item
An example WTabWidget (default) |
An example WTabWidget (polished) |
| Nested Class Summary | |
|---|---|
static class |
WTabWidget.LoadPolicy
When should the contents be loaded ? |
| Constructor Summary | |
|---|---|
WTabWidget()
Creates a new tab widget. |
|
WTabWidget(java.util.EnumSet<AlignmentFlag> layoutAlignment)
Creates a new tab widget (indicating layout alignment) (deprecated). |
|
WTabWidget(java.util.EnumSet<AlignmentFlag> layoutAlignment,
WContainerWidget parent)
Deprecated. Since JWt 3.1.1, the layoutAlignment is no
longer needed and its value is ignored |
|
WTabWidget(WContainerWidget parent)
Creates a new tab widget. |
|
| Method Summary | |
|---|---|
WMenuItem |
addTab(WWidget child,
java.lang.CharSequence label)
Adds a new tab, with child as content, and the given label. |
WMenuItem |
addTab(WWidget child,
java.lang.CharSequence label,
WTabWidget.LoadPolicy loadPolicy)
Adds a new tab, with child as content, and the given label. |
void |
closeTab(int index)
Closes a tab at index. |
Signal1<java.lang.Integer> |
currentChanged()
Signal emitted when the user activates a tab. |
WStackedWidget |
getContentsStack()
Returns the contents stack. |
int |
getCount()
Returns the number of tabs. |
int |
getCurrentIndex()
Returns the index of the activated tab. |
WWidget |
getCurrentWidget()
Returns the widget of the activated tab. |
int |
getIndexOf(WWidget widget)
Returns the index of the tab of the given content widget. |
java.lang.String |
getInternalBasePath()
Returns the internal base path. |
WString |
getTabText(int index)
Returns the label for a tab. |
WString |
getTabToolTip(int index)
Returns the tooltip for a tab. |
WWidget |
getWidget(int index)
Returns the content widget at the given tab index. |
boolean |
isInternalPathEnabled()
Returns whether internal paths are enabled. |
boolean |
isTabCloseable(int index)
Returns whether a tab is closeable. |
boolean |
isTabEnabled(int index)
Returns whether a tab is enabled. |
boolean |
isTabHidden(int index)
Returns whether a tab is hidden. |
void |
removeTab(WWidget child)
Removes a tab item. |
void |
setCurrentIndex(int index)
Activates the tab at index. |
void |
setCurrentWidget(WWidget widget)
Activates the tab showing the given widget. |
void |
setInternalBasePath(java.lang.String path)
Sets the internal base path. |
void |
setInternalPathEnabled()
Enables internal paths for items. |
void |
setInternalPathEnabled(java.lang.String basePath)
Enables internal paths for items. |
void |
setTabCloseable(int index,
boolean closeable)
Make it possible to close a tab interactively or by closeTab. |
void |
setTabEnabled(int index,
boolean enable)
Enables or disables a tab. |
void |
setTabHidden(int index,
boolean hidden)
Hides or shows a tab. |
void |
setTabText(int index,
java.lang.CharSequence label)
Changes the label for a tab. |
void |
setTabToolTip(int index,
java.lang.CharSequence tip)
Sets the tooltip for a tab. |
Signal1<java.lang.Integer> |
tabClosed()
Signal emitted when the user closes a tab. |
| Methods inherited from class eu.webtoolkit.jwt.WWidget |
|---|
acceptDrops, acceptDrops, addCssRule, addCssRule, addStyleClass, animateHide, animateShow, containsExposed, disable, dropEvent, enable, getDrop, getJsRef, getParent, hide, htmlText, isLayoutSizeAware, isRendered, layoutSizeChanged, positionAt, positionAt, removeStyleClass, resize, setClearSides, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr |
| Methods inherited from class eu.webtoolkit.jwt.WObject |
|---|
addChild, getObjectName, setObjectName |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public WTabWidget(WContainerWidget parent)
public WTabWidget()
Calls this((WContainerWidget)null)
public WTabWidget(java.util.EnumSet<AlignmentFlag> layoutAlignment,
WContainerWidget parent)
layoutAlignment is no
longer needed and its value is ignored
public WTabWidget(java.util.EnumSet<AlignmentFlag> layoutAlignment)
Calls this(layoutAlignment, (WContainerWidget)null)
| Method Detail |
|---|
public WMenuItem addTab(WWidget child,
java.lang.CharSequence label,
WTabWidget.LoadPolicy loadPolicy)
Returns the menu item that implements the tab item.
public final WMenuItem addTab(WWidget child,
java.lang.CharSequence label)
Returns
addTab(child, label, WTabWidget.LoadPolicy.LazyLoading)
public void removeTab(WWidget child)
The widget itself is not deleted.
WMenu.removeItem(WMenuItem item)public int getCount()
public WWidget getWidget(int index)
public int getIndexOf(WWidget widget)
If the widget is not in this tab widget, then -1 is returned.
public void setCurrentIndex(int index)
public int getCurrentIndex()
public void setCurrentWidget(WWidget widget)
public WWidget getCurrentWidget()
public void setTabEnabled(int index,
boolean enable)
Enables or disables the tab at index. A disabled tab cannot
be activated.
public boolean isTabEnabled(int index)
public void setTabHidden(int index,
boolean hidden)
Hides or shows the tab at index.
public boolean isTabHidden(int index)
public void setTabCloseable(int index,
boolean closeable)
closeTab.
A tab that has been closed is marked as hidden, but not removed from the menu.
removeTab(WWidget child)public boolean isTabCloseable(int index)
setTabCloseable(int index, boolean closeable)
public void setTabText(int index,
java.lang.CharSequence label)
public WString getTabText(int index)
setTabText(int index, CharSequence label)
public void setTabToolTip(int index,
java.lang.CharSequence tip)
The tooltip is shown when the user hovers over the label.
public WString getTabToolTip(int index)
setTabToolTip(int index, CharSequence tip)public void setInternalPathEnabled(java.lang.String basePath)
The menu participates in the internal path by changing the internal path when an item has been selected, and listening for path changes to react to path selections. As a consequence this allows the user to bookmark the current menu selection and revisit it later, use back/forward buttons to navigate through history of visited menu items, and allows indexing of pages.
For each menu item, WMenuItem#getPathComponent() is appended to the basePath,
which defaults to the internal path (
WApplication#getBookmarkUrl()). A
'/' is appended to the base path, to turn it into a folder, if
needed.
By default, menu interaction does not change the application internal path.
WMenuItem.setPathComponent(String path)public final void setInternalPathEnabled()
Calls setInternalPathEnabled("")
public boolean isInternalPathEnabled()
WMenu.setInternalPathEnabled(String basePath)public void setInternalBasePath(java.lang.String path)
A '/' is appended to turn it into a folder, if needed.
WMenu.setInternalPathEnabled(String basePath),
WMenu.getInternalBasePath()public java.lang.String getInternalBasePath()
The default value is the application's internalPath (
WApplication#getBookmarkUrl()) that
was recorded when WMenu#setInternalPathEnabled() was called, and together with each
WMenuItem#getPathComponent()
determines the paths for each item.
For example, if WMenu#getInternalBasePath() is "/examples/" and
pathComponent() for a particular item is "charts/"
, then the internal path for that item will be
"/examples/charts/".
WMenu.setInternalPathEnabled(String basePath)public Signal1<java.lang.Integer> currentChanged()
The index of the newly activated tab is passed as an argument.
public void closeTab(int index)
index.
A tab that has been closed is marked as hidden, but not removed from the menu.
removeTab(WWidget child),
setTabHidden(int index, boolean hidden)public Signal1<java.lang.Integer> tabClosed()
The index of the closed tab is passed as an argument.
closeTab(int index),
setTabCloseable(int index, boolean closeable)public WStackedWidget getContentsStack()
The tab widget is implemented as a WMenu + WStackedWidget
which displays the contents. This method returns a reference to this
contents stack.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||