Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 351433 - [General] IllegalArgumentException: An EditPart has to be selectable...
Summary: [General] IllegalArgumentException: An EditPart has to be selectable...
Status: RESOLVED FIXED
Alias: None
Product: Papyrus
Classification: Modeling
Component: Core (show other bugs)
Version: 0.8.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 352994
Blocks: 348549 350423 350884 351419
  Show dependency tree
 
Reported: 2011-07-07 08:15 EDT by Yann Tanguy CLA
Modified: 2015-04-24 09:02 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yann Tanguy CLA 2011-07-07 08:15:43 EDT
The following exception sometimes occurs in various situation (dnd from Model explorer in diagram, creation in a compartment...) :

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.setSelection(SelectionManager.java:273)
	at org.eclipse.gef.ui.parts.AbstractEditPartViewer.setSelection(AbstractEditPartViewer.java:751)
	at org.eclipse.gmf.runtime.diagram.ui.tools.CreationTool.selectAddedObject(CreationTool.java:158)
	at org.eclipse.papyrus.diagram.common.service.AspectUnspecifiedTypeCreationTool.performCreation(AspectUnspecifiedTypeCreationTool.java:132)
	at org.eclipse.gef.tools.CreationTool.handleButtonUp(CreationTool.java:189)
	at org.eclipse.gef.tools.AbstractTool.mouseUp(AbstractTool.java:1200)
	at org.eclipse.gef.EditDomain.mouseUp(EditDomain.java:301)
	at org.eclipse.gef.ui.parts.DomainEventDispatcher.dispatchMouseReleased(DomainEventDispatcher.java:380)
	at org.eclipse.draw2d.LightweightSystem$EventHandler.mouseUp(LightweightSystem.java:548)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:219)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4163)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3752)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Comment 1 Yann Tanguy CLA 2011-07-07 08:16:56 EDT
To reproduce :
- A reproductible JUnit test has been added in BlockDefinitionDiagram tests (compartment.setFocus(true)).
Comment 2 Yann Tanguy CLA 2011-07-07 08:26:27 EDT
Related GEF bug: 

333865: Exception thrown when deleting several edit parts with GEF 3.7
https://bugs.eclipse.org/bugs/show_bug.cgi?id=333865
Comment 3 Yann Tanguy CLA 2011-07-07 08:37:50 EDT
(In reply to comment #2)
> Related GEF bug:
> 
> 333865: Exception thrown when deleting several edit parts with GEF 3.7
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=333865

349124: java.lang.IllegalArgumentException thrown when selecting ToolEntryEditPart in PaletteStack
https://bugs.eclipse.org/bugs/show_bug.cgi?id=349124

As far as I understand this has something to do with change in selection methods implementation (see. comments in previous bug) and is supposed to be fixed in 3.7 SR1.

TODO: 
- Make sure as soon as possible that this issue is also fixed for Papyrus in 3.7 SR1
- Make sure as soon as possible that the GEF fix is sufficient and does not also requires a corrective action in GMF Runtime...

the selection methods have been changed as part of bug #330859
Comment 4 Yann Tanguy CLA 2011-07-25 07:37:55 EDT
GMF Tooling generates ChildNodeLabels edit parts with an inheritance to org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart.

Pretty strange as ChildNodeLabels are definitely not compartments... Anyway, the problem here occurs while trying to select such ChildNodeLabels (for instance right after creation), in case their owner is not selected.

In CompartmentEditPart, the selection behavior does only allow the compartment to be selected if its owner already has the focus. This ensures the a click anywhere on a element without focus result in the selection of the element, not one of its compartments. As ChildNodeLabels inherits from CompartmentEditPart they inherit the same behavior.

On creation, the creation tool tries to select the new object after creation. The problem is that when a ChildLabelNode is created whereas its owner doesn't have the focus, the newly created element cannot be selected (isSelectable from CompartmentEditPart implementation will return null). Before GEF 3.7, this was probably ignored, but some changes in GEF 3.7 now throw an exception in any attempt to set focus or selection on an edit part which is not selectable which is the case here...
Comment 5 Yann Tanguy CLA 2011-07-25 11:28:20 EDT
In r5124 : Fix for BDD
- AbstractElementChildLabelEditPart now inherits from GraphicalEditPart instead of UMLCompartmentEditPart or CompartmentEditPart (BDD Specific ChildLabelNodes)
- EditPart replacement for Slot element from the ClassDiagram (not corrected in ClassDiagram yet).

- NamedElementLabelNameEditPart renamed into NamedElementNodeLabelNameEditPart to avoid possible confusion, this is a node label, not a ChildLabelNode.
Comment 6 Yann Tanguy CLA 2011-07-27 04:04:48 EDT
(In reply to comment #5)
> In r5124 : Fix for BDD
> - AbstractElementChildLabelEditPart now inherits from GraphicalEditPart instead
> of UMLCompartmentEditPart or CompartmentEditPart (BDD Specific ChildLabelNodes)
> - EditPart replacement for Slot element from the ClassDiagram (not corrected in
> ClassDiagram yet).
> 
> - NamedElementLabelNameEditPart renamed into NamedElementNodeLabelNameEditPart
> to avoid possible confusion, this is a node label, not a ChildLabelNode.

Trunk merge in r5127.
Comment 7 Yann Tanguy CLA 2011-07-27 07:08:38 EDT
(In reply to comment #1)
> To reproduce :
> - A reproductible JUnit test has been added in BlockDefinitionDiagram tests
> (compartment.setFocus(true)).

Test modified in BDD (r5137) : see oep.sysml.diagram.blockdefinition.tests.creation.TestNodeCreationOnDiagram::dropExceptionToFix_bug348549().
Comment 8 Camille Letavernier CLA 2011-09-12 10:05:08 EDT
The same bug appears when creating Operations or Properties in a Class, in the Class Diagram.

r5433 : A similar fix has been applied : the implementation of the isSelectable() method from the UMLCompartmentEditPart has been changed.

This fix has side effects : you can know select an operation (or a property) without selecting its class beforehand. Therefore, the selection area for a Class has been reduced, which may lead to difficulties for moving or resizing a Class (Or other elements with a similar behavior)
Comment 9 Camille Letavernier CLA 2013-06-17 05:26:34 EDT
Still valid e.g. in the Profile Diagram, when creating Properties
Comment 10 Camille Letavernier CLA 2015-04-24 09:02:45 EDT
I haven't seen this bug for a while

I close the task