diff options
Diffstat (limited to 'plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies')
8 files changed, 464 insertions, 464 deletions
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/CompartmentItemSemanticEditPolicy.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/CompartmentItemSemanticEditPolicy.xtend index 237da6a0154..846bc041d6e 100644 --- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/CompartmentItemSemanticEditPolicy.xtend +++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/CompartmentItemSemanticEditPolicy.xtend @@ -10,20 +10,20 @@ * Alexander Shatalin (Borland) - initial API and implementation * Michael Golubev (Montages) - #386838 - migrate to Xtend2 */ -package aspects.xpt.diagram.editpolicies
-
-import com.google.inject.Inject
-import com.google.inject.Singleton
-import metamodel.MetaModel
-import org.eclipse.emf.common.util.EList
-import org.eclipse.gmf.codegen.gmfgen.GenChildNode
-import org.eclipse.gmf.codegen.gmfgen.GenCompartment
-import org.eclipse.gmf.codegen.gmfgen.GenNode
-import org.eclipse.gmf.codegen.gmfgen.TypeModelFacet
-import org.eclipse.papyrus.papyrusgmfgenextension.ConstrainedByReferenceCompartmentItemSemanticEditPolicy
-import xpt.Common
-import xpt.diagram.editpolicies.childContainerCreateCommand
-
+package aspects.xpt.diagram.editpolicies + +import com.google.inject.Inject +import com.google.inject.Singleton +import metamodel.MetaModel +import org.eclipse.emf.common.util.EList +import org.eclipse.gmf.codegen.gmfgen.GenChildNode +import org.eclipse.gmf.codegen.gmfgen.GenCompartment +import org.eclipse.gmf.codegen.gmfgen.GenNode +import org.eclipse.gmf.codegen.gmfgen.TypeModelFacet +import org.eclipse.papyrus.papyrusgmfgenextension.ConstrainedByReferenceCompartmentItemSemanticEditPolicy +import xpt.Common +import xpt.diagram.editpolicies.childContainerCreateCommand + @Singleton class CompartmentItemSemanticEditPolicy extends xpt.diagram.editpolicies.CompartmentItemSemanticEditPolicy { @Inject extension Common; @Inject extension MetaModel diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/DiagramItemSemanticEditPolicy.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/DiagramItemSemanticEditPolicy.xtend index 037fcbdaa0f..70e7cd045fd 100644 --- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/DiagramItemSemanticEditPolicy.xtend +++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/DiagramItemSemanticEditPolicy.xtend @@ -1,20 +1,20 @@ -/**
- * Copyright (c) 2006, 2009 Borland Software Corporation
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- */
-package aspects.xpt.diagram.editpolicies
-
-import com.google.inject.Singleton
-
-@Singleton class DiagramItemSemanticEditPolicy extends xpt.diagram.editpolicies.DiagramItemSemanticEditPolicy {
-
-
+/** + * Copyright (c) 2006, 2009 Borland Software Corporation + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Alexander Shatalin (Borland) - initial API and implementation + * Michael Golubev (Montages) - #386838 - migrate to Xtend2 + */ +package aspects.xpt.diagram.editpolicies + +import com.google.inject.Singleton + +@Singleton class DiagramItemSemanticEditPolicy extends xpt.diagram.editpolicies.DiagramItemSemanticEditPolicy { + + }
\ No newline at end of file diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/LinkItemSemanticEditPolicy.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/LinkItemSemanticEditPolicy.xtend index 7e62ee0e930..6e90c98ed11 100644 --- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/LinkItemSemanticEditPolicy.xtend +++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/LinkItemSemanticEditPolicy.xtend @@ -1,54 +1,54 @@ -/**
- * Copyright (c) 2007-2012 Borland Software Corporation and others
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Borland) - [243151] explicit source/target for links
- * - #386838 - migrate to Xtend2
- * Vincent Lorenzo (CEA-LIST)
- */
-package aspects.xpt.diagram.editpolicies
-
-import com.google.inject.Inject
-import com.google.inject.Singleton
-import impl.diagram.commands.DeleteLinkCommand
-import org.eclipse.gmf.codegen.gmfgen.GenLink
-import org.eclipse.gmf.codegen.gmfgen.TypeLinkModelFacet
-import org.eclipse.papyrus.papyrusgmfgenextension.EditPartUsingDeleteService
-import utils.UtilsItemSemanticEditPolicy
-import xpt.Common
-
-@Singleton class LinkItemSemanticEditPolicy extends xpt.diagram.editpolicies.LinkItemSemanticEditPolicy {
- @Inject extension Common;
- @Inject extension DeleteLinkCommand
- @Inject extension UtilsItemSemanticEditPolicy
-
- override dispatch getDestroySemanticCommand(TypeLinkModelFacet it, GenLink genLink) '''
- ««« Test to know which delete command should be used in the generated code : "Traditional Delete Command" or the Delete Service
-
- «IF it.eResource.allContents.filter(typeof (EditPartUsingDeleteService)).filter[v | v.genView.contains(genLink)].size !=0 »
-
- «generatedMemberComment»
- «getDestroyElementCommandByService(it)»
- «ELSE»
- «generatedMemberComment»
- protected org.eclipse.gef.commands.Command getDestroyElementCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest req) {
- org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand cmd = new org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- java.util.List<org.eclipse.emf.ecore.EObject> todestroy=new java.util.ArrayList<org.eclipse.emf.ecore.EObject>();
- todestroy.add(req.getElementToDestroy());
- //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new org.eclipse.papyrus.infra.emf.gmf.command.EMFtoGMFCommandWrapper(new org.eclipse.emf.edit.command.DeleteCommand(getEditingDomain(),todestroy )));
- return getGEFWrapper(cmd.reduce());
- //return getGEFWrapper(«newDeleteLinkWithClassCommand(it,genLink, 'req')»);
- }
- «ENDIF»
- '''
-
-
-}
+/** + * Copyright (c) 2007-2012 Borland Software Corporation and others + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Alexander Shatalin (Borland) - initial API and implementation + * Michael Golubev (Borland) - [243151] explicit source/target for links + * - #386838 - migrate to Xtend2 + * Vincent Lorenzo (CEA-LIST) + */ +package aspects.xpt.diagram.editpolicies + +import com.google.inject.Inject +import com.google.inject.Singleton +import impl.diagram.commands.DeleteLinkCommand +import org.eclipse.gmf.codegen.gmfgen.GenLink +import org.eclipse.gmf.codegen.gmfgen.TypeLinkModelFacet +import org.eclipse.papyrus.papyrusgmfgenextension.EditPartUsingDeleteService +import utils.UtilsItemSemanticEditPolicy +import xpt.Common + +@Singleton class LinkItemSemanticEditPolicy extends xpt.diagram.editpolicies.LinkItemSemanticEditPolicy { + @Inject extension Common; + @Inject extension DeleteLinkCommand + @Inject extension UtilsItemSemanticEditPolicy + + override dispatch getDestroySemanticCommand(TypeLinkModelFacet it, GenLink genLink) ''' + ««« Test to know which delete command should be used in the generated code : "Traditional Delete Command" or the Delete Service + + «IF it.eResource.allContents.filter(typeof (EditPartUsingDeleteService)).filter[v | v.genView.contains(genLink)].size !=0 » + + «generatedMemberComment» + «getDestroyElementCommandByService(it)» + «ELSE» + «generatedMemberComment» + protected org.eclipse.gef.commands.Command getDestroyElementCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest req) { + org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand cmd = new org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand(getEditingDomain(), null); + cmd.setTransactionNestingEnabled(true); + java.util.List<org.eclipse.emf.ecore.EObject> todestroy=new java.util.ArrayList<org.eclipse.emf.ecore.EObject>(); + todestroy.add(req.getElementToDestroy()); + //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req)); + cmd.add(new org.eclipse.papyrus.infra.emf.gmf.command.EMFtoGMFCommandWrapper(new org.eclipse.emf.edit.command.DeleteCommand(getEditingDomain(),todestroy ))); + return getGEFWrapper(cmd.reduce()); + //return getGEFWrapper(«newDeleteLinkWithClassCommand(it,genLink, 'req')»); + } + «ENDIF» + ''' + + +} diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xtend index 5da4736c1e6..793aa38e235 100644 --- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xtend +++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xtend @@ -1,253 +1,253 @@ -/**
- * Copyright (c) 2007-2013 Borland Software Corporation and others
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * Artem Tikhomirov (Borland) - [257632] do not rely on EditPart presence for element deletion
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- */
-package aspects.xpt.diagram.editpolicies
-
-import com.google.inject.Inject
-import com.google.inject.Singleton
-import java.util.List
-import org.eclipse.gmf.codegen.gmfgen.FeatureLinkModelFacet
-import org.eclipse.gmf.codegen.gmfgen.GenChildNode
-import org.eclipse.gmf.codegen.gmfgen.GenNode
-import org.eclipse.gmf.codegen.gmfgen.TypeLinkModelFacet
-import org.eclipse.papyrus.papyrusgmfgenextension.EditPartUsingDeleteService
-import utils.UtilsItemSemanticEditPolicy
-import xpt.Common
-import xpt.diagram.editpolicies.childContainerCreateCommand
-import xpt.editor.VisualIDRegistry
-
-/**
- * This template should be called only for non-design nodes (modelFacet != null)
- * because *ItemSemanticEditPolicy responsible for dealing with semantic model
- * elements and meaningless (should not be generated) for pure design nodes.
- */
-@Singleton class NodeItemSemanticEditPolicy extends xpt.diagram.editpolicies.NodeItemSemanticEditPolicy {
-
- @Inject extension Common;
- @Inject extension xpt.diagram.editpolicies.Utils_qvto;
- @Inject extension UtilsItemSemanticEditPolicy
-
-
- @Inject BaseItemSemanticEditPolicy xptBaseItemSemanticEditPolicy;
- @Inject childContainerCreateCommand xptChildContainerCreateCommand;
- @Inject linkCommands xptLinkCommands;
- @Inject VisualIDRegistry xptVisualIDRegistry;
-
-
-
- override NodeItemSemanticEditPolicy(GenNode it) '''
- «copyright(getDiagram().editorGen)»
- package «packageName(it)»;
-
- «generatedClassComment()»
- public class «className(it)» extends «xptBaseItemSemanticEditPolicy.qualifiedClassName(getDiagram())» {
-
- «xptBaseItemSemanticEditPolicy.defaultConstructor(it)»
-
- «xptChildContainerCreateCommand.childContainerCreateCommand(it.childNodes)»
-
- ««« Papyrus REM :
- ««« Test to know how the delete of this EditPart is done : we used the DeleteService or the "Traditional method"
-
- «IF it.eResource.allContents.filter(typeof (EditPartUsingDeleteService)).filter[v | v.genView.contains(it)].size != 0»
- «generatedMemberComment»
- «getDestroyElementCommandByService(it)»
- «ELSE»
- «getDestroyElementCommand(it)»
- «IF hasChildrenOrCompartments(it)»
- «addDestroyChildNodesCommand(it)»
- «ENDIF»
- «ENDIF»
-
- «xptLinkCommands.linkCommands(it)»
-
- «additions(it)»
- }
- '''
-
- override getDestroyElementCommand(GenNode it) '''
- «generatedMemberComment()»
-protected org.eclipse.gef.commands.Command getDestroyElementCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest req) {
- org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) getHost().getModel();
- org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand cmd = new org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(true);
- ««« «destroyEdges('view')»
- org.eclipse.emf.ecore.EAnnotation annotation = view.getEAnnotation("Shortcut");«nonNLS»
- if (annotation == null) {
- // there are indirectly referenced children, need extra commands: «it.childNodes.union(compartments.map(c | c.childNodes).flatten).exists[GenChildNode gcn | !isDirectlyOwned(gcn, it)]»
- «IF hasChildrenOrCompartments(it)»
- addDestroyChildNodesCommand(cmd);
- «ENDIF»
- addDestroyShortcutsCommand(cmd, view);
- // delete host element
- java.util.List<org.eclipse.emf.ecore.EObject> todestroy=new java.util.ArrayList<org.eclipse.emf.ecore.EObject>();
- todestroy.add(req.getElementToDestroy());
- //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- cmd.add(new org.eclipse.papyrus.infra.emf.gmf.command.EMFtoGMFCommandWrapper(new org.eclipse.emf.edit.command.DeleteCommand(getEditingDomain(),todestroy )));
- } else {«««Here, we may play smart and don't generate else for non-toplevel nodes(which can't be shortcuts). Is it worth doing?
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
-}
- '''
-
- override addDestroyChildNodesCommand(GenNode it) '''
- «generatedMemberComment()»
- protected void addDestroyChildNodesCommand(org.eclipse.gmf.runtime.common.core.command.ICompositeCommand cmd) {
- org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) getHost().getModel();
- for (java.util.Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
- org.eclipse.gmf.runtime.notation.Node node = (org.eclipse.gmf.runtime.notation.Node) nit.next();
- String vid = «xptVisualIDRegistry.getVisualIDMethodCall(it.diagram)»(node);
- if (vid != null) {
- switch (vid) {
- «FOR cn : it.childNodes»
- «destroyChildNodes(cn, 'node', it)»
- «ENDFOR»
- «FOR compartment : it.compartments»
- «xptVisualIDRegistry.caseVisualID(compartment)»
- for (java.util.Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
- org.eclipse.gmf.runtime.notation.Node cnode = (org.eclipse.gmf.runtime.notation.Node) cit.next();
- String cvid = «xptVisualIDRegistry.getVisualIDMethodCall(it.diagram)»(cnode);
- if (cvid != null) {
- switch (cvid) {
- «FOR cn : compartment.childNodes»
- «destroyChildNodes(cn, 'cnode', it)»
- «ENDFOR»
- }
- }
- }
- break;
- «ENDFOR»
- }
- }
- }
- }
- '''
-
-
- /**
- * @param view - Notation element for the passed node
- * assumes 'cmd' to point to composite command
- */
- override destroyEdges(GenNode it, String view) '''
-
-««« XXX: Though semantic editpolicy is supposed to create commands that operate with semantic elements only,
-««« old code used to delegate child/link deletion to respective editparts, which in turn led to semantic commands
-««« being combined with notational commands (BaseItemSemanticEditPolicy#addDeleteViewCommand()).
-««« ---
-««« Use DiagramUpdater.get[Incoming|Outgoing]View instead, to clean links that are not present on a diagram
-««« (but don't forget to clean corresponding Edge, if any)
-
-
-«««// This part is commented for Papyrus
-«««// Some Papyrus diagrams with lots of elements are reaching the 65K Java limit for method size.
-«««// The following change is not supposed to modify the method behavior, just propose a slight more
-«««// compact code to avoid size limit.
-«««
-««««IF genIncomingLinks->notEmpty()-»
-««« for («EXPAND CodeStyle::G('java.util.Iterator', '?' /*FIXME Refactor once Notation model is Java5*/)» it = «view».getTargetEdges().iterator(); it.hasNext();) {
-««« org.eclipse.gmf.runtime.notation.Edge incomingLink = (org.eclipse.gmf.runtime.notation.Edge) it.next();
-««««FOREACH genIncomingLinks AS il-»
-««« if («EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR getDiagram()»(incomingLink) == «EXPAND xpt::editor::VisualIDRegistry::visualID FOR il») {
-««« «EXPAND impl::diagram::commands::DeleteLinkCommand::newRequest('r', 'incomingLink') FOR il-»
-««« cmd.add(«EXPAND impl::diagram::commands::DeleteLinkCommand::newInstance('r') FOR il»);
-««« cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
-««« continue;
-««« }
-««««ENDFOREACH-»
-««« }
-««««ENDIF-»
-««««IF genOutgoingLinks->notEmpty()-»
-««« for («EXPAND CodeStyle::G('java.util.Iterator', '?' /*FIXME Refactor once Notation model is Java5*/)» it = «view».getSourceEdges().iterator(); it.hasNext();) {
-««« org.eclipse.gmf.runtime.notation.Edge outgoingLink = (org.eclipse.gmf.runtime.notation.Edge) it.next();
-««««FOREACH genOutgoingLinks AS ol-»
-««« if («EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR getDiagram()»(outgoingLink) == «EXPAND xpt::editor::VisualIDRegistry::visualID FOR ol») {
-««« «EXPAND impl::diagram::commands::DeleteLinkCommand::newRequest('r', 'outgoingLink') FOR ol-»
-««« cmd.add(«EXPAND impl::diagram::commands::DeleteLinkCommand::newInstance('r') FOR ol»);
-««« cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), outgoingLink));
-««« continue;
-««« }
-««««ENDFOREACH-»
-««« }
-««««ENDIF-»
-
-
-«IF !genIncomingLinks.isEmpty()»
- for (java.util.Iterator<?> it = «view».getTargetEdges().iterator(); it.hasNext();) {
- org.eclipse.gmf.runtime.notation.Edge incomingLink = (org.eclipse.gmf.runtime.notation.Edge) it.next();
- String vid = «xptVisualIDRegistry.getVisualIDMethodCall(getDiagram())»(incomingLink);
- if (vid != null) {
- switch(vid) {
-«IF !genIncomingLinks.filter[l | l.modelFacet instanceof FeatureLinkModelFacet].empty»
-«FOR il : genIncomingLinks.filter[l | l.modelFacet instanceof FeatureLinkModelFacet]»
- case «VisualIDRegistry.visualID(il)»:
-«ENDFOR»
- org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest destroyRefReq = new org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
-«ENDIF»
-«IF !genIncomingLinks.filter[l | l.modelFacet instanceof TypeLinkModelFacet].empty»
-«FOR il : genIncomingLinks.filter[l | l.modelFacet instanceof TypeLinkModelFacet]»
- case «VisualIDRegistry.visualID(il)»:
-«ENDFOR»
- org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest destroyEltReq = new org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
-«ENDIF»
- }
- }
- }
-«ENDIF»
-
-«IF genOutgoingLinks.isEmpty()»
- for (java.util.Iterator<?> it = «view».getSourceEdges().iterator(); it.hasNext();) {
- org.eclipse.gmf.runtime.notation.Edge outgoingLink = (org.eclipse.gmf.runtime.notation.Edge) it.next();
- String vid = «xptVisualIDRegistry.getVisualIDMethodCall(getDiagram())»(outgoingLink);
- if (vid != null) {
- switch(vid) {
-«IF !genOutgoingLinks.filter[l | l.modelFacet instanceof FeatureLinkModelFacet].empty»
-«FOR ol : genOutgoingLinks.filter[l | l.modelFacet instanceof FeatureLinkModelFacet]»
- case «VisualIDRegistry.visualID(ol)»:
-«ENDFOR»
- org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest destroyRefReq = new org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest(outgoingLink.getSource().getElement(), null, outgoingLink.getTarget().getElement(), false);
- cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), outgoingLink));
- break;
-«ENDIF»
-«IF !genOutgoingLinks.filter[l | l.modelFacet instanceof TypeLinkModelFacet].empty»
-«FOR ol : genOutgoingLinks.filter[l | l.modelFacet instanceof TypeLinkModelFacet]»
- case «VisualIDRegistry.visualID(ol)»:
-«ENDFOR»
- org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest destroyEltReq = new org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest(outgoingLink.getElement(), false);
- cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), outgoingLink));
- break;
-«ENDIF»
- }
- }
- }
-«ENDIF»
- '''
-
-
-
- private def static <T> Iterable<T> union(Iterable<? extends T> listA, Iterable<? extends T> listB) {
- var List<T> result = newLinkedList();
- result.addAll(listA);
- result.addAll(listB);
- return result;
- }
-
-}
+/** + * Copyright (c) 2007-2013 Borland Software Corporation and others + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Alexander Shatalin (Borland) - initial API and implementation + * Artem Tikhomirov (Borland) - [257632] do not rely on EditPart presence for element deletion + * Michael Golubev (Montages) - #386838 - migrate to Xtend2 + */ +package aspects.xpt.diagram.editpolicies + +import com.google.inject.Inject +import com.google.inject.Singleton +import java.util.List +import org.eclipse.gmf.codegen.gmfgen.FeatureLinkModelFacet +import org.eclipse.gmf.codegen.gmfgen.GenChildNode +import org.eclipse.gmf.codegen.gmfgen.GenNode +import org.eclipse.gmf.codegen.gmfgen.TypeLinkModelFacet +import org.eclipse.papyrus.papyrusgmfgenextension.EditPartUsingDeleteService +import utils.UtilsItemSemanticEditPolicy +import xpt.Common +import xpt.diagram.editpolicies.childContainerCreateCommand +import xpt.editor.VisualIDRegistry + +/** + * This template should be called only for non-design nodes (modelFacet != null) + * because *ItemSemanticEditPolicy responsible for dealing with semantic model + * elements and meaningless (should not be generated) for pure design nodes. + */ +@Singleton class NodeItemSemanticEditPolicy extends xpt.diagram.editpolicies.NodeItemSemanticEditPolicy { + + @Inject extension Common; + @Inject extension xpt.diagram.editpolicies.Utils_qvto; + @Inject extension UtilsItemSemanticEditPolicy + + + @Inject BaseItemSemanticEditPolicy xptBaseItemSemanticEditPolicy; + @Inject childContainerCreateCommand xptChildContainerCreateCommand; + @Inject linkCommands xptLinkCommands; + @Inject VisualIDRegistry xptVisualIDRegistry; + + + + override NodeItemSemanticEditPolicy(GenNode it) ''' + «copyright(getDiagram().editorGen)» + package «packageName(it)»; + + «generatedClassComment()» + public class «className(it)» extends «xptBaseItemSemanticEditPolicy.qualifiedClassName(getDiagram())» { + + «xptBaseItemSemanticEditPolicy.defaultConstructor(it)» + + «xptChildContainerCreateCommand.childContainerCreateCommand(it.childNodes)» + + ««« Papyrus REM : + ««« Test to know how the delete of this EditPart is done : we used the DeleteService or the "Traditional method" + + «IF it.eResource.allContents.filter(typeof (EditPartUsingDeleteService)).filter[v | v.genView.contains(it)].size != 0» + «generatedMemberComment» + «getDestroyElementCommandByService(it)» + «ELSE» + «getDestroyElementCommand(it)» + «IF hasChildrenOrCompartments(it)» + «addDestroyChildNodesCommand(it)» + «ENDIF» + «ENDIF» + + «xptLinkCommands.linkCommands(it)» + + «additions(it)» + } + ''' + + override getDestroyElementCommand(GenNode it) ''' + «generatedMemberComment()» +protected org.eclipse.gef.commands.Command getDestroyElementCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest req) { + org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) getHost().getModel(); + org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand cmd = new org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand(getEditingDomain(), null); + cmd.setTransactionNestingEnabled(true); + ««« «destroyEdges('view')» + org.eclipse.emf.ecore.EAnnotation annotation = view.getEAnnotation("Shortcut");«nonNLS» + if (annotation == null) { + // there are indirectly referenced children, need extra commands: «it.childNodes.union(compartments.map(c | c.childNodes).flatten).exists[GenChildNode gcn | !isDirectlyOwned(gcn, it)]» + «IF hasChildrenOrCompartments(it)» + addDestroyChildNodesCommand(cmd); + «ENDIF» + addDestroyShortcutsCommand(cmd, view); + // delete host element + java.util.List<org.eclipse.emf.ecore.EObject> todestroy=new java.util.ArrayList<org.eclipse.emf.ecore.EObject>(); + todestroy.add(req.getElementToDestroy()); + //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req)); + cmd.add(new org.eclipse.papyrus.infra.emf.gmf.command.EMFtoGMFCommandWrapper(new org.eclipse.emf.edit.command.DeleteCommand(getEditingDomain(),todestroy ))); + } else {«««Here, we may play smart and don't generate else for non-toplevel nodes(which can't be shortcuts). Is it worth doing? + cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view)); + } + return getGEFWrapper(cmd.reduce()); +} + ''' + + override addDestroyChildNodesCommand(GenNode it) ''' + «generatedMemberComment()» + protected void addDestroyChildNodesCommand(org.eclipse.gmf.runtime.common.core.command.ICompositeCommand cmd) { + org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) getHost().getModel(); + for (java.util.Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) { + org.eclipse.gmf.runtime.notation.Node node = (org.eclipse.gmf.runtime.notation.Node) nit.next(); + String vid = «xptVisualIDRegistry.getVisualIDMethodCall(it.diagram)»(node); + if (vid != null) { + switch (vid) { + «FOR cn : it.childNodes» + «destroyChildNodes(cn, 'node', it)» + «ENDFOR» + «FOR compartment : it.compartments» + «xptVisualIDRegistry.caseVisualID(compartment)» + for (java.util.Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) { + org.eclipse.gmf.runtime.notation.Node cnode = (org.eclipse.gmf.runtime.notation.Node) cit.next(); + String cvid = «xptVisualIDRegistry.getVisualIDMethodCall(it.diagram)»(cnode); + if (cvid != null) { + switch (cvid) { + «FOR cn : compartment.childNodes» + «destroyChildNodes(cn, 'cnode', it)» + «ENDFOR» + } + } + } + break; + «ENDFOR» + } + } + } + } + ''' + + + /** + * @param view - Notation element for the passed node + * assumes 'cmd' to point to composite command + */ + override destroyEdges(GenNode it, String view) ''' + +««« XXX: Though semantic editpolicy is supposed to create commands that operate with semantic elements only, +««« old code used to delegate child/link deletion to respective editparts, which in turn led to semantic commands +««« being combined with notational commands (BaseItemSemanticEditPolicy#addDeleteViewCommand()). +««« --- +««« Use DiagramUpdater.get[Incoming|Outgoing]View instead, to clean links that are not present on a diagram +««« (but don't forget to clean corresponding Edge, if any) + + +«««// This part is commented for Papyrus +«««// Some Papyrus diagrams with lots of elements are reaching the 65K Java limit for method size. +«««// The following change is not supposed to modify the method behavior, just propose a slight more +«««// compact code to avoid size limit. +««« +««««IF genIncomingLinks->notEmpty()-» +««« for («EXPAND CodeStyle::G('java.util.Iterator', '?' /*FIXME Refactor once Notation model is Java5*/)» it = «view».getTargetEdges().iterator(); it.hasNext();) { +««« org.eclipse.gmf.runtime.notation.Edge incomingLink = (org.eclipse.gmf.runtime.notation.Edge) it.next(); +««««FOREACH genIncomingLinks AS il-» +««« if («EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR getDiagram()»(incomingLink) == «EXPAND xpt::editor::VisualIDRegistry::visualID FOR il») { +««« «EXPAND impl::diagram::commands::DeleteLinkCommand::newRequest('r', 'incomingLink') FOR il-» +««« cmd.add(«EXPAND impl::diagram::commands::DeleteLinkCommand::newInstance('r') FOR il»); +««« cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink)); +««« continue; +««« } +««««ENDFOREACH-» +««« } +««««ENDIF-» +««««IF genOutgoingLinks->notEmpty()-» +««« for («EXPAND CodeStyle::G('java.util.Iterator', '?' /*FIXME Refactor once Notation model is Java5*/)» it = «view».getSourceEdges().iterator(); it.hasNext();) { +««« org.eclipse.gmf.runtime.notation.Edge outgoingLink = (org.eclipse.gmf.runtime.notation.Edge) it.next(); +««««FOREACH genOutgoingLinks AS ol-» +««« if («EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR getDiagram()»(outgoingLink) == «EXPAND xpt::editor::VisualIDRegistry::visualID FOR ol») { +««« «EXPAND impl::diagram::commands::DeleteLinkCommand::newRequest('r', 'outgoingLink') FOR ol-» +««« cmd.add(«EXPAND impl::diagram::commands::DeleteLinkCommand::newInstance('r') FOR ol»); +««« cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), outgoingLink)); +««« continue; +««« } +««««ENDFOREACH-» +««« } +««««ENDIF-» + + +«IF !genIncomingLinks.isEmpty()» + for (java.util.Iterator<?> it = «view».getTargetEdges().iterator(); it.hasNext();) { + org.eclipse.gmf.runtime.notation.Edge incomingLink = (org.eclipse.gmf.runtime.notation.Edge) it.next(); + String vid = «xptVisualIDRegistry.getVisualIDMethodCall(getDiagram())»(incomingLink); + if (vid != null) { + switch(vid) { +«IF !genIncomingLinks.filter[l | l.modelFacet instanceof FeatureLinkModelFacet].empty» +«FOR il : genIncomingLinks.filter[l | l.modelFacet instanceof FeatureLinkModelFacet]» + case «VisualIDRegistry.visualID(il)»: +«ENDFOR» + org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest destroyRefReq = new org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false); + cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyReferenceCommand(destroyRefReq)); + cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink)); + break; +«ENDIF» +«IF !genIncomingLinks.filter[l | l.modelFacet instanceof TypeLinkModelFacet].empty» +«FOR il : genIncomingLinks.filter[l | l.modelFacet instanceof TypeLinkModelFacet]» + case «VisualIDRegistry.visualID(il)»: +«ENDFOR» + org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest destroyEltReq = new org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest(incomingLink.getElement(), false); + cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(destroyEltReq)); + cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink)); + break; +«ENDIF» + } + } + } +«ENDIF» + +«IF genOutgoingLinks.isEmpty()» + for (java.util.Iterator<?> it = «view».getSourceEdges().iterator(); it.hasNext();) { + org.eclipse.gmf.runtime.notation.Edge outgoingLink = (org.eclipse.gmf.runtime.notation.Edge) it.next(); + String vid = «xptVisualIDRegistry.getVisualIDMethodCall(getDiagram())»(outgoingLink); + if (vid != null) { + switch(vid) { +«IF !genOutgoingLinks.filter[l | l.modelFacet instanceof FeatureLinkModelFacet].empty» +«FOR ol : genOutgoingLinks.filter[l | l.modelFacet instanceof FeatureLinkModelFacet]» + case «VisualIDRegistry.visualID(ol)»: +«ENDFOR» + org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest destroyRefReq = new org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest(outgoingLink.getSource().getElement(), null, outgoingLink.getTarget().getElement(), false); + cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyReferenceCommand(destroyRefReq)); + cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), outgoingLink)); + break; +«ENDIF» +«IF !genOutgoingLinks.filter[l | l.modelFacet instanceof TypeLinkModelFacet].empty» +«FOR ol : genOutgoingLinks.filter[l | l.modelFacet instanceof TypeLinkModelFacet]» + case «VisualIDRegistry.visualID(ol)»: +«ENDFOR» + org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest destroyEltReq = new org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest(outgoingLink.getElement(), false); + cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(destroyEltReq)); + cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), outgoingLink)); + break; +«ENDIF» + } + } + } +«ENDIF» + ''' + + + + private def static <T> Iterable<T> union(Iterable<? extends T> listA, Iterable<? extends T> listB) { + var List<T> result = newLinkedList(); + result.addAll(listA); + result.addAll(listB); + return result; + } + +} diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/TextNonResizableEditPolicy.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/TextNonResizableEditPolicy.xtend index e02ba0f64e6..2487fbd04ec 100644 --- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/TextNonResizableEditPolicy.xtend +++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/TextNonResizableEditPolicy.xtend @@ -1,21 +1,21 @@ -/*****************************************************************************
- * Copyright (c) 2017 CEA LIST and other.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - #510281 change dependency to replace gmft-runtime
- *****************************************************************************/
-package aspects.xpt.diagram.editpolicies
-
-import com.google.inject.Inject
-import com.google.inject.Singleton
-import org.eclipse.gmf.codegen.gmfgen.GenDiagram
-import xpt.Common
-
+/***************************************************************************** + * Copyright (c) 2017 CEA LIST and other. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - #510281 change dependency to replace gmft-runtime + *****************************************************************************/ +package aspects.xpt.diagram.editpolicies + +import com.google.inject.Inject +import com.google.inject.Singleton +import org.eclipse.gmf.codegen.gmfgen.GenDiagram +import xpt.Common + /** * FIXME: [MG] - reverse the calls? call common code from here and TextelectionEP and not vice versa */ diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/TextSelectionEditPolicy.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/TextSelectionEditPolicy.xtend index 75567599f6c..f9eeda69216 100644 --- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/TextSelectionEditPolicy.xtend +++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/TextSelectionEditPolicy.xtend @@ -1,56 +1,56 @@ -/*****************************************************************************
- * Copyright (c) 2017 CEA LIST and other.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - #510281 change dependency to replace gmft-runtime
- *****************************************************************************/
-package aspects.xpt.diagram.editpolicies
-
-import org.eclipse.gmf.codegen.gmfgen.GenDiagram
-import com.google.inject.Inject
-import xpt.Common
-import com.google.inject.Singleton
-import xpt.CodeStyle
-
-@Singleton class TextSelectionEditPolicy extends xpt.diagram.editpolicies.TextSelectionEditPolicy {
-
- @Inject extension Common
- @Inject extension CodeStyle
-
- // rebranch to the tooling runtime in the release train.
- override TextSelectionEditPolicy_implementsClause(GenDiagram it) '''implements org.eclipse.papyrus.infra.gmfdiag.tooling.runtime.edit.policies.labels.IRefreshableFeedbackEditPolicy'''
-
- override textFeedback_createFocusFeedbackFigure(GenDiagram it) '''
- «generatedMemberComment»
- protected org.eclipse.draw2d.IFigure createFocusFeedbackFigure() {
- return new org.eclipse.draw2d.Figure() {
-
- «overrideC»
- protected void paintFigure(org.eclipse.draw2d.Graphics graphics) {
- graphics.drawFocus(getBounds().getResized(-1, -1));
- }
- };
- }
- '''
-
- override textFeedback_getHostPositionListener(GenDiagram it) '''
- «generatedMemberComment»
- private org.eclipse.draw2d.FigureListener getHostPositionListener() {
- if (hostPositionListener == null) {
- hostPositionListener = new org.eclipse.draw2d.FigureListener() {
- «overrideI»
- public void figureMoved(org.eclipse.draw2d.IFigure source) {
- refreshFeedback();
- }
- };
- }
- return hostPositionListener;
- }
- '''
-
+/***************************************************************************** + * Copyright (c) 2017 CEA LIST and other. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - #510281 change dependency to replace gmft-runtime + *****************************************************************************/ +package aspects.xpt.diagram.editpolicies + +import org.eclipse.gmf.codegen.gmfgen.GenDiagram +import com.google.inject.Inject +import xpt.Common +import com.google.inject.Singleton +import xpt.CodeStyle + +@Singleton class TextSelectionEditPolicy extends xpt.diagram.editpolicies.TextSelectionEditPolicy { + + @Inject extension Common + @Inject extension CodeStyle + + // rebranch to the tooling runtime in the release train. + override TextSelectionEditPolicy_implementsClause(GenDiagram it) '''implements org.eclipse.papyrus.infra.gmfdiag.tooling.runtime.edit.policies.labels.IRefreshableFeedbackEditPolicy''' + + override textFeedback_createFocusFeedbackFigure(GenDiagram it) ''' + «generatedMemberComment» + protected org.eclipse.draw2d.IFigure createFocusFeedbackFigure() { + return new org.eclipse.draw2d.Figure() { + + «overrideC» + protected void paintFigure(org.eclipse.draw2d.Graphics graphics) { + graphics.drawFocus(getBounds().getResized(-1, -1)); + } + }; + } + ''' + + override textFeedback_getHostPositionListener(GenDiagram it) ''' + «generatedMemberComment» + private org.eclipse.draw2d.FigureListener getHostPositionListener() { + if (hostPositionListener == null) { + hostPositionListener = new org.eclipse.draw2d.FigureListener() { + «overrideI» + public void figureMoved(org.eclipse.draw2d.IFigure source) { + refreshFeedback(); + } + }; + } + return hostPositionListener; + } + ''' + }
\ No newline at end of file diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/Utils_qvto.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/Utils_qvto.xtend index 50246d06683..4eb215bd4d6 100644 --- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/Utils_qvto.xtend +++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/Utils_qvto.xtend @@ -11,11 +11,11 @@ * Michael Golubev (Borland) - [243151] explicit source/target for links * - #386838 - migrate to Xtend2 */ -package aspects.xpt.diagram.editpolicies
-
-import com.google.inject.Singleton
-import org.eclipse.gmf.codegen.gmfgen.GenLinkEnd
-
+package aspects.xpt.diagram.editpolicies + +import com.google.inject.Singleton +import org.eclipse.gmf.codegen.gmfgen.GenLinkEnd + @Singleton class Utils_qvto extends xpt.diagram.editpolicies.Utils_qvto { def Boolean containsCreateStartLinkCommand(GenLinkEnd it){ diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/linkCommands.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/linkCommands.xtend index 7141f4fb939..0b053d973f3 100644 --- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/linkCommands.xtend +++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/linkCommands.xtend @@ -12,21 +12,21 @@ * Michael Golubev (Borland) - [243151] explicit source/target for links * - #386838 - migrate to Xtend2 * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation - */
-package aspects.xpt.diagram.editpolicies
-
-import com.google.inject.Inject
-import com.google.inject.Singleton
-import org.eclipse.gmf.codegen.gmfgen.GenLink
-import org.eclipse.gmf.codegen.gmfgen.GenLinkEnd
-import org.eclipse.papyrus.papyrusgmfgenextension.EditPartUsingReorientService
-import org.eclipse.papyrus.papyrusgmfgenextension.GenerateUsingElementTypeCreationCommand
-import xpt.Common
-import xpt.diagram.commands.CreateLinkCommand
-import xpt.diagram.editpolicies.Utils_qvto
-import xpt.editor.VisualIDRegistry
-import xpt.providers.ElementTypes
-
+ */ +package aspects.xpt.diagram.editpolicies + +import com.google.inject.Inject +import com.google.inject.Singleton +import org.eclipse.gmf.codegen.gmfgen.GenLink +import org.eclipse.gmf.codegen.gmfgen.GenLinkEnd +import org.eclipse.papyrus.papyrusgmfgenextension.EditPartUsingReorientService +import org.eclipse.papyrus.papyrusgmfgenextension.GenerateUsingElementTypeCreationCommand +import xpt.Common +import xpt.diagram.commands.CreateLinkCommand +import xpt.diagram.editpolicies.Utils_qvto +import xpt.editor.VisualIDRegistry +import xpt.providers.ElementTypes + /** * Start start of link creation. * User click to this editpart and start dragging with link tool. @@ -47,16 +47,16 @@ import xpt.providers.ElementTypes * in the latter case it is assumed that its a TypeLink (so its model facet is LinkTypeModelFacet), * because RefLinks don't have underlying semantic identity * -*/
-@Singleton class linkCommands extends xpt.diagram.editpolicies.linkCommands {
- @Inject extension Utils_qvto;
- @Inject extension Common;
+*/ +@Singleton class linkCommands extends xpt.diagram.editpolicies.linkCommands { + @Inject extension Utils_qvto; + @Inject extension Common; - @Inject aspects.xpt.diagram.editpolicies.Utils_qvto aspectsUtils_qvto
+ @Inject aspects.xpt.diagram.editpolicies.Utils_qvto aspectsUtils_qvto @Inject VisualIDRegistry xptVisualIDRegistry; @Inject ElementTypes xptElementTypes; - @Inject CreateLinkCommand xptCreateLinkCommand;
-
+ @Inject CreateLinkCommand xptCreateLinkCommand; + override createLinkCommands(GenLinkEnd it) ''' «IF it.eResource.allContents.filter(typeof (GenerateUsingElementTypeCreationCommand)).size <1» @@ -133,11 +133,11 @@ import xpt.providers.ElementTypes «ENDIF» ''' -
+ // We overwrite the reorientTypeLinkCommands to manages the links which use the ReorientCommand provided by the EditService - override reorientTypeLinkCommands(GenLinkEnd it) '''
- «generatedMemberComment(
- 'Returns command to reorient EClass based link. New link target or source\n' + 'should be the domain model element associated with this node.\n'
+ override reorientTypeLinkCommands(GenLinkEnd it) ''' + «generatedMemberComment( + 'Returns command to reorient EClass based link. New link target or source\n' + 'should be the domain model element associated with this node.\n' )» protected org.eclipse.gef.commands.Command getReorientRelationshipCommand( org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest req) { @@ -155,21 +155,21 @@ import xpt.providers.ElementTypes } return super.getReorientRelationshipCommand(req); } - '''
-
+ ''' + //This function writes only : "case myLinkEditPart.VISUAL_ID:" //for the link which uses the ReorientCommand provided by the EditService - def reorientLinkCommandWithService(GenLink it) '''
- «IF it.eResource.allContents.filter(typeof(EditPartUsingReorientService)).filter[v| v.genView.contains(it)].size != 0»
+ def reorientLinkCommandWithService(GenLink it) ''' + «IF it.eResource.allContents.filter(typeof(EditPartUsingReorientService)).filter[v| v.genView.contains(it)].size != 0» «xptVisualIDRegistry.caseVisualID(it)» - «ENDIF»
- '''
-
+ «ENDIF» + ''' + // This function writes the code to call the ReorientCommand provided by the ReorientService - def callReorientCommand(GenLinkEnd it) '''
+ def callReorientCommand(GenLinkEnd it) ''' «var rServiceNodes = it.eResource.allContents.filter(typeof (EditPartUsingReorientService))» - «IF !rServiceNodes.empty»
- «IF !rServiceNodes.filter[rServiceNode|(!(rServiceNode.genView.filter[view|getReroutableTypeLinks(it).toList.contains(view)].empty))].empty»
+ «IF !rServiceNodes.empty» + «IF !rServiceNodes.filter[rServiceNode|(!(rServiceNode.genView.filter[view|getReroutableTypeLinks(it).toList.contains(view)].empty))].empty» org.eclipse.papyrus.infra.services.edit.service.IElementEditService provider =org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils.getCommandProvider(req.getRelationship()); if(provider == null) { return org.eclipse.gef.commands.UnexecutableCommand.INSTANCE; @@ -180,15 +180,15 @@ import xpt.providers.ElementTypes return org.eclipse.gef.commands.UnexecutableCommand.INSTANCE; } return getGEFWrapper(reorientCommand.reduce()); - «ENDIF»
- «ENDIF»
- '''
-
+ «ENDIF» + «ENDIF» + ''' + // This function writes the code for the Links which uses their own ReorientCommand (the initial code) - def reorientLinkCommandWithoutService(GenLink it) '''
- «IF it.eResource.allContents.filter(EditPartUsingReorientService).filter[v|v.genView.contains(it)].size == 0»
+ def reorientLinkCommandWithoutService(GenLink it) ''' + «IF it.eResource.allContents.filter(EditPartUsingReorientService).filter[v|v.genView.contains(it)].size == 0» «reorientLinkCommand(it)» - «ENDIF»
- '''
-
-}
+ «ENDIF» + ''' + +} |