API Reference 0.3.24dart_web_toolkit_uiHtmlTable

HtmlTable abstract class

HTMLTable contains the common table algorithms for {@link com.google.gwt.user.client.ui.Grid} and {@link com.google.gwt.user.client.ui.FlexTable}. <p> <img class='gallery' src='doc-files/Table.png'/> </p>

abstract class HtmlTable extends Panel implements HasAllDragAndDropHandlers, HasClickHandlers, HasDoubleClickHandlers {

 /**
  * Table's body.
  */
 dart_html.TableSectionElement bodyElem;

 /**
  * Current cell formatter.
  */
 CellFormatter cellFormatter;

 /**
  * Column Formatter.
  */
 ColumnFormatter columnFormatter;

 /**
  * Current row formatter.
  */
 RowFormatter rowFormatter;

 /**
  * Table element.
  */
 dart_html.TableElement tableElem;

 ElementMapperImpl<Widget> widgetMap = new ElementMapperImpl<Widget>();

 /**
  * Create a new empty HTML Table.
  */
 HtmlTable() {
   tableElem = new dart_html.TableElement();
   bodyElem = tableElem.createTBody();
   tableElem.append(bodyElem);
   setElement(tableElem);
 }

 HandlerRegistration addClickHandler(ClickHandler handler) {
   return addDomHandler(handler, ClickEvent.TYPE);
 }

 HandlerRegistration addDoubleClickHandler(DoubleClickHandler handler) {
   return addDomHandler(handler, DoubleClickEvent.TYPE);
 }

 HandlerRegistration addDragEndHandler(DragEndHandler handler) {
   return addDomHandler(handler, DragEndEvent.TYPE);
 }

 HandlerRegistration addDragEnterHandler(DragEnterHandler handler) {
   return addDomHandler(handler, DragEnterEvent.TYPE);
 }

 HandlerRegistration addDragHandler(DragHandler handler) {
   return addDomHandler(handler, DragEvent.TYPE);
 }

 HandlerRegistration addDragLeaveHandler(DragLeaveHandler handler) {
   return addDomHandler(handler, DragLeaveEvent.TYPE);
 }

 HandlerRegistration addDragOverHandler(DragOverHandler handler) {
   return addDomHandler(handler, DragOverEvent.TYPE);
 }

 HandlerRegistration addDragStartHandler(DragStartHandler handler) {
   return addDomHandler(handler, DragStartEvent.TYPE);
 }

 HandlerRegistration addDropHandler(DropHandler handler) {
   return addDomHandler(handler, DropEvent.TYPE);
 }

 /**
  * Removes all widgets from this table, optionally clearing the inner HTML of
  * each cell.  Note that this method does not remove any cells or rows.
  *
  * @param clearInnerHTML should the cell's inner html be cleared?
  */
 void clear([bool clearInnerHTML = false]) {
   for (int row = 0; row < getRowCount(); ++row) {
     for (int col = 0; col < getCellCount(row); ++col) {
       cleanCell(row, col, clearInnerHTML);
     }
   }
 }

 /**
  * Clears the cell at the given row and column. If it contains a Widget, it
  * will be removed from the table. If not, its contents will simply be
  * cleared.
  *
  * @param row the widget's row
  * @param column the widget's column
  * @return true if a widget was removed
  * @throws IndexOutOfBoundsException
  */
 bool clearCell(int row, int column) {
   dart_html.Element td = getCellFormatter().getElement(row, column);
   return internalClearCell(td, true);
 }

 /**
  * Gets the number of cells in a given row.
  *
  * @param row the row whose cells are to be counted
  * @return the number of cells present in the row
  */
 int getCellCount(int row);

 /**
  * Given a click event, return the Cell that was clicked, or null if the event
  * did not hit this table.  The cell can also be null if the click event does
  * not occur on a specific cell.
  *
  * @param event A click event of indeterminate origin
  * @return The appropriate cell, or null
  */
 Cell getCellForEvent(ClickEvent event) {
   dart_html.Element td = getEventTargetCell(event.getNativeEvent());
   if (td == null) {
     return null;
   }

   int row = (td.parent as dart_html.TableRowElement).sectionRowIndex;
   int column = (td as dart_html.TableCellElement).cellIndex;
   return new Cell(this, row, column);
 }

 /**
  * Gets the {@link CellFormatter} associated with this table. Use casting to
  * get subclass-specific functionality
  *
  * @return this table's cell formatter
  */
 CellFormatter getCellFormatter() {
   return cellFormatter;
 }

 /**
  * Gets the amount of padding that is added around all cells.
  *
  * @return the cell padding, in pixels
  */
 int getCellPadding() {
   return Dom.getElementPropertyInt(tableElem, "cellPadding");
 }

 /**
  * Gets the amount of spacing that is added around all cells.
  *
  * @return the cell spacing, in pixels
  */
 int getCellSpacing() {
   return Dom.getElementPropertyInt(tableElem, "cellSpacing");
 }

 /**
  * Gets the column formatter.
  *
  * @return the column formatter
  */
 ColumnFormatter getColumnFormatter() {
   return columnFormatter;
 }

 /**
  * Gets the HTML contents of the specified cell.
  *
  * @param row the cell's row
  * @param column the cell's column
  * @return the cell's HTML contents
  * @throws IndexOutOfBoundsException
  */
 String getHTML(int row, int column) {
   return cellFormatter.getElement(row, column).innerHtml;
 }

 /**
  * Gets the number of rows present in this table.
  *
  * @return the table's row count
  */
 int getRowCount();

 /**
  * Gets the RowFormatter associated with this table.
  *
  * @return the table's row formatter
  */
 RowFormatter getRowFormatter() {
   return rowFormatter;
 }

 /**
  * Gets the text within the specified cell.
  *
  * @param row the cell's row
  * @param column the cell's column
  * @return the cell's text contents
  * @throws IndexOutOfBoundsException
  */
 String getText(int row, int column) {
   checkCellBounds(row, column);
   return cellFormatter.getElement(row, column).text;
 }

 /**
  * Gets the widget in the specified cell.
  *
  * @param row the cell's row
  * @param column the cell's column
  * @return the widget in the specified cell, or <code>null</code> if none is
  *         present
  * @throws IndexOutOfBoundsException
  */
 Widget getWidget(int row, int column) {
   checkCellBounds(row, column);
   return getWidgetImpl(row, column);
 }

 /**
  * Determines whether the specified cell exists.
  *
  * @param row the cell's row
  * @param column the cell's column
  * @return <code>true</code> if the specified cell exists
  */
 bool isCellPresent(int row, int column) {
   if ((row >= getRowCount()) || (row < 0)) {
     return false;
   }
   if ((column < 0) || (column >= getCellCount(row))) {
     return false;
   } else {
     return true;
   }
 }

 /**
  * Returns an iterator containing all the widgets in this table.
  *
  * @return the iterator
  */
 Iterator<Widget> iterator() {
   return new _WidgetIterator(this);
 }

 /**
  * Remove the specified widget from the table.
  *
  * @param widget widget to remove
  * @return was the widget removed from the table.
  */

 bool remove(Widget widget) {
   // Validate.
   if (widget.getParent() != this) {
     return false;
   }

   // Orphan.
   try {
     orphan(widget);
   } finally {
     // Physical detach.
     dart_html.Element elem = widget.getElement();
     //Dom.removeChild(Dom.getParent(elem), elem);
     elem.remove();

     // Logical detach.
     widgetMap.removeByElement(elem);
   }
   return true;
 }

 /**
  * Sets the width of the table's border. This border is displayed around all
  * cells in the table.
  *
  * @param width the width of the border, in pixels
  */
 void setBorderWidth(int width) {
   Dom.setElementProperty(tableElem, "border", width.toString());
 }

 /**
  * Sets the amount of padding to be added around all cells.
  *
  * @param padding the cell padding, in pixels
  */
 void setCellPadding(int padding) {
   Dom.setElementPropertyInt(tableElem, "cellPadding", padding);
 }

 /**
  * Sets the amount of spacing to be added around all cells.
  *
  * @param spacing the cell spacing, in pixels
  */
 void setCellSpacing(int spacing) {
   Dom.setElementPropertyInt(tableElem, "cellSpacing", spacing);
 }

 /**
  * Sets the HTML contents of the specified cell.
  *
  * @param row the cell's row
  * @param column the cell's column
  * @param html the cell's HTML contents
  * @throws IndexOutOfBoundsException
  */
 void setHtml(int row, int column, String html) {
   prepareCell(row, column);
   dart_html.Element td = cleanCell(row, column, html == null);
   if (html != null) {
     td.innerHtml = html;
   }
 }

//  /**
//   * Sets the HTML contents of the specified cell.
//   *
//   * @param row the cell's row
//   * @param column the cell's column
//   * @param html the cell's safe html contents
//   * @throws IndexOutOfBoundsException
//   */
//  void setHTML(int row, int column, SafeHtml html) {
//    setHTML(row, column, html.asString());
//  }

 /**
  * Sets the text within the specified cell.
  *
  * @param row the cell's row
  * @param column cell's column
  * @param text the cell's text contents
  * @throws IndexOutOfBoundsException
  */
 void setText(int row, int column, String text) {
   prepareCell(row, column);
   dart_html.Element td;
   td = cleanCell(row, column, text == null);
   if (text != null) {
     //Dom.setInnerText(td, text);
     td.text = text;
   }
 }

 /**
  * Sets the widget within the specified cell.
  * <p>
  * Inherited implementations may either throw IndexOutOfBounds exception if
  * the cell does not exist, or allocate a new cell to store the content.
  * </p>
  * <p>
  * FlexTable will automatically allocate the cell at the correct location and
  * then set the widget. Grid will set the widget if and only if the cell is
  * within the Grid's bounding box.
  * </p>
  *
  * @param widget The widget to be added, or null to clear the cell
  * @param row the cell's row
  * @param column the cell's column
  * @throws IndexOutOfBoundsException
  */
 void setWidget(int row, int column, Widget widget) {
   prepareCell(row, column);

   // Removes any existing widget.
   dart_html.Element td = cleanCell(row, column, true);

   if (widget != null) {
     widget.removeFromParent();

     // Logical attach.
     widgetMap.put(widget);

     // Physical attach.
     td.append(widget.getElement());

     adopt(widget);
   }
 }

 /**
  * Overloaded version for IsWidget.
  *
  * @see #setWidget(int,int,Widget)
  */
 void setIsWidget(int row, int column, IsWidget widget) {
   this.setWidget(row, column, Widget.asWidgetOrNull(widget));
 }

 /**
  * Bounds checks that the cell exists at the specified location.
  *
  * @param row cell's row
  * @param column cell's column
  * @throws IndexOutOfBoundsException
  */
 void checkCellBounds(int row, int column) {
   checkRowBounds(row);
   if (column < 0) {
     throw new Exception("IndexOutOfBounds. Column ${column} must be non-negative: $column");
   }
   int cellSize = getCellCount(row);
   if (cellSize <= column) {
     throw new Exception("IndexOutOfBounds. Column index: $column, Column size: ${getCellCount(row)}");
   }
 }

 /**
  * Checks that the row is within the correct bounds.
  *
  * @param row row index to check
  * @throws IndexOutOfBoundsException
  */
 void checkRowBounds(int row) {
   int rowSize = getRowCount();
   if ((row >= rowSize) || (row < 0)) {
     throw new Exception("IndexOutOfBounds. Row index: $row, Row size: $rowSize");
   }
 }

 /**
  * Creates a new cell. Override this method if the cell should have initial
  * contents.
  *
  * @return the newly created TD
  */
 dart_html.Element createCell() {
   return new dart_html.TableCellElement();
 }

 /**
  * Gets the table's TBODY element.
  *
  * @return the TBODY element
  */
 dart_html.TableSectionElement getBodyElement() {
   return bodyElem;
 }

 /**
  * Directly ask the underlying Dom what the cell count on the given row is.
  *
  * @param tableBody the element
  * @param row the row
  * @return number of columns in the row
  */
 int getDomCellCount(int row, [dart_html.Element tableBody = null]) {
   if (tableBody == null) {
     return (bodyElem.parent as dart_html.TableElement).rows[row].cells.length;
   } else {
     return (tableBody.parent as dart_html.TableElement).rows[row].cells.length;
   }
 }

 /**
  * Directly ask the underlying Dom what the row count is.
  *
  * @return Returns the number of rows in the table
  */
 int getDomRowCount([dart_html.Element elem = null]) {
   if (elem == null) {
     return (bodyElem.parent as dart_html.TableElement).rows.length;
   } else {
     return (elem.parent as dart_html.TableElement).rows.length;
   }
 }

 /**
  * Determines the TD associated with the specified event.
  *
  * @param event the event to be queried
  * @return the TD associated with the event, or <code>null</code> if none is
  *         found.
  */
 dart_html.Element getEventTargetCell(dart_html.Event event) {
   for (dart_html.Element td = event.target; td != null; td = td.parent) {
     // If it's a TD, it might be the one we're looking for.
     if (td is dart_html.TableCellElement) {
       // Make sure it's directly a part of this table before returning it.
       dart_html.Element tr = td.parent;
       dart_html.Element body = tr.parent;
       if (body == bodyElem) {
         return td;
       }
     }
     // If we run into this table's body, we're out of options.
     if (td == bodyElem) {
       return null;
     }
   }
   return null;
 }

 /**
  * Inserts a new cell into the specified row.
  *
  * @param row the row into which the new cell will be inserted
  * @param column the column before which the cell will be inserted
  * @throws IndexOutOfBoundsException
  */
 void insertCell(int row, int column) {
   dart_html.Element tr = rowFormatter.getRow(bodyElem, row);
   dart_html.Element td = createCell();
   Dom.insertChild(tr, td, column);
 }

 /**
  * Inserts a number of cells before the specified cell.
  *
  * @param row the row into which the new cells will be inserted
  * @param column the column before which the new cells will be inserted
  * @param count number of cells to be inserted
  * @throws IndexOutOfBoundsException
  */
 void insertCells(int row, int column, int count) {
   dart_html.Element tr = rowFormatter.getRow(bodyElem, row);
   for (int i = column; i < column + count; i++) {
     dart_html.Element td = createCell();
     Dom.insertChild(tr, td, i);
   }
 }

 /**
  * Inserts a new row into the table.
  *
  * @param beforeRow the index before which the new row will be inserted
  * @return the index of the newly-created row
  * @throws IndexOutOfBoundsException
  */
 int insertRow(int beforeRow) {
   // Specifically allow the row count as an insert position.
   if (beforeRow != getRowCount()) {
     checkRowBounds(beforeRow);
   }
   dart_html.Element tr = new dart_html.TableRowElement();
   Dom.insertChild(bodyElem, tr, beforeRow);
   return beforeRow;
 }

 /**
  * Does actual clearing, used by clearCell and cleanCell. All HTMLTable
  * methods should use internalClearCell rather than clearCell, as clearCell
  * may be overridden in subclasses to format an empty cell.
  *
  * @param td element to clear
  * @param clearInnerHTML should the cell's inner html be cleared?
  * @return returns whether a widget was cleared
  */
 bool internalClearCell(dart_html.Element td, bool clearInnerHTML) {
   var maybeChild = td.firstChild;
   Widget widget = null;
   if (maybeChild != null && maybeChild is dart_html.Element) {
     widget = widgetMap.get(maybeChild as dart_html.Element);
   }
   if (widget != null) {
     // If there is a widget, remove it.
     remove(widget);
     return true;
   } else {
     // Otherwise, simply clear whatever text and/or HTML may be there.
     if (clearInnerHTML) {
       td.innerHtml = "";
     }
     return false;
   }
 }

 /**
  * Subclasses must implement this method. It allows them to decide what to do
  * just before a cell is accessed. If the cell already exists, this method
  * must do nothing. Otherwise, a subclass must either ensure that the cell
  * exists or throw an {@link IndexOutOfBoundsException}.
  *
  * @param row the cell's row
  * @param column the cell's column
  */
 void prepareCell(int row, int column);

 /**
  * Subclasses can implement this method. It allows them to decide what to do
  * just before a column is accessed. For classes, such as
  * <code>FlexTable</code>, that do not have a concept of a global column
  * length can ignore this method.
  *
  * @param column the cell's column
  * @throws IndexOutOfBoundsException
  */
 void prepareColumn(int column) {
   // Ensure that the indices are not negative.
   if (column < 0) {
     throw new Exception("IndexOutOfBounds. Cannot access a column with a negative index: $column");
   }
 }

 /**
  * Subclasses must implement this method. If the row already exists, this
  * method must do nothing. Otherwise, a subclass must either ensure that the
  * row exists or throw an {@link IndexOutOfBoundsException}.
  *
  * @param row the cell's row
  */
 void prepareRow(int row);

 /**
  * Removes the specified cell from the table.
  *
  * @param row the row of the cell to remove
  * @param column the column of cell to remove
  * @throws IndexOutOfBoundsException
  */
 void removeCell(int row, int column) {
   checkCellBounds(row, column);
   dart_html.Element td = cleanCell(row, column, false);
   dart_html.Element tr = rowFormatter.getRow(bodyElem, row);
   td.remove();
 }

 /**
  * Removes the specified row from the table.
  *
  * @param row the index of the row to be removed
  * @throws IndexOutOfBoundsException
  */
 void removeRow(int row) {
   int columnCount = getCellCount(row);
   for (int column = 0; column < columnCount; ++column) {
     cleanCell(row, column, false);
   }
   rowFormatter.getRow(bodyElem, row).remove();
 }

 /**
  * Sets the table's CellFormatter.
  *
  * @param cellFormatter the table's cell formatter
  */
 void setCellFormatter(CellFormatter cellFormatter) {
   this.cellFormatter = cellFormatter;
 }

 void setColumnFormatter(ColumnFormatter formatter) {
   // Copy the columnGroup element to the new formatter so we don't create a
   // second colgroup element.
   if (columnFormatter != null) {
     formatter.columnGroup = columnFormatter.columnGroup;
   }
   columnFormatter = formatter;
   columnFormatter._table = this;
   columnFormatter.prepareColumnGroup();
 }

 /**
  * Sets the table's RowFormatter.
  *
  * @param rowFormatter the table's row formatter
  */
 void setRowFormatter(RowFormatter rowFormatter) {
   this.rowFormatter = rowFormatter;
   this.rowFormatter._table = this;
 }

 /**
  * Removes any widgets, text, and HTML within the cell. This method assumes
  * that the requested cell already exists.
  *
  * @param row the cell's row
  * @param column the cell's column
  * @param clearInnerHTML should the cell's inner html be cleared?
  * @return element that has been cleaned
  */
 dart_html.Element cleanCell(int row, int column, bool clearInnerHTML) {
   // Clear whatever is in the cell.
   dart_html.Element td = getCellFormatter().getRawElement(row, column);
   internalClearCell(td, clearInnerHTML);
   return td;
 }

 /**
  * Gets the Widget associated with the given cell.
  *
  * @param row the cell's row
  * @param column the cell's column
  * @return the widget
  */
 Widget getWidgetImpl(int row, int column) {
   dart_html.Element e = cellFormatter.getRawElement(row, column);
   dart_html.Element child = e.firstChild;
   if (child == null) {
     return null;
   } else {
     return widgetMap.get(child);
   }
 }
}

Extends

UiObject > Widget > Panel > HtmlTable

Subclasses

FlexTable, Grid

Implements

HasDoubleClickHandlers, HasClickHandlers, HasAllDragAndDropHandlers

Constructors

new HtmlTable() #

Create a new empty HTML Table.

HtmlTable() {
 tableElem = new dart_html.TableElement();
 bodyElem = tableElem.createTBody();
 tableElem.append(bodyElem);
 setElement(tableElem);
}

Properties

TableSectionElement bodyElem #

Table's body.

dart_html.TableSectionElement bodyElem

CellFormatter cellFormatter #

Current cell formatter.

CellFormatter cellFormatter

ColumnFormatter columnFormatter #

Column Formatter.

ColumnFormatter columnFormatter

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

RowFormatter rowFormatter #

Current row formatter.

RowFormatter rowFormatter

TableElement tableElem #

Table element.

dart_html.TableElement tableElem

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);
}

ElementMapperImpl<Widget> widgetMap #

ElementMapperImpl<Widget> widgetMap = new ElementMapperImpl<Widget>()

Methods

void add(Widget child) #

inherited from Panel

Adds a child widget.

How to Override this Method

There are several important things that must take place in the correct order to properly add or insert a Widget to a Panel. Not all of these steps will be relevant to every Panel, but all of the steps must be considered.

  1. Validate: Perform any sanity checks to ensure the Panel can accept a new Widget. Examples: checking for a valid index on insertion; checking that the Panel is not full if there is a max capacity.
  2. Adjust for Reinsertion: Some Panels need to handle the case where the Widget is already a child of this Panel. Example: when performing a reinsert, the index might need to be adjusted to account for the Widget's removal. See {@link ComplexPanel#adjustIndex(Widget, int)}.
  3. Detach Child: Remove the Widget from its existing parent, if any. Most Panels will simply call {@link Widget#removeFromParent()} on the Widget.
  4. Logical Attach: Any state variables of the Panel should be updated to reflect the addition of the new Widget. Example: the Widget is added to the Panel's {@link WidgetCollection} at the appropriate index.
  5. Physical Attach: The Widget's Element must be physically attached to the Panel's Element, either directly or indirectly.
  6. Adopt: Call {@link #adopt(Widget)} to finalize the add as the very last step.

@param child the widget to be added @throws UnsupportedOperationException if this method is not supported (most

      often this means that a specific overload must be called)

@see HasWidgets#add(Widget)

void add(Widget child) {
 throw new Exception("This panel does not support no-arg add()");
}

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 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 addClickHandler(ClickHandler handler) #

Adds a {@link ClickEvent} handler.

@param handler the click handler @return {@link HandlerRegistration} used to remove this handler

docs inherited from HasClickHandlers
HandlerRegistration addClickHandler(ClickHandler handler) {
 return addDomHandler(handler, ClickEvent.TYPE);
}

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 addDoubleClickHandler(DoubleClickHandler handler) #

Adds a {@link DoubleClickEvent} handler.

@param handler the double click handler @return {@link HandlerRegistration} used to remove this handler

docs inherited from HasDoubleClickHandlers
HandlerRegistration addDoubleClickHandler(DoubleClickHandler handler) {
 return addDomHandler(handler, DoubleClickEvent.TYPE);
}

HandlerRegistration addDragEndHandler(DragEndHandler handler) #

Adds a {@link DragEndEvent} handler.

@param handler the drag end handler @return {@link HandlerRegistration} used to remove this handler

docs inherited from HasDragEndHandlers
HandlerRegistration addDragEndHandler(DragEndHandler handler) {
 return addDomHandler(handler, DragEndEvent.TYPE);
}

HandlerRegistration addDragEnterHandler(DragEnterHandler handler) #

Adds a {@link DragEnterEvent} handler.

@param handler the drag end handler @return {@link HandlerRegistration} used to remove this handler

docs inherited from HasDragEnterHandlers
HandlerRegistration addDragEnterHandler(DragEnterHandler handler) {
 return addDomHandler(handler, DragEnterEvent.TYPE);
}

HandlerRegistration addDragHandler(DragHandler handler) #

Adds a {@link DragEvent} handler.

@param handler the drag handler @return {@link HandlerRegistration} used to remove this handler

docs inherited from HasDragHandlers
HandlerRegistration addDragHandler(DragHandler handler) {
 return addDomHandler(handler, DragEvent.TYPE);
}

HandlerRegistration addDragLeaveHandler(DragLeaveHandler handler) #

Adds a {@link DragLeaveEvent} handler.

@param handler the drag leave handler @return {@link HandlerRegistration} used to remove this handler

docs inherited from HasDragLeaveHandlers
HandlerRegistration addDragLeaveHandler(DragLeaveHandler handler) {
 return addDomHandler(handler, DragLeaveEvent.TYPE);
}

HandlerRegistration addDragOverHandler(DragOverHandler handler) #

Adds a {@link DragOverEvent} handler.

@param handler the drag over handler @return {@link HandlerRegistration} used to remove this handler

docs inherited from HasDragOverHandlers
HandlerRegistration addDragOverHandler(DragOverHandler handler) {
 return addDomHandler(handler, DragOverEvent.TYPE);
}

HandlerRegistration addDragStartHandler(DragStartHandler handler) #

Adds a {@link DragStartEvent} handler.

@param handler the drag start handler @return {@link HandlerRegistration} used to remove this handler

docs inherited from HasDragStartHandlers
HandlerRegistration addDragStartHandler(DragStartHandler handler) {
 return addDomHandler(handler, DragStartEvent.TYPE);
}

HandlerRegistration addDropHandler(DropHandler handler) #

Adds a {@link DropEvent} handler.

@param handler the drop handler @return {@link HandlerRegistration} used to remove this handler

docs inherited from HasDropHandlers
HandlerRegistration addDropHandler(DropHandler handler) {
 return addDomHandler(handler, DropEvent.TYPE);
}

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);
}

void addIsWidget(IsWidget child) #

inherited from Panel
void addIsWidget(IsWidget child) {
 this.add(Widget.asWidgetOrNull(child));
}

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 adopt(Widget child) #

inherited from Panel

Finalize the attachment of a Widget to this Panel. This method is the <b>last</b> step in adding or inserting a Widget into a Panel, and should be called after physical attachment in the DOM is complete. This Panel becomes the parent of the child Widget, and the child will now fire its {@link Widget#onAttach()} event if this Panel is currently attached.

@param child the widget to be adopted @see #add(Widget)

void adopt(Widget child) {
 assert (child.getParent() == null);
 child.setParent(this);
}

Widget asWidget() #

inherited from Widget

Returns the Widget aspect of the receiver.

Widget asWidget() {
 return this;
}

void checkCellBounds(int row, int column) #

Bounds checks that the cell exists at the specified location.

@param row cell's row @param column cell's column @throws IndexOutOfBoundsException

void checkCellBounds(int row, int column) {
 checkRowBounds(row);
 if (column < 0) {
   throw new Exception("IndexOutOfBounds. Column ${column} must be non-negative: $column");
 }
 int cellSize = getCellCount(row);
 if (cellSize <= column) {
   throw new Exception("IndexOutOfBounds. Column index: $column, Column size: ${getCellCount(row)}");
 }
}

void checkRowBounds(int row) #

Checks that the row is within the correct bounds.

@param row row index to check @throws IndexOutOfBoundsException

void checkRowBounds(int row) {
 int rowSize = getRowCount();
 if ((row >= rowSize) || (row < 0)) {
   throw new Exception("IndexOutOfBounds. Row index: $row, Row size: $rowSize");
 }
}

Element cleanCell(int row, int column, bool clearInnerHTML) #

Removes any widgets, text, and HTML within the cell. This method assumes that the requested cell already exists.

@param row the cell's row @param column the cell's column @param clearInnerHTML should the cell's inner html be cleared? @return element that has been cleaned

dart_html.Element cleanCell(int row, int column, bool clearInnerHTML) {
 // Clear whatever is in the cell.
 dart_html.Element td = getCellFormatter().getRawElement(row, column);
 internalClearCell(td, clearInnerHTML);
 return td;
}

void clear([bool clearInnerHTML = false]) #

Removes all widgets from this table, optionally clearing the inner HTML of each cell. Note that this method does not remove any cells or rows.

@param clearInnerHTML should the cell's inner html be cleared?

void clear([bool clearInnerHTML = false]) {
 for (int row = 0; row < getRowCount(); ++row) {
   for (int col = 0; col < getCellCount(row); ++col) {
     cleanCell(row, col, clearInnerHTML);
   }
 }
}

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);
}

bool clearCell(int row, int column) #

Clears the cell at the given row and column. If it contains a Widget, it will be removed from the table. If not, its contents will simply be cleared.

@param row the widget's row @param column the widget's column @return true if a widget was removed @throws IndexOutOfBoundsException

bool clearCell(int row, int column) {
 dart_html.Element td = getCellFormatter().getElement(row, column);
 return internalClearCell(td, true);
}

Element createCell() #

Creates a new cell. Override this method if the cell should have initial contents.

@return the newly created TD

dart_html.Element createCell() {
 return new dart_html.TableCellElement();
}

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 Panel

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()

docs inherited from Widget
void doAttachChildren() {
 AttachDetachException.tryCommand(this.iterator(), AttachDetachException.attachCommand);
}

void doDetachChildren() #

inherited from Panel

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()

docs inherited from Widget
void doDetachChildren() {
 AttachDetachException.tryCommand(this.iterator(), AttachDetachException.detachCommand);
}

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);
     }
   }
 }
}

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());
}

TableSectionElement getBodyElement() #

Gets the table's TBODY element.

@return the TBODY element

dart_html.TableSectionElement getBodyElement() {
 return bodyElem;
}

abstract int getCellCount(int row) #

Gets the number of cells in a given row.

@param row the row whose cells are to be counted @return the number of cells present in the row

Cell getCellForEvent(ClickEvent event) #

Given a click event, return the Cell that was clicked, or null if the event did not hit this table. The cell can also be null if the click event does not occur on a specific cell.

@param event A click event of indeterminate origin @return The appropriate cell, or null

Cell getCellForEvent(ClickEvent event) {
 dart_html.Element td = getEventTargetCell(event.getNativeEvent());
 if (td == null) {
   return null;
 }

 int row = (td.parent as dart_html.TableRowElement).sectionRowIndex;
 int column = (td as dart_html.TableCellElement).cellIndex;
 return new Cell(this, row, column);
}

CellFormatter getCellFormatter() #

Gets the {@link CellFormatter} associated with this table. Use casting to get subclass-specific functionality

@return this table's cell formatter

CellFormatter getCellFormatter() {
 return cellFormatter;
}

int getCellPadding() #

Gets the amount of padding that is added around all cells.

@return the cell padding, in pixels

int getCellPadding() {
 return Dom.getElementPropertyInt(tableElem, "cellPadding");
}

int getCellSpacing() #

Gets the amount of spacing that is added around all cells.

@return the cell spacing, in pixels

int getCellSpacing() {
 return Dom.getElementPropertyInt(tableElem, "cellSpacing");
}

ColumnFormatter getColumnFormatter() #

Gets the column formatter.

@return the column formatter

ColumnFormatter getColumnFormatter() {
 return columnFormatter;
}

int getDomCellCount(int row, [Element tableBody = null]) #

Directly ask the underlying Dom what the cell count on the given row is.

@param tableBody the element @param row the row @return number of columns in the row

int getDomCellCount(int row, [dart_html.Element tableBody = null]) {
 if (tableBody == null) {
   return (bodyElem.parent as dart_html.TableElement).rows[row].cells.length;
 } else {
   return (tableBody.parent as dart_html.TableElement).rows[row].cells.length;
 }
}

int getDomRowCount([Element elem = null]) #

Directly ask the underlying Dom what the row count is.

@return Returns the number of rows in the table

int getDomRowCount([dart_html.Element elem = null]) {
 if (elem == null) {
   return (bodyElem.parent as dart_html.TableElement).rows.length;
 } else {
   return (elem.parent as dart_html.TableElement).rows.length;
 }
}

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;
}

Element getEventTargetCell(Event event) #

Determines the TD associated with the specified event.

@param event the event to be queried @return the TD associated with the event, or <code>null</code> if none is

    found.
dart_html.Element getEventTargetCell(dart_html.Event event) {
 for (dart_html.Element td = event.target; td != null; td = td.parent) {
   // If it's a TD, it might be the one we're looking for.
   if (td is dart_html.TableCellElement) {
     // Make sure it's directly a part of this table before returning it.
     dart_html.Element tr = td.parent;
     dart_html.Element body = tr.parent;
     if (body == bodyElem) {
       return td;
     }
   }
   // If we run into this table's body, we're out of options.
   if (td == bodyElem) {
     return null;
   }
 }
 return null;
}

String getHTML(int row, int column) #

Gets the HTML contents of the specified cell.

@param row the cell's row @param column the cell's column @return the cell's HTML contents @throws IndexOutOfBoundsException

String getHTML(int row, int column) {
 return cellFormatter.getElement(row, column).innerHtml;
}

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;
}

abstract int getRowCount() #

Gets the number of rows present in this table.

@return the table's row count

RowFormatter getRowFormatter() #

Gets the RowFormatter associated with this table.

@return the table's row formatter

RowFormatter getRowFormatter() {
 return rowFormatter;
}

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());
}

String getText(int row, int column) #

Gets the text within the specified cell.

@param row the cell's row @param column the cell's column @return the cell's text contents @throws IndexOutOfBoundsException

String getText(int row, int column) {
 checkCellBounds(row, column);
 return cellFormatter.getElement(row, column).text;
}

Widget getWidget(int row, int column) #

Gets the widget in the specified cell.

@param row the cell's row @param column the cell's column @return the widget in the specified cell, or <code>null</code> if none is

    present

@throws IndexOutOfBoundsException

Widget getWidget(int row, int column) {
 checkCellBounds(row, column);
 return getWidgetImpl(row, column);
}

Widget getWidgetImpl(int row, int column) #

Gets the Widget associated with the given cell.

@param row the cell's row @param column the cell's column @return the widget

Widget getWidgetImpl(int row, int column) {
 dart_html.Element e = cellFormatter.getRawElement(row, column);
 dart_html.Element child = e.firstChild;
 if (child == null) {
   return null;
 } else {
   return widgetMap.get(child);
 }
}

void insertCell(int row, int column) #

Inserts a new cell into the specified row.

@param row the row into which the new cell will be inserted @param column the column before which the cell will be inserted @throws IndexOutOfBoundsException

void insertCell(int row, int column) {
 dart_html.Element tr = rowFormatter.getRow(bodyElem, row);
 dart_html.Element td = createCell();
 Dom.insertChild(tr, td, column);
}

void insertCells(int row, int column, int count) #

Inserts a number of cells before the specified cell.

@param row the row into which the new cells will be inserted @param column the column before which the new cells will be inserted @param count number of cells to be inserted @throws IndexOutOfBoundsException

void insertCells(int row, int column, int count) {
 dart_html.Element tr = rowFormatter.getRow(bodyElem, row);
 for (int i = column; i < column + count; i++) {
   dart_html.Element td = createCell();
   Dom.insertChild(tr, td, i);
 }
}

int insertRow(int beforeRow) #

Inserts a new row into the table.

@param beforeRow the index before which the new row will be inserted @return the index of the newly-created row @throws IndexOutOfBoundsException

int insertRow(int beforeRow) {
 // Specifically allow the row count as an insert position.
 if (beforeRow != getRowCount()) {
   checkRowBounds(beforeRow);
 }
 dart_html.Element tr = new dart_html.TableRowElement();
 Dom.insertChild(bodyElem, tr, beforeRow);
 return beforeRow;
}

bool internalClearCell(Element td, bool clearInnerHTML) #

Does actual clearing, used by clearCell and cleanCell. All HTMLTable methods should use internalClearCell rather than clearCell, as clearCell may be overridden in subclasses to format an empty cell.

@param td element to clear @param clearInnerHTML should the cell's inner html be cleared? @return returns whether a widget was cleared

bool internalClearCell(dart_html.Element td, bool clearInnerHTML) {
 var maybeChild = td.firstChild;
 Widget widget = null;
 if (maybeChild != null && maybeChild is dart_html.Element) {
   widget = widgetMap.get(maybeChild as dart_html.Element);
 }
 if (widget != null) {
   // If there is a widget, remove it.
   remove(widget);
   return true;
 } else {
   // Otherwise, simply clear whatever text and/or HTML may be there.
   if (clearInnerHTML) {
     td.innerHtml = "";
   }
   return false;
 }
}

bool isAttached() #

inherited from Widget

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() {
 return _attached;
}

bool isCellPresent(int row, int column) #

Determines whether the specified cell exists.

@param row the cell's row @param column the cell's column @return <code>true</code> if the specified cell exists

bool isCellPresent(int row, int column) {
 if ((row >= getRowCount()) || (row < 0)) {
   return false;
 }
 if ((column < 0) || (column >= getCellCount(row))) {
   return false;
 } else {
   return true;
 }
}

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 containing all the widgets in this table.

@return the iterator

Iterator<Widget> iterator() {
 return new _WidgetIterator(this);
}

void onAttach() #

inherited from Widget

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 (isAttached()) {
   throw new Exception("Should only call onAttach when the widget is detached from the browser's document");
 }

 _attached = true;

 // Event hookup code
 Dom.setEventListener(getElement(), this);
 int bitsToAdd = eventsToSink;
 eventsToSink = -1;
 if (bitsToAdd > 0) {
   sinkEvents(bitsToAdd);
 }
 doAttachChildren();

 // onLoad() gets called only *after* all of the children are attached and
 // the attached flag is set. This allows widgets to be notified when they
 // are fully attached, and panels when all of their children are attached.
 onLoad();
 AttachEvent.fire(this, true);
}

void onBrowserEvent(Event event) #

inherited from Widget

Fired whenever a browser event is received.

@param event the event received

TODO

void onBrowserEvent(dart_html.Event event) {
 switch (Dom.eventGetType(event)) {
   case IEvent.ONMOUSEOVER:
     // Only fire the mouse over event if it's coming from outside this
     // widget.
   case IEvent.ONMOUSEOUT:
     // Only fire the mouse over event if it's coming from outside this widget.
     // Only fire the mouse out event if it's leaving this widget.
     dart_html.Element related = (event as dart_html.MouseEvent).relatedTarget as dart_html.Element;
     if (related != null && Dom.isOrHasChild(getElement(), related)) {
       return;
     }
     break;
 }

 DomEvent.fireNativeEvent(event, this, this.getElement());
}

void onDetach() #

inherited from Widget

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() {
 if (!isAttached()) {
   throw new Exception("Should only call onDetach when the widget is attached to the browser's document");
 }

 try {
   // onUnload() gets called *before* everything else (the opposite of
   // onLoad()).
   onUnload();
   AttachEvent.fire(this, false);
 } finally {
   // Put this in a finally, just in case onUnload throws an exception.
   try {
     doDetachChildren();
   } finally {
     // Put this in a finally, in case doDetachChildren throws an exception.
     Dom.setEventListener(getElement(), null);
     _attached = false;
   }
 }
}

void onLoad() #

inherited from Widget

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

void onLoad() {
}

void onUnload() #

inherited from Widget

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

void onUnload() {
}

void orphan(Widget child) #

inherited from Panel

This method must be called as part of the remove method of any Panel. It ensures that the Widget's parent is cleared. This method should be called after verifying that the child Widget is an existing child of the Panel, but before physically removing the child Widget from the DOM. The child will now fire its {@link Widget#onDetach()} event if this Panel is currently attached.

Calls to {@link #orphan(Widget)} should be wrapped in a try/finally block to ensure that the widget is physically detached even if orphan throws an exception.

@param child the widget to be disowned @see #add(Widget)

void orphan(Widget child) {
 assert (child.getParent() == this);
 child.setParent(null);
}

abstract void prepareCell(int row, int column) #

Subclasses must implement this method. It allows them to decide what to do just before a cell is accessed. If the cell already exists, this method must do nothing. Otherwise, a subclass must either ensure that the cell exists or throw an {@link IndexOutOfBoundsException}.

@param row the cell's row @param column the cell's column

void prepareColumn(int column) #

Subclasses can implement this method. It allows them to decide what to do just before a column is accessed. For classes, such as <code>FlexTable</code>, that do not have a concept of a global column length can ignore this method.

@param column the cell's column @throws IndexOutOfBoundsException

void prepareColumn(int column) {
 // Ensure that the indices are not negative.
 if (column < 0) {
   throw new Exception("IndexOutOfBounds. Cannot access a column with a negative index: $column");
 }
}

abstract void prepareRow(int row) #

Subclasses must implement this method. If the row already exists, this method must do nothing. Otherwise, a subclass must either ensure that the row exists or throw an {@link IndexOutOfBoundsException}.

@param row the cell's row

bool remove(Widget widget) #

Remove the specified widget from the table.

@param widget widget to remove @return was the widget removed from the table.

bool remove(Widget widget) {
 // Validate.
 if (widget.getParent() != this) {
   return false;
 }

 // Orphan.
 try {
   orphan(widget);
 } finally {
   // Physical detach.
   dart_html.Element elem = widget.getElement();
   //Dom.removeChild(Dom.getParent(elem), elem);
   elem.remove();

   // Logical detach.
   widgetMap.removeByElement(elem);
 }
 return true;
}

void removeCell(int row, int column) #

Removes the specified cell from the table.

@param row the row of the cell to remove @param column the column of cell to remove @throws IndexOutOfBoundsException

void removeCell(int row, int column) {
 checkCellBounds(row, column);
 dart_html.Element td = cleanCell(row, column, false);
 dart_html.Element tr = rowFormatter.getRow(bodyElem, row);
 td.remove();
}

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");
 }
}

bool removeIsWidget(IsWidget child) #

inherited from Panel
bool removeIsWidget(IsWidget child) {
 return remove(Widget.asWidgetOrNull(child));
}

void removeRow(int row) #

Removes the specified row from the table.

@param row the index of the row to be removed @throws IndexOutOfBoundsException

void removeRow(int row) {
 int columnCount = getCellCount(row);
 for (int column = 0; column < columnCount; ++column) {
   cleanCell(row, column, false);
 }
 rowFormatter.getRow(bodyElem, row).remove();
}

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 setBorderWidth(int width) #

Sets the width of the table's border. This border is displayed around all cells in the table.

@param width the width of the border, in pixels

void setBorderWidth(int width) {
 Dom.setElementProperty(tableElem, "border", width.toString());
}

void setCellFormatter(CellFormatter cellFormatter) #

Sets the table's CellFormatter.

@param cellFormatter the table's cell formatter

void setCellFormatter(CellFormatter cellFormatter) {
 this.cellFormatter = cellFormatter;
}

void setCellPadding(int padding) #

Sets the amount of padding to be added around all cells.

@param padding the cell padding, in pixels

void setCellPadding(int padding) {
 Dom.setElementPropertyInt(tableElem, "cellPadding", padding);
}

void setCellSpacing(int spacing) #

Sets the amount of spacing to be added around all cells.

@param spacing the cell spacing, in pixels

void setCellSpacing(int spacing) {
 Dom.setElementPropertyInt(tableElem, "cellSpacing", spacing);
}

void setColumnFormatter(ColumnFormatter formatter) #

void setColumnFormatter(ColumnFormatter formatter) {
 // Copy the columnGroup element to the new formatter so we don't create a
 // second colgroup element.
 if (columnFormatter != null) {
   formatter.columnGroup = columnFormatter.columnGroup;
 }
 columnFormatter = formatter;
 columnFormatter._table = this;
 columnFormatter.prepareColumnGroup();
}

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 setHtml(int row, int column, String html) #

Sets the HTML contents of the specified cell.

@param row the cell's row @param column the cell's column @param html the cell's HTML contents @throws IndexOutOfBoundsException

void setHtml(int row, int column, String html) {
 prepareCell(row, column);
 dart_html.Element td = cleanCell(row, column, html == null);
 if (html != null) {
   td.innerHtml = html;
 }
}

void setIsWidget(int row, int column, IsWidget widget) #

Overloaded version for IsWidget.

@see #setWidget(int,int,Widget)

void setIsWidget(int row, int column, IsWidget widget) {
 this.setWidget(row, column, Widget.asWidgetOrNull(widget));
}

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 setRowFormatter(RowFormatter rowFormatter) #

Sets the table's RowFormatter.

@param rowFormatter the table's row formatter

void setRowFormatter(RowFormatter rowFormatter) {
 this.rowFormatter = rowFormatter;
 this.rowFormatter._table = this;
}

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 setText(int row, int column, String text) #

Sets the text within the specified cell.

@param row the cell's row @param column cell's column @param text the cell's text contents @throws IndexOutOfBoundsException

void setText(int row, int column, String text) {
 prepareCell(row, column);
 dart_html.Element td;
 td = cleanCell(row, column, text == null);
 if (text != null) {
   //Dom.setInnerText(td, text);
   td.text = text;
 }
}

void setWidget(int row, int column, Widget widget) #

Sets the widget within the specified cell. <p> Inherited implementations may either throw IndexOutOfBounds exception if the cell does not exist, or allocate a new cell to store the content. </p> <p> FlexTable will automatically allocate the cell at the correct location and then set the widget. Grid will set the widget if and only if the cell is within the Grid's bounding box. </p>

@param widget The widget to be added, or null to clear the cell @param row the cell's row @param column the cell's column @throws IndexOutOfBoundsException

void setWidget(int row, int column, Widget widget) {
 prepareCell(row, column);

 // Removes any existing widget.
 dart_html.Element td = cleanCell(row, column, true);

 if (widget != null) {
   widget.removeFromParent();

   // Logical attach.
   widgetMap.put(widget);

   // Physical attach.
   td.append(widget.getElement());

   adopt(widget);
 }
}

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));
}