Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 334988

Summary: Wrong instance of selected element in SynchronizePageActionGroup.fillContextMenu()
Product: [Eclipse Project] Platform Reporter: Dariusz Luksza <dariusz.luksza>
Component: TeamAssignee: Platform Team Inbox <platform-team-inbox>
Status: RESOLVED INVALID QA Contact:
Severity: critical    
Priority: P3 CC: tomasz.zarna
Version: 3.6.1   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Dariusz Luksza CLA 2011-01-21 05:10:54 EST
I'm currently implementing context menu actions in EGit change set model. I would like to have dynamically build context menu based on kind of selected element therefore I use SynchronizePageActionGroup.fillContextMenu() where using getContext().getSelection() I can obtain selected element in synchronize view.

Here is my test structure of elements in view:
|- GitModelWorking Tree
|  |- GitModelCacheTree
|- GitModelCache
|  |- GitModelCacheTree(1)
|- GitModelCommit
|  |- GitModelTree(2)
|- GitModelCommit
   |- GitModelTree(3)

Every thing works well until the GitModelCacheTree(1) have same name as GitModelTree(2) in this case if right mouse button click occurs on GitModelTree(2) framework returns instance of GitModelCacheTree(1) in getContext().getSeletion() which is a bug. Such situation doesn't occurs if every three elements (1, 2, 3) have same name and the third one was selected.
Comment 1 Tomasz Zarna CLA 2011-01-21 07:13:35 EST
Have you tried creating your own view and adding the same set of elements to it? Will calling getContext().getSelection() then give you the same results?

Why did you mark the bug as critical? Does it result loss of data when you execute an action on a bad selection?
Comment 2 Dariusz Luksza CLA 2011-01-21 14:20:05 EST
Sorry for bothering you guys ... it appears that this was problem in my code. I didn't overwrite properly hashCode() and equals() methods.