[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Problem with Tree and checkboxes

Hello,

I have created a Tree which can only be checked on certain leafs. I didn't use SWT.CHECK on the whole tree, because it displays checkboxes on every leaf. I used a TreeEditor instead, as follows:

When I have to add a leaf with no checkbox:
TreeItem itemJ = new TreeItem(itemI, SWT.NONE); // itemJ is the parent node
itemJ.setText(t.getPresentationName());
itemJ.setImage( ... );


And when I have to add a leaf with a checkbox on the left:
  TreeItem itemJ = new TreeItem(itemI, SWT.CHECK);
  itemJ.setImage( ... );
  TreeEditor editor = new TreeEditor(tree_tasks); // tree_tasks in my tree
  Button combo = new Button(tree_taches, SWT.CHECK);
  combo.setText(t.getPresentationName());
  combo.setSelection(true);
  editor.grabHorizontal = true;
  editor.setEditor(combo, itemJ, 0);

The problem is that, when I want to "read" my tree with nested loops, I can't get the text of leafs that have a checkbox, nor the state of the checkbox itself.
I tried item.getChecked() but it always return "false", even if I did setChecked(true) before. Maybe because I didn't use SWT.CHECK for the tree. But the fact is that I used another method to display the checkboxes.
I've been searching the for a long time now, and I don't find any solution to this problem.


Thanks in advance for your help,

Quentin Demé