diff options
author | Philippe ROLAND | 2014-03-14 15:16:43 +0000 |
---|---|---|
committer | Philippe ROLAND | 2014-03-14 15:16:43 +0000 |
commit | 6f70c04962bc001ae9a61ccf39665168ba3626cf (patch) | |
tree | 6e0ee714eb1298e29bc1382dda2a9b6efd1c7537 /plugins/developer | |
parent | c05175d4aee887c85fa8c32daa7b991123f274a9 (diff) | |
parent | 9f626161fd840f0cdbbd96a0bbba8454f140d8a3 (diff) | |
download | org.eclipse.papyrus-6f70c04962bc001ae9a61ccf39665168ba3626cf.tar.gz org.eclipse.papyrus-6f70c04962bc001ae9a61ccf39665168ba3626cf.tar.xz org.eclipse.papyrus-6f70c04962bc001ae9a61ccf39665168ba3626cf.zip |
Merge branch 'master' of ssh://git.eclipse.org/gitroot/papyrus/org.eclipse.papyrus
Diffstat (limited to 'plugins/developer')
5 files changed, 212 insertions, 203 deletions
diff --git a/plugins/developer/org.eclipse.papyrus.def/dynamic-templates3.5/codegen/xpt/diagram/commands/CreateNodeCommand.xpt b/plugins/developer/org.eclipse.papyrus.def/dynamic-templates3.5/codegen/xpt/diagram/commands/CreateNodeCommand.xpt index 8182b8c5b9c..aa60a52deed 100644 --- a/plugins/developer/org.eclipse.papyrus.def/dynamic-templates3.5/codegen/xpt/diagram/commands/CreateNodeCommand.xpt +++ b/plugins/developer/org.eclipse.papyrus.def/dynamic-templates3.5/codegen/xpt/diagram/commands/CreateNodeCommand.xpt @@ -1,196 +1,208 @@ -/*
- * Copyright (c) 2007, 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
- * modified by Patrick Tessier (CEA LIST)
- */
-
-«IMPORT 'http://www.eclipse.org/gmf/2009/GenModel'»
-«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
-«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
-«EXTENSION xpt::GenModelUtils»
-«EXTENSION xpt::diagram::Utils»
-«EXTENSION xpt::diagram::commands::file»
-«EXTENSION xpt::diagram::commands::NodeConstraintUtils»
-«EXTENSION xpt::OclMigrationProblems»
-
-«DEFINE CreateNodeCommand FOR gmfgen::GenNode-»
-«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
-package «getDiagram().editCommandsPackageName»;
-«EXPAND xpt::Common::generatedClassComment»
-public class «createCommandClassName» extends org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand {
- «REM» Mutating canvas auxiliary «ENDREM»
- «EXPAND xpt::Common::generatedMemberComment-»
- private org.eclipse.emf.ecore.EClass eClass = null;
- «EXPAND xpt::Common::generatedMemberComment-»
- private org.eclipse.emf.ecore.EObject eObject = null;
- «REM» Mutating canvas auxiliary constructor «ENDREM»
- «EXPAND xpt::Common::generatedMemberComment-»
- public «createCommandClassName»(org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest req, org.eclipse.emf.ecore.EObject eObject) {
- super(req.getLabel(), null, req);
- this.eObject = eObject;
- this.eClass = eObject != null ? eObject.eClass() : null;
- }
- «REM» Mutating canvas auxiliary builder «ENDREM»
- «EXPAND xpt::Common::generatedMemberComment-»
- public static «createCommandClassName» create(org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest req, org.eclipse.emf.ecore.EObject eObject) {
- return new «createCommandClassName»(req, eObject);
- }
- «EXPAND _constructor-»
- «EXPAND getElementToEdit-»
- «EXPAND canExecuteMethod-»
- «EXPAND doExecuteWithResultMethod»
- «EXPAND doConfigureMethod»
-}
-«ENDDEFINE»
-«DEFINE _constructor FOR gmfgen::GenNode-»
- «EXPAND xpt::Common::generatedMemberComment»
- public «createCommandClassName»(org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest req) {
- super(req.getLabel(), null, req);
- }
-«ENDDEFINE»
-/*
- * TODO: either use setElementToEdit, or generate downcasted version (which may be troublesome if containment and child features point to a different parent)
- */
-«DEFINE getElementToEdit FOR gmfgen::GenNode-»
- «EXPAND xpt::Common::generatedMemberComment('FIXME: replace with setElementToEdit()')»
-protected org.eclipse.emf.ecore.EObject getElementToEdit() {
-
- «REM» Mutating canvas helper «ENDREM»
- org.eclipse.emf.ecore.EObject container =
- ((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) getRequest()).getContainer();
- if (container instanceof org.eclipse.gmf.runtime.notation.View) {
- container = ((org.eclipse.gmf.runtime.notation.View) container).getElement();
- }
- if (container != null) {
- return container;
- }
- return eObject;
-}
-«ENDDEFINE»
-
-«REM» [AbstractElement] Modified for Abstract domain element «ENDREM»
-«DEFINE doExecuteWithResultMethod FOR gmfgen::GenNode-»
- «EXPAND xpt::Common::generatedMemberComment»
- protected org.eclipse.gmf.runtime.common.core.command.CommandResult doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info) throws org.eclipse.core.commands.ExecutionException {
-«REM» [AbstractElement] START «ENDREM»
-
-«IF modelFacet.metaClass.ecoreClass._abstract <> true-»
-«REM» [AbstractElement] END «ENDREM»
-«IF modelFacet.isPhantomElement()-»
- «EXPAND phantomElementCreation(self, 'newElement') FOR modelFacet»
-«ELSE-»
- «EXPAND normalElementCreation(self, 'newElement') FOR modelFacet»
-«ENDIF»
- «EXPAND initialize(self, 'newElement') FOR modelFacet-»
-«IF true/*FIXME boolean needsExternalConfiguration*/»
- doConfigure(newElement, monitor, info);
-«ENDIF»
- ((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) getRequest()).setNewElement(«EXPAND MetaModel::DowncastToEObject('newElement') FOR modelFacet.metaClass»);
- return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult(newElement);
- }
-«REM» [AbstractElement] START «ENDREM»
-«ELSE-»
- throw new UnsupportedOperationException("Unimplemented operation (abstract domain element).");
- }
-«ENDIF»
-«REM» [AbstractElement] END «ENDREM»
-«ENDDEFINE»
-/*
- * Unlike original CreateElementCommand, we don't keep track of IStatus from configureCommand.execute,
- * nor allow status setting from doDefaultCreation. The reason is ICommandProxy#execute implementation,
- * which ignores any status from wrapped ICommand. Besides, both CommandResult and IStatus seems too much to me.
- */
-«DEFINE doConfigureMethod FOR gmfgen::GenNode-»
- «EXPAND xpt::Common::generatedMemberComment»
- protected void doConfigure(«EXPAND MetaModel::QualifiedClassName FOR modelFacet.metaClass» newElement, org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info) throws org.eclipse.core.commands.ExecutionException {
- org.eclipse.gmf.runtime.emf.type.core.IElementType elementType = ((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) getRequest()).getElementType();
- org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest configureRequest = new org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest(getEditingDomain(), «EXPAND MetaModel::DowncastToEObject('newElement') FOR modelFacet.metaClass», elementType);
- configureRequest.setClientContext(((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) getRequest()).getClientContext());
- configureRequest.addParameters(getRequest().getParameters());
- org.eclipse.gmf.runtime.common.core.command.ICommand configureCommand = elementType.getEditCommand(configureRequest);
- if (configureCommand != null && configureCommand.canExecute()) {
- configureCommand.execute(monitor, info);
- }
- }
-«ENDDEFINE»
-«DEFINE canExecuteMethod FOR gmfgen::GenNode-»
- «EXPAND xpt::Common::generatedMemberComment»
- public boolean canExecute() {
-«IF modelFacet.isPhantomElement()-»
- return true;
-«ELSE-»
- «EXPAND canExecute_Normal FOR modelFacet»
-«ENDIF-»
- }
-«ENDDEFINE»
-«DEFINE canExecute_Normal FOR gmfgen::TypeModelFacet-»
-«IF not containmentMetaFeature.oclIsUndefined()-»
- «IF not containmentMetaFeature.ecoreFeature.oclIsUndefined()-»
- «IF not isUnbounded(containmentMetaFeature.ecoreFeature) or (childMetaFeature <> containmentMetaFeature and not isUnbounded(childMetaFeature.ecoreFeature))-»
- «EXPAND MetaModel::DeclareAndAssign('container', 'getElementToEdit()') FOR containmentMetaFeature.genClass-»
- «IF not isUnbounded(containmentMetaFeature.ecoreFeature)-»
- «IF isSingleValued(containmentMetaFeature.ecoreFeature)»
- if («EXPAND MetaModel::getFeatureValue('container', containmentMetaFeature.genClass) FOR containmentMetaFeature» != null) {
- «ELSE-»
- if («EXPAND MetaModel::getFeatureValue('container', containmentMetaFeature.genClass) FOR containmentMetaFeature».size() >= «containmentMetaFeature.ecoreFeature.upperBound») {
- «ENDIF-»
- return false;
- }
- «ENDIF-»
- «IF childMetaFeature <> containmentMetaFeature and not isUnbounded(childMetaFeature.ecoreFeature)-»
- «IF isSingleValued(childMetaFeature.ecoreFeature)-»
- if («EXPAND MetaModel::getFeatureValue('container', containmentMetaFeature.genClass) FOR childMetaFeature» != null) {
- «ELSE-»
- if («EXPAND MetaModel::getFeatureValue('container', containmentMetaFeature.genClass) FOR childMetaFeature».size() >= «childMetaFeature.ecoreFeature.upperBound») {
- «ENDIF-»
- return false;
- }
- «ENDIF-»
- «ENDIF-»
- «ENDIF-»
-«ENDIF-»
-«REM» [NodeCreationConstraint] START «ENDREM»
-«IF getOwningGenNode().hasNodeCreationConstraint()-»
- «getOwningGenNode().getNodeCreationConstraintBody()-»
-«ELSE-»
-«REM» [NodeCreationConstraint] END «ENDREM»
-return true;
-«REM» [NodeCreationConstraint] START «ENDREM» -«ENDIF-»
-«REM» [NodeCreationConstraint] END «ENDREM»
-«ENDDEFINE»
-«DEFINE phantomElementCreation(node : gmfgen::GenNode, varName : String) FOR gmfgen::TypeModelFacet-»
- // Uncomment to put "phantom" objects into the diagram file.
- // org.eclipse.emf.ecore.resource.Resource resource =
- // ((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) getRequest()).getContainer().eResource();
- // if (resource == null) {
- // return null;
- // }
- org.eclipse.emf.ecore.resource.Resource resource = getElementToEdit().eResource();
- «EXPAND MetaModel::NewInstance(varName) FOR metaClass»
- resource.getContents().add(«EXPAND MetaModel::DowncastToEObject(varName) FOR metaClass»);
-«ENDDEFINE»
-«DEFINE normalElementCreation(node : gmfgen::GenNode, varName : String) FOR gmfgen::TypeModelFacet-»
- «EXPAND MetaModel::NewInstance(varName) FOR metaClass»
-«IF not containmentMetaFeature.oclIsUndefined()-»
- «EXPAND MetaModel::DeclareAndAssign('owner', 'getElementToEdit()') FOR containmentMetaFeature.genClass»
- «EXPAND MetaModel::modifyFeature('owner', containmentMetaFeature.genClass, varName) FOR containmentMetaFeature-»
-«ELSE-»
- //
- // FIXME no containment feature found in the genmodel, toolsmith need to manually write code here to add «varName» to a parent
- //
-«ENDIF»
-«IF hasExplicitChildFeature(self)-»
- «EXPAND MetaModel::DeclareAndAssign('childHolder', 'getElementToEdit()') FOR childMetaFeature.genClass»
- «EXPAND MetaModel::modifyFeature('childHolder', childMetaFeature.genClass, varName) FOR childMetaFeature»
-«ENDIF-»
-«ENDDEFINE»
+/* + * Copyright (c) 2007, 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 + * modified by Patrick Tessier (CEA LIST) + */ + +«IMPORT 'http://www.eclipse.org/gmf/2009/GenModel'» +«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'» +«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'» +«EXTENSION xpt::GenModelUtils» +«EXTENSION xpt::diagram::Utils» +«EXTENSION xpt::diagram::commands::file» +«EXTENSION xpt::diagram::commands::NodeConstraintUtils» +«EXTENSION xpt::OclMigrationProblems» + +«DEFINE CreateNodeCommand FOR gmfgen::GenNode-» +«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-» +package «getDiagram().editCommandsPackageName»; +«EXPAND xpt::Common::generatedClassComment» +public class «createCommandClassName» extends org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand { + «REM» Mutating canvas auxiliary «ENDREM» + «EXPAND xpt::Common::generatedMemberComment-» + private org.eclipse.gmf.runtime.notation.Diagram diagram = null; + «EXPAND xpt::Common::generatedMemberComment-» + private org.eclipse.emf.ecore.EObject eObject = null; + «REM» Mutating canvas auxiliary constructor «ENDREM» + «EXPAND xpt::Common::generatedMemberComment-» + public «createCommandClassName»(org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest req, org.eclipse.emf.ecore.EObject eObject, org.eclipse.gmf.runtime.notation.Diagram diagram) { + super(req.getLabel(), null, req); + this.eObject = eObject; + this.diagram = diagram; + } + «REM» Mutating canvas auxiliary builder «ENDREM» + «EXPAND xpt::Common::generatedMemberComment-» + public static «createCommandClassName» create(org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest req, org.eclipse.emf.ecore.EObject eObject, org.eclipse.gmf.runtime.notation.Diagram diagram) { + return new «createCommandClassName»(req, eObject, diagram); + } + «EXPAND _constructor-» + «EXPAND getElementToEdit-» + «EXPAND canExecuteMethod-» + «EXPAND doExecuteWithResultMethod» + «EXPAND doConfigureMethod» +} +«ENDDEFINE» +«DEFINE _constructor FOR gmfgen::GenNode-» + «EXPAND xpt::Common::generatedMemberComment» + public «createCommandClassName»(org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest req, org.eclipse.gmf.runtime.notation.Diagram diagram) { + super(req.getLabel(), null, req); + this.diagram = diagram; + } +«ENDDEFINE» +/* + * TODO: either use setElementToEdit, or generate downcasted version (which may be troublesome if containment and child features point to a different parent) + */ +«DEFINE getElementToEdit FOR gmfgen::GenNode-» + «EXPAND xpt::Common::generatedMemberComment('FIXME: replace with setElementToEdit()')» +protected org.eclipse.emf.ecore.EObject getElementToEdit() { + + «REM» Mutating canvas helper «ENDREM» + org.eclipse.emf.ecore.EObject container = + ((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) getRequest()).getContainer(); + if (container instanceof org.eclipse.gmf.runtime.notation.View) { + container = ((org.eclipse.gmf.runtime.notation.View) container).getElement(); + } + if (container != null) { + return container; + } + return eObject; +} +«ENDDEFINE» + +«REM» [AbstractElement] Modified for Abstract domain element «ENDREM» +«DEFINE doExecuteWithResultMethod FOR gmfgen::GenNode-» + «EXPAND xpt::Common::generatedMemberComment» + protected org.eclipse.gmf.runtime.common.core.command.CommandResult doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info) throws org.eclipse.core.commands.ExecutionException { +«REM» [AbstractElement] START «ENDREM» + +«IF modelFacet.metaClass.ecoreClass._abstract <> true-» +«REM» [AbstractElement] END «ENDREM» +«IF modelFacet.isPhantomElement()-» + «EXPAND phantomElementCreation(self, 'newElement') FOR modelFacet» +«ELSE-» + «EXPAND normalElementCreation(self, 'newElement') FOR modelFacet» +«ENDIF» + «EXPAND initialize(self, 'newElement') FOR modelFacet-» +«IF true/*FIXME boolean needsExternalConfiguration*/» + doConfigure(newElement, monitor, info); +«ENDIF» + ((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) getRequest()).setNewElement(«EXPAND MetaModel::DowncastToEObject('newElement') FOR modelFacet.metaClass»); + return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult(newElement); + } +«REM» [AbstractElement] START «ENDREM» +«ELSE-» + throw new UnsupportedOperationException("Unimplemented operation (abstract domain element)."); + } +«ENDIF» +«REM» [AbstractElement] END «ENDREM» +«ENDDEFINE» +/* + * Unlike original CreateElementCommand, we don't keep track of IStatus from configureCommand.execute, + * nor allow status setting from doDefaultCreation. The reason is ICommandProxy#execute implementation, + * which ignores any status from wrapped ICommand. Besides, both CommandResult and IStatus seems too much to me. + */ +«DEFINE doConfigureMethod FOR gmfgen::GenNode-» + «EXPAND xpt::Common::generatedMemberComment» + protected void doConfigure(«EXPAND MetaModel::QualifiedClassName FOR modelFacet.metaClass» newElement, org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info) throws org.eclipse.core.commands.ExecutionException { + org.eclipse.gmf.runtime.emf.type.core.IElementType elementType = ((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) getRequest()).getElementType(); + org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest configureRequest = new org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest(getEditingDomain(), «EXPAND MetaModel::DowncastToEObject('newElement') FOR modelFacet.metaClass», elementType); + configureRequest.setClientContext(((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) getRequest()).getClientContext()); + configureRequest.addParameters(getRequest().getParameters()); + org.eclipse.gmf.runtime.common.core.command.ICommand configureCommand = elementType.getEditCommand(configureRequest); + if (configureCommand != null && configureCommand.canExecute()) { + configureCommand.execute(monitor, info); + } + } +«ENDDEFINE» +«DEFINE canExecuteMethod FOR gmfgen::GenNode-» + «EXPAND xpt::Common::generatedMemberComment» + public boolean canExecute() { +«IF modelFacet.isPhantomElement()-» + return true; +«ELSE-» + «EXPAND canExecute_Normal FOR modelFacet» +«ENDIF-» + } +«ENDDEFINE» +«DEFINE canExecute_Normal FOR gmfgen::TypeModelFacet-» + +«IF not containmentMetaFeature.oclIsUndefined()-» + «IF not containmentMetaFeature.ecoreFeature.oclIsUndefined()-» + «IF not isUnbounded(containmentMetaFeature.ecoreFeature) or (childMetaFeature <> containmentMetaFeature and not isUnbounded(childMetaFeature.ecoreFeature))-» + «IF not isUnbounded(containmentMetaFeature.ecoreFeature)-» + «EXPAND MetaModel::DeclareAndAssign('container', 'getElementToEdit()') FOR containmentMetaFeature.genClass-» + «IF isSingleValued(containmentMetaFeature.ecoreFeature)» + if («EXPAND MetaModel::getFeatureValue('container', containmentMetaFeature.genClass) FOR containmentMetaFeature» != null) { + «ELSE-» + if («EXPAND MetaModel::getFeatureValue('container', containmentMetaFeature.genClass) FOR containmentMetaFeature».size() >= «containmentMetaFeature.ecoreFeature.upperBound») { + «ENDIF-» + return false; + } + «ENDIF-» + «IF childMetaFeature <> containmentMetaFeature and not isUnbounded(childMetaFeature.ecoreFeature)-» + «IF isSingleValued(childMetaFeature.ecoreFeature)-» + if («EXPAND MetaModel::getFeatureValue('container', containmentMetaFeature.genClass) FOR childMetaFeature» != null) { + «ELSE-» + if («EXPAND MetaModel::getFeatureValue('container', containmentMetaFeature.genClass) FOR childMetaFeature».size() >= «childMetaFeature.ecoreFeature.upperBound») { + «ENDIF-» + return false; + } + «ENDIF-» + «ENDIF-» + «ENDIF-» +«ENDIF-» + + org.eclipse.emf.ecore.EObject target = getElementToEdit(); + org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData data = org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), «EXPAND MetaModel::MetaClass FOR metaClass»); + return data.isPermitted(); +«ENDDEFINE» + +«DEFINE phantomElementCreation(node : gmfgen::GenNode, varName : String) FOR gmfgen::TypeModelFacet-» + // Uncomment to put "phantom" objects into the diagram file. + // org.eclipse.emf.ecore.resource.Resource resource = + // ((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) getRequest()).getContainer().eResource(); + // if (resource == null) { + // return null; + // } + org.eclipse.emf.ecore.resource.Resource resource = getElementToEdit().eResource(); + «EXPAND MetaModel::NewInstance(varName) FOR metaClass» + resource.getContents().add(«EXPAND MetaModel::DowncastToEObject(varName) FOR metaClass»); +«ENDDEFINE» + +«DEFINE normalElementCreation(node : gmfgen::GenNode, varName : String) FOR gmfgen::TypeModelFacet-» + «EXPAND MetaModel::NewInstance(varName) FOR metaClass» + org.eclipse.emf.ecore.EObject target = getElementToEdit(); + org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData data = org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker.getCurrent().getChildAddData(diagram, target, «varName»); + if (data.isPermitted()) { + if (data.isPathDefined()) { + if (!data.execute(target, «varName»)) + return org.eclipse.gmf.runtime.common.core.command.CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element"); + } else { +«IF not containmentMetaFeature.oclIsUndefined()-» + «EXPAND MetaModel::DeclareAndAssign('qualifiedTarget', 'target') FOR containmentMetaFeature.genClass» + «EXPAND MetaModel::modifyFeature('qualifiedTarget', containmentMetaFeature.genClass, varName) FOR containmentMetaFeature-» +«ELSE-» + // + // FIXME no containment feature found in the genmodel, toolsmith need to manually write code here to add «varName» to a parent + // +«ENDIF» + } + } else { + return org.eclipse.gmf.runtime.common.core.command.CommandResult.newErrorCommandResult("The active policy restricts the addition of this element"); + } + +«IF hasExplicitChildFeature(self)-» + «EXPAND MetaModel::DeclareAndAssign('childHolder', 'getElementToEdit()') FOR childMetaFeature.genClass» + «EXPAND MetaModel::modifyFeature('childHolder', childMetaFeature.genClass, varName) FOR childMetaFeature» +«ENDIF-» +«ENDDEFINE» «DEFINE initialize(node : gmfgen::GenNode, newElementVar : String) FOR gmfgen::TypeModelFacet»«EXPAND xpt::providers::ElementInitializers::initMethodCall(self, newElementVar) FOR node»«ENDDEFINE» + diff --git a/plugins/developer/org.eclipse.papyrus.def/dynamic-templates3.5/codegen/xpt/diagram/editpolicies/DiagramItemSemanticEditPolicy.xpt b/plugins/developer/org.eclipse.papyrus.def/dynamic-templates3.5/codegen/xpt/diagram/editpolicies/DiagramItemSemanticEditPolicy.xpt index 81ee568ca53..63883132bc2 100644 --- a/plugins/developer/org.eclipse.papyrus.def/dynamic-templates3.5/codegen/xpt/diagram/editpolicies/DiagramItemSemanticEditPolicy.xpt +++ b/plugins/developer/org.eclipse.papyrus.def/dynamic-templates3.5/codegen/xpt/diagram/editpolicies/DiagramItemSemanticEditPolicy.xpt @@ -59,7 +59,7 @@ public class «itemSemanticEditPolicyClassName» extends «getBaseItemSemanticEd «ENDDEFINE»
«DEFINE childNodeCreateCommand(gmfgen::GenNode node) FOR gmfgen::TypeModelFacet-»
if («node.getDiagram().getElementTypesQualifiedClassName()».«node.getUniqueIdentifier()» == req.getElementType()) {
- return getGEFWrapper(«node.getCreateCommandQualifiedClassName()».create(req, canvasElement));
+ return getGEFWrapper(«node.getCreateCommandQualifiedClassName()».create(req, canvasElement, org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils.getDiagramFrom(getHost())));
}
«ENDDEFINE»
«REM» Mutating canvas Switch to create command «ENDREM»
diff --git a/plugins/developer/org.eclipse.papyrus.def/dynamic-templates3.5/codegen/xpt/diagram/editpolicies/childContainerCreateCommand.xpt b/plugins/developer/org.eclipse.papyrus.def/dynamic-templates3.5/codegen/xpt/diagram/editpolicies/childContainerCreateCommand.xpt index 16cf63832b6..cf42cf9558d 100644 --- a/plugins/developer/org.eclipse.papyrus.def/dynamic-templates3.5/codegen/xpt/diagram/editpolicies/childContainerCreateCommand.xpt +++ b/plugins/developer/org.eclipse.papyrus.def/dynamic-templates3.5/codegen/xpt/diagram/editpolicies/childContainerCreateCommand.xpt @@ -57,7 +57,7 @@ if («EXPAND xpt::providers::ElementTypes::accessElementType FOR node» == baseE «IF papyrusgmfgenextension::GenerateUsingElementTypeCreationCommand.allInstances()->size()>0» return getGEFWrapper(getSemanticCreationCommand(req)); «ELSE-» - return getGEFWrapper(new «node.getCreateCommandQualifiedClassName()»(req)); + return getGEFWrapper(new «node.getCreateCommandQualifiedClassName()»(req, org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils.getDiagramFrom(getHost()))); «ENDIF» } diff --git a/plugins/developer/org.eclipse.papyrus.def/dynamic-templates3.5/codegen/xpt/editor/VisualIDRegistry.xpt b/plugins/developer/org.eclipse.papyrus.def/dynamic-templates3.5/codegen/xpt/editor/VisualIDRegistry.xpt index 391603667e0..331acf4b3a4 100644 --- a/plugins/developer/org.eclipse.papyrus.def/dynamic-templates3.5/codegen/xpt/editor/VisualIDRegistry.xpt +++ b/plugins/developer/org.eclipse.papyrus.def/dynamic-templates3.5/codegen/xpt/editor/VisualIDRegistry.xpt @@ -166,10 +166,7 @@ public static int «EXPAND getDiagramVisualIDMethodName»(org.eclipse.emf.ecore. if (domainElement == null) { «EXPAND unrecognizedVID-» } -«IF null <> domainDiagramElement-» - «EXPAND returnVisualID-» -«ENDIF-» - «EXPAND unrecognizedVID-» + return «EXPAND visualID»; } «ENDDEFINE» @@ -491,4 +488,4 @@ return -1; }; «ENDDEFINE» -«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE»
\ No newline at end of file +«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE» diff --git a/plugins/developer/org.eclipse.papyrus.def/dynamic-templates3.5/codegen/xpt/editor/palette/Utils.qvto b/plugins/developer/org.eclipse.papyrus.def/dynamic-templates3.5/codegen/xpt/editor/palette/Utils.qvto index dc4e936301d..b699f8e7697 100644 --- a/plugins/developer/org.eclipse.papyrus.def/dynamic-templates3.5/codegen/xpt/editor/palette/Utils.qvto +++ b/plugins/developer/org.eclipse.papyrus.def/dynamic-templates3.5/codegen/xpt/editor/palette/Utils.qvto @@ -29,7 +29,7 @@ helper gmfgen::ToolGroup::activatorFQN() : String { } helper i18nKey(group : gmfgen::EntryBase) : String { - return let rv = group.createMethodName in (if rv.xpandStartsWith('get') then rv.xpandSubstring(3) else (if rv.xpandStartsWith('create') then rv.xpandSubstring(6) else rv endif) endif) + return let rv = group.createMethodName in (if rv.startsWith('get') then rv.xpandSubstring(3) else (if rv.startsWith('create') then rv.xpandSubstring(6) else rv endif) endif) } helper i18nTitleKey(group : gmfgen::EntryBase) : String { @@ -82,4 +82,4 @@ helper getUpperAndUnderscoreString(value:String) : String { helper getUpper(value:String) : String { return value.toUpper(); -}
\ No newline at end of file +} |