Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #1869

JFace, CheckboxTreeViewer

From "Markward" <markward@THRWHITE.remove-dii-this>
Subject JFace, CheckboxTreeViewer
Message-ID <1182324673.729864.180420@q69g2000hsb.googlegroups.com> (permalink)
Newsgroups comp.lang.java.gui
Date 2011-04-27 15:35 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
Hello everybody!

I have a big problem understanding the setChecked and
setCheckedElements methods of CheckboxTreeViewer.

What exact data do these methods expect?


This is our scenario:

We have lets say "items", which are represented as leafs in the tree-
structure. These items are organized in "folders" to facilitate
finding the items in the Tree-Control.

So to populate the TreeViewer-component, we build up a tree-data-
structure consisting of folders and items. This works very well so
far, as the tree is shown correctly.

Now comes the usecase:

The selected items are associated with entitys in our database. When
reading such an entity from the db, we get back a flat list of items
(without their folder-information), associated with the db-entity. Our
goal is now to set the appropriate checkboxes in the
CheckboxTreeViewer by calling setChecked/setCheckedElements.

As the Javadocs say, that setCheckedElements expects Object[]. Our
assuption was now, that we can provide a flat list of items, that can
be uniquely identified by their .equals()-method, or with the help of
an IElementComparer-implementation.

But when such a flat list is provided, the items can not be found in
the CheckboxedTreeViewer. Inspecting the code at runtime suggested,
that the control tries to climb along some parent/child-structure,
which of course is not present in our flat db-items.

The only way we could get the methods to work was to access the exact
reference of the underlying tree-data-structure, get a reference to
one of its nodes and provide this reference to the mentioned methods.

Does that mean, that we have to implement the search in the tree
ourselfs and memorize the references to the proper tree-items in the
Object[] ?

Any help is very appreciated.

Regards,

Markward

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | NextNext in thread | Find similar | Unroll thread


Thread

JFace, CheckboxTreeViewer "Markward" <markward@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
  Re: JFace, CheckboxTreeVi "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000
    Re: JFace, CheckboxTreeVi "Markward" <markward@THRWHITE.remove-dii-this> - 2011-04-27 15:35 +0000

csiph-web