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