|
|||||||||||
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.TreeEditor
Safe: A TreeEditor is a manager for a Control that appears above a cell in a Tree and tracks with the moving and resizing of that cell. It can be used to display a text widget above a cell in a Tree 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 TreeEditor:
final Tree tree = new Tree(parent, SWT.FULL_SELECTION);
final TreeEditor editor = new TreeEditor (tree);
tree.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
TreeItem item = (TreeItem)e.item;
// The control that will be the editor must be a child of the Tree
Text text = new Text(tree, 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 on the selected row.
editor.setEditor (text, item);
// Assign focus to the text control
text.setFocus ();
}
});
Field Summary | |
(package private) TreeItem |
item
|
(package private) Tree |
tree
|
(package private) TreeListener |
treeListener
|
Fields inherited from class org.eclipse.swt.custom.ControlEditor |
editor, grabHorizontal, grabVertical, horizontalAlignment, minimumHeight, minimumWidth, parent, verticalAlignment |
Constructor Summary | |
TreeEditor(Tree tree)
Enabled: Creates a TreeEditor for the specified Tree. |
Method Summary | |
(package private) Rectangle |
computeBounds()
|
void |
dispose()
Enabled: Removes all associations between the TreeEditor and the cell in the tree. |
TreeItem |
getItem()
Enabled: Returns the TreeItem for the row of the cell being tracked by this editor. |
(package private) void |
resize()
|
void |
setEditor(Control editor,
TreeItem item)
Enabled: Specify the Control that is to be displayed and the cell in the tree that it is to be positioned above. |
void |
setItem(TreeItem 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 |
Tree tree
TreeItem item
TreeListener treeListener
Constructor Detail |
public TreeEditor(Tree tree)
tree
- the Tree Control above which this editor will be displayedMethod Detail |
Rectangle computeBounds()
computeBounds
in class ControlEditor
public void dispose()
dispose
in class ControlEditor
public TreeItem getItem()
public void setItem(TreeItem item)
public void setEditor(Control editor, TreeItem item)
Note: The Control provided as the editor must be created with its parent being the Tree control specified in the TreeEditor constructor.
editor
- the Control that is displayed above the cell being editeditem
- the TreeItem for the row 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 |