Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands')
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateLinkCommand.xpt126
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateLinkUtils.xpt148
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateNodeCommand.xpt161
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateRefLinkCommand.xpt18
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateShortcutDecorationsCommand.xpt60
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientLinkCommand.xpt46
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientLinkUtils.xpt302
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientLinkViewCommand.xpt63
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientRefLinkCommand.xpt50
9 files changed, 974 insertions, 0 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateLinkCommand.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateLinkCommand.xpt
new file mode 100644
index 000000000..969764c76
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateLinkCommand.xpt
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2007, 2008 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:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
+
+«EXTENSION xpt::GenModelUtils»
+«EXTENSION xpt::diagram::Utils»
+
+«DEFINE CreateLinkCommand FOR gmfgen::GenLink»«EXPAND Main»«ENDDEFINE»
+
+«DEFINE Main FOR gmfgen::GenLink-»
+«EXPAND xpt::Common::copyright FOR diagram.editorGen-»
+package «diagram.editCommandsPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «createCommandClassName» extends org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand {
+ «EXPAND xpt::diagram::commands::CreateLinkUtils::fields FOR modelFacet-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «createCommandClassName»(org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest request, org.eclipse.emf.ecore.EObject source, org.eclipse.emf.ecore.EObject target) {
+ super(request.getLabel(), null, request);
+ «EXPAND xpt::diagram::commands::CreateLinkUtils::_init FOR modelFacet-»
+ }
+ «EXPAND xpt::diagram::commands::CreateLinkUtils::canCreate(self) FOR modelFacet-»
+
+ «EXPAND doExecuteWithResultMethod»
+
+ «EXPAND doConfigure(self) FOR modelFacet-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void setElementToEdit(org.eclipse.emf.ecore.EObject element) {
+ throw new UnsupportedOperationException();
+ }
+ «EXPAND xpt::diagram::commands::CreateLinkUtils::accessors FOR modelFacet-»
+«EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenLink»«ENDDEFINE»
+
+«DEFINE doExecuteWithResultMethod FOR gmfgen::GenLink»
+ «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 {
+ if (!canExecute()) {
+ throw new org.eclipse.core.commands.ExecutionException("Invalid arguments in create link command");«EXPAND xpt::Common::nonNLS»
+ }
+ «EXPAND execute(self) FOR modelFacet»
+ }
+«ENDDEFINE»
+
+«DEFINE execute(link : gmfgen::GenLink) FOR gmfgen::LinkModelFacet»«ENDDEFINE»
+
+«DEFINE execute(link : gmfgen::GenLink) FOR gmfgen::TypeLinkModelFacet»
+«IF (if sourceMetaFeature = null then containmentMetaFeature.ecoreFeature.changeable else sourceMetaFeature.ecoreFeature.changeable endif) and targetMetaFeature.ecoreFeature.changeable-»
+ «EXPAND MetaModel::NewInstance('newElement') FOR metaClass-»
+ «EXPAND MetaModel::modifyFeature((if hasContainerOtherThanSource(self) then 'getContainer()' else 'getSource()' endif), containmentMetaFeature.genClass, 'newElement') FOR containmentMetaFeature-»
+ «IF sourceMetaFeature <> null-»
+ «EXPAND MetaModel::modifyFeature('newElement', metaClass, 'getSource()') FOR sourceMetaFeature-»
+ «ENDIF-»
+ «EXPAND MetaModel::modifyFeature('newElement', metaClass, 'getTarget()') FOR targetMetaFeature-»
+ «IF hasExplicitChildFeature(self)-»
+ «IF sourceMetaFeature <> null-»
+ «EXPAND MetaModel::modifyFeature('getContainer()', containmentMetaFeature.genClass, 'newElement') FOR childMetaFeature-»
+ «ELSE-»
+ «EXPAND MetaModel::modifyFeature('getSource()', getSourceType(), 'newElement') FOR childMetaFeature-»
+ «ENDIF-»
+ «ENDIF-»
+ «EXPAND initialize(link, 'newElement')-»
+ doConfigure(newElement, monitor, info);
+ ((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) getRequest()).setNewElement(«EXPAND MetaModel::DowncastToEObject('newElement') FOR metaClass»);
+ return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult(newElement);
+«ELSE-»
+ throw new UnsupportedOperationException();
+«ENDIF-»
+«ENDDEFINE»
+
+
+«DEFINE initialize(link : gmfgen::GenLink, newElementvVar : String) FOR gmfgen::TypeModelFacet»«IF modelElementInitializer <> null-»
+«link.diagram.getElementTypesQualifiedClassName()».init_«link.getUniqueIdentifier()»(«newElementvVar»);
+«ENDIF»«ENDDEFINE»
+
+
+«DEFINE execute(link : gmfgen::GenLink) FOR gmfgen::FeatureLinkModelFacet»
+«IF metaFeature.ecoreFeature.changeable-»
+ if (getSource() != null && getTarget() != null) {
+ «EXPAND MetaModel::modifyFeature('getSource()', getSourceType(), 'getTarget()') FOR metaFeature-»
+ }
+ return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult();
+«ELSE-»
+ throw new UnsupportedOperationException();
+«ENDIF-»
+«ENDDEFINE»
+
+
+«DEFINE doConfigure(link : gmfgen::GenLink) FOR gmfgen::LinkModelFacet»«ENDDEFINE»
+
+/*
+ * TODO invocation of configure command should be optional, and better yet,
+ * configuration should rather happen from EditPolicy then from within creation command
+ */
+«DEFINE doConfigure(link : gmfgen::GenLink) FOR gmfgen::TypeLinkModelFacet-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void doConfigure(«EXPAND MetaModel::QualifiedClassName FOR 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 metaClass», elementType);
+ configureRequest.setClientContext(((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) getRequest()).getClientContext());
+ configureRequest.addParameters(getRequest().getParameters());
+ configureRequest.setParameter(org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest.SOURCE, getSource());
+ configureRequest.setParameter(org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest.TARGET, getTarget());
+ org.eclipse.gmf.runtime.common.core.command.ICommand configureCommand = elementType.getEditCommand(configureRequest);
+ if (configureCommand != null && configureCommand.canExecute()) {
+ configureCommand.execute(monitor, info);
+ }
+ }
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateLinkUtils.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateLinkUtils.xpt
new file mode 100644
index 000000000..f19cbc901
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateLinkUtils.xpt
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2007, 2008 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:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
+
+«EXTENSION xpt::GenModelUtils»
+«EXTENSION xpt::diagram::Utils»
+
+«REM»
+ Check whether link may be created.
+«ENDREM»
+«DEFINE canCreate(link : gmfgen::GenLink) FOR gmfgen::LinkModelFacet-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public boolean canExecute() {
+ if (source == null && target == null) {
+ return false;
+ }
+ if (source != null && «EXPAND MetaModel::NotInstance('source') FOR getSourceType()») {
+ return false;
+ }
+ if (target != null && «EXPAND MetaModel::NotInstance('target') FOR getTargetType()») {
+ return false;
+ }
+ if (getSource() == null) {
+ return true; // link creation is in progress; source is not defined yet
+ }
+ // target may be null here but it's possible to check constraint
+ «EXPAND canCreateElement(link)-»
+ }
+«ENDDEFINE»
+
+«DEFINE canCreateElement(link : gmfgen::GenLink) FOR gmfgen::LinkModelFacet-»
+«ENDDEFINE»
+
+«DEFINE canCreateElement(link : gmfgen::GenLink) FOR gmfgen::TypeLinkModelFacet-»
+«IF hasContainerOtherThanSource(self)-»
+ if (getContainer() == null) {
+ return false;
+ }
+«ENDIF-»
+ return «EXPAND validatorInvocation FOR link»(«IF hasContainerOtherThanSource(self)»getContainer(), «ENDIF»getSource(), getTarget());
+«ENDDEFINE»
+
+«DEFINE canCreateElement(link : gmfgen::GenLink) FOR gmfgen::FeatureLinkModelFacet-»
+ return «EXPAND validatorInvocation FOR link»(getSource(), getTarget());
+«ENDDEFINE»
+
+«DEFINE validatorInvocation FOR gmfgen::GenLink-»
+«diagram.getBaseItemSemanticEditPolicyQualifiedClassName()».«diagram.getLinkCreationConstraintsClassName()».canCreate«getUniqueIdentifier()-»
+«ENDDEFINE»
+
+«REM»
+ Fields of command that creates link.
+«ENDREM»
+«DEFINE fields FOR gmfgen::LinkModelFacet»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final org.eclipse.emf.ecore.EObject source;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final org.eclipse.emf.ecore.EObject target;
+«ENDDEFINE»
+
+«DEFINE fields FOR gmfgen::TypeLinkModelFacet»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final org.eclipse.emf.ecore.EObject source;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final org.eclipse.emf.ecore.EObject target;
+«IF hasContainerOtherThanSource(self)»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final «EXPAND MetaModel::QualifiedClassName FOR containmentMetaFeature.genClass» container;
+«ENDIF-»
+«ENDDEFINE»
+
+«REM»
+ Field accessors of command that creates link.
+«ENDREM»
+«DEFINE accessors FOR gmfgen::LinkModelFacet-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected «EXPAND MetaModel::QualifiedClassName FOR getSourceType()» getSource() {
+ return «EXPAND MetaModel::CastEObject('source') FOR getSourceType()»;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected «EXPAND MetaModel::QualifiedClassName FOR getTargetType()» getTarget() {
+ return «EXPAND MetaModel::CastEObject('target') FOR getTargetType()»;
+ }
+ «EXPAND containerAccessor-»
+«ENDDEFINE»
+
+«DEFINE containerAccessor FOR gmfgen::LinkModelFacet»«ENDDEFINE»
+
+«DEFINE containerAccessor FOR gmfgen::TypeLinkModelFacet-»
+«IF hasContainerOtherThanSource(self)-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «EXPAND MetaModel::QualifiedClassName FOR containmentMetaFeature.genClass» getContainer() {
+ return container;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment(
+ 'Default approach is to traverse ancestors of the source to find instance of container.
+Modify with appropriate logic.'
+ )»
+ private static «EXPAND MetaModel::QualifiedClassName FOR containmentMetaFeature.genClass» deduceContainer(org.eclipse.emf.ecore.EObject source, org.eclipse.emf.ecore.EObject target) {
+ // Find container element for the new link.
+ // Climb up by containment hierarchy starting from the source
+ // and return the first element that is instance of the container class.
+ for (org.eclipse.emf.ecore.EObject element = source; element != null; element = element.eContainer()) {
+ if («EXPAND MetaModel::IsInstance('element') FOR containmentMetaFeature.genClass») {
+ return «EXPAND MetaModel::CastEObject('element') FOR containmentMetaFeature.genClass»;
+ }
+ }
+ return null;
+ }
+«ENDIF-»
+
+«ENDDEFINE»
+
+«REM»
+ Part of the constructor that performs initialization.
+«ENDREM»
+«DEFINE _init FOR gmfgen::LinkModelFacet-»
+ this.source = source;
+ this.target = target;
+«ENDDEFINE»
+
+«DEFINE _init FOR gmfgen::TypeLinkModelFacet-»
+ this.source = source;
+ this.target = target;
+«IF hasContainerOtherThanSource(self)-»
+ container = deduceContainer(source, target);
+«ENDIF-»
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateNodeCommand.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateNodeCommand.xpt
new file mode 100644
index 000000000..bd46cb821
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateNodeCommand.xpt
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2007, 2008 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:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
+«EXTENSION xpt::GenModelUtils»
+«EXTENSION xpt::diagram::Utils»
+
+«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 {
+
+ «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() {
+ 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();
+ }
+ return container;
+}
+«ENDDEFINE»
+
+«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 {
+«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);
+ }
+«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 containmentMetaFeature.ecoreFeature.upperBound.oclAsType(Integer) > 0 or (childMetaFeature <> containmentMetaFeature and childMetaFeature.ecoreFeature.upperBound.oclAsType(Integer) > 0)-»
+ «EXPAND MetaModel::DeclareAndAssign('container', 'getElementToEdit()') FOR containmentMetaFeature.genClass-»
+ «IF containmentMetaFeature.ecoreFeature.upperBound.oclAsType(Integer) > 0-»
+ «IF containmentMetaFeature.ecoreFeature.upperBound.oclAsType(Integer) = 1»
+ if («EXPAND MetaModel::getFeatureValue('container', containmentMetaFeature.genClass) FOR containmentMetaFeature» != null) {
+ «ELSE-»
+ if («EXPAND MetaModel::getFeatureValue('container', containmentMetaFeature.genClass) FOR containmentMetaFeature».size() >= «containmentMetaFeature.ecoreFeature.upperBound.oclAsType(Integer)») {
+ «ENDIF-»
+ return false;
+ }
+ «ENDIF-»
+ «IF childMetaFeature <> containmentMetaFeature and childMetaFeature.ecoreFeature.upperBound.oclAsType(Integer) > 0-»
+ «IF childMetaFeature.ecoreFeature.upperBound.oclAsType(Integer) = 1-»
+ if («EXPAND MetaModel::getFeatureValue('container', containmentMetaFeature.genClass) FOR childMetaFeature» != null) {
+ «ELSE-»
+ if («EXPAND MetaModel::getFeatureValue('container', containmentMetaFeature.genClass) FOR childMetaFeature».size() >= «childMetaFeature.ecoreFeature.upperBound.oclAsType(Integer)») {
+ «ENDIF-»
+ return false;
+ }
+ «ENDIF-»
+«ENDIF-»
+ return true;
+«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 containmentMetaFeature <> null-»
+ «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»
+
+«DEFINE initialize(node : gmfgen::GenNode, newElementVar : String) FOR gmfgen::TypeModelFacet»«IF modelElementInitializer <> null-»
+«node.getDiagram().getElementTypesQualifiedClassName()».init_«node.getUniqueIdentifier()»(«newElementVar»);
+«ENDIF»«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateRefLinkCommand.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateRefLinkCommand.xpt
new file mode 100644
index 000000000..67ca118a7
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateRefLinkCommand.xpt
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2007, 2008 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:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+/*
+ * TODO: remove the template, as it's no longer in use
+ */
+«DEFINE CreateRefLinkCommand FOR gmfgen::GenLink»«EXPAND CreateLinkCommand::Main»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateShortcutDecorationsCommand.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateShortcutDecorationsCommand.xpt
new file mode 100644
index 000000000..e2609af6f
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateShortcutDecorationsCommand.xpt
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2007 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:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«DEFINE CreateShortcutDecorationsCommand FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «editCommandsPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «createShortcutDecorationsCommandClassName»
+ extends org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private java.util.List myDescriptors;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «createShortcutDecorationsCommandClassName»(
+ org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain,
+ org.eclipse.gmf.runtime.notation.View parentView,
+ java.util.List viewDescriptors) {
+ super(editingDomain, "Create Shortcuts", getWorkspaceFiles(parentView)); //$NON-NLS-1$
+ myDescriptors = viewDescriptors;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «createShortcutDecorationsCommandClassName»(
+ org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain,
+ org.eclipse.gmf.runtime.notation.View parentView,
+ org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor viewDescriptor) {
+ this(editingDomain, parentView, java.util.Collections.singletonList(viewDescriptor));
+ }
+
+ «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 {
+ for (java.util.Iterator it = myDescriptors.iterator(); it.hasNext();) {
+ org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor nextDescriptor =
+ (org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor) it.next();
+ org.eclipse.gmf.runtime.notation.View view =
+ (org.eclipse.gmf.runtime.notation.View) nextDescriptor.getAdapter(
+ org.eclipse.gmf.runtime.notation.View.class);
+ if (view != null && view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$
+ «EXPAND xpt::Common::addShortcutAnnotation('view')-»
+ }
+ }
+ return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult();
+ }
+}
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientLinkCommand.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientLinkCommand.xpt
new file mode 100644
index 000000000..4772f23c9
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientLinkCommand.xpt
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2007 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:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
+
+«EXTENSION xpt::GenModelUtils»
+
+«DEFINE ReorientLinkCommand FOR gmfgen::GenLink-»
+«EXPAND xpt::Common::copyright FOR diagram.editorGen-»
+package «diagram.editCommandsPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «reorientCommandClassName» extends org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final int reorientDirection;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final org.eclipse.emf.ecore.EObject oldEnd;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final org.eclipse.emf.ecore.EObject newEnd;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «reorientCommandClassName»(org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest request) {
+ super(request.getLabel(), request.getRelationship(), request);
+ reorientDirection = request.getDirection();
+ oldEnd = request.getOldRelationshipEnd();
+ newEnd = request.getNewRelationshipEnd();
+ }
+ «EXPAND xpt::diagram::commands::ReorientLinkUtils::canReorient(self) FOR modelFacet-»
+ «EXPAND xpt::diagram::commands::ReorientLinkUtils::reorient FOR modelFacet-»
+ «EXPAND xpt::diagram::commands::ReorientLinkUtils::accessors-»
+}
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientLinkUtils.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientLinkUtils.xpt
new file mode 100644
index 000000000..7ff98dbfa
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientLinkUtils.xpt
@@ -0,0 +1,302 @@
+/*
+ * Copyright (c) 2007, 2008 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:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
+
+«EXTENSION xpt::GenModelUtils»
+«EXTENSION xpt::diagram::Utils»
+
+«REM»
+ Expands to all accessor methods for link and it's ends.
+«ENDREM»
+«DEFINE accessors FOR gmfgen::GenLink-»
+ «EXPAND linkAccessor FOR modelFacet-»
+ «EXPAND oldSourceAccessor FOR modelFacet-»
+ «EXPAND newSourceAccessor FOR modelFacet-»
+ «EXPAND oldTargetAccessor FOR modelFacet-»
+ «EXPAND newTargetAccessor FOR modelFacet-»
+«ENDDEFINE»
+
+«DEFINE linkAccessor FOR gmfgen::LinkModelFacet-»
+«ENDDEFINE»
+
+«DEFINE linkAccessor FOR gmfgen::TypeLinkModelFacet-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected «EXPAND MetaModel::QualifiedClassName FOR metaClass» getLink() {
+ return «EXPAND MetaModel::CastEObject('getElementToEdit()') FOR metaClass»;
+ }
+«ENDDEFINE»
+
+«DEFINE oldSourceAccessor FOR gmfgen::LinkModelFacet-»
+«ENDDEFINE»
+
+«DEFINE oldSourceAccessor FOR gmfgen::TypeLinkModelFacet-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected «EXPAND MetaModel::QualifiedClassName FOR getSourceType()» getOldSource() {
+ return «EXPAND MetaModel::CastEObject('oldEnd') FOR getSourceType()»;
+ }
+«ENDDEFINE»
+
+«DEFINE oldSourceAccessor FOR gmfgen::FeatureLinkModelFacet-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected «EXPAND MetaModel::QualifiedClassName FOR getSourceType()» getOldSource() {
+ return «EXPAND MetaModel::CastEObject('referenceOwner') FOR getSourceType()»;
+ }
+«ENDDEFINE»
+
+«DEFINE newSourceAccessor FOR gmfgen::LinkModelFacet-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected «EXPAND MetaModel::QualifiedClassName FOR getSourceType()» getNewSource() {
+ return «EXPAND MetaModel::CastEObject('newEnd') FOR getSourceType()»;
+ }
+«ENDDEFINE»
+
+«DEFINE oldTargetAccessor FOR gmfgen::LinkModelFacet-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected «EXPAND MetaModel::QualifiedClassName FOR getTargetType()» getOldTarget() {
+ return «EXPAND MetaModel::CastEObject('oldEnd') FOR getTargetType()»;
+ }
+«ENDDEFINE»
+
+«DEFINE newTargetAccessor FOR gmfgen::LinkModelFacet-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected «EXPAND MetaModel::QualifiedClassName FOR getTargetType()» getNewTarget() {
+ return «EXPAND MetaModel::CastEObject('newEnd') FOR getTargetType()»;
+ }
+«ENDDEFINE»
+
+«REM»
+ Generates canExecute() method for the command that reorients link.
+ Implementation should perform all static checks that command can be executed.
+«ENDREM»
+«DEFINE canReorient(link : gmfgen::GenLink) FOR gmfgen::LinkModelFacet-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public boolean canExecute() {
+ «EXPAND checkLinkValidity-»
+ if (reorientDirection == org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest.REORIENT_SOURCE) {
+ return canReorientSource();
+ }
+ if (reorientDirection == org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest.REORIENT_TARGET) {
+ return canReorientTarget();
+ }
+ return false;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected boolean canReorientSource() {
+ «EXPAND checkSourceRequestValidity(link)-»
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected boolean canReorientTarget() {
+ «EXPAND checkTargetRequestValidity(link)-»
+ }
+«ENDDEFINE»
+
+«DEFINE checkLinkValidity FOR gmfgen::LinkModelFacet-»
+«ENDDEFINE»
+
+«DEFINE checkLinkValidity FOR gmfgen::TypeLinkModelFacet-»
+ if («EXPAND MetaModel::NotInstance('getElementToEdit()') FOR metaClass») {
+ return false;
+ }
+«ENDDEFINE»
+
+«DEFINE checkLinkValidity FOR gmfgen::FeatureLinkModelFacet-»
+ if («EXPAND MetaModel::NotInstance('referenceOwner') FOR getSourceType()») {
+ return false;
+ }
+«ENDDEFINE»
+
+«DEFINE checkSourceRequestValidity(link : gmfgen::GenLink) FOR gmfgen::LinkModelFacet-»
+«ENDDEFINE»
+
+«DEFINE checkSourceRequestValidity(link : gmfgen::GenLink) FOR gmfgen::TypeLinkModelFacet-»
+ if (!(«EXPAND MetaModel::IsInstance('oldEnd') FOR getSourceType()» && «EXPAND MetaModel::IsInstance('newEnd') FOR getSourceType()»)) {
+ return false;
+ }
+ «EXPAND extractFeatureWithCheck('getLink()', metaClass, 'target', getTargetType()) FOR targetMetaFeature-»
+ «EXPAND checkLinkConstraint(link, 'getNewSource()', 'target')-»
+«ENDDEFINE»
+
+«REM»
+ When feature source is being reoriented oldEnd is the link target.
+«ENDREM»
+«DEFINE checkSourceRequestValidity(link : gmfgen::GenLink) FOR gmfgen::FeatureLinkModelFacet-»
+ if (!(«EXPAND MetaModel::IsInstance('oldEnd') FOR getTargetType()» && «EXPAND MetaModel::IsInstance('newEnd') FOR getSourceType()»)) {
+ return false;
+ }
+ return «EXPAND checkLinkConstraintInvocation FOR link»(getNewSource(), getOldTarget());
+«ENDDEFINE»
+
+«DEFINE checkTargetRequestValidity(link : gmfgen::GenLink) FOR gmfgen::LinkModelFacet-»
+«ENDDEFINE»
+
+«DEFINE checkTargetRequestValidity(link : gmfgen::GenLink) FOR gmfgen::TypeLinkModelFacet-»
+ if (!(«EXPAND MetaModel::IsInstance('oldEnd') FOR getTargetType()» && «EXPAND MetaModel::IsInstance('newEnd') FOR getTargetType()»)) {
+ return false;
+ }
+ «IF sourceMetaFeature <> null-»
+ «EXPAND extractFeatureWithCheck('getLink()', metaClass, 'source', getSourceType()) FOR sourceMetaFeature-»
+ «ELSE-»
+ if (!(«EXPAND MetaModel::IsContainerInstance('getLink()', metaClass) FOR getSourceType()»)) {
+ return false;
+ }
+ «EXPAND MetaModel::DeclareAndAssignContainer('source', 'getLink()', metaClass) FOR getSourceType()»
+ «ENDIF-»
+ «EXPAND checkLinkConstraint(link, 'source', 'getNewTarget()')-»
+«ENDDEFINE»
+
+«DEFINE checkTargetRequestValidity(link : gmfgen::GenLink) FOR gmfgen::FeatureLinkModelFacet-»
+ if (!(«EXPAND MetaModel::IsInstance('oldEnd') FOR getTargetType()» && «EXPAND MetaModel::IsInstance('newEnd') FOR getTargetType()»)) {
+ return false;
+ }
+ return «EXPAND checkLinkConstraintInvocation FOR link»(getOldSource(), getNewTarget());
+«ENDDEFINE»
+
+«DEFINE extractFeatureWithCheck(containerVar : String, containerMetaClass : genmodel::GenClass, _var : String, varMetaClass : genmodel::GenClass) FOR genmodel::GenFeature-»
+ «IF ecoreFeature.many-»
+ if («EXPAND MetaModel::getFeatureValue(containerVar, containerMetaClass)».size() != 1) {
+ return false;
+ }
+ «EXPAND MetaModel::DeclareAndAssign2(_var, containerVar, containerMetaClass, self, 'get(0)', true) FOR varMetaClass»
+ «ELSE-»
+ «EXPAND MetaModel::DeclareAndAssign(_var, containerVar, containerMetaClass, self) FOR varMetaClass»
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE checkLinkConstraint(link : gmfgen::GenLink, sourceVar : String, targetVar : String) FOR gmfgen::TypeLinkModelFacet-»
+ «IF hasContainerOtherThanSource(self)-»
+ if (!(«EXPAND MetaModel::IsContainerInstance('getLink()', metaClass) FOR containmentMetaFeature.genClass»)) {
+ return false;
+ }
+ «EXPAND MetaModel::DeclareAndAssignContainer('container', 'getLink()', metaClass) FOR containmentMetaFeature.genClass»
+ return «EXPAND checkLinkConstraintInvocation FOR link»(container, «sourceVar», «targetVar»);
+ «ELSE-»
+ return «EXPAND checkLinkConstraintInvocation FOR link»(«sourceVar», «targetVar»);
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE checkLinkConstraintInvocation FOR gmfgen::GenLink-»
+ «diagram.getBaseItemSemanticEditPolicyQualifiedClassName()».«diagram.getLinkCreationConstraintsClassName()».canExist«getUniqueIdentifier()»
+«ENDDEFINE»
+
+«REM»
+ Generates doExecuteWithResult() method for the command that reorients link.
+ Implementation should throw ExecutionException if it can't execute the command.
+«ENDREM»
+«DEFINE reorient FOR gmfgen::LinkModelFacet-»
+
+ «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 {
+ if (!canExecute()) {
+ throw new org.eclipse.core.commands.ExecutionException("Invalid arguments in reorient link command"); «EXPAND xpt::Common::nonNLS»
+ }
+ if (reorientDirection == org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest.REORIENT_SOURCE) {
+ return reorientSource();
+ }
+ if (reorientDirection == org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest.REORIENT_TARGET) {
+ return reorientTarget();
+ }
+ throw new IllegalStateException();
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.common.core.command.CommandResult reorientSource() throws org.eclipse.core.commands.ExecutionException {
+ «EXPAND reorientSource-»
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.common.core.command.CommandResult reorientTarget() throws org.eclipse.core.commands.ExecutionException {
+ «EXPAND reorientTarget-»
+ }
+«ENDDEFINE»
+
+«DEFINE reorientSource FOR gmfgen::LinkModelFacet-»
+«ENDDEFINE»
+
+«REM»
+ Shouldn't we change link container here?
+ [artem] especially when there's explicit childMetaFeature and
+ we changed source to another, but didn't change the container. Perhaps,
+ makes sense to deduceContainer() using new source?
+«ENDREM»
+«DEFINE reorientSource FOR gmfgen::TypeLinkModelFacet-»
+«IF (if sourceMetaFeature = null then containmentMetaFeature.ecoreFeature.changeable else sourceMetaFeature.ecoreFeature.changeable endif)-»
+«IF sourceMetaFeature <> null-»
+ «EXPAND changeTarget('getLink()', metaClass, 'getOldSource()', 'getNewSource()') FOR sourceMetaFeature-»
+«ELSE-»
+ «EXPAND changeSource('getLink()', 'getOldSource()', 'getNewSource()', getSourceType()) FOR (if hasExplicitChildFeature(self) then childMetaFeature else containmentMetaFeature endif)-»
+«ENDIF-»
+ return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult(getLink());
+«ELSE-»
+ throw new UnsupportedOperationException();
+«ENDIF-»
+«ENDDEFINE»
+
+«REM»
+ When feature source is being reoriented oldEnd is the link target.
+«ENDREM»
+«DEFINE reorientSource FOR gmfgen::FeatureLinkModelFacet-»
+«IF metaFeature.ecoreFeature.changeable-»
+ «EXPAND changeSource('getOldTarget()', 'getOldSource()', 'getNewSource()', getSourceType()) FOR metaFeature-»
+ return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult(referenceOwner);
+«ELSE-»
+ throw new UnsupportedOperationException();
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE reorientTarget FOR gmfgen::LinkModelFacet-»
+«ENDDEFINE»
+
+«DEFINE reorientTarget FOR gmfgen::TypeLinkModelFacet-»
+«IF targetMetaFeature.ecoreFeature.changeable-»
+ «EXPAND changeTarget('getLink()', metaClass, 'getOldTarget()', 'getNewTarget()') FOR targetMetaFeature-»
+ return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult(getLink());
+«ELSE-»
+ throw new UnsupportedOperationException();
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE reorientTarget FOR gmfgen::FeatureLinkModelFacet-»
+«IF metaFeature.ecoreFeature.changeable-»
+ «EXPAND changeTarget('getOldSource()', getSourceType(), 'getOldTarget()', 'getNewTarget()') FOR metaFeature-»
+ return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult(referenceOwner);
+«ELSE-»
+ throw new UnsupportedOperationException();
+«ENDIF-»
+«ENDDEFINE»
+
+«REM»
+ Replace old target with the new one in the source.
+«ENDREM»
+«DEFINE changeTarget(sourceVar : String, sourceVarGenClass : genmodel::GenClass, oldTargetVar : String, newTargetVar : String) FOR genmodel::GenFeature-»
+«EXPAND MetaModel::replaceFeatureValue(sourceVar, sourceVarGenClass, oldTargetVar, newTargetVar)»
+«ENDDEFINE»
+
+«REM»
+ Move target from old source to the new one.
+«ENDREM»
+«DEFINE changeSource(targetVar : String, oldSourceVar : String, newSourceVar : String, sourceVarGenClass : genmodel::GenClass) FOR genmodel::GenFeature-»
+«EXPAND MetaModel::moveFeatureValue(oldSourceVar, newSourceVar, sourceVarGenClass, targetVar)»
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientLinkViewCommand.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientLinkViewCommand.xpt
new file mode 100644
index 000000000..0498a9209
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientLinkViewCommand.xpt
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2007, 2008 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:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«DEFINE ReorientLinkViewCommand FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «editCommandsPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «reorientConnectionViewCommandClassName»
+ extends org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.core.runtime.IAdaptable edgeAdaptor;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «reorientConnectionViewCommandClassName»(
+ org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain, String label) {
+ super(editingDomain, label, null);
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public java.util.List getAffectedFiles() {
+ org.eclipse.gmf.runtime.notation.View view =
+ (org.eclipse.gmf.runtime.notation.View) edgeAdaptor.getAdapter(org.eclipse.gmf.runtime.notation.View.class);
+ if (view != null) {
+ return getWorkspaceFiles(view);
+ }
+ return super.getAffectedFiles();
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.core.runtime.IAdaptable getEdgeAdaptor() {
+ return edgeAdaptor;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void setEdgeAdaptor(org.eclipse.core.runtime.IAdaptable edgeAdaptor) {
+ this.edgeAdaptor = edgeAdaptor;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.common.core.command.CommandResult doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor progressMonitor, org.eclipse.core.runtime.IAdaptable info) {
+ «EXPAND xpt::Common::_assert('null != edgeAdaptor : "Null child in ' + reorientConnectionViewCommandClassName + '"')-»
+ org.eclipse.gmf.runtime.notation.Edge edge = (org.eclipse.gmf.runtime.notation.Edge) getEdgeAdaptor().getAdapter(org.eclipse.gmf.runtime.notation.Edge.class);
+ «EXPAND xpt::Common::_assert('null != edge : "Null edge in ' + reorientConnectionViewCommandClassName + '"')-»
+ org.eclipse.gmf.runtime.notation.View tempView = edge.getSource();
+ edge.setSource(edge.getTarget());
+ edge.setTarget(tempView);
+ return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult();
+ }
+}
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientRefLinkCommand.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientRefLinkCommand.xpt
new file mode 100644
index 000000000..60b348301
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientRefLinkCommand.xpt
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2007 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:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
+
+«EXTENSION xpt::GenModelUtils»
+
+«DEFINE ReorientRefLinkCommand FOR gmfgen::GenLink-»
+«EXPAND xpt::Common::copyright FOR diagram.editorGen-»
+package «diagram.editCommandsPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «reorientCommandClassName» extends org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final int reorientDirection;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final org.eclipse.emf.ecore.EObject referenceOwner;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final org.eclipse.emf.ecore.EObject oldEnd;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final org.eclipse.emf.ecore.EObject newEnd;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «reorientCommandClassName»(org.eclipse.gmf.runtime.emf.type.core.requests.ReorientReferenceRelationshipRequest request) {
+ super(request.getLabel(), null, request);
+ reorientDirection = request.getDirection();
+ referenceOwner = request.getReferenceOwner();
+ oldEnd = request.getOldRelationshipEnd();
+ newEnd = request.getNewRelationshipEnd();
+ }
+ «EXPAND xpt::diagram::commands::ReorientLinkUtils::canReorient(self) FOR modelFacet-»
+ «EXPAND xpt::diagram::commands::ReorientLinkUtils::reorient FOR modelFacet-»
+ «EXPAND xpt::diagram::commands::ReorientLinkUtils::accessors-»
+}
+«ENDDEFINE»

Back to the top