org.xwiki.gwt.wysiwyg.client.plugin.table.util
Class TableUtils

java.lang.Object
  extended by org.xwiki.gwt.wysiwyg.client.plugin.table.util.TableUtils

public final class TableUtils
extends java.lang.Object

Utility class designed to ease HTML tables manipulation.

Version:
$Id: TableUtils.java 26786 2010-02-07 16:46:17Z mflorea $

Field Summary
static java.lang.String BODY_NODENAME
          HTML tag defining the root node of the area being edited.
static java.lang.String CELL_DEFAULTHTML
          HTML to be inserted in newly created table cells.
static java.lang.String COL_HNODENAME
          HTML tag defining a table heading cell.
static java.lang.String COL_NODENAME
          HTML tag defining a table cell.
static java.lang.String ROW_NODENAME
          HTML tag defining a table row.
static java.lang.String TABLE_NODENAME
          HTML tag defining a table.
static java.lang.String TBODY_NODENAME
          HTML tag defining a table body.
 
Constructor Summary
TableUtils()
           
 
Method Summary
 com.google.gwt.dom.client.Node getCaretNode(Document doc)
          Get the node in which the caret is currently positioned.
 com.google.gwt.dom.client.TableCellElement getCell(com.google.gwt.dom.client.Node node)
          Browse node ancestors and return the first table cell element (TD or TH).
static TableUtils getInstance()
          Get the instance in use.
 com.google.gwt.dom.client.TableCellElement getNextCellInColumn(com.google.gwt.dom.client.TableCellElement cell)
          Get next cell in cell's column.
 com.google.gwt.dom.client.TableCellElement getNextCellInRow(com.google.gwt.dom.client.TableCellElement cell)
          Get next cell in cell's row.
 com.google.gwt.dom.client.TableCellElement getPreviousCellInColumn(com.google.gwt.dom.client.TableCellElement cell)
          Get previous cell in cell's column.
 com.google.gwt.dom.client.TableCellElement getPreviousCellInRow(com.google.gwt.dom.client.TableCellElement cell)
          Get previous cell in cell's row.
 Range getRange(Document doc)
          Inspect a Document to get the currently selected Range.
 com.google.gwt.dom.client.TableRowElement getRow(com.google.gwt.dom.client.Node node)
          Browse node ancestors and return the first table row element.
 com.google.gwt.dom.client.TableElement getTable(com.google.gwt.dom.client.Node node)
          Browse node ancestors and return the first table element.
 void insertCol(Document doc, boolean insertBefore)
          Insert a column in the currently edited table.
 com.google.gwt.dom.client.TableRowElement insertRow(Document doc, boolean insertBefore)
          Insert a row in the currently edited table.
 boolean isHeaderRow(com.google.gwt.dom.client.TableRowElement row)
          Determine if the row is a header row.
 void putCaretInNode(RichTextArea rta, com.google.gwt.dom.client.Node node)
          Put caret in the given HTML node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BODY_NODENAME

public static final java.lang.String BODY_NODENAME
HTML tag defining the root node of the area being edited.

See Also:
Constant Field Values

TABLE_NODENAME

public static final java.lang.String TABLE_NODENAME
HTML tag defining a table.

See Also:
Constant Field Values

TBODY_NODENAME

public static final java.lang.String TBODY_NODENAME
HTML tag defining a table body.

See Also:
Constant Field Values

ROW_NODENAME

public static final java.lang.String ROW_NODENAME
HTML tag defining a table row.

See Also:
Constant Field Values

COL_NODENAME

public static final java.lang.String COL_NODENAME
HTML tag defining a table cell.

See Also:
Constant Field Values

COL_HNODENAME

public static final java.lang.String COL_HNODENAME
HTML tag defining a table heading cell.

See Also:
Constant Field Values

CELL_DEFAULTHTML

public static final java.lang.String CELL_DEFAULTHTML
HTML to be inserted in newly created table cells.

See Also:
Constant Field Values
Constructor Detail

TableUtils

public TableUtils()
Method Detail

getInstance

public static TableUtils getInstance()
Get the instance in use.

Returns:
the instance in use.

getRange

public Range getRange(Document doc)
Inspect a Document to get the currently selected Range.

Parameters:
doc - Document to inspect.
Returns:
currently selected range.

getCaretNode

public com.google.gwt.dom.client.Node getCaretNode(Document doc)
Get the node in which the caret is currently positioned.

Parameters:
doc - Document to get the caret from.
Returns:
node holding the caret.

putCaretInNode

public void putCaretInNode(RichTextArea rta,
                           com.google.gwt.dom.client.Node node)
Put caret in the given HTML node.

Parameters:
rta - wysiwyg RichTextArea
node - the node to put the caret in.

getTable

public com.google.gwt.dom.client.TableElement getTable(com.google.gwt.dom.client.Node node)
Browse node ancestors and return the first table element.

Parameters:
node - the Node to inspect.
Returns:
the matching TableElement if any, null otherwise.

getRow

public com.google.gwt.dom.client.TableRowElement getRow(com.google.gwt.dom.client.Node node)
Browse node ancestors and return the first table row element.

Parameters:
node - the Node to inspect.
Returns:
the matching TableRowElement if any, null otherwise.

isHeaderRow

public boolean isHeaderRow(com.google.gwt.dom.client.TableRowElement row)
Determine if the row is a header row. A header row contains TH nodes describing their respective columns.

Parameters:
row - the row to inspect.
Returns:
true if the row is a heading row.

getCell

public com.google.gwt.dom.client.TableCellElement getCell(com.google.gwt.dom.client.Node node)
Browse node ancestors and return the first table cell element (TD or TH).

Parameters:
node - the node to inspect.
Returns:
the matching TableCellElement if any, null otherwise.

getNextCellInRow

public com.google.gwt.dom.client.TableCellElement getNextCellInRow(com.google.gwt.dom.client.TableCellElement cell)
Get next cell in cell's row.

Parameters:
cell - currently edited cell.
Returns:
the next TableCellElement if any, null otherwise.

getPreviousCellInRow

public com.google.gwt.dom.client.TableCellElement getPreviousCellInRow(com.google.gwt.dom.client.TableCellElement cell)
Get previous cell in cell's row.

Parameters:
cell - currently edited cell.
Returns:
the previous TableCellElement if any, null otherwise.

getNextCellInColumn

public com.google.gwt.dom.client.TableCellElement getNextCellInColumn(com.google.gwt.dom.client.TableCellElement cell)
Get next cell in cell's column.

Parameters:
cell - currently edited cell.
Returns:
the next TableCellElement if any, null otherwise.

getPreviousCellInColumn

public com.google.gwt.dom.client.TableCellElement getPreviousCellInColumn(com.google.gwt.dom.client.TableCellElement cell)
Get previous cell in cell's column.

Parameters:
cell - currently edited cell.
Returns:
the previous TableCellElement if any, null otherwise.

insertRow

public com.google.gwt.dom.client.TableRowElement insertRow(Document doc,
                                                           boolean insertBefore)
Insert a row in the currently edited table.

Parameters:
doc - the Document to get the selection from.
insertBefore - indicates the creation position relatively to the currently edited row.
Returns:
the newly created TableRowElement.

insertCol

public void insertCol(Document doc,
                      boolean insertBefore)
Insert a column in the currently edited table.

Parameters:
doc - the Document to get the selection from.
insertBefore - indicates the creation position relatively to the currently edited column.


Copyright © 2004-2011 XWiki. All Rights Reserved.