How to dis/enable a TreeItem in a TreeView? [message #316869] |
Wed, 20 June 2007 11:45  |
Eclipse User |
|
|
|
Originally posted by: ku_long.hotmail.com
Hey,
I am trying to disable/enable a tree item in a CheckboxTreeView
depending on the status of a domain object. But the CheckboxTreeView
only provides setCheck(Object element, boolean state) and setGrayed(Object
element, boolean state). I tried the setGrayed
method, the TreeItem still can be checked/unchecked after I set
it as grayed. So, it seems it's not what I want. How can I disable/
enable a TreeItem in a CheckboxTreeView?
Thanks.
|
|
|
|
|
|
|
|
|
Re: How to dis/enable a TreeItem in a TreeView? [message #316920 is a reply to message #316918] |
Thu, 21 June 2007 11:04   |
Eclipse User |
|
|
|
Hi,
You need to catch them on the tree and then calculate the item using
Tree#getItem(new Point(e.x,e.y)). This is only possible when you use
MouseListeners. All other events won't give you x and y.
Another problem you might have is that you also need to catch keyboard
navigation (e.g. a user is clicking a parent node, afterwards collapses
the tree using ARROW_LEFT and afterwards ARROW_DOWN => and suddenly he's
on an item you don't allow him to access)!
As I already told you you are maybe better of by shifting your whole
code to use CellEditors.
Another possibility is that you allow the user to click the item but
immediately reset the restate.
Tom
Raymond schrieb:
> Ok, it seem it can not be eassily solved, :-(
> I have another question. I tried to catch the mouse event on an
> TreeItem, I wrote the
> code like following:
>
> children[i].addListener(SWT.SELECTED, new Listener(){
> public void handleEvent(Event event) {
> System.out.println("Mous event: " + event.type);
> }
> });
>
> children is defined as TreeItem[]. I tried to output some simple
> information to see if the SELECTED event can be caught. But it turned out
> that the event could not be caught. I also tried
> lots of other events like mousedown, mouse doubleclick.
> No one can be caught if I add the listeners on the
> TreeItem. If I add the listeners on the Tree, the
> events can be caught but that's not what I want. Anyone knows why that
> could happen?
>
|
|
|
|
Re: How to dis/enable a TreeItem in a TreeView? [message #316925 is a reply to message #316921] |
Thu, 21 June 2007 11:39  |
Eclipse User |
|
|
|
Because SWT-Items for TreeItem and TableItem don't have such a concept
it's a very though thing for JFace to overcome such "limitation" because
when JFace provides it it has to catch all possibilities. We cann't
advertise a feature which is only working half way.
Although we started to over come SWT-Limitations in JFace in 3.3 like
e.g. cell navigation I cann't currently imaging how support for such a
feature from JFace could look like.
Have you ever searched bugzilla whether someone has requested such a
feature once? If not you could file a feature request.
Tom
Raymond schrieb:
> Ok, I will try them. I read the link you gave me in the previous answer
> thread.
> I have a question why JFace does not make the TreeItem can
> be simply enabled/disabled? Is that very difficult to implement?
>
> Thanks.
>
|
|
|
Powered by
FUDForum. Page generated in 0.05643 seconds