Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » TreeViewer expansion(Trying to expand a TreeViewer element on label double-click)
TreeViewer expansion [message #502010] Fri, 04 December 2009 18:23 Go to next message
Craig Noah is currently offline Craig NoahFriend
Messages: 1
Registered: December 2009
Junior Member
I have a TreeViewer that currently expands and collapses only when a user clicks on the plus sign. We want to expand the level when the user clicks on the label text. I have created an action that extends Action and implements IDoubleClickListener. The doubleClick(DoubleClickEvent event) method is:

TreeViewer viewer = (TreeViewer) event.getViewer();
ISelection selection = event.getSelection();
viewer.expandToLevel (selection, 1);
viewer.refresh();

I have tried all 4 versions of the viewer.refresh():
viewer.refresh()
viewer.refresh (false)
viewer.refresh (selection)
viewer.refresh (selection, false)

None of them have worked for me. Depending on the refresh call used, either nothing happens, or the deep version of the element gets selected.

What I mean by "deep version" is this: we have a tree similar to the following structure:

+ - Test Data
|    |
|    + - data
|          |
|          + - Category 1
|          + - Category 2
|          + - Category 3
|
+ - C:\
      |
     + - app_home
          |
          + - common
          + - test
                |
                + - data
                      |
                      + - Category 1
                      + - Category 2
                      + - Category 3



The "Test Data" element is a shortcut (link, pointer) to the "test" element within the C:\ tree. Start with the top two elements collapsed. Expand the "Test Data" element, then double-click on the data element. The data element inside the C:\app_home tree gets selected and all the parent elements are expanded to show this element. This is the "deep selection" or "deep version" that I get with the call to viewer.refresh().

The Package Explorer in Eclipse correctly expands and contracts a package to show or hide the package elements when I double-click on the package name. I want that behavior in my TreeViewer. Any ideas how to make that happen?

Sincerely,
Craig
Re: TreeViewer expansion [message #504930 is a reply to message #502010] Wed, 23 December 2009 15:06 Go to previous message
Eclipse UserFriend
Originally posted by: eclipse.ahoegger.ch

Hope it helps
viewer.setExpandedState(selectedNode,!viewer.getExpandedStat e(selectedNode))

BR Andreas

Craig Noah wrote:
> I have a TreeViewer that currently expands and collapses only when a
> user clicks on the plus sign. We want to expand the level when the user
> clicks on the label text. I have created an action that extends Action
> and implements IDoubleClickListener. The doubleClick(DoubleClickEvent
> event) method is:
>
> TreeViewer viewer = (TreeViewer) event.getViewer();
> ISelection selection = event.getSelection();
> viewer.expandToLevel (selection, 1);
> viewer.refresh();
>
> I have tried all 4 versions of the viewer.refresh():
> viewer.refresh()
> viewer.refresh (false)
> viewer.refresh (selection)
> viewer.refresh (selection, false)
>
> None of them have worked for me. Depending on the refresh call used,
> either nothing happens, or the deep version of the element gets selected.
>
> What I mean by "deep version" is this: we have a tree similar to the
> following structure:
>
>
> + - Test Data
> | |
> | + - data
> | |
> | + - Category 1
> | + - Category 2
> | + - Category 3
> |
> + - C:\
> |
> + - app_home
> |
> + - common
> + - test
> |
> + - data
> |
> + - Category 1
> + - Category 2
> + - Category 3
>
>
>
> The "Test Data" element is a shortcut (link, pointer) to the "test"
> element within the C:\ tree. Start with the top two elements
> collapsed. Expand the "Test Data" element, then double-click on the
> data element. The data element inside the C:\app_home tree gets
> selected and all the parent elements are expanded to show this element.
> This is the "deep selection" or "deep version" that I get with the call
> to viewer.refresh().
>
> The Package Explorer in Eclipse correctly expands and contracts a
> package to show or hide the package elements when I double-click on the
> package name. I want that behavior in my TreeViewer. Any ideas how to
> make that happen?
>
> Sincerely,
> Craig
Previous Topic:Problem when manually activating bundles
Next Topic:Activating a text cell editor
Goto Forum:
  


Current Time: Fri Mar 29 07:01:31 GMT 2024

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

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

Back to the top