How to dis/enable a TreeItem in a TreeView? [message #316869] |
Wed, 20 June 2007 15: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 #316883 is a reply to message #316882] |
Wed, 20 June 2007 21:32 |
Eclipse User |
|
|
|
Originally posted by: ku_long.hotmail.com
Thanks for you guys' answers. Since the TreeItem
can not be simply disabled/enabled, I tried lots
of other approaches (e.g. catch mouse down event)
to prevent a TreeItem on a CheckboxTreeView from
being checked. But no one worked. Anyone know how
to do that?
Thanks.
|
|
|
|
Re: How to dis/enable a TreeItem in a TreeView? [message #316918 is a reply to message #316890] |
Thu, 21 June 2007 14:53 |
Eclipse User |
|
|
|
Originally posted by: ku_long.hotmail.com
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 #316920 is a reply to message #316918] |
Thu, 21 June 2007 15:04 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
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 #316921 is a reply to message #316920] |
Thu, 21 June 2007 15:19 |
Eclipse User |
|
|
|
Originally posted by: ku_long.hotmail.com
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.02738 seconds