|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.eclipse.swt.custom.ControlEditor | +--org.eclipse.swt.custom.TableEditor
Safe: A TableEditor is a manager for a Control that appears above a cell in a Table and tracks with the moving and resizing of that cell. It can be used to display a text widget above a cell in a Table so that the user can edit the contents of that cell. It can also be used to display a button that can launch a dialog for modifying the contents of the associated cell.
Here is an example of using a TableEditor:
Table table = new Table(parent, SWT.FULL_SELECTION);
TableEditor editor = new TableEditor (table);
table.addSelectionListener (new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
// Clean up any previous editor control
Control oldEditor = editor.getEditor();
if (oldEditor != null)
oldEditor.dispose();
// Identify the selected row
int index = table.getSelectionIndex ();
if (index == -1) return;
TableItem item = table.getItem (index);
// The control that will be the editor must be a child of the Table
Text text = new Text(table, SWT.NONE);
//The text editor must have the same size as the cell and must
//not be any smaller than 50 pixels.
editor.horizontalAlignment = SWT.LEFT;
editor.grabHorizontal = true;
editor.minimumWidth = 50;
// Open the text editor in the second column of the selected row.
editor.setEditor (text, item, 1);
// Assign focus to the text control
text.setFocus ();
}
});
Field Summary | |
(package private) int |
column
|
(package private) Listener |
columnListener
|
(package private) TableItem |
item
|
(package private) Table |
table
|
Fields inherited from class org.eclipse.swt.custom.ControlEditor |
editor, grabHorizontal, grabVertical, horizontalAlignment, minimumHeight, minimumWidth, parent, verticalAlignment |
Constructor Summary | |
TableEditor(Table table)
Enabled: Creates a TableEditor for the specified Table. |
Method Summary | |
(package private) Rectangle |
computeBounds()
|
void |
dispose()
Enabled: Removes all associations between the TableEditor and the cell in the table. |
int |
getColumn()
Enabled: Returns the zero based index of the column of the cell being tracked by this editor. |
TableItem |
getItem()
Enabled: Returns the TableItem for the row of the cell being tracked by this editor. |
(package private) void |
resize()
|
void |
setColumn(int column)
Enabled: |
void |
setEditor(Control editor,
TableItem item,
int column)
Enabled: Specify the Control that is to be displayed and the cell in the table that it is to be positioned above. |
void |
setItem(TableItem item)
Enabled: |
Methods inherited from class org.eclipse.swt.custom.ControlEditor |
getEditor, layout, scroll, setEditor |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
Table table
TableItem item
int column
Listener columnListener
Constructor Detail |
public TableEditor(Table table)
table
- the Table Control above which this editor will be displayedMethod Detail |
Rectangle computeBounds()
computeBounds
in class ControlEditor
public void dispose()
dispose
in class ControlEditor
public int getColumn()
public TableItem getItem()
public void setColumn(int column)
public void setItem(TableItem item)
public void setEditor(Control editor, TableItem item, int column)
Note: The Control provided as the editor must be created with its parent being the Table control specified in the TableEditor constructor.
editor
- the Control that is displayed above the cell being editeditem
- the TableItem for the row of the cell being tracked by this editorcolumn
- the zero based index of the column of the cell being tracked by this editorvoid resize()
resize
in class ControlEditor
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |