Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to use TableTreeEditor??
How to use TableTreeEditor?? [message #456731] Wed, 08 June 2005 03:31
Chris is currently offline ChrisFriend
Messages: 97
Registered: July 2009
Member
How would I retrieve the column index of a cell? If I use the example
shown on:
http://help.eclipse.org/help30/index.jsp?topic=/org.eclipse. platform.doc.isv/reference/api/org/eclipse/swt/custom/TableT reeEditor.html
(I also provided the example at the bottom of this post) how could I
dynamically change the EDITABLECOLUMN property to reference the proper
cell/column value?

Thank you for you help in advance.


final TableTree tableTree = new TableTree(shell, SWT.FULL_SELECTION |
SWT.HIDE_SELECTION);
final Table table = tableTree.getTable();
TableColumn column1 = new TableColumn(table, SWT.NONE);
TableColumn column2 = new TableColumn(table, SWT.NONE);
for (int i = 0; i < 10; i++) {
TableTreeItem item = new TableTreeItem(tableTree, SWT.NONE);
item.setText(0, "item " + i);
item.setText(1, "edit this value");
for (int j = 0; j < 3; j++) {
TableTreeItem subitem = new TableTreeItem(item, SWT.NONE);
subitem.setText(0, "subitem " + i + " " + j);
subitem.setText(1, "edit this value");
}
}
column1.setWidth(100);
column2.pack();

final TableTreeEditor editor = new TableTreeEditor(tableTree);
//The 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;
// editing the second column
final int EDITABLECOLUMN = 1;

tableTree.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
TableTreeItem item = (TableTreeItem)e.item;
if (item == null) return;

// The control that will be the editor must be a child of the Table
Text newEditor = new Text(table, SWT.NONE);
newEditor.setText(item.getText(EDITABLECOLUMN));
newEditor.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
Text text = (Text)editor.getEditor();
editor.getItem().setText(EDITABLECOLUMN, text.getText());
}
});
newEditor.selectAll();
newEditor.setFocus();
editor.setEditor(newEditor, item, EDITABLECOLUMN);
}
});
Previous Topic:Help with SWT Separator widget...Can't get rid of the white line across the shell
Next Topic:How to deploy swt apps on Mac OS X
Goto Forum:
  


Current Time: Thu Apr 25 19:44:15 GMT 2024

Powered by FUDForum. Page generated in 0.02779 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top