carbidecpp22devenv/plugins/org.eclipse.gmf.templates.legacy_1.0.0.v20090614-0839/codegen.templates/xpt/diagram/commands/CreateRefLinkCommand.xpt
changeset 422 033392511bf7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/carbidecpp22devenv/plugins/org.eclipse.gmf.templates.legacy_1.0.0.v20090614-0839/codegen.templates/xpt/diagram/commands/CreateRefLinkCommand.xpt	Fri Dec 04 11:06:59 2009 -0600
@@ -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"»
+«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
+«IMPORT "http://www.eclipse.org/emf/2002/GenModel"»
+
+«EXTENSION xpt::GenModelUtils»
+
+«DEFINE CreateRefLinkCommand 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(this) FOR modelFacet-»
+
+	«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»
+		}
+		if (getSource() != null && getTarget() != null) {
+			«EXPAND setValue FOR modelFacet-»
+		}
+		return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult();
+	}
+	«EXPAND xpt::diagram::commands::CreateLinkUtils::accessors FOR modelFacet-»
+}
+«ENDDEFINE»
+
+«DEFINE setValue FOR gmfgen::LinkModelFacet-»
+«ENDDEFINE»
+
+«REM»
+	Code to update reference.
+«ENDREM»
+«DEFINE setValue FOR gmfgen::FeatureLinkModelFacet-»
+	«IF metaFeature.ecoreFeature.many-»
+		«EXPAND MetaModel::getFeatureValue("getSource()", getSourceType()) FOR metaFeature».add(getTarget());
+	«ELSE-»
+		«EXPAND MetaModel::setFeatureValue("getSource()", getSourceType(), "getTarget()") FOR metaFeature»;
+	«ENDIF-»
+«ENDDEFINE»