aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorskovalsky2012-02-20 12:46:14 (EST)
committermgolubev2012-02-20 12:46:14 (EST)
commit29adc6ac0a437218cec6aee03147eac9797178a8 (patch)
treeb9346248cc609aab7ba2c1cbbc8a329aa0b42534
parent670b5fcb8f9db6ce9e6de8b300af49e6b9138006 (diff)
downloadorg.eclipse.gmf-tooling-29adc6ac0a437218cec6aee03147eac9797178a8.zip
org.eclipse.gmf-tooling-29adc6ac0a437218cec6aee03147eac9797178a8.tar.gz
org.eclipse.gmf-tooling-29adc6ac0a437218cec6aee03147eac9797178a8.tar.bz2
Allow VisualEffectMappings's for LinkMappings - bridge and templates368398-visual-effects-All
-rw-r--r--plugins/org.eclipse.gmf.bridge/src/org/eclipse/gmf/internal/bridge/genmodel/DiagramGenModelTransformer.java26
-rw-r--r--plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/Generator.java7
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editpolicies/VisualEffectEditPolicy.xpt109
3 files changed, 121 insertions, 21 deletions
diff --git a/plugins/org.eclipse.gmf.bridge/src/org/eclipse/gmf/internal/bridge/genmodel/DiagramGenModelTransformer.java b/plugins/org.eclipse.gmf.bridge/src/org/eclipse/gmf/internal/bridge/genmodel/DiagramGenModelTransformer.java
index d698526..36ae51d 100644
--- a/plugins/org.eclipse.gmf.bridge/src/org/eclipse/gmf/internal/bridge/genmodel/DiagramGenModelTransformer.java
+++ b/plugins/org.eclipse.gmf.bridge/src/org/eclipse/gmf/internal/bridge/genmodel/DiagramGenModelTransformer.java
@@ -589,8 +589,12 @@ public class DiagramGenModelTransformer extends MappingTransformer {
genNode.getBehaviour().add(openDiagramPolicy);
}
+ createVisualEffects(mapping, genNode, mapping.getDiagramNode());
+ }
+
+ private void createVisualEffects(MappingEntry mapping, GenCommonBase genCommon, DiagramElement diagramElement) {
for (VisualEffectMapping visualEffectMapping : mapping.getVisualEffects()) {
- createVisualEffect(genNode, visualEffectMapping);
+ createVisualEffect(genCommon, visualEffectMapping, diagramElement);
}
}
@@ -634,6 +638,8 @@ public class DiagramGenModelTransformer extends MappingTransformer {
if (!rcp) {
myNavigatorProcessor.process(gl);
}
+
+ createVisualEffects(lme, gl, lme.getDiagramLink());
}
@Override
@@ -665,11 +671,11 @@ public class DiagramGenModelTransformer extends MappingTransformer {
return label;
}
- private void createVisualEffect(GenNode node, VisualEffectMapping mapping) {
+ private void createVisualEffect(GenCommonBase parent, VisualEffectMapping mapping, DiagramElement parentDiagramElement) {
addOclToolingPlugin();
-
+
GenVisualEffect visualEffect = GMFGenFactory.eINSTANCE.createGenVisualEffect();
- node.getBehaviour().add(visualEffect);
+ parent.getBehaviour().add(visualEffect);
Pin graphPin = mapping.getDiagramPin();
@@ -680,7 +686,7 @@ public class DiagramGenModelTransformer extends MappingTransformer {
String operationName = graphPin.getOperationName();
- FigureDescriptor graphFigureDescriptor = mapping.getParentNode().getDiagramNode().getFigure();
+ FigureDescriptor graphFigureDescriptor = parentDiagramElement.getFigure();
if (!hasFigurePin(graphFigureDescriptor.getActualFigure(), graphPin)) {
for (ChildAccess graphChildAccess : graphFigureDescriptor.getAccessors()) {
@@ -695,8 +701,8 @@ public class DiagramGenModelTransformer extends MappingTransformer {
visualEffect.setOperationType(graphPin.getOperationType());
visualEffect.setOclExpression(mapping.getOclExpression());
- String editPolicyQualifiedClassName = node.getDiagram().getEditPoliciesPackageName() + '.'//
- + CodeGenUtil.capName(CodeGenUtil.validJavaIdentifier(name)) + node.getVisualID() //
+ String editPolicyQualifiedClassName = parent.getDiagram().getEditPoliciesPackageName() + '.'//
+ + CodeGenUtil.capName(CodeGenUtil.validJavaIdentifier(name)) + parent.getVisualID() //
+ "Policy";
visualEffect.setEditPolicyQualifiedClassName(editPolicyQualifiedClassName);
@@ -709,9 +715,9 @@ public class DiagramGenModelTransformer extends MappingTransformer {
: (RealFigure) figure;
return realFigure.getPins().contains(pin);
}
-
+
private void addOclToolingPlugin() {
- final String pluginId = "org.eclipse.gmf.tooling.runtime.ocl.expressions";
+ final String pluginId = "org.eclipse.gmf.tooling.runtime.ocl";
EList<String> reguiredPlugins = getGenEssence().getPlugin().getRequiredPlugins();
if (!reguiredPlugins.contains(pluginId)) {
reguiredPlugins.add(pluginId);
@@ -1065,7 +1071,7 @@ public class DiagramGenModelTransformer extends MappingTransformer {
// XXX perhaps, combining #createValueExpression and #createGenConstraint into a single method makes sense?
private ValueExpression createValueExpression(org.eclipse.gmf.mappings.ValueExpression valueExpression) {
addOclToolingPlugin();
-
+
if (valueExpression instanceof Constraint) {
return createGenConstraint((Constraint) valueExpression);
}
diff --git a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/Generator.java b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/Generator.java
index d81812b..cb58ac3 100644
--- a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/Generator.java
+++ b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/Generator.java
@@ -124,6 +124,7 @@ public class Generator extends GeneratorBase implements Runnable {
for (GenLinkLabel label : next.getLabels()) {
generateLinkLabelEditPart(label);
}
+ generateVisualEffectEditPolicies(next);
}
generateDiagram();
//
@@ -280,7 +281,11 @@ public class Generator extends GeneratorBase implements Runnable {
generateNodeLabelEditPart(label);
}
}
- for (Behaviour behaviour : node.getBehaviour()) {
+ generateVisualEffectEditPolicies(node);
+ }
+
+ private void generateVisualEffectEditPolicies(GenCommonBase commonBase) throws InterruptedException {
+ for (Behaviour behaviour : commonBase.getBehaviour()) {
if (behaviour instanceof GenVisualEffect) {
GenVisualEffect visualEffect = (GenVisualEffect) behaviour;
generateVisualEffectEditPolicy(visualEffect);
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editpolicies/VisualEffectEditPolicy.xpt b/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editpolicies/VisualEffectEditPolicy.xpt
index c3eb115..dad7df8 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editpolicies/VisualEffectEditPolicy.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editpolicies/VisualEffectEditPolicy.xpt
@@ -1,8 +1,9 @@
«IMPORT 'http://www.eclipse.org/gmf/2009/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
-«IMPORT 'http://www.eclipse.org/ocl/1.1.0/Ecore'»
«EXTENSION xpt::diagram::Utils»
+«EXTENSION xpt::GenModelUtils»
«DEFINE VisualEffectEditPolicy FOR gmfgen::GenVisualEffect-»
«EXPAND xpt::Common::copyright FOR subject.getDiagram().editorGen-»
@@ -36,6 +37,8 @@ public class «EXPAND xpt::Common::disqualifiedClassName FOR getEditPolicyQualif
«EXPAND getHostImpl-»
«EXPAND getExpressionBody-»
+
+ «EXPAND getContext-»
«ENDDEFINE»
«DEFINE setVisualEffectValue FOR gmfgen::GenVisualEffect-»
@@ -65,11 +68,43 @@ public class «EXPAND xpt::Common::disqualifiedClassName FOR getEditPolicyQualif
«DEFINE getExpressionBody FOR gmfgen::GenVisualEffect-»
«EXPAND xpt::Common::generatedMemberComment»
@Override
- protected String getExpressionBody() {
- return «getOclExpressionString()»; «EXPAND xpt::Common::nonNLS»
+ protected String getExpressionBody() {
+ return
+ «IF subject.oclIsKindOf(gmfgen::GenLink)-»
+ «EXPAND expressionLinkEnds FOR subject.oclAsType(gmfgen::GenLink).modelFacet-»
+ «ENDIF-»
+ «getOclExpressionString()»; «EXPAND xpt::Common::nonNLS»
}
«ENDDEFINE»
+«DEFINE expressionLinkEnds FOR gmfgen::LinkModelFacet»«ENDDEFINE»
+
+«DEFINE expressionLinkEnds FOR gmfgen::FeatureLinkModelFacet-»
+ «IF metaFeature.ecoreFeature.upperBound = 1-»
+ «EXPAND expressionLinkEnds('', '.'+metaFeature.ecoreFeature.name)-»
+ «ELSE-»
+ «LET getReverse(metaFeature) AS reverseMetaFeature-»
+ «IF reverseMetaFeature <> null-»
+ «EXPAND expressionLinkEnds('.'+reverseMetaFeature.ecoreFeature.name, '')-»
+ «ELSEIF metaFeature.ecoreFeature.oclAsType(ecore::EReference).containment-»
+ «EXPAND expressionLinkEnds('.oclAsType(ecore::EObject).eContainer().oclAsType('+getSourceType().ecoreClass.name+')', '')-»
+ «ELSE-»
+ /* unable to set up both link ends */
+ «ENDIF-»
+ «ENDLET-»
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE expressionLinkEnds FOR gmfgen::TypeLinkModelFacet-»
+ «EXPAND expressionLinkEnds('.'+sourceMetaFeature.ecoreFeature.name, '.'+targetMetaFeature.ecoreFeature.name)-»
+«ENDDEFINE»
+
+«DEFINE expressionLinkEnds(sourcePath : String, targetPath : String) FOR gmfgen::LinkModelFacet-»
+ " let _src : «getSourceType().ecoreClass.name» = self«sourcePath» in " //
+ + " let _dst : «getTargetType().ecoreClass.name» = self«targetPath» in " //
+ +
+«ENDDEFINE»
+
«DEFINE callOperation FOR gmfgen::GenVisualEffect-»
getHostImpl().getPrimaryShape().«operationName-»
«ENDDEFINE»
@@ -82,13 +117,6 @@ getHostImpl().getPrimaryShape().«operationName-»
«ENDLET-»
«ENDDEFINE»
-«REM»
-«DEFINE setVisualEffectValueOnVisiblePin FOR gmfgen::GenVisualEffect-»
- «EXPAND setVisualEffectValueOfType(self) FOR getOperationRuntimeType()»
- «EXPAND callOperation»((Boolean)value);
-«ENDDEFINE»
-«ENDREM»
-
«DEFINE setVisualEffectValueOnCustomPin FOR gmfgen::GenVisualEffect-»
«EXPAND setVisualEffectValueOfType(self) FOR getOperationRuntimeType()»
«ENDDEFINE»
@@ -122,3 +150,64 @@ getHostImpl().getPrimaryShape().«operationName-»
«ENDFOREACH-»
«ENDDEFINE»
+«DEFINE getContext FOR gmfgen::GenVisualEffect-»
+ «IF subject.oclIsKindOf(gmfgen::GenLink)-»
+ «EXPAND getContext FOR subject.oclAsType(gmfgen::GenLink).modelFacet-»
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE getContext FOR gmfgen::LinkModelFacet»«ENDDEFINE»
+
+«DEFINE getContext FOR gmfgen::FeatureLinkModelFacet-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ @Override
+ protected org.eclipse.emf.ecore.EObject getContext() {
+ «IF metaFeature.ecoreFeature.upperBound = 1-»
+ «EXPAND getContextBody('source', 'target', getSourceType(), getTargetType(), metaFeature)-»
+ «ELSE-»
+ «LET getReverse(metaFeature) AS reverseMetaFeature-»
+ «IF reverseMetaFeature <> null or metaFeature.ecoreFeature.oclAsType(ecore::EReference).containment-»
+ «EXPAND getContextBody('target', 'source', getTargetType(), getSourceType(), reverseMetaFeature)-»
+ «ELSE-»
+ // unable to pass both link ends
+ return null;
+ «ENDIF-»
+ «ENDLET-»
+ «ENDIF-»
+ }
+«ENDDEFINE»
+
+
+«DEFINE getContextBody(selfName : String,
+ oppositeName : String,
+ selfType : genmodel::GenClass,
+ oppositeType : genmodel::GenClass,
+ selfFeature : genmodel::GenFeature) FOR gmfgen::FeatureLinkModelFacet-»
+ org.eclipse.gmf.runtime.notation.Edge hostModel = (org.eclipse.gmf.runtime.notation.Edge) host().getModel();
+ org.eclipse.gmf.runtime.notation.View targetModel = hostModel.getTarget();
+ org.eclipse.gmf.runtime.notation.View sourceModel = hostModel.getSource();
+
+ if (targetModel == null || sourceModel == null) {
+ return null;
+ }
+
+ org.eclipse.emf.ecore.EObject «selfName»SemanticModel = org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.resolveSemanticElement(«selfName»Model);
+ // need to check actual opposite of the semantic element, since diagram opposite could be not up to date
+ «REM»(selfFeature = null) if link is multiplicity containment without opposite«ENDREM-»
+ «IF selfFeature <> null-»
+ «EXPAND MetaModel::QualifiedClassName FOR selfType» «selfName»TypedModel = «EXPAND MetaModel::CastEObject(selfName + 'SemanticModel') FOR selfType»;
+ «ENDIF-»
+ org.eclipse.emf.ecore.EObject «oppositeName»SemanticModel =
+ «IF selfFeature <> null-»
+ «EXPAND MetaModel::getFeatureValue(selfName + 'TypedModel', oppositeType) FOR selfFeature»
+ «ELSE-»
+ «selfName»SemanticModel.eContainer()
+ «ENDIF-»
+ ;
+
+ if («oppositeName»SemanticModel == null) {
+ return null;
+ }
+
+ return «selfName»SemanticModel;
+«ENDDEFINE» \ No newline at end of file