Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » CheckboxTreeViewer - correct CellEditor and Checkbox only at root elements?
CheckboxTreeViewer - correct CellEditor and Checkbox only at root elements? [message #23875] Fri, 24 July 2009 10:50 Go to next message
Patrick Konemann is currently offline Patrick KonemannFriend
Messages: 116
Registered: July 2009
Senior Member
Hi everyone,

I am confused about the API of a CheckboxTreeViewer (Galileo Release).
The Javadoc for setCellEditors says:
"Since 3.3, an alternative API is available, see ViewerColumn.setEditingSupport(EditingSupport) for a more flexible way of editing values in a column viewer."

But the class TreeColumn doesn't seem to have the API mentioned.
Also the snippet in [1] refers to a TableViewer, not to a TreeViewer.
So what is the correct way of using cell editors here?
Still using setCellEditors, setColumnProperties, and setCellModifier?


And I am wondering if it is possible to have checkboxes only for root elements?
Right now, all elements in the tree have a checkbox attached.


Best regards
Patrick


[1] http://wiki.eclipse.org/JFaceSnippets#Snippet034CellEditorPe rRowNewAPI
Re: CheckboxTreeViewer - correct CellEditor and Checkbox only at root elements? [message #23994 is a reply to message #23875] Fri, 24 July 2009 14:44 Go to previous messageGo to next message
Patrick Konemann is currently offline Patrick KonemannFriend
Messages: 116
Registered: July 2009
Senior Member
Hi again,

A follow-up question about checkboxes - I am not sure how to handle them:
If I use a cell editor to modify some data and call viewer.refresh(), all the checkbox states are gone, i.e. all items are unchecked again.
The workaround I see here is to manually iterate over all items again and set the checkbox state for each item.

Furthermore, after a refresh the entire tree is collapsed again.
Is there a trick how I can easily restore the state (collapsed/expanded items and the checkbox state) after a refresh?

Best regards
Patrick


On 24-07-2009 12:50, Patrick Könemann wrote:
> Hi everyone,
>
> I am confused about the API of a CheckboxTreeViewer (Galileo Release).
> The Javadoc for setCellEditors says:
> "Since 3.3, an alternative API is available, see
> ViewerColumn.setEditingSupport(EditingSupport) for a more flexible way
> of editing values in a column viewer."
>
> But the class TreeColumn doesn't seem to have the API mentioned.
> Also the snippet in [1] refers to a TableViewer, not to a TreeViewer.
> So what is the correct way of using cell editors here?
> Still using setCellEditors, setColumnProperties, and setCellModifier?
>
>
> And I am wondering if it is possible to have checkboxes only for root
> elements?
> Right now, all elements in the tree have a checkbox attached.
>
>
> Best regards
> Patrick
>
>
> [1] http://wiki.eclipse.org/JFaceSnippets#Snippet034CellEditorPe rRowNewAPI
Re: CheckboxTreeViewer - correct CellEditor and Checkbox only at root elements? [message #24329 is a reply to message #23875] Mon, 27 July 2009 16:55 Go to previous messageGo to next message
Will Horn is currently offline Will HornFriend
Messages: 265
Registered: July 2009
Senior Member
"Patrick Könemann" <pk@imm.dtu.dk> wrote in message
news:h4c3lk$m31$1@build.eclipse.org...
> But the class TreeColumn doesn't seem to have the API mentioned.
Look at TreeViewerColumn.

> So what is the correct way of using cell editors here?
I'd use setEditingSupport.

> And I am wondering if it is possible to have checkboxes only for root
> elements?
> Right now, all elements in the tree have a checkbox attached.
I don't know the answer to this. I assume it is all or nothing with
checkboxes on a tree.

-Will
Re: CheckboxTreeViewer - correct CellEditor and Checkbox only at root elements? [message #372840 is a reply to message #24329] Wed, 29 July 2009 11:08 Go to previous messageGo to next message
Patrick Konemann is currently offline Patrick KonemannFriend
Messages: 116
Registered: July 2009
Senior Member
Thanks Will, I'll give the TreeViewerColumn a try as soon as I have time.

Concerning the checkboxes, I use the workaround to mark the checkboxes gray of all elements which should not be checkable (using setGrayedElements).
Not the nicest solution, but it at least it works.

Best regards
Patrick


On 27-07-2009 18:55, Will Horn wrote:
>
> "Patrick Könemann" <pk@imm.dtu.dk> wrote in message
> news:h4c3lk$m31$1@build.eclipse.org...
>> But the class TreeColumn doesn't seem to have the API mentioned.
> Look at TreeViewerColumn.
>
>> So what is the correct way of using cell editors here?
> I'd use setEditingSupport.
>
>> And I am wondering if it is possible to have checkboxes only for root
>> elements?
>> Right now, all elements in the tree have a checkbox attached.
> I don't know the answer to this. I assume it is all or nothing with
> checkboxes on a tree.
>
> -Will
Re: CheckboxTreeViewer - correct CellEditor and Checkbox only at root elements? [message #372841 is a reply to message #23994] Wed, 29 July 2009 11:11 Go to previous message
Patrick Konemann is currently offline Patrick KonemannFriend
Messages: 116
Registered: July 2009
Senior Member
Strange... I don't know what happened, but I cannot reproduce that behavior.
Now a refresh doesn't destroy the state of the tree any more :-D

Patrick


On 24-07-2009 16:44, Patrick Könemann wrote:
> Hi again,
>
> A follow-up question about checkboxes - I am not sure how to handle them:
> If I use a cell editor to modify some data and call viewer.refresh(),
> all the checkbox states are gone, i.e. all items are unchecked again.
> The workaround I see here is to manually iterate over all items again
> and set the checkbox state for each item.
>
> Furthermore, after a refresh the entire tree is collapsed again.
> Is there a trick how I can easily restore the state (collapsed/expanded
> items and the checkbox state) after a refresh?
>
> Best regards
> Patrick
Previous Topic:Problems with org.eclipse.jface.text source
Next Topic:TextViewer and revealRange
Goto Forum:
  


Current Time: Fri Apr 19 23:52:08 GMT 2024

Powered by FUDForum. Page generated in 0.04033 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top