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

Bug 477211

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: Jessy Mallet <jessy.mallet>
Severity: major    
Priority: P3 CC: jessy.mallet, maxime.porhel
Version: 3.0.0Keywords: triaged
Target Milestone: 3.1.0   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/55748
https://git.eclipse.org/r/55761
https://git.eclipse.org/r/55852
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=ee528044b8de2d0992ab458e5a2c925893618b8e
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=9cf1783c487c077ba2915922ec5e8a4679a30ce0
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=af1d22c7376477e55a3dc84e844f7be1ff527026
Whiteboard:
Bug Depends on: 477208    
Bug Blocks:    

Description Pierre-Charles David CLA 2015-09-11 10:52:40 EDT
+++ This bug was initially created as a clone of Bug #477208 +++

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 Maxime Porhel CLA 2015-09-11 11:39:07 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 occurS 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 2 Eclipse Genie CLA 2015-09-11 11:45:30 EDT
New Gerrit change created: https://git.eclipse.org/r/55761
Comment 3 Eclipse Genie CLA 2015-09-14 08:04:08 EDT
New Gerrit change created: https://git.eclipse.org/r/55852
Comment 7 Pierre-Charles David CLA 2015-09-14 10:22:17 EDT
Fixed by af1d22c7376477e55a3dc84e844f7be1ff527026.
Comment 8 Jessy Mallet CLA 2015-09-29 09:41:17 EDT
Validated with Sirius 3.1.0.201509241504
Comment 9 Pierre-Charles David CLA 2015-10-16 09:09:57 EDT
Available in Sirius 3.1.0.