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

Bug 348503

Summary: [Class Diagram] Drag tracker exception when selecting and dragging Package compartment
Product: [Modeling] Papyrus Reporter: Yann Tanguy <yann.tanguy>
Component: CoreAssignee: Patrick Tessier <Patrick.Tessier>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Bug Depends on:    
Bug Blocks: 348505, 348506    

Description Yann Tanguy CLA 2011-06-07 03:35:12 EDT
Drag tracker exception when selecting and dragging Package compartment.

To reproduce:
- create a class diagram and put a Package inside
- select the package compartment (not the Package itself)
- try to drag this to another position -> leads to the exception below


java.lang.NullPointerException
	at org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy.getConstraintFor(XYLayoutEditPolicy.java:229)
	at org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy.getAddCommand(ConstrainedLayoutEditPolicy.java:184)
	at org.eclipse.gef.editpolicies.LayoutEditPolicy.getCommand(LayoutEditPolicy.java:216)
	at org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy.getCommand(ConstrainedLayoutEditPolicy.java:214)
	at org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy.getCommand(XYLayoutEditPolicy.java:325)
	at org.eclipse.gef.editparts.AbstractEditPart.getCommand(AbstractEditPart.java:502)
	at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.access$1(GraphicalEditPart.java:1)
	at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart$1.run(GraphicalEditPart.java:482)
	at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.runExclusive(TransactionalEditingDomainImpl.java:328)
	at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.getCommand(GraphicalEditPart.java:477)
	at org.eclipse.gef.tools.DragEditPartsTracker.getCommand(DragEditPartsTracker.java:281)
	at org.eclipse.gef.tools.DragEditPartsTracker.handleDragInProgress(DragEditPartsTracker.java:370)
	at org.eclipse.gef.tools.AbstractTool.mouseDrag(AbstractTool.java:1114)
	at org.eclipse.gef.tools.SelectionTool.mouseDrag(SelectionTool.java:538)
	at org.eclipse.gef.EditDomain.mouseDrag(EditDomain.java:259)
	at org.eclipse.gef.ui.parts.DomainEventDispatcher.dispatchMouseMoved(DomainEventDispatcher.java:363)
	at org.eclipse.draw2d.LightweightSystem$EventHandler.mouseMove(LightweightSystem.java:543)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:211)
	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)
Comment 1 Yann Tanguy CLA 2011-06-07 03:36:16 EDT
Occurs on 0.8.0 RC3.
Comment 2 Yann Tanguy CLA 2011-07-26 08:20:55 EDT
Related to this, I'm not sure that  org.eclipse.papyrus.diagram.clazz.custom.policies.AbstractPackageableElementCompartmentEditPart is really useful. Especially, I don't understand the need to override the getDragTracker from parent here :

	public DragTracker getDragTracker(Request req) {
		if (!supportsDragSelection())
			return super.getDragTracker(req);
		
		return new DragEditPartsTracker(this);
	}
Comment 3 Patrick Tessier CLA 2011-07-29 05:36:51 EDT
The drag tracker has been changed. when the compartment is moved it call the drag tracker of the package.

I was done to allow double click on compartment.
Done in the branch version 5151
Comment 4 Patrick Tessier CLA 2011-07-29 05:44:42 EDT
merge has been done in the version 5153
Comment 5 Yann Tanguy CLA 2011-07-29 06:33:57 EDT
I don't agree with your fix, the compartment is no more selectable (not really a problem but differs from default behavior), and the marquee tool does not work correctly -> a move of the figure is done instead. 

This may be a problem, the marquee tool is useful to graphically select elements inside a PackageableElement compartment. It could be better to extend the RubberBandDragTracker to add DoubleClick support (assuming nothing similar already exists in GEF or GMF).
Comment 6 Patrick Tessier CLA 2011-07-29 08:23:21 EDT
the method "handleDoubleClick" of "RubberbandDragTracker" in order to manage the double click and to not interfere the functionality marquee tool.

Done in the revision 5156