Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 124201 - [Viewers] Additional baheviour for TreeSelection
Summary: [Viewers] Additional baheviour for TreeSelection
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 M5   Edit
Assignee: Boris Bokowski CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-17 15:17 EST by Dirk Baeumer CLA
Modified: 2006-02-14 17:24 EST (History)
0 users

See Also:


Attachments
The patch (6.81 KB, patch)
2006-01-18 09:47 EST, Dirk Baeumer CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Baeumer CLA 2006-01-17 15:17:26 EST
I tried to convert the package explorer to the new JFaca API and stumbled over the following issues: I need a method to find out the tree pathes for a given element. I can implement this by iterating over all pathes, but a method like getTreePathsFor(Object element) would be helpful. More ciritical is the following behaviour: most clients (especially actions) don't assume that an element appears twice in a selection even when sent out by a tree viewer (imagine a delete action simply iterating over all elements. That action will fail when it deletes the element the second time since it appeared twice in the list). The the tree selection implementation I did for the package explorer solved the problem as follows: the tree paths reflected all elements. However the elements accessable via the structured selection only contained an element once. This ensure that no clients of the tree are broken. Can we add this behaviour to the current tree selection implementation ?

I will provide a patch for this ;-)
Comment 1 Boris Bokowski CLA 2006-01-17 17:24:48 EST
Sure, I agree we should do this. If you can provide a patch, even better.

Thanks for trying to convert the package explorer!
Comment 2 Dirk Baeumer CLA 2006-01-18 09:47:07 EST
Boris, attached a patch against JFace [I20060117-0800] to add the requested functionality.

I did some first testing and so far it looks good. The only improvement I would like to see is the following: when I create a new type in a package and the package is rendered twice in the tree then it is random in which packge the new type is selected. The reason for this is that at the end the wizard calls setSelection on the viewer simply providing a structured selection (the wizard doesn't know about how (in a tree or table) a viewer renders elements. So it can't create a TreeSelection). What I would like to see happening is that the CU is selected in the package that was selected when activating the action.

The bahaviour currently exists in the package explorer as well. I didn't fix this in the past since it required overriding even more internal code. Do you think this is possible ?
Comment 3 Dirk Baeumer CLA 2006-01-18 09:47:32 EST
Created attachment 33209 [details]
The patch
Comment 4 Boris Bokowski CLA 2006-01-18 14:49:40 EST
Patch released >20060118.

Re comment #2: Do you think the tree viewer, upon setSelection(), should look at the existing selection and try to select the element occurrence that is nearest to it, rather than the first one it finds?

I'm leaving this bug open for now until we have reached consensus regarding this issue.
Comment 5 Dirk Baeumer CLA 2006-01-19 04:29:42 EST
Boris, thanks for releasing the patch.

> Re comment #2: Do you think the tree viewer, upon setSelection(), should look
> at the existing selection and try to select the element occurrence that is
> nearest to it, rather than the first one it finds?

Yes.
Comment 6 Boris Bokowski CLA 2006-02-01 13:47:00 EST
The remaining issue is now tracked by bug 125708. Closing this one as fixed.
Comment 7 Boris Bokowski CLA 2006-02-14 17:24:59 EST
[I20060214-0800]

Verfied that the patch was applied by looking at the code in the imported JFace plug-in.

We should have a test for this. Filed bug 127923.