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

Bug 477208

Summary: Exception when selecting part of a container already selected
Product: [Modeling] Sirius Reporter: Pierre-Charles David <pierre-charles.david>
Component: DiagramAssignee: Maxime Porhel <maxime.porhel>
Status: CLOSED FIXED QA Contact:
Severity: major    
Priority: P3 CC: maxime.porhel
Version: 3.0.0Keywords: triaged
Target Milestone: 3.0.2   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/55750
https://git.eclipse.org/r/55825
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=d5fdd89eb12714b0a0d1ccb73a54daa3065b45a7
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=0f636b815543dc6330e1641fb662958b37a18618
https://git.eclipse.org/r/55853
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=de8b0096f1108b8c7c5460aec8976a0346e71621
Whiteboard:
Bug Depends on:    
Bug Blocks: 477211    

Description Pierre-Charles David CLA 2015-09-11 10:51:44 EDT
Steps to reproduce:
1. Open a diagram with two containers with labels.
2. Select both containers using Ctrl-click. One is the primary selection (black handles) and one is not (white handles).
3. Click on the label of the container which is not the primary selection: KO, an exception appears in the error log:

eclipse.buildId=4.5.1.M20150904-0015
java.version=1.7.0_79
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=fr_FR
Framework arguments:  -product org.eclipse.epp.package.modeling.product
Command-line arguments:  -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.modeling.product

org.eclipse.ui
Error
Fri Sep 11 16:49:09 CEST 2015
Unhandled event loop exception

java.lang.IllegalArgumentException: An EditPart has to be selectable (isSelectable() == true) in order to get selected.
	at org.eclipse.core.runtime.Assert.isLegal(Assert.java:63)
	at org.eclipse.gef.editparts.AbstractEditPart.setSelected(AbstractEditPart.java:1060)
	at org.eclipse.gef.SelectionManager.appendSelection(SelectionManager.java:89)
	at org.eclipse.gef.ui.parts.AbstractEditPartViewer.appendSelection(AbstractEditPartViewer.java:190)
	at org.eclipse.gef.ui.parts.AbstractEditPartViewer.select(AbstractEditPartViewer.java:599)
	at org.eclipse.gef.tools.SelectEditPartTracker.performSelection(SelectEditPartTracker.java:221)
	at org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx.performSelection(DragEditPartsTrackerEx.java:247)
	at org.eclipse.gef.tools.SelectEditPartTracker.performConditionalSelection(SelectEditPartTracker.java:167)
	at org.eclipse.gef.tools.SelectEditPartTracker.handleButtonDown(SelectEditPartTracker.java:92)
	at org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx.handleButtonDown(DragEditPartsTrackerEx.java:231)
	at org.eclipse.gef.tools.AbstractTool.mouseDown(AbstractTool.java:1091)
	at org.eclipse.gef.tools.SelectionTool.mouseDown(SelectionTool.java:514)
	at org.eclipse.gef.EditDomain.mouseDown(EditDomain.java:245)
	at org.eclipse.gef.ui.parts.DomainEventDispatcher.dispatchMousePressed(DomainEventDispatcher.java:348)
	at org.eclipse.draw2d.LightweightSystem$EventHandler.mouseDown(LightweightSystem.java:523)

If at step 3 you use the mouse to draw a selection rectangle which includes the non-primary selected container's label, the exception appears too, but in addition the selection marquee stays on the diagram and can not be removed except by closing and reopening the diagram.
Comment 1 Eclipse Genie CLA 2015-09-11 11:00:16 EDT
New Gerrit change created: https://git.eclipse.org/r/55750
Comment 2 Maxime Porhel CLA 2015-09-11 11:38:54 EDT
The getParent().isSelectable() == EditPart.SELECTED has been introduce before the move to open source. 

This test is weird, it make the name part selectable only when the main part is in secondary selection (see EditPart.SELECTED vs EditPart.SELECTED_PRIMARY). Furthermore, the container/list/region name parts cannot be moved and the direct edit works. So we can simply always return false in isSelectable().

The IllegalArgumentException occured because the drag tracker saw the name edit part as a selectable part (its parent is secondary selected) but during the set selection the AbstractEditPartView call primDeselectAll() which change the isSelectable() status of the DDiagramElementContainer name edit parts.
Comment 3 Eclipse Genie CLA 2015-09-14 03:43:09 EDT
New Gerrit change created: https://git.eclipse.org/r/55825
Comment 6 Eclipse Genie CLA 2015-09-14 08:10:30 EDT
New Gerrit change created: https://git.eclipse.org/r/55853
Comment 8 Pierre-Charles David CLA 2015-09-14 09:48:15 EDT
Fixed by 0f636b815543dc6330e1641fb662958b37a18618
Comment 9 Pierre-Charles David CLA 2015-09-15 04:44:19 EDT
Verified on 3.0.2rc1.
Comment 10 Pierre-Charles David CLA 2015-12-15 05:23:58 EST
Available in Sirius 3.0.2 released on 2015-09-15.