API Reference 0.3.24dart_web_toolkit_uiTabLayoutPanel

TabLayoutPanel class

A panel that represents a tabbed set of pages, each of which contains another widget. Its child widgets are shown as the user selects the various tabs associated with them. The tabs can contain arbitrary text, HTML, or widgets.

This widget will only work in standards mode, which requires that the HTML page in which it is run have an explicit <!DOCTYPE> declaration.

CSS Style Rules

.gwt-TabLayoutPanel
the panel itself
.gwt-TabLayoutPanel .gwt-TabLayoutPanelTabs
the tab bar element
.gwt-TabLayoutPanel .gwt-TabLayoutPanelTab
an individual tab
.gwt-TabLayoutPanel .gwt-TabLayoutPanelTabInner
an element nested in each tab (useful for styling)
.gwt-TabLayoutPanel .gwt-TabLayoutPanelContent
applied to all child content widgets

Example

{@example com.google.gwt.examples.TabLayoutPanelExample}

Use in UiBinder Templates

A TabLayoutPanel element in a {@link com.google.gwt.uibinder.client.UiBinder UiBinder} template must have a barHeight attribute with a double value, and may have a barUnit attribute with a {@link com.google.gwt.dom.client.Style.Unit Style.Unit} value. barUnit defaults to PX.

The children of a TabLayoutPanel element are laid out in <g:tab> elements. Each tab can have one widget child and one of two types of header elements. A <g:header> element can hold html, or a <g:customHeader> element can hold a widget. (Note that the tags of the header elements are not capitalized. This is meant to signal that the head is not a runtime object, and so cannot have a ui:field attribute.)

For example:

<g:TabLayoutPanel barUnit='EM' barHeight='3'>
 <g:tab>
   <g:header size='7'><b>HTML</b> header</g:header>
   <g:Label>able</g:Label>
 </g:tab>
 <g:tab>
   <g:customHeader size='7'>
     <g:Label>Custom header</g:Label>
   </g:customHeader>
   <g:Label>baker</g:Label>
 </g:tab>
</g:TabLayoutPanel>
class TabLayoutPanel extends ResizeComposite implements HasWidgets, ProvidesResize, IndexedPanelForIsWidget, AnimatedLayout, HasBeforeSelectionHandlers<int>, HasSelectionHandlers<int> {

 static final String _CONTENT_CONTAINER_STYLE = "dwt-TabLayoutPanelContentContainer";
 static final String _CONTENT_STYLE = "dwt-TabLayoutPanelContent";
 static final String _TAB_STYLE = "dwt-TabLayoutPanelTab";
 
 static final String _TAB_INNER_STYLE = "dwt-TabLayoutPanelTabInner";
 
 static final int _BIG_ENOUGH_TO_NOT_WRAP = 16384;

 _TabbedDeckLayoutPanel _deckPanel;
 final FlowPanel _tabBar = new FlowPanel();
 final List<_Tab> _tabs = new List<_Tab>();
 int _selectedIndex = -1;

 /**
  * Creates an empty tab panel.
  *
  * @param barHeight the size of the tab bar
  * @param barUnit the unit in which the tab bar size is specified
  */
 TabLayoutPanel(double barHeight, Unit barUnit) {
   _deckPanel = new _TabbedDeckLayoutPanel(this);
   _deckPanel.addStyleName(_CONTENT_CONTAINER_STYLE);
   //
   LayoutPanel panel = new LayoutPanel();
   initWidget(panel);

   // Add the tab bar to the panel.
   panel.add(_tabBar);
   panel.setWidgetLeftRight(_tabBar, 0.0, Unit.PX, 0.0, Unit.PX);
   panel.setWidgetTopHeight(_tabBar, 0.0, Unit.PX, barHeight, barUnit);
   panel.setWidgetVerticalPosition(_tabBar, Alignment.END);

   // Add the deck panel to the panel.
   panel.add(_deckPanel);
   panel.setWidgetLeftRight(_deckPanel, 0.0, Unit.PX, 0.0, Unit.PX);
   panel.setWidgetTopBottom(_deckPanel, barHeight, barUnit, 0.0, Unit.PX);

   // Make the tab bar extremely wide so that _tabs themselves never wrap.
   // (Its layout container is overflow:hidden)
   _tabBar.getElement().style.width = _BIG_ENOUGH_TO_NOT_WRAP.toString() + Unit.PX.value;

   _tabBar.clearAndSetStyleName("dwt-TabLayoutPanelTabs");
   clearAndSetStyleName("dwt-TabLayoutPanel");
 }

//  /**
//   * Convenience overload to allow {@link IsWidget} to be used directly.
//   */
//  void addIsWidget(IsWidget w) {
//    add(asWidgetOrNull(w));
//  }
//
//  /**
//   * Convenience overload to allow {@link IsWidget} to be used directly.
//   */
//  void addIsWidgetTab(IsWidget w, IsWidget tab) {
//    addIsWidget(asWidgetOrNull(w), asWidgetOrNull(tab));
//  }
//
//  /**
//   * Convenience overload to allow {@link IsWidget} to be used directly.
//   */
//  void addIsWidgetText(IsWidget w, String text) {
//    add(asWidgetOrNull(w), text);
//  }
//
//  /**
//   * Convenience overload to allow {@link IsWidget} to be used directly.
//   */
//  void add(IsWidget w, String text, bool asHtml) {
//    add(asWidgetOrNull(w), text, asHtml);
//  }

//  /**
//   * Adds a widget to the panel. If the Widget is already attached, it will be
//   * moved to the right-most index.
//   *
//   * @param child the widget to be added
//   * @param html the html to be shown on its tab
//   */
//  void add(Widget child, SafeHtml html) {
//    add(child, html.asString(), true);
//  }

 /**
  * Adds a widget to the panel. If the Widget is already attached, it will be
  * moved to the right-most index.
  *
  * @param child the widget to be added
  * @param html the html to be shown on its tab
  */
 void add(Widget w) {
   insert(w, getWidgetCount());
 }
 
 /**
  * Adds a widget to the panel. If the Widget is already attached, it will be
  * moved to the right-most index.
  *
  * @param child the widget to be added
  * @param text the text to be shown on its tab
  * @param asHtml <code>true</code> to treat the specified text as HTML
  */
 void addTabText(Widget child, [String text = "", bool asHtml = false]) {
   insert(child, getWidgetCount(), text, asHtml);
 }

 /**
  * Adds a widget to the panel. If the Widget is already attached, it will be
  * moved to the right-most index.
  *
  * @param child the widget to be added
  * @param tab the widget to be placed in the associated tab
  */
 void addTab(Widget child, Widget tab) {
   insertTab(child, tab, getWidgetCount());
 }

 HandlerRegistration addBeforeSelectionHandler(
     BeforeSelectionHandler<int> handler) {
   return addHandler(handler, BeforeSelectionEvent.getType());
 }

 HandlerRegistration addSelectionHandler(
     SelectionHandler<int> handler) {
   return addHandler(handler, SelectionEvent.getType());
 }

 void animate(int duration, [LayoutAnimationCallback callback = null]) {
   _deckPanel.animate(duration, callback);
 }

 void clear() {
   Iterator<Widget> it = iterator();
   while (it.moveNext()) {
     it.current.removeFromParent();
   }
 }

 void forceLayout() {
   _deckPanel.forceLayout();
 }

 /**
  * Get the duration of the animated transition between _tabs.
  *
  * @return the duration in milliseconds
  */
 int getAnimationDuration() {
   return _deckPanel.getAnimationDuration();
 }

 /**
  * Gets the index of the currently-selected tab.
  *
  * @return the selected index, or <code>-1</code> if none is selected.
  */
 int getSelectedIndex() {
   return _selectedIndex;
 }

 /**
  * Gets the widget in the tab at the given index.
  *
  * @param index the index of the tab to be retrieved
  * @return the tab's widget
  */
 Widget getTabWidgetById(int index) {
   checkIndex(index);
   return _tabs[index].getWidget();
 }

 /**
  * Convenience overload to allow {@link IsWidget} to be used directly.
  */
 Widget getTabIsWidget(IsWidget child) {
   return getTabWidget(Widget.asWidgetOrNull(child));
 }

 /**
  * Gets the widget in the tab associated with the given child widget.
  *
  * @param child the child whose tab is to be retrieved
  * @return the tab's widget
  */
 Widget getTabWidget(Widget child) {
   checkChild(child);
   return getTabWidgetById(getWidgetIndex(child));
 }

 /**
  * Returns the widget at the given index.
  */
 Widget getWidgetAt(int index) {
   return _deckPanel.getWidgetAt(index);
 }

 /**
  * Returns the number of _tabs and widgets.
  */
 int getWidgetCount() {
   return _deckPanel.getWidgetCount();
 }

 /**
  * Convenience overload to allow {@link IsWidget} to be used directly.
  */
 int getWidgetIndexIsWidget(IsWidget child) {
   return getWidgetIndex(Widget.asWidgetOrNull(child));
 }

 /**
  * Returns the index of the given child, or -1 if it is not a child.
  */
 int getWidgetIndex(Widget child) {
   return _deckPanel.getWidgetIndex(child);
 }

//  /**
//   * Convenience overload to allow {@link IsWidget} to be used directly.
//   */
//  void insert(IsWidget child, int beforeIndex) {
//    insert(asWidgetOrNull(child), beforeIndex);
//  }
//
//  /**
//   * Convenience overload to allow {@link IsWidget} to be used directly.
//   */
//  void insert(IsWidget child, IsWidget tab, int beforeIndex) {
//    insert(asWidgetOrNull(child), asWidgetOrNull(tab), beforeIndex);
//  }
//
//  /**
//   * Convenience overload to allow {@link IsWidget} to be used directly.
//   */
//  void insert(IsWidget child, String text, bool asHtml, int beforeIndex) {
//    insert(asWidgetOrNull(child), text, asHtml, beforeIndex);
//  }
//
//  /**
//   * Convenience overload to allow {@link IsWidget} to be used directly.
//   */
//  void insert(IsWidget child, String text, int beforeIndex) {
//    insert(asWidgetOrNull(child), text, beforeIndex);
//  }

//  /**
//   * Inserts a widget into the panel. If the Widget is already attached, it will
//   * be moved to the requested index.
//   *
//   * @param child the widget to be added
//   * @param html the html to be shown on its tab
//   * @param beforeIndex the index before which it will be inserted
//   */
//  void insert(Widget child, SafeHtml html, int beforeIndex) {
//    insert(child, html.asString(), true, beforeIndex);
//  }

 /**
  * Inserts a widget into the panel. If the Widget is already attached, it will
  * be moved to the requested index.
  *
  * @param child the widget to be added
  * @param text the text to be shown on its tab
  * @param asHtml <code>true</code> to treat the specified text as HTML
  * @param beforeIndex the index before which it will be inserted
  */
 void insert(Widget child, int beforeIndex, [String text = "", bool asHtml = false]) {
   Widget contents;
   if (asHtml) {
     contents = new Html(text);
   } else {
     contents = new Label(text);
   }
   insertTab(child, contents, beforeIndex);
 }

 /**
  * Inserts a widget into the panel. If the Widget is already attached, it will
  * be moved to the requested index.
  *
  * @param child the widget to be added
  * @param tab the widget to be placed in the associated tab
  * @param beforeIndex the index before which it will be inserted
  */
 void insertTab(Widget child, Widget tab, int beforeIndex) {
   _insert(child, new _Tab(this, tab), beforeIndex);
 }

 /**
  * Check whether or not transitions slide in vertically or horizontally.
  * Defaults to horizontally.
  *
  * @return true for vertical transitions, false for horizontal
  */
 bool isAnimationVertical() {
   return _deckPanel.isAnimationVertical();
 }

 Iterator<Widget> iterator() {
   return _deckPanel.iterator();
 }

 bool removeAt(int index) {
   if ((index < 0) || (index >= getWidgetCount())) {
     return false;
   }

   Widget child = getWidgetAt(index);
   _tabBar.removeAt(index);
   _deckPanel._removeProtected(child);
   child.removeStyleName(_CONTENT_STYLE);

   _Tab tab = _tabs.removeAt(index);
   tab.getWidget().removeFromParent();

   if (index == _selectedIndex) {
     // If the selected tab is being removed, select the first tab (if there
     // is one).
     _selectedIndex = -1;
     if (getWidgetCount() > 0) {
       selectTab(0);
     }
   } else if (index < _selectedIndex) {
     // If the _selectedIndex is greater than the one being removed, it needs
     // to be adjusted.
     --_selectedIndex;
   }
   return true;
 }

 bool remove(Widget w) {
   int index = getWidgetIndex(w);
   if (index == -1) {
     return false;
   }

   return removeAt(index);
 }

 /**
  * Programmatically selects the specified tab.
  *
  * @param index the index of the tab to be selected
  * @param fireEvents true to fire events, false not to
  */
 void selectTab(int index, [bool fireEvents = true]) {
   checkIndex(index);
   if (index == _selectedIndex) {
     return;
   }

   // Fire the before selection event, giving the recipients a chance to
   // cancel the selection.
   if (fireEvents) {
     BeforeSelectionEvent<int> event = BeforeSelectionEvent.fire(this, index);
     if ((event != null) && event.isCanceled()) {
       return;
     }
   }

   // Update the _tabs being selected and unselected.
   if (_selectedIndex != -1) {
     _tabs[_selectedIndex].setSelected(false);
   }

   _deckPanel.showWidgetAt(index);
   _tabs[index].setSelected(true);
   _selectedIndex = index;

   // Fire the selection event.
   if (fireEvents) {
     SelectionEvent.fire(this, index);
   }
 }

//  /**
//   * Convenience overload to allow {@link IsWidget} to be used directly.
//   */
//  void selectTab(IsWidget child) {
//    selectTab(asWidgetOrNull(child));
//  }
//
//  /**
//   * Convenience overload to allow {@link IsWidget} to be used directly.
//   */
//  void selectTab(IsWidget child, bool fireEvents) {
//    selectTab(asWidgetOrNull(child), fireEvents);
//  }

 /**
  * Programmatically selects the specified tab.
  *
  * @param child the child whose tab is to be selected
  * @param fireEvents true to fire events, false not to
  */
 void selectTabWidget(Widget child, [bool fireEvents = true]) {
   selectTab(getWidgetIndex(child), fireEvents);
 }

 /**
  * Set the duration of the animated transition between _tabs.
  *
  * @param duration the duration in milliseconds.
  */
 void setAnimationDuration(int duration) {
   _deckPanel.setAnimationDuration(duration);
 }

 /**
  * Set whether or not transitions slide in vertically or horizontally.
  *
  * @param isVertical true for vertical transitions, false for horizontal
  */
 void setAnimationVertical(bool isVertical) {
   _deckPanel.setAnimationVertical(isVertical);
 }

 /**
  * Sets a tab's HTML contents.
  *
  * Use care when setting an object's HTML; it is an easy way to expose
  * script-based security problems. Consider using
  * {@link #setTabHTML(int, SafeHtml)} or
  * {@link #setTabText(int, String)} whenever possible.
  *
  * @param index the index of the tab whose HTML is to be set
  * @param html the tab's new HTML contents
  */
 void setTabHtml(int index, String html) {
   checkIndex(index);
   _tabs[index].setWidget(new Html(html));
 }

//  /**
//   * Sets a tab's HTML contents.
//   *
//   * @param index the index of the tab whose HTML is to be set
//   * @param html the tab's new HTML contents
//   */
//  void setTabHhtml(int index, SafeHtml html) {
//    setTabHTML(index, html.asString());
//  }

 /**
  * Sets a tab's text contents.
  *
  * @param index the index of the tab whose text is to be set
  * @param text the object's new text
  */
 void setTabText(int index, String text) {
   checkIndex(index);
   _tabs[index].setWidget(new Label(text));
 }

 void checkChild(Widget child) {
   assert (getWidgetIndex(child) >= 0); // : "Child is not a part of this panel";
 }

 void checkIndex(int index) {
   assert ((index >= 0) && (index < getWidgetCount())); // : "Index out of bounds";
 }

 void _insert(Widget child, _Tab tab, int beforeIndex) {
   assert ((beforeIndex >= 0) && (beforeIndex <= getWidgetCount())); // : "beforeIndex out of bounds";

   // Check to see if the TabPanel already contains the Widget. If so,
   // remove it and see if we need to shift the position to the left.
   int idx = getWidgetIndex(child);
   if (idx != -1) {
     remove(child);
     if (idx < beforeIndex) {
       beforeIndex--;
     }
   }

   _deckPanel._insertProtected(child, beforeIndex);
//    _tabs.insertRange(beforeIndex, 1, tab);
   _tabs.insert(beforeIndex, tab);
   _tabBar.insertAt(tab, beforeIndex);
   tab.addClickHandler(new ClickHandlerAdapter((ClickEvent event) {
     selectTabWidget(child);
   }));

   child.addStyleName(_CONTENT_STYLE);

   if (_selectedIndex == -1) {
     selectTab(0);
   } else if (_selectedIndex >= beforeIndex) {
     // If we inserted before the currently selected tab, its index has just
     // increased.
     _selectedIndex++;
   }
 }
}

Extends

UiObject > Widget > Composite > ResizeComposite > TabLayoutPanel

Implements

HasSelectionHandlers<int>, HasBeforeSelectionHandlers<int>, AnimatedLayout, IndexedPanelForIsWidget, ProvidesResize, HasWidgets

Constructors

new TabLayoutPanel(double barHeight, Unit barUnit) #

Creates an empty tab panel.

@param barHeight the size of the tab bar @param barUnit the unit in which the tab bar size is specified

TabLayoutPanel(double barHeight, Unit barUnit) {
 _deckPanel = new _TabbedDeckLayoutPanel(this);
 _deckPanel.addStyleName(_CONTENT_CONTAINER_STYLE);
 //
 LayoutPanel panel = new LayoutPanel();
 initWidget(panel);

 // Add the tab bar to the panel.
 panel.add(_tabBar);
 panel.setWidgetLeftRight(_tabBar, 0.0, Unit.PX, 0.0, Unit.PX);
 panel.setWidgetTopHeight(_tabBar, 0.0, Unit.PX, barHeight, barUnit);
 panel.setWidgetVerticalPosition(_tabBar, Alignment.END);

 // Add the deck panel to the panel.
 panel.add(_deckPanel);
 panel.setWidgetLeftRight(_deckPanel, 0.0, Unit.PX, 0.0, Unit.PX);
 panel.setWidgetTopBottom(_deckPanel, barHeight, barUnit, 0.0, Unit.PX);

 // Make the tab bar extremely wide so that _tabs themselves never wrap.
 // (Its layout container is overflow:hidden)
 _tabBar.getElement().style.width = _BIG_ENOUGH_TO_NOT_WRAP.toString() + Unit.PX.value;

 _tabBar.clearAndSetStyleName("dwt-TabLayoutPanelTabs");
 clearAndSetStyleName("dwt-TabLayoutPanel");
}

Properties

int eventsToSink #

inherited from Widget

A set og events that should be sunk when the widget is attached to the DOM. (We delay the sinking of events to improve startup performance.) When the widget is attached, this is set is empty

Package protected to allow Composite to see it.

int eventsToSink = 0

String get title #

inherited from UiObject

Gets the title associated with this object. The title is the 'tool-tip' displayed to users when they hover over the object.

@return the object's title

String get title => getElement().title;

void set title(String value) #

inherited from UiObject

Sets the element's title.

void set title(String value) {
 getElement().title = value;
}

bool get visible #

inherited from UiObject

Determines whether or not this object is visible. Note that this does not necessarily take into account whether or not the receiver's parent is visible, or even if it is attached to the Document. The default implementation of this trait in UIObject is based on the value of a dom element's style object's display attribute.

@return <code>true</code> if the object is visible

bool get visible => isVisible(getElement());

void set visible(bool visible) #

inherited from UiObject

Sets whether this object is visible.

@param visible <code>true</code> to show the object, <code>false</code> to

     hide it
void set visible(bool visible) {
 setVisible(getElement(), visible);
}

Methods

void add(Widget w) #

Adds a widget to the panel. If the Widget is already attached, it will be moved to the right-most index.

@param child the widget to be added @param html the html to be shown on its tab

void add(Widget w) {
 insert(w, getWidgetCount());
}

HandlerRegistration addAttachHandler(AttachEventHandler handler) #

inherited from Widget

Adds an AttachEvent handler.

@param handler the handler @return the handler registration

HandlerRegistration addAttachHandler(AttachEventHandler handler) {
 return addHandler(handler, AttachEvent.TYPE);
}

HandlerRegistration addBeforeSelectionHandler(BeforeSelectionHandler<int> handler) #

Adds a {@link BeforeSelectionEvent} handler.

@param handler the handler @return the registration for the event

docs inherited from HasBeforeSelectionHandlers<int>
HandlerRegistration addBeforeSelectionHandler(
   BeforeSelectionHandler<int> handler) {
 return addHandler(handler, BeforeSelectionEvent.getType());
}

HandlerRegistration addBitlessDomHandler(EventHandler handler, DomEventType type) #

inherited from Widget

For <a href= "http://code.google.com/p/google-web-toolkit/wiki/UnderstandingMemoryLeaks"

browsers which do not leak</a>, adds a native event handler to the widget.

Note that, unlike the {@link #addDomHandler(EventHandler, com.google.gwt.event.dom.client.DomEvent.Type)} implementation, there is no need to attach the widget to the DOM in order to cause the event handlers to be attached.

@param <H> the type of handler to add @param type the event key @param handler the handler @return {@link HandlerRegistration} used to remove the handler

HandlerRegistration addBitlessDomHandler(EventHandler handler, DomEventType type) {
 assert (handler != null);; // : "handler must not be null";
 assert (type != null); // : "type must not be null";
 sinkBitlessEvent(type.eventName);
 return ensureHandlers().addHandler(type, handler);
}

HandlerRegistration addDomHandler(EventHandler handler, DomEventType type) #

inherited from Widget

Adds a native event handler to the widget and sinks the corresponding native event. If you do not want to sink the native event, use the generic addHandler method instead.

@param <H> the type of handler to add @param type the event key @param handler the handler @return {@link HandlerRegistration} used to remove the handler

HandlerRegistration addDomHandler(EventHandler handler, DomEventType type) {
 assert (handler != null); // : "handler must not be null";
 assert (type != null); // : "type must not be null";
 int typeInt = IEvent.getTypeInt(type.eventName);
 if (typeInt == -1) {
   sinkBitlessEvent(type.eventName);
 } else {
   sinkEvents(typeInt);
 }
 return ensureHandlers().addHandler(type, handler);
}

HandlerRegistration addHandler(EventHandler handler, EventType<EventHandler> type) #

inherited from Widget

Adds this handler to the widget.

@param <H> the type of handler to add @param type the event type @param handler the handler @return {@link HandlerRegistration} used to remove the handler

HandlerRegistration addHandler(EventHandler handler, EventType<EventHandler> type) {
 return ensureHandlers().addHandler(type, handler);
}

HandlerRegistration addSelectionHandler(SelectionHandler<int> handler) #

Adds a {@link SelectionEvent} handler.

@param handler the handler @return the registration for the event

docs inherited from HasSelectionHandlers<int>
HandlerRegistration addSelectionHandler(
   SelectionHandler<int> handler) {
 return addHandler(handler, SelectionEvent.getType());
}

void addStyleDependentName(String styleSuffix) #

inherited from UiObject

Adds a dependent style name by specifying the style name's suffix. The actual form of the style name that is added is:

getStylePrimaryName() + '-' + styleSuffix

@param styleSuffix the suffix of the dependent style to be added. @see #setStylePrimaryName(String) @see #removeStyleDependentName(String) @see #setStyleDependentName(String, boolean) @see #addStyleName(String)

void addStyleDependentName(String styleSuffix) {
 setStyleDependentName(styleSuffix, true);
}

void addStyleName(String style) #

inherited from UiObject

Adds a secondary or dependent style name to this object. A secondary style name is an additional style name that is, in HTML/CSS terms, included as a space-separated token in the value of the CSS <code>class</code> attribute for this object's root element.

The most important use for this method is to add a special kind of secondary style name called a dependent style name. To add a dependent style name, use {@link #addStyleDependentName(String)}, which will prefix the 'style' argument with the result of {@link #k()} (followed by a '-'). For example, suppose the primary style name is gwt-TextBox. If the following method is called as obj.setReadOnly(true):

public void setReadOnly(boolean readOnly) {
  isReadOnlyMode = readOnly;

// Create a dependent style name. String readOnlyStyle = "readonly";

if (readOnly) {

addStyleDependentName(readOnlyStyle);

} else {

removeStyleDependentName(readOnlyStyle);

} }</pre>

then both of the CSS style rules below will be applied:

// This rule is based on the primary style name and is always active. .gwt-TextBox { font-size: 12pt; }

// This rule is based on a dependent style name that is only active // when the widget has called addStyleName(getStylePrimaryName() + // "-readonly"). .gwt-TextBox-readonly { background-color: lightgrey; border: none; }</pre>

The code can also be simplified with {@link #setStyleDependentName(String, boolean)}:

public void setReadOnly(boolean readOnly) {
  isReadOnlyMode = readOnly;
  setStyleDependentName("readonly", readOnly);
}

Dependent style names are powerful because they are automatically updated whenever the primary style name changes. Continuing with the example above, if the primary style name changed due to the following call:

setStylePrimaryName("my-TextThingy");

then the object would be re-associated with following style rules, removing those that were shown above.

.my-TextThingy {
  font-size: 20pt;
}

.my-TextThingy-readonly { background-color: red; border: 2px solid yellow; }</pre>

Secondary style names that are not dependent style names are not automatically updated when the primary style name changes.

@param style the secondary style name to be added @see UIObject @see #removeStyleName(String)

void addStyleName(String style) {
 setStyleName(style, true);
}

void addTab(Widget child, Widget tab) #

Adds a widget to the panel. If the Widget is already attached, it will be moved to the right-most index.

@param child the widget to be added @param tab the widget to be placed in the associated tab

void addTab(Widget child, Widget tab) {
 insertTab(child, tab, getWidgetCount());
}

void addTabText(Widget child, [String text = "", bool asHtml = false]) #

Adds a widget to the panel. If the Widget is already attached, it will be moved to the right-most index.

@param child the widget to be added @param text the text to be shown on its tab @param asHtml <code>true</code> to treat the specified text as HTML

void addTabText(Widget child, [String text = "", bool asHtml = false]) {
 insert(child, getWidgetCount(), text, asHtml);
}

void animate(int duration, [LayoutAnimationCallback callback = null]) #

Layout children, animating over the specified period of time.

This method provides a callback that will be informed of animation updates. This can be used to create more complex animation effects.

@param duration the animation duration, in milliseconds @param callback the animation callback

docs inherited from AnimatedLayout
void animate(int duration, [LayoutAnimationCallback callback = null]) {
 _deckPanel.animate(duration, callback);
}

Widget asWidget() #

inherited from Widget

Returns the Widget aspect of the receiver.

Widget asWidget() {
 return this;
}

void checkChild(Widget child) #

void checkChild(Widget child) {
 assert (getWidgetIndex(child) >= 0); // : "Child is not a part of this panel";
}

void checkIndex(int index) #

void checkIndex(int index) {
 assert ((index >= 0) && (index < getWidgetCount())); // : "Index out of bounds";
}

void clear() #

Removes all child widgets.

docs inherited from HasWidgets
void clear() {
 Iterator<Widget> it = iterator();
 while (it.moveNext()) {
   it.current.removeFromParent();
 }
}

void clearAndSetStyleName(String style) #

inherited from UiObject

Clears all of the object's style names and sets it to the given style. You should normally use {@link #setStylePrimaryName(String)} unless you wish to explicitly remove all existing styles.

@param style the new style name @see #setStylePrimaryName(String)

void clearAndSetStyleName(String style) {
 setElementStyleName(getStyleElement(), style);
}

EventBus createEventBus() #

inherited from Widget

Creates the SimpleEventBus used by this Widget. You can override this method to create a custom EventBus.

@return the EventBus you want to use.

EventBus createEventBus() {
 return new SimpleEventBus();
}

void delegateEvent(Widget target, DwtEvent event) #

inherited from Widget

Fires an event on a child widget. Used to delegate the handling of an event from one widget to another.

@param event the event @param target fire the event on the given target

void delegateEvent(Widget target, DwtEvent event) {
 target.fireEvent(event);
}

void doAttachChildren() #

inherited from Widget

If a widget contains one or more child widgets that are not in the logical widget hierarchy (the child is physically connected only on the DOM level), it must override this method and call {@link #onAttach()} for each of its child widgets.

@see #onAttach()

void doAttachChildren() {
}

void doDetachChildren() #

inherited from Widget

If a widget contains one or more child widgets that are not in the logical widget hierarchy (the child is physically connected only on the DOM level), it must override this method and call {@link #onDetach()} for each of its child widgets.

@see #onDetach()

void doDetachChildren() {
}

EventBus ensureHandlers() #

inherited from Widget

Ensures the existence of the event bus.

@return the EventBus.

EventBus ensureHandlers() {
 return _eventBus == null ? _eventBus = createEventBus() : _eventBus;
}

double extractLengthValue(String s) #

inherited from UiObject

Intended to be used to pull the value out of a CSS length. If the value is "auto" or "inherit", 0 will be returned.

@param s The CSS length string to extract @return The leading numeric portion of <code>s</code>, or 0 if "auto" or

    "inherit" are passed in.
double extractLengthValue(String s) {
 if (s == "auto" || s == "inherit" || s == "") {
   return 0.0;
 } else {
   // numberRegex divides the string into a leading numeric portion
   // followed by an arbitrary portion.
   if(numberRegex.hasMatch(s)) {
     // Extract the leading numeric portion of string
     s = numberRegex.firstMatch(s)[0];
   }
   return double.parse(s);
 }
}

void fireEvent(DwtEvent event) #

inherited from Widget

Fires the given event to the handlers listening to the event's type.

Any exceptions thrown by handlers will be bundled into a UmbrellaException and then re-thrown after all handlers have completed. An exception thrown by a handler will not prevent other handlers from executing.

@param event the event

void fireEvent(DwtEvent event) {
//    if (_eventBus != null) {
//      _eventBus.fireEvent(event);
//    }
 if (_eventBus != null) {
   // If it not live we should revive it.
   if (!event.isLive()) {
     event.revive();
   }
   Object oldSource = event.getSource();
   event.overrideSource(getElement());
   try {

     // May throw an UmbrellaException.
     _eventBus.fireEventFromSource(event, getElement());
   } on UmbrellaException catch (e) {
     throw new UmbrellaException(e.causes);
   } finally {
     if (oldSource == null) {
       // This was my event, so I should kill it now that I'm done.
       event.kill();
     } else {
       // Restoring the source for the next handler to use.
       event.overrideSource(oldSource);
     }
   }
 }
}

void forceLayout() #

Layout children immediately.

This is not normally necessary, unless you want to update child widgets' positions explicitly to create a starting point for a subsequent call to {@link #animate(int)}.

@see #animate(int) @see #animate(int, Layout.AnimationCallback)

docs inherited from AnimatedLayout
void forceLayout() {
 _deckPanel.forceLayout();
}

int getAbsoluteLeft() #

inherited from UiObject

Gets the object's absolute left position in pixels, as measured from the browser window's client area.

@return the object's absolute left position

int getAbsoluteLeft() {
 return Dom.getAbsoluteLeft(getElement());
}

int getAbsoluteTop() #

inherited from UiObject

Gets the object's absolute top position in pixels, as measured from the browser window's client area.

@return the object's absolute top position

int getAbsoluteTop() {
 return Dom.getAbsoluteTop(getElement());
}

int getAnimationDuration() #

Get the duration of the animated transition between _tabs.

@return the duration in milliseconds

int getAnimationDuration() {
 return _deckPanel.getAnimationDuration();
}

Element getElement() #

inherited from UiObject

Gets this object's browser element.

dart_html.Element getElement() {
 assert (_element != null); // : MISSING_ELEMENT_ERROR;
 return _element;
}

EventBus getEventBus() #

inherited from Widget

Return EventBus.

EventBus getEventBus() {
 return _eventBus;
}

Object getLayoutData() #

inherited from Widget

Gets the panel-defined layout data associated with this widget.

@return the widget's layout data @see #setLayoutData

Object getLayoutData() {
 return _layoutData;
}

int getOffsetHeight() #

inherited from UiObject

Gets the object's offset height in pixels. This is the total height of the object, including decorations such as border and padding, but not margin.

@return the object's offset height

int getOffsetHeight() {
 return getElement().offset.height; // Dom.getElementPropertyInt(getElement(), "offsetHeight");
}

int getOffsetWidth() #

inherited from UiObject

Gets the object's offset width in pixels. This is the total width of the object, including decorations such as border and padding, but not margin.

@return the object's offset width

int getOffsetWidth() {
 return getElement().offset.width; // Dom.getElementPropertyInt(getElement(), "offsetWidth");
}

Widget getParent() #

inherited from Widget

Gets this widget's parent panel.

@return the widget's parent panel

Widget getParent() {
 return _parent;
}

int getSelectedIndex() #

Gets the index of the currently-selected tab.

@return the selected index, or <code>-1</code> if none is selected.

int getSelectedIndex() {
 return _selectedIndex;
}

Element getStyleElement() #

inherited from UiObject

Template method that returns the element to which style names will be applied. By default it returns the root element, but this method may be overridden to apply styles to a child element.

@return the element to which style names will be applied

dart_html.Element getStyleElement() {
 return getElement();
}

String getStyleName() #

inherited from UiObject

Gets all of the object's style names, as a space-separated list. If you wish to retrieve only the primary style name, call {@link #getStylePrimaryName()}.

@return the objects's space-separated style names @see #getStylePrimaryName()

String getStyleName() {
 return getElementStyleName(getStyleElement());
}

String getStylePrimaryName() #

inherited from UiObject

Gets the primary style name associated with the object.

@return the object's primary style name @see #setStyleName(String) @see #addStyleName(String) @see #removeStyleName(String)

String getStylePrimaryName() {
 return getElementStylePrimaryName(getStyleElement());
}

Widget getTabIsWidget(IsWidget child) #

Convenience overload to allow {@link IsWidget} to be used directly.

Widget getTabIsWidget(IsWidget child) {
 return getTabWidget(Widget.asWidgetOrNull(child));
}

Widget getTabWidget(Widget child) #

Gets the widget in the tab associated with the given child widget.

@param child the child whose tab is to be retrieved @return the tab's widget

Widget getTabWidget(Widget child) {
 checkChild(child);
 return getTabWidgetById(getWidgetIndex(child));
}

Widget getTabWidgetById(int index) #

Gets the widget in the tab at the given index.

@param index the index of the tab to be retrieved @return the tab's widget

Widget getTabWidgetById(int index) {
 checkIndex(index);
 return _tabs[index].getWidget();
}

Widget getWidget() #

inherited from Composite

Provides subclasses access to the topmost widget that defines this composite.

@return the widget

Widget getWidget() {
 return _widget;
}

Widget getWidgetAt(int index) #

Returns the widget at the given index.

Widget getWidgetAt(int index) {
 return _deckPanel.getWidgetAt(index);
}

int getWidgetCount() #

Returns the number of _tabs and widgets.

int getWidgetCount() {
 return _deckPanel.getWidgetCount();
}

int getWidgetIndex(Widget child) #

Returns the index of the given child, or -1 if it is not a child.

int getWidgetIndex(Widget child) {
 return _deckPanel.getWidgetIndex(child);
}

int getWidgetIndexIsWidget(IsWidget child) #

Convenience overload to allow {@link IsWidget} to be used directly.

int getWidgetIndexIsWidget(IsWidget child) {
 return getWidgetIndex(Widget.asWidgetOrNull(child));
}

void initWidget(Widget widget) #

inherited from ResizeComposite

Sets the widget to be wrapped by the composite. The wrapped widget must be set before calling any {@link Widget} methods on this object, or adding it to a panel. This method may only be called once for a given composite.

@param widget the widget to be wrapped

docs inherited from Composite
void initWidget(Widget widget) {
 assert (widget is RequiresResize); // : "LayoutComposite requires that its wrapped widget implement RequiresResize";
 super.initWidget(widget);
}

void insert(Widget child, int beforeIndex, [String text = "", bool asHtml = false]) #

Inserts a widget into the panel. If the Widget is already attached, it will be moved to the requested index.

@param child the widget to be added @param text the text to be shown on its tab @param asHtml <code>true</code> to treat the specified text as HTML @param beforeIndex the index before which it will be inserted

void insert(Widget child, int beforeIndex, [String text = "", bool asHtml = false]) {
 Widget contents;
 if (asHtml) {
   contents = new Html(text);
 } else {
   contents = new Label(text);
 }
 insertTab(child, contents, beforeIndex);
}

void insertTab(Widget child, Widget tab, int beforeIndex) #

Inserts a widget into the panel. If the Widget is already attached, it will be moved to the requested index.

@param child the widget to be added @param tab the widget to be placed in the associated tab @param beforeIndex the index before which it will be inserted

void insertTab(Widget child, Widget tab, int beforeIndex) {
 _insert(child, new _Tab(this, tab), beforeIndex);
}

bool isAnimationVertical() #

Check whether or not transitions slide in vertically or horizontally. Defaults to horizontally.

@return true for vertical transitions, false for horizontal

bool isAnimationVertical() {
 return _deckPanel.isAnimationVertical();
}

bool isAttached() #

inherited from Composite

Returns whether or not the receiver is attached to the {@link com.google.gwt.dom.client.Document Document}'s {@link com.google.gwt.dom.client.BodyElement BodyElement}.

@return true if attached, false otherwise

bool isAttached() {
 if (_widget != null) {
   return _widget.isAttached();
 }
 return false;
}

bool isOrWasAttached() #

inherited from Widget

Has this widget ever been attached?

@return true if this widget ever been attached to the DOM, false otherwise

bool isOrWasAttached() {
 return eventsToSink == -1;
}

Iterator<Widget> iterator() #

Returns an Iterator that iterates over this Iterable object.

docs inherited from HasWidgets
Iterator<Widget> iterator() {
 return _deckPanel.iterator();
}

void onAttach() #

inherited from Composite

This method is called when a widget is attached to the browser's document. To receive notification after a Widget has been added to the document, override the {@link #onLoad} method or use {@link #addAttachHandler}.

It is strongly recommended that you override {@link #onLoad()} or {@link #doAttachChildren()} instead of this method to avoid inconsistencies between logical and physical attachment states.

Subclasses that override this method must call super.onAttach() to ensure that the Widget has been attached to its underlying Element.

@throws IllegalStateException if this widget is already attached @see #onLoad() @see #doAttachChildren()

void onAttach() {
 if (!isOrWasAttached()) {
   _widget.sinkEvents(eventsToSink);
   eventsToSink = -1;
 }

 _widget.onAttach();

 // Clobber the widget's call to setEventListener(), causing all events to
 // be routed to this composite, which will delegate back to the widget by
 // default (note: it's not necessary to clear this in onDetach(), because
 // the widget's onDetach will do so).
 Dom.setEventListener(getElement(), this);

 // Call onLoad() directly, because we're not calling super.onAttach().
 onLoad();
 AttachEvent.fire(this, true);
}

void onBrowserEvent(Event event) #

inherited from Composite

Fired whenever a browser event is received.

@param event the event received

TODO

void onBrowserEvent(dart_html.Event event) {
 // Fire any handler added to the composite itself.
 super.onBrowserEvent(event);

 // Delegate events to the widget.
 _widget.onBrowserEvent(event);
}

void onDetach() #

inherited from Composite

This method is called when a widget is detached from the browser's document. To receive notification before a Widget is removed from the document, override the {@link #onUnload} method or use {@link #addAttachHandler}.

It is strongly recommended that you override {@link #onUnload()} or {@link #doDetachChildren()} instead of this method to avoid inconsistencies between logical and physical attachment states.

Subclasses that override this method must call super.onDetach() to ensure that the Widget has been detached from the underlying Element. Failure to do so will result in application memory leaks due to circular references between DOM Elements and JavaScript objects.

@throws IllegalStateException if this widget is already detached @see #onUnload() @see #doDetachChildren()

void onDetach() {
 try {
   onUnload();
   AttachEvent.fire(this, false);
 } finally {
   // We don't want an exception in user code to keep us from calling the
   // super implementation (or event listeners won't get cleaned up and
   // the attached flag will be wrong).
   _widget.onDetach();
 }
}

void onLoad() #

inherited from Widget

This method is called immediately after a widget becomes attached to the browser's document.

void onLoad() {
}

void onResize() #

inherited from ResizeComposite

This method must be called whenever the implementor's size has been modified.

docs inherited from RequiresResize
void onResize() {
 (getWidget() as RequiresResize).onResize();
}

void onUnload() #

inherited from Widget

This method is called immediately before a widget will be detached from the browser's document.

void onUnload() {
}

bool remove(Widget w) #

Removes a child widget.

@param w the widget to be removed @return <code>true</code> if the widget was present

docs inherited from HasWidgets
bool remove(Widget w) {
 int index = getWidgetIndex(w);
 if (index == -1) {
   return false;
 }

 return removeAt(index);
}

bool removeAt(int index) #

Removes the widget at the specified index.

@param index the index of the widget to be removed @return <code>false</code> if the widget is not present

docs inherited from IndexedPanel
bool removeAt(int index) {
 if ((index < 0) || (index >= getWidgetCount())) {
   return false;
 }

 Widget child = getWidgetAt(index);
 _tabBar.removeAt(index);
 _deckPanel._removeProtected(child);
 child.removeStyleName(_CONTENT_STYLE);

 _Tab tab = _tabs.removeAt(index);
 tab.getWidget().removeFromParent();

 if (index == _selectedIndex) {
   // If the selected tab is being removed, select the first tab (if there
   // is one).
   _selectedIndex = -1;
   if (getWidgetCount() > 0) {
     selectTab(0);
   }
 } else if (index < _selectedIndex) {
   // If the _selectedIndex is greater than the one being removed, it needs
   // to be adjusted.
   --_selectedIndex;
 }
 return true;
}

void removeFromParent() #

inherited from Widget

Removes this widget from its parent widget, if one exists.

If it has no parent, this method does nothing. If it is a "root" widget (meaning it's been added to the detach list via {@link RootPanel#detachOnWindowClose(Widget)}), it will be removed from the detached immediately. This makes it possible for Composites and Panels to adopt root widgets.

@throws IllegalStateException if this widget's parent does not support

      removal (e.g. {@link Composite})
void removeFromParent() {
 if (_parent == null) {
   // If the widget had no parent, check to see if it was in the detach list
   // and remove it if necessary.
   if (RootPanel.isInDetachList(this)) {
     RootPanel.detachNow(this);
   }
 } else if (_parent is HasWidgets) {
   (_parent as HasWidgets).remove(this);
 } else if (_parent != null) {
   throw new Exception("This widget's parent does not implement HasWidgets");
 }
}

void removeStyleDependentName(String styleSuffix) #

inherited from UiObject

Removes a dependent style name by specifying the style name's suffix.

@param styleSuffix the suffix of the dependent style to be removed @see #setStylePrimaryName(Element, String) @see #addStyleDependentName(String) @see #setStyleDependentName(String, boolean)

void removeStyleDependentName(String styleSuffix) {
 setStyleDependentName(styleSuffix, false);
}

void removeStyleName(String style) #

inherited from UiObject

Removes a style name. This method is typically used to remove secondary style names, but it can be used to remove primary stylenames as well. That use is not recommended.

@param style the secondary style name to be removed @see #addStyleName(String) @see #setStyleName(String, boolean)

void removeStyleName(String style) {
 setStyleName(style, false);
}

void replaceElement(Element elem) #

inherited from Widget

Replaces this object's browser element.

This method exists only to support a specific use-case in Image, and should not be used by other classes.

@param elem the object's new element

void replaceElement(dart_html.Element elem) {
 if (isAttached()) {
   // Remove old event listener to avoid leaking. onDetach will not do this
   // for us, because it is only called when the widget itself is detached
   // from the document.
   Dom.setEventListener(getElement(), null);
 }

 super.replaceElement(elem);

 if (isAttached()) {
   // Hook the event listener back up on the new element. onAttach will not
   // do this for us, because it is only called when the widget itself is
   // attached to the document.
   Dom.setEventListener(getElement(), this);
 }
}

void selectTab(int index, [bool fireEvents = true]) #

Programmatically selects the specified tab.

@param index the index of the tab to be selected @param fireEvents true to fire events, false not to

void selectTab(int index, [bool fireEvents = true]) {
 checkIndex(index);
 if (index == _selectedIndex) {
   return;
 }

 // Fire the before selection event, giving the recipients a chance to
 // cancel the selection.
 if (fireEvents) {
   BeforeSelectionEvent<int> event = BeforeSelectionEvent.fire(this, index);
   if ((event != null) && event.isCanceled()) {
     return;
   }
 }

 // Update the _tabs being selected and unselected.
 if (_selectedIndex != -1) {
   _tabs[_selectedIndex].setSelected(false);
 }

 _deckPanel.showWidgetAt(index);
 _tabs[index].setSelected(true);
 _selectedIndex = index;

 // Fire the selection event.
 if (fireEvents) {
   SelectionEvent.fire(this, index);
 }
}

void selectTabWidget(Widget child, [bool fireEvents = true]) #

Programmatically selects the specified tab.

@param child the child whose tab is to be selected @param fireEvents true to fire events, false not to

void selectTabWidget(Widget child, [bool fireEvents = true]) {
 selectTab(getWidgetIndex(child), fireEvents);
}

void setAnimationDuration(int duration) #

Set the duration of the animated transition between _tabs.

@param duration the duration in milliseconds.

void setAnimationDuration(int duration) {
 _deckPanel.setAnimationDuration(duration);
}

void setAnimationVertical(bool isVertical) #

Set whether or not transitions slide in vertically or horizontally.

@param isVertical true for vertical transitions, false for horizontal

void setAnimationVertical(bool isVertical) {
 _deckPanel.setAnimationVertical(isVertical);
}

void setElement(Element elem) #

inherited from UiObject

Sets this object's browser element. UIObject subclasses must call this method before attempting to call any other methods, and it may only be called once.

@param elem the object's element

void setElement(dart_html.Element elem) {
 assert (_element == null);
 this._element = elem;
}

void setHeight(String height) #

inherited from UiObject

Sets the object's height. This height does not include decorations such as border, margin, and padding.

@param height the object's new height, in CSS units (e.g. "10px", "1em")

void setHeight(String height) {
 // This exists to deal with an inconsistency in IE's implementation where
 // it won't accept negative numbers in length measurements
 assert (extractLengthValue(height.trim().toLowerCase()) >= 0); // : "CSS heights should not be negative";
 Dom.setStyleAttribute(getElement(), "height", height);
}

void setLayoutData(Object value) #

inherited from Widget

Sets the panel-defined layout data associated with this widget. Only the panel that currently contains a widget should ever set this value. It serves as a place to store layout bookkeeping data associated with a widget.

@param layoutData the widget's layout data

void setLayoutData(Object value) {
 this._layoutData = value;
}

void setParent(Widget parent) #

inherited from Widget

Sets this widget's parent. This method should only be called by {@link Panel} and {@link Composite}.

@param parent the widget's new parent @throws IllegalStateException if <code>parent</code> is non-null and the

      widget already has a parent
void setParent(Widget parent) {
 Widget oldParent = this._parent;
 if (parent == null) {
   try {
     if (oldParent != null && oldParent.isAttached()) {
       onDetach();
       assert (!isAttached()); // : "Failure of " + this.getClass().getName() + " to call super.onDetach()";
     }
   } finally {
     // Put this in a finally in case onDetach throws an exception.
     this._parent = null;
   }
 } else {
   if (oldParent != null) {
     throw new Exception("Cannot set a new parent without first clearing the old parent");
   }
   this._parent = parent;
   if (parent.isAttached()) {
     onAttach();
     assert (isAttached()); // : "Failure of " + this.getClass().getName() + " to call super.onAttach()";
   }
 }
}

void setPixelSize(int width, int height) #

inherited from UiObject

Sets the object's size, in pixels, not including decorations such as border, margin, and padding.

@param width the object's new width, in pixels @param height the object's new height, in pixels

void setPixelSize(int width, int height) {
 if (width >= 0) {
   setWidth(width.toString() + "px");
 }
 if (height >= 0) {
   setHeight(height.toString() + "px");
 }
}

void setSize(String width, String height) #

inherited from UiObject

Sets the object's size. This size does not include decorations such as border, margin, and padding.

@param width the object's new width, in CSS units (e.g. "10px", "1em") @param height the object's new height, in CSS units (e.g. "10px", "1em")

void setSize(String width, String height) {
 setWidth(width);
 setHeight(height);
}

void setStyleDependentName(String styleSuffix, bool add) #

inherited from UiObject

Adds or removes a dependent style name by specifying the style name's suffix. The actual form of the style name that is added is:

getStylePrimaryName() + '-' + styleSuffix

@param styleSuffix the suffix of the dependent style to be added or removed @param add <code>true</code> to add the given style, <code>false</code> to

     remove it

@see #setStylePrimaryName(Element, String) @see #addStyleDependentName(String) @see #setStyleName(String, boolean) @see #removeStyleDependentName(String)

void setStyleDependentName(String styleSuffix, bool add) {
 setStyleName(getStylePrimaryName() + '-' + styleSuffix, add);
}

void setStyleName(String style, bool add) #

inherited from UiObject

Adds or removes a style name. This method is typically used to remove secondary style names, but it can be used to remove primary stylenames as well. That use is not recommended.

@param style the style name to be added or removed @param add <code>true</code> to add the given style, <code>false</code> to

     remove it

@see #addStyleName(String) @see #removeStyleName(String)

void setStyleName(String style, bool add) {
 manageElementStyleName(getStyleElement(), style, add);
}

void setStylePrimaryName(String style) #

inherited from UiObject

Sets the object's primary style name and updates all dependent style names.

@param style the new primary style name @see #addStyleName(String) @see #removeStyleName(String)

void setStylePrimaryName(String style) {
 setElementStylePrimaryName(getStyleElement(), style);
}

void setTabHtml(int index, String html) #

Sets a tab's HTML contents.

Use care when setting an object's HTML; it is an easy way to expose script-based security problems. Consider using {@link #setTabHTML(int, SafeHtml)} or {@link #setTabText(int, String)} whenever possible.

@param index the index of the tab whose HTML is to be set @param html the tab's new HTML contents

void setTabHtml(int index, String html) {
 checkIndex(index);
 _tabs[index].setWidget(new Html(html));
}

void setTabText(int index, String text) #

Sets a tab's text contents.

@param index the index of the tab whose text is to be set @param text the object's new text

void setTabText(int index, String text) {
 checkIndex(index);
 _tabs[index].setWidget(new Label(text));
}

void setWidth(String width) #

inherited from UiObject

Sets the object's width. This width does not include decorations such as border, margin, and padding.

@param width the object's new width, in CSS units (e.g. "10px", "1em")

void setWidth(String width) {
 // This exists to deal with an inconsistency in IE's implementation where
 // it won't accept negative numbers in length measurements
 assert (extractLengthValue(width.trim().toLowerCase()) >= 0); // : "CSS widths should not be negative";
 Dom.setStyleAttribute(getElement(), "width", width);
}

void sinkBitlessEvent(String eventTypeName) #

inherited from UiObject

Sinks a named event. Note that only {@link Widget widgets} may actually receive events, but can receive events from all objects contained within them.

@param eventTypeName name of the event to sink on this element @see com.google.gwt.user.client.Event

void sinkBitlessEvent(String eventTypeName) {
 Dom.sinkBitlessEvent(getElement(), eventTypeName);
}

void sinkEvents(int eventBitsToAdd) #

inherited from Widget

Overridden to defer the call to super.sinkEvents until the first time this widget is attached to the dom, as a performance enhancement. Subclasses wishing to customize sinkEvents can preserve this deferred sink behavior by putting their implementation behind a check of <code>isOrWasAttached()</code>:

{@literal @}Override
public void sinkEvents(int eventBitsToAdd) {
  if (isOrWasAttached()) {
    /{@literal *} customized sink code goes here {@literal *}/
  } else {
    super.sinkEvents(eventBitsToAdd);
 }
} 
void sinkEvents(int eventBitsToAdd) {
 if (isOrWasAttached()) {
   super.sinkEvents(eventsToSink);
 } else {
   eventsToSink |= eventBitsToAdd;
 }
}

String toString() #

inherited from UiObject

This method is overridden so that any object can be viewed in the debugger as an HTML snippet.

@return a string representation of the object

String toString() {
 if (_element == null) {
   return "(null handle)";
 }
 return getElement().toString();
}

void unsinkEvents(int eventBitsToRemove) #

inherited from UiObject

Removes a set of events from this object's event list.

@param eventBitsToRemove a bitfield representing the set of events to be

     removed from this element's event set

@see #sinkEvents @see com.google.gwt.user.client.Event

void unsinkEvents(int eventBitsToRemove) {
 Dom.sinkEvents(getElement(), Dom.getEventsSunk(getElement()) & (~eventBitsToRemove));
}