Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Drop element in Papyrus (Make an existing Papyrus element a drop area)
Drop element in Papyrus [message #1751131] Wed, 04 January 2017 17:57 Go to next message
Ismael Soulama is currently offline Ismael SoulamaFriend
Messages: 39
Registered: November 2016
Member
Hi,
I would like to drop element on an existing one in Papyrus.
In my receptive CustomEditPart, I've overrided the policies:
@Override
	protected void createDefaultEditPolicies() {
		super.createDefaultEditPolicies();
		installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
		installEditPolicy(EditPolicy.LAYOUT_ROLE, new CustomLayoutEditPolicy());
		installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDragDropEditPolicy());
	}


and defined the drop command for some specific nodes.
But it don't work. I can't drop any element on it.
Did someone have any idea?
Re: Drop element in Papyrus [message #1751158 is a reply to message #1751131] Thu, 05 January 2017 07:08 Go to previous messageGo to next message
Benoit Maggi is currently offline Benoit MaggiFriend
Messages: 129
Registered: March 2013
Location: Bordeaux, France
Senior Member
Hi Ismael,


You can override the EditPolicy and it should work but the recommended way to add a dnd action in Papyrus is to register an extension
Ex:
<extension point="org.eclipse.papyrus.infra.gmfdiag.dnd.dropStrategy">
<strategy
strategy="org.eclipse.papyrus.uml.diagram.dnd.strategy.instancespecification.ClassifierToSlotsDropStrategy">
</strategy
</extension>

usually your class extends TransactionalDropStrategy
See https://git.eclipse.org/c/papyrus/org.eclipse.papyrus.git/tree/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/strategy/PortToTypesPortDropStrategy.java

You can check some more examples in Papyrus Code
https://git.eclipse.org/c/papyrus/org.eclipse.papyrus.git/tree/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd

Regards,
Benoit
Re: Drop element in Papyrus [message #1751247 is a reply to message #1751158] Fri, 06 January 2017 09:03 Go to previous messageGo to next message
Ismael Soulama is currently offline Ismael SoulamaFriend
Messages: 39
Registered: November 2016
Member
Hi Benoit,
Thanks for the reply.
I try your solution, by extending the dropstrategy, but I get a CreateUnspecifiedTypeRequest when I drag an element from the palette. But the doGetCommand need a DropObjectsRequest.
How did I found the EObject in my CreateUnspecifiedTypeRequest?
Re: Drop element in Papyrus [message #1751371 is a reply to message #1751247] Mon, 09 January 2017 13:22 Go to previous messageGo to next message
Benoit Maggi is currently offline Benoit MaggiFriend
Messages: 129
Registered: March 2013
Location: Bordeaux, France
Senior Member
Hi Ismael,

I fear that I can't help you more without you sharing some code.
Can you share your plugin? (Github,Dropbox....)

Regards,
Benoit
Re: Drop element in Papyrus [message #1751398 is a reply to message #1751371] Mon, 09 January 2017 17:43 Go to previous messageGo to next message
Ismael Soulama is currently offline Ismael SoulamaFriend
Messages: 39
Registered: November 2016
Member
OK,
I use the plugin extension for on a drop strategy, and in my custom drop strategy, I wrote:

<extension point="org.eclipse.papyrus.infra.gmfdiag.dnd.dropStrategy">
		<strategy
			strategy="a.b.c.CustomdropStrategy">
		</strategy>
</extension>


public class CustomdropStrategy extends TransactionalDropStrategy {
      @Override
	public Command doGetCommand(final Request request, final EditPart targetEditPart) {

		if(!(request instanceof CreateUnspecifiedTypeRequest)){
			return null;
		}
		
		final List<EObject> sourceEObjects = getSourceEObjects(request);

		if (sourceEObjects.size() != 1) {
			return null;
		}
//.....
          }
}

But I Don't get a DropObjectsRequest and the source element.
Re: Drop element in Papyrus [message #1751762 is a reply to message #1751398] Fri, 13 January 2017 15:16 Go to previous message
Ismael Soulama is currently offline Ismael SoulamaFriend
Messages: 39
Registered: November 2016
Member
I try to extend the elementTypes extension point to add my own shape in a papyrus diagram, but when I drag it, I get:
org.eclipse.papyrus.infra.core.services.ServiceException: No IElementType bound to Papyrus shared client context for MetamodelType[My_Shape].
	at org.eclipse.papyrus.infra.services.edit.internal.ElementEditServiceProvider.getEditService(ElementEditServiceProvider.java:119)
	at org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils.getCommandProvider(ElementEditServiceUtils.java:68)
	at org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy.getDefaultSemanticCommand(DefaultSemanticEditPolicy.java:239)
	at org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy.getCreateCommand(DefaultSemanticEditPolicy.java:154)
	at org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy.getSemanticCommandSwitch(DefaultSemanticEditPolicy.java:118)
	at org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy.getSemanticCommand(DefaultSemanticEditPolicy.java:78)
	at org.eclipse.gmf.runtime.diagram.ui.editpolicies.SemanticEditPolicy.getCommand(SemanticEditPolicy.java:69)
	at org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy.getCommand(DefaultSemanticEditPolicy.java:72)
	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.papyrus.infra.emf.readonly.PapyrusROTransactionalEditingDomain.runExclusive(PapyrusROTransactionalEditingDomain.java:271)
	at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.getCommand(GraphicalEditPart.java:477)
	at org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy.getCreateElementAndViewCommand(CreationEditPolicy.java:340)
	at org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy.getCommand(CreationEditPolicy.java:87)
	at org.eclipse.papyrus.infra.gmfdiag.dnd.policy.CustomizableDropEditPolicy.getCommand(CustomizableDropEditPolicy.java:118)
	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.papyrus.infra.emf.readonly.PapyrusROTransactionalEditingDomain.runExclusive(PapyrusROTransactionalEditingDomain.java:271)
	at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.getCommand(GraphicalEditPart.java:477)
	at org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy.getUnspecifiedTypeCreateCommand(CreationEditPolicy.java:395)
	at org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy.getCommand(CreationEditPolicy.java:85)
	at org.eclipse.papyrus.infra.gmfdiag.dnd.policy.CustomizableDropEditPolicy.getCommand(CustomizableDropEditPolicy.java:118)
	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.papyrus.infra.emf.readonly.PapyrusROTransactionalEditingDomain.runExclusive(PapyrusROTransactionalEditingDomain.java:271)
	at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.getCommand(GraphicalEditPart.java:477)
	at org.eclipse.gef.tools.TargetingTool.getCommand(TargetingTool.java:123)
	at org.eclipse.gmf.runtime.diagram.ui.tools.CreationTool.getCommand(CreationTool.java:277)
	at org.eclipse.gef.tools.CreationTool.handleMove(CreationTool.java:253)
	at org.eclipse.gmf.runtime.diagram.ui.tools.CreationTool.handleMove(CreationTool.java:258)
	at org.eclipse.gef.tools.AbstractTool.mouseMove(AbstractTool.java:1182)
	at org.eclipse.gef.EditDomain.mouseMove(EditDomain.java:287)
	at org.eclipse.gef.ui.parts.DomainEventDispatcher.dispatchMouseMoved(DomainEventDispatcher.java:365)
	at org.eclipse.draw2d.LightweightSystem$EventHandler.mouseMove(LightweightSystem.java:543)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:213)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4410)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1079)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4228)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3816)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1121)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1022)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:150)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:687)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:604)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:138)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
	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:673)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1492)


Did I forget something?
Previous Topic:How to model object creation in a sequence diagram with Papyrus
Next Topic:Icon presentation for elements in diagrams
Goto Forum:
  


Current Time: Sat Jan 25 13:23:22 GMT 2020

Powered by FUDForum. Page generated in 0.02034 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top