carbidecpp22devenv/plugins/org.eclipse.gmf.templates.legacy_1.0.0.v20090614-0839/codegen.lite.templates/xpt/commands/Common.xpt
author cawthron
Fri, 04 Dec 2009 11:06:59 -0600
changeset 422 033392511bf7
permissions -rw-r--r--
add files for RCL_2_2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
422
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     1
/*
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     2
 * Copyright (c) 2007, 2008 Borland Software Corporation
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     3
 * 
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     4
 * All rights reserved. This program and the accompanying materials
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     5
 * are made available under the terms of the Eclipse Public License v1.0
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     6
 * which accompanies this distribution, and is available at
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     7
 * http://www.eclipse.org/legal/epl-v10.html
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     8
 *
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     9
 * Contributors:
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    10
 *    bblajer (Borland) - initial API and implementation
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    11
 */
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    12
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    13
«IMPORT "http://www.eclipse.org/gmf/2008/GenModel"»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    14
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    15
«IMPORT "http://www.eclipse.org/emf/2002/GenModel"»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    16
«EXTENSION xpt::diagram::ViewmapAttributesUtils»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    17
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    18
«DEFINE getRelationshipContainer FOR gmfgen::LinkModelFacet»«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    19
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    20
«DEFINE getRelationshipContainer FOR gmfgen::TypeLinkModelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    21
		«EXPAND xpt::Common::generatedMemberComment("Finds container element for the relationship of the specified type.\n" + 
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    22
		  "Default implementation goes up by containment hierarchy starting from\n" + 
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    23
		  "the specified element and returns the first element that is instance of\n" + 
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    24
		  "the specified container class.")»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    25
		protected org.eclipse.emf.ecore.EObject getRelationshipContainer(org.eclipse.emf.ecore.EObject element, org.eclipse.emf.ecore.EClass containerClass) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    26
			for (; element != null; element = element.eContainer()) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    27
				if (containerClass.isSuperTypeOf(element.eClass())) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    28
					return element;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    29
				}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    30
			}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    31
			return null;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    32
		}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    33
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    34
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    35
«DEFINE featureMultiplicityComparator(String ownerVar, genmodel::GenClass ownerClass) FOR genmodel::GenFeature-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    36
«IF ecoreFeature.upperBound == 1»«EXPAND MetaModel::getFeatureValue(ownerVar, ownerClass, false)» != null«ELSE-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    37
«EXPAND MetaModel::MetaFeature».getUpperBound() > 1 && «EXPAND MetaModel::getFeatureValue(ownerVar, ownerClass, true)».size() >= «EXPAND MetaModel::MetaFeature».getUpperBound()«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    38
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    39
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    40
«DEFINE checkLinkConstraints(String sourceVar, String targetVar) FOR gmfgen::GenLinkConstraints-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    41
	if(!«EXPAND xpt::providers::DomainElementInitializer::qualifiedClassName FOR link.getDiagram()».«link.diagram.getLinkCreationConstraintsClassName()».canExist«link.getUniqueIdentifier()»(«sourceVar», «targetVar»)) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    42
		return false;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    43
	}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    44
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    45
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    46
«DEFINE plugFeatureCommand(String domainVar, String containerVar, String elementVar) FOR genmodel::GenFeature-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    47
«IF ecoreFeature.many»org.eclipse.emf.edit.command.AddCommand«ELSE»org.eclipse.emf.edit.command.SetCommand«ENDIF».create(«domainVar», «containerVar», «EXPAND MetaModel::MetaFeature», «elementVar»)«-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    48
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    49
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    50
«DEFINE unplugFeatureCommand(String domainVar, String containerVar, String elementVar) FOR genmodel::GenFeature-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    51
«IF ecoreFeature.many-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    52
org.eclipse.emf.edit.command.RemoveCommand.create(«domainVar», «containerVar», «EXPAND MetaModel::MetaFeature», «elementVar»)«-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    53
«ELSE-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    54
org.eclipse.emf.edit.command.SetCommand.create(«domainVar», «containerVar», «EXPAND MetaModel::MetaFeature», org.eclipse.emf.edit.command.SetCommand.UNSET_VALUE)«-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    55
«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    56
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    57
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    58
«DEFINE adjustConstraint FOR gmfgen::GenNode-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    59
«LET getResizeConstraints(viewmap) AS rc-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    60
«LET rc == null || rc.resizeHandleNames.select(e| e=="EAST" || e=="WEST").size() > 0 AS resizableWidth-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    61
«LET rc == null || rc.resizeHandleNames.select(e| e=="NORTH" || e=="SOUTH").size() > 0 AS resizableHeight-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    62
		if (constraint != null) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    63
	«IF resizableWidth || resizableHeight-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    64
			constraint.union(new org.eclipse.draw2d.geometry.Dimension(«EXPAND defaultWidth», «EXPAND defaultHeight»));
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    65
	«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    66
	«IF !resizableWidth-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    67
			constraint.width = «EXPAND defaultWidth»;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    68
	«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    69
	«IF !resizableHeight-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    70
			constraint.height = «EXPAND defaultHeight»;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    71
	«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    72
		}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    73
«ENDLET-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    74
«ENDLET-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    75
«ENDLET-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    76
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    77
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    78
«DEFINE defaultWidth FOR gmfgen::GenNode»«defaultSizeWidth(viewmap, 40)»«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    79
«DEFINE defaultHeight FOR gmfgen::GenNode»«defaultSizeHeight(viewmap, 40)»«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    80
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    81
«DEFINE commandNameInfix FOR gmfgen::GenNode-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    82
«EXPAND commandNameInfix FOR modelFacet.metaClass»«visualID-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    83
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    84
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    85
«DEFINE commandNameInfix FOR gmfgen::GenLink-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    86
«EXPAND commandNameInfix FOR modelFacet»«visualID-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    87
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    88
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    89
«DEFINE commandNameInfix FOR gmfgen::LinkModelFacet»«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    90
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    91
«DEFINE commandNameInfix FOR gmfgen::TypeLinkModelFacet»«EXPAND commandNameInfix FOR metaClass»«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    92
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    93
«DEFINE commandNameInfix FOR genmodel::GenClass»«ecoreClass.name»«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    94
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    95
«DEFINE commandNameInfix FOR gmfgen::FeatureLinkModelFacet»«metaFeature.genClass.ecoreClass.name + "_" + metaFeature.ecoreFeature.name.toFirstUpper()»«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    96
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    97
«DEFINE getPhantomContainmentResource FOR String»«this».getDiagram().getElement().eResource()«ENDDEFINE»