Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Different CellEditors in one column
Different CellEditors in one column [message #444591] Fri, 15 October 2004 16:28
Eclipse UserFriend
Originally posted by:

Hy all,

I have a problem with my TableTree.
It consists of two columns. The first one
shows the name of a variable and the second
one its value.
What I like to do is to have different CellEditors
in the same column which can show and edit the
variable values. Since each variable can have a
different value I like to set different CellEditors.
For example one row has a color label, next row a
combo box and another row a checkbox and so on.
The problem is that I can only set an editor for
the whole column, but not for a cell.
As an example take the code below. You will notice
that the second editor will replace the first on.
Any hints how I can preserve both editors?

Thanks in advance,



public class TableTreeEditors extends ApplicationWindow {
public TableTreeEditors() {

protected Control createContents(final Composite parent) {
//create table
final TableTree tableTree = new TableTree(parent, SWT.FULL_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");

//try to set different editors
final TableTreeEditor editor = new TableTreeEditor(tableTree);
//a simple button
Button buttonEditor = new Button(table, SWT.PUSH);
TableTreeItem item = tableTree.getItems()[0];
editor.setEditor(buttonEditor, item, 1);

//checkbox button:
Button cbEditor = new Button(table, SWT.CHECK);
TableTreeItem secondItem = tableTree.getItems()[1];
editor.setEditor(cbEditor, secondItem, 1);

//editor must have cell size
editor.horizontalAlignment = SWT.LEFT;
editor.grabHorizontal = true;
editor.minimumWidth = 50;

return tableTree;

public static void main(String[] args) {
TableTreeEditors w = new TableTreeEditors();
Previous Topic:Wrap Text on Button
Next Topic:Viewer and widget
Goto Forum:

Current Time: Sun Oct 25 20:27:23 GMT 2020

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

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

Back to the top