Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » TreeViewer: cancelling expansion
icon3.gif  TreeViewer: cancelling expansion [message #487739] Thu, 24 September 2009 10:11
Bianca Thelen is currently offline Bianca ThelenFriend
Messages: 26
Registered: July 2009
Junior Member
Hello everybody,

I need to realize the following: a user expands an element in a TreeViewer. On expansion the user needs to be asked if they really want to expand the selected element. If the user answers no the element must not be expanded but it must be possible to expand the element later on.

I tried to realize this with ITreeViewerListener. When the expansion event occurs I ask the question if the element is to be expanded. This doesn't work, however, because the ITreeViewerListener is only notified _after_ ITreeContentProvider#getChildren is called.

I could subclass TreeViewer to achieve the behaviour I need but I must or should not subclass TreeViewer.

So then I tried asking the question in ITreeContentProvider#getChildren to avoid loading the children when the user doesn't want the element to be expanded. If the user answers no I return a dummy element. However, the tree is still expanded with the dummy element and I couldn't collapse its parent element inside ITreeViewerListener#treeExpanded. Is there any way that the expansion can be prevented? I don't want the dummy element to show but I need it so that its parent element is expandable the next time the user tries to expand it.

<EDIT> My problem seems to be related to
Bug 108941
With the suggested asyncExec I am now able to collapse the tree if it's not to be expanded. </EDIT>

Kind regards
Bianca
PS I'm using JFace 3.4.2

[Updated on: Thu, 24 September 2009 10:42]

Report message to a moderator

Previous Topic:isBlockSelectionModeEnabled error on code from jface
Next Topic:How to drag to reorder TabItem in a TabFolder?
Goto Forum:
  


Current Time: Fri Apr 19 13:19:42 GMT 2024

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

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

Back to the top