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

Hi,

The only way to get the item labels and checked states in your case is from
each editor's Button, because the only data being set on itemJ itself is the
image.  You could add line "itemJ.setData(combo)" to make these Buttons
easily accessible from their respective TreeItems.

Grant


"Quentin Demé" <qdeme@xxxxxxxx> wrote in message
news:51e8735f6c9929f85f43ed65e28a7f89$1@xxxxxxxxxxxxxxxxxx
> 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é
>
>