com.leafdigital.ui.api
Interface Table

All Superinterfaces:
SupportsMacIndent, Widget

public interface Table
extends Widget, SupportsMacIndent

Interface for tables.

Tables have a number of columns, specified with 'column' elements within the Table tag. Each column has a type (string or boolean), an editable flag, and an optional width (0 = as small as possible).

Here's an example table in XML format:

 <Table id="nicknames" OnChange="nicknamesChange" OnEditing="nicknamesEditing" OnSelect="nicknamesSelect" Width="200" Rows="4">
   <column name="Nickname" type="string" editable="y" width="100"/>
   <column name="Password" type="string" editable="y"/>
   <column name="Default" type="boolean" editable="y" width="0"/>
 </Table>
 


Nested Class Summary
static class Table.EditingControl
          Class passed as part of the onEditing callback.
 
Field Summary
static int NONE
          Value used to indicate no selection
 
Fields inherited from interface com.leafdigital.ui.api.SupportsMacIndent
TYPE_BUTTON, TYPE_EDIT, TYPE_EDIT_LEGACY, TYPE_NONE
 
Method Summary
 int addItem()
          Adds new item to end of list.
 void clear()
          Remove all items from list
 boolean getBoolean(int index, int column)
          Obtains value at given column.
 int getNumItems()
           
 int getSelectedIndex()
           
 int[] getSelectedIndices()
           
 java.lang.String getString(int index, int column)
          Obtains value at given column.
 boolean isDim(int index, int column)
           
 boolean isEditable(int index, int column)
           
 boolean isOverwrite(int index, int column)
           
 void removeItem(int index)
          Removes item from list.
 void setBoolean(int index, int column, boolean value)
          Sets value at a given column.
 void setDim(int index, int column, boolean dim)
          Sets the dim state of given cell.
 void setEditable(int index, int column, boolean editable)
          Sets the editable state of given cell.
 void setMultiSelect(boolean multiSelect)
           
 void setOnAction(java.lang.String callback)
          Sets callback method used when somebody double-clicks or presses Return.
 void setOnChange(java.lang.String callback)
          Sets the callback method used when user edits something (or, in the case of textfields, finishes editing it).
 void setOnEditing(java.lang.String callback)
          Sets the callback method used while the user is editing a textfield after each change.
 void setOnSelect(java.lang.String callback)
          Sets the callback method used when selection changes.
 void setOverwrite(int index, int column, boolean overwrite)
          Sets the overwrite state of given cell (this just means that its text content will be highlighted when you select it).
 void setRows(int rows)
          Set number of displayed rows.
 void setSelectedIndex(int selected)
          Sets a single selected row.
 void setSelectedIndices(int[] selected)
          Sets multiple selected indices.
 void setString(int index, int column, java.lang.String value)
          Sets value at a given column.
 void setWidth(int width)
          Sets preferred width of table.
 
Methods inherited from interface com.leafdigital.ui.api.Widget
getID, getOwner, informClosed, isVisible, setOwner, setVisible
 
Methods inherited from interface com.leafdigital.ui.api.SupportsMacIndent
setMacIndent, setMacIndent
 

Field Detail

NONE

static final int NONE
Value used to indicate no selection

See Also:
Constant Field Values
Method Detail

addItem

int addItem()
Adds new item to end of list.

Returns:
Index of newly-added item

setWidth

void setWidth(int width)
Sets preferred width of table.

Parameters:
width - Preferred width

removeItem

void removeItem(int index)
Removes item from list.

Parameters:
index - Index of item to remove
Throws:
BugException - If index is out of bounds

clear

void clear()
Remove all items from list


getNumItems

int getNumItems()
Returns:
Number of items

getSelectedIndex

int getSelectedIndex()
Returns:
Selected index or Table.NONE if none are selected.
Throws:
BugException - If MultiSelect="y"

setSelectedIndex

void setSelectedIndex(int selected)
Sets a single selected row.

Parameters:
selected - Row to select

getSelectedIndices

int[] getSelectedIndices()
Returns:
Array of selected indices

setSelectedIndices

void setSelectedIndices(int[] selected)
Sets multiple selected indices.

Parameters:
selected - Rows to select

setRows

void setRows(int rows)
Set number of displayed rows.

Parameters:
rows - Number of rows

setString

void setString(int index,
               int column,
               java.lang.String value)
Sets value at a given column.

Parameters:
index - Index of item
column - Column index
value - Value at column
Throws:
BugException - If index or column are out of bounds, or column isn't a string

getString

java.lang.String getString(int index,
                           int column)
Obtains value at given column.

Parameters:
index - Index of item
column - Column index
Returns:
Value at column
Throws:
BugException - If index or column are out of bounds, or column isn't a string

setBoolean

void setBoolean(int index,
                int column,
                boolean value)
Sets value at a given column.

Parameters:
index - Index of item
column - Column index
value - Value at column
Throws:
BugException - If index or column are out of bounds, or column isn't correct type

getBoolean

boolean getBoolean(int index,
                   int column)
Obtains value at given column.

Parameters:
index - Index of item
column - Column index
Returns:
Value at column
Throws:
BugException - If index or column are out of bounds, or column isn't correct type

setEditable

void setEditable(int index,
                 int column,
                 boolean editable)
Sets the editable state of given cell. Only applies to columns that are in general editable.

Parameters:
index - Index of item
column - Column index
editable - True to allow edits, false to prohibit
Throws:
BugException - If index or column are out of bounds, or column isn't editable

isEditable

boolean isEditable(int index,
                   int column)
Parameters:
index - Index of item
column - Column index
Returns:
True if item can be edited (in editable column and editable)
Throws:
BugException - If index or column are out of bounds

setDim

void setDim(int index,
            int column,
            boolean dim)
Sets the dim state of given cell.

Parameters:
index - Index of item
column - Column index
dim - True to make dim, false for normal
Throws:
BugException - If index or column are out of bounds

isDim

boolean isDim(int index,
              int column)
Parameters:
index - Index of item
column - Column index
Returns:
True if item is dim
Throws:
BugException - If index or column are out of bounds

setOverwrite

void setOverwrite(int index,
                  int column,
                  boolean overwrite)
Sets the overwrite state of given cell (this just means that its text content will be highlighted when you select it). Only applies to string columns.

Parameters:
index - Index of item
column - Column index
overwrite - True to turn overwrite on, false to turn it off
Throws:
BugException - If index or column are out of bounds, or column isn't a string

isOverwrite

boolean isOverwrite(int index,
                    int column)
Parameters:
index - Index of item
column - Column index
Returns:
True if item has overwrite set
Throws:
BugException - If index or column are out of bounds or isn't a string

setOnChange

@UICallback
void setOnChange(java.lang.String callback)
Sets the callback method used when user edits something (or, in the case of textfields, finishes editing it). Signature of callback is: public void onChange(int index,int column,Object before)

Parameters:
callback - Name of method
Throws:
BugException - If method doesn't exist etc.

setOnSelect

@UICallback
void setOnSelect(java.lang.String callback)
Sets the callback method used when selection changes.

Parameters:
callback - Name of method
Throws:
BugException - If method doesn't exist etc.

setOnEditing

@UICallback
void setOnEditing(java.lang.String callback)
Sets the callback method used while the user is editing a textfield after each change. Signature of callback is: public void onEditing(int index,int column,String value,EditingControl ec)

Parameters:
callback - Name of method
Throws:
BugException - If method doesn't exist etc.

setMultiSelect

void setMultiSelect(boolean multiSelect)
Parameters:
multiSelect - If true, allows multiple rows to be selected

setOnAction

@UICallback
void setOnAction(java.lang.String callback)
Sets callback method used when somebody double-clicks or presses Return.

Parameters:
callback - Name of callback method


Copyright © 2011 Samuel Marshall. All rights reserved.