summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorskovalsky2012-01-13 10:04:11 (EST)
committer mgolubev2012-01-13 10:04:11 (EST)
commitd7f3b7efb1cc9fc2da78c111fabd52866ec9925e (patch)
tree27ad87cee185bcb52dc9b77af2a519714411aab6
parent8ed65ae8dcc5e27a4b1cd2fcffebd859987fc3b4 (diff)
downloadorg.eclipse.gmf-tooling-d7f3b7efb1cc9fc2da78c111fabd52866ec9925e.zip
org.eclipse.gmf-tooling-d7f3b7efb1cc9fc2da78c111fabd52866ec9925e.tar.gz
org.eclipse.gmf-tooling-d7f3b7efb1cc9fc2da78c111fabd52866ec9925e.tar.bz2
[368521] - separate code for modeling assistants and edit parts 368521-separate-MAP-and-EP
-rw-r--r--plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/CodegenEmitters.java67
-rw-r--r--plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/Generator.java59
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/diagram/editparts/ChildNodeLabelEditPart.xpt14
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/diagram/editparts/NodeEditPart.xpt14
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/impl/diagram/editparts/NodeEditPart.xpt72
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/xpt/providers/EditPartModelingAssistantProvider.xpt198
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/xpt/providers/ModelingAssistantProvider.xpt125
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/xpt/providers/extensions.xpt35
-rw-r--r--plugins/org.eclipse.gmf.common/src/org/eclipse/gmf/internal/common/codegen/ClassEmitter.java12
9 files changed, 357 insertions, 239 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/CodegenEmitters.java b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/CodegenEmitters.java
index 9346b98..8620260 100644
--- a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/CodegenEmitters.java
+++ b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/CodegenEmitters.java
@@ -29,6 +29,7 @@ import org.eclipse.emf.common.CommonPlugin;
import org.eclipse.emf.common.util.URI;
import org.eclipse.gmf.common.UnexpectedBehaviourException;
import org.eclipse.gmf.internal.common.codegen.BinaryEmitter;
+import org.eclipse.gmf.internal.common.codegen.ClassEmitter;
import org.eclipse.gmf.internal.common.codegen.DefaultTextMerger;
import org.eclipse.gmf.internal.common.codegen.GIFEmitter;
import org.eclipse.gmf.internal.common.codegen.JETGIFEmitterAdapter;
@@ -47,6 +48,7 @@ public class CodegenEmitters {
private static final String PATH_SEPARATOR = "::"; //$NON-NLS-1$
private final ResourceManager myResourceManager;
+
private final URL[] myLocations;
private Map<String, Object> myGlobals;
@@ -155,6 +157,14 @@ public class CodegenEmitters {
return getMainEmitter("diagram::editparts::NodeEditPart"); //$NON-NLS-1$
}
+ public ClassEmitter getNodeEditPartModelingAssistantProviderClassEmitter() {
+ return new ClassEmitterImpl("xpt::providers::EditPartModelingAssistantProvider"); //$NON-NLS-1$
+ }
+
+ public TextEmitter getNodeEditPartMAProviderEmitter() throws UnexpectedBehaviourException {
+ return getMainEmitter("diagram::editparts::NodeEditPartMAProvider"); //$NON-NLS-1$
+ }
+
public TextEmitter getNodeLabelEditPartEmitter() throws UnexpectedBehaviourException {
return getMainEmitter("diagram::editparts::NodeLabelEditPart"); //$NON-NLS-1$
}
@@ -633,6 +643,23 @@ public class CodegenEmitters {
return newXpandEmitter(definition);
}
+ /**
+ * Returns emitter for class name definition in the specified template.
+ * Definition should be named 'className'.
+ */
+ private TextEmitter getClassNameEmitter(String templateName) throws UnexpectedBehaviourException {
+ String definition = templateName + PATH_SEPARATOR + "className"; //$NON-NLS-1$
+ return newXpandEmitter(definition);
+ }
+
+ /**
+ * Returns emitter for package name definition in the specified template.
+ * Definition should be named 'packageName'.
+ */
+ private TextEmitter getPackageNameEmitter(String templateName) throws UnexpectedBehaviourException {
+ String definition = templateName + PATH_SEPARATOR + "packageName"; //$NON-NLS-1$
+ return newXpandEmitter(definition);
+ }
/**
* Returns text generated by emitter.
@@ -655,6 +682,22 @@ public class CodegenEmitters {
return getText(emitter, input);
}
+ /**
+ * Returns class name defined in template.
+ */
+ private String getClassName(String templateName, Object... input) throws UnexpectedBehaviourException {
+ TextEmitter emitter = getClassNameEmitter(templateName);
+ return getText(emitter, input);
+ }
+
+ /**
+ * Returns package name defined in template.
+ */
+ private String getPackageName(String templateName, Object... input) throws UnexpectedBehaviourException {
+ TextEmitter emitter = getPackageNameEmitter(templateName);
+ return getText(emitter, input);
+ }
+
private BinaryEmitter newGIFEmitter(String relativePath) throws UnexpectedBehaviourException {
return new GIFEmitter(checkTemplateLocation(relativePath));
}
@@ -678,4 +721,28 @@ public class CodegenEmitters {
protected TextEmitter newXpandEmitter(String definition) {
return new XpandTextEmitter(myResourceManager, definition, myGlobals);
}
+
+ private class ClassEmitterImpl implements ClassEmitter {
+
+ private final String myTemplateName;
+
+ public ClassEmitterImpl(String templateName) {
+ myTemplateName = templateName;
+ }
+
+ @Override
+ public TextEmitter getTextEmitter() {
+ return getMainEmitter(myTemplateName);
+ }
+
+ @Override
+ public String getPackageName(Object... input) throws UnexpectedBehaviourException {
+ return CodegenEmitters.this.getPackageName(myTemplateName, input);
+ }
+
+ @Override
+ public String getClassName(Object... input) throws UnexpectedBehaviourException {
+ return CodegenEmitters.this.getClassName(myTemplateName, input);
+ }
+ };
} \ No newline at end of file
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 cd5159d..8682c17 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
@@ -24,8 +24,54 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.emf.codegen.util.CodeGenUtil;
-import org.eclipse.gmf.codegen.gmfgen.*;
+import org.eclipse.gmf.codegen.gmfgen.CustomParser;
+import org.eclipse.gmf.codegen.gmfgen.ElementType;
+import org.eclipse.gmf.codegen.gmfgen.ExpressionLabelParser;
+import org.eclipse.gmf.codegen.gmfgen.ExternalParser;
+import org.eclipse.gmf.codegen.gmfgen.FeatureLinkModelFacet;
+import org.eclipse.gmf.codegen.gmfgen.GMFGenFactory;
+import org.eclipse.gmf.codegen.gmfgen.GMFGenPackage;
+import org.eclipse.gmf.codegen.gmfgen.GenAction;
+import org.eclipse.gmf.codegen.gmfgen.GenApplication;
+import org.eclipse.gmf.codegen.gmfgen.GenChildContainer;
+import org.eclipse.gmf.codegen.gmfgen.GenChildLabelNode;
+import org.eclipse.gmf.codegen.gmfgen.GenChildNode;
+import org.eclipse.gmf.codegen.gmfgen.GenCommonBase;
+import org.eclipse.gmf.codegen.gmfgen.GenCompartment;
+import org.eclipse.gmf.codegen.gmfgen.GenContainerBase;
+import org.eclipse.gmf.codegen.gmfgen.GenContributionItem;
+import org.eclipse.gmf.codegen.gmfgen.GenContributionManager;
+import org.eclipse.gmf.codegen.gmfgen.GenCustomAction;
+import org.eclipse.gmf.codegen.gmfgen.GenCustomPreferencePage;
+import org.eclipse.gmf.codegen.gmfgen.GenCustomPropertyTab;
+import org.eclipse.gmf.codegen.gmfgen.GenDiagram;
+import org.eclipse.gmf.codegen.gmfgen.GenEditorGenerator;
+import org.eclipse.gmf.codegen.gmfgen.GenEditorView;
+import org.eclipse.gmf.codegen.gmfgen.GenExpressionInterpreter;
+import org.eclipse.gmf.codegen.gmfgen.GenExpressionProviderBase;
+import org.eclipse.gmf.codegen.gmfgen.GenExpressionProviderContainer;
+import org.eclipse.gmf.codegen.gmfgen.GenExternalNodeLabel;
+import org.eclipse.gmf.codegen.gmfgen.GenLanguage;
+import org.eclipse.gmf.codegen.gmfgen.GenLink;
+import org.eclipse.gmf.codegen.gmfgen.GenLinkLabel;
+import org.eclipse.gmf.codegen.gmfgen.GenNavigatorChildReference;
+import org.eclipse.gmf.codegen.gmfgen.GenNode;
+import org.eclipse.gmf.codegen.gmfgen.GenNodeLabel;
+import org.eclipse.gmf.codegen.gmfgen.GenParserImplementation;
+import org.eclipse.gmf.codegen.gmfgen.GenPreferencePage;
+import org.eclipse.gmf.codegen.gmfgen.GenPropertyTab;
+import org.eclipse.gmf.codegen.gmfgen.GenSharedContributionItem;
+import org.eclipse.gmf.codegen.gmfgen.GenStandardPreferencePage;
+import org.eclipse.gmf.codegen.gmfgen.GenTopLevelNode;
+import org.eclipse.gmf.codegen.gmfgen.InitDiagramAction;
+import org.eclipse.gmf.codegen.gmfgen.MetamodelType;
+import org.eclipse.gmf.codegen.gmfgen.OpenDiagramBehaviour;
+import org.eclipse.gmf.codegen.gmfgen.PredefinedParser;
+import org.eclipse.gmf.codegen.gmfgen.SpecializationType;
+import org.eclipse.gmf.codegen.gmfgen.StandardPreferencePages;
+import org.eclipse.gmf.codegen.gmfgen.TypeLinkModelFacet;
import org.eclipse.gmf.common.UnexpectedBehaviourException;
+import org.eclipse.gmf.internal.common.codegen.ClassEmitter;
import org.eclipse.gmf.internal.common.codegen.GeneratorBase;
import org.eclipse.gmf.internal.common.codegen.ImportUtil;
import org.eclipse.gmf.internal.common.codegen.TextEmitter;
@@ -256,6 +302,7 @@ public class Generator extends GeneratorBase implements Runnable {
generateDiagramItemSemanticEditPolicy();
generateEditSupport(myDiagram);
generateDiagramEditPart();
+ generateEditPartModelingAssistantProvider(myDiagram);
}
private void generateNode(GenNode node) throws UnexpectedBehaviourException, InterruptedException {
@@ -265,6 +312,7 @@ public class Generator extends GeneratorBase implements Runnable {
}
generateEditSupport(node);
generateNodeEditPart(node);
+ generateEditPartModelingAssistantProvider(node);
generateBehaviours(node);
if (node.needsCanonicalEditPolicy()) {
generateChildContainerCanonicalEditPolicy(node);
@@ -290,6 +338,7 @@ public class Generator extends GeneratorBase implements Runnable {
generateEditSupport(child);
generateBehaviours(child);
generateChildNodeLabelEditPart(child);
+ generateEditPartModelingAssistantProvider(child);
}
// commands
@@ -364,6 +413,10 @@ public class Generator extends GeneratorBase implements Runnable {
doGenerateJavaClass(myEmitters.getNodeEditPartEmitter(), node.getEditPartQualifiedClassName(), node);
}
+ private void generateEditPartModelingAssistantProvider(GenContainerBase container) throws UnexpectedBehaviourException, InterruptedException {
+ doGenerateJavaClass(myEmitters.getNodeEditPartModelingAssistantProviderClassEmitter(), container);
+ }
+
private void generateNodeLabelEditPart(GenNodeLabel label) throws UnexpectedBehaviourException, InterruptedException {
doGenerateJavaClass(myEmitters.getNodeLabelEditPartEmitter(), label.getEditPartQualifiedClassName(), label);
}
@@ -968,4 +1021,8 @@ public class Generator extends GeneratorBase implements Runnable {
private static boolean needsGraphicalNodeEditPolicy(GenNode node) {
return node.getModelFacet() != null && !node.getReorientedIncomingLinks().isEmpty();
}
+
+ private void doGenerateJavaClass(ClassEmitter classEmitter, GenCommonBase input) throws InterruptedException, UnexpectedBehaviourException {
+ doGenerateJavaClass(classEmitter.getTextEmitter(), classEmitter.getPackageName(input), classEmitter.getClassName(input), input);
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates/diagram/editparts/ChildNodeLabelEditPart.xpt b/plugins/org.eclipse.gmf.codegen/templates/diagram/editparts/ChildNodeLabelEditPart.xpt
index 7ed6792..ae0c9de 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/diagram/editparts/ChildNodeLabelEditPart.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/diagram/editparts/ChildNodeLabelEditPart.xpt
@@ -34,20 +34,6 @@ public class «editPartClassName» «EXPAND extendsList» «EXPAND implementsLis
«EXPAND xpt::diagram::editparts::Common::notationalListeners-»
-«IF getAssistantOutgoingLinks(self)->size() > 0-»
- «EXPAND impl::diagram::editparts::NodeEditPart::getMARelTypesOnSource-»
-
- «EXPAND impl::diagram::editparts::NodeEditPart::getMARelTypesOnSourceAndTarget-»
-
- «EXPAND impl::diagram::editparts::NodeEditPart::getMATypesForTarget-»
-«ENDIF-»
-
-«IF getAssistantIncomingLinks(self)->size() > 0-»
- «EXPAND impl::diagram::editparts::NodeEditPart::getMARelTypesOnTarget-»
-
- «EXPAND impl::diagram::editparts::NodeEditPart::getMATypesForSource-»
-«ENDIF-»
-
«EXPAND handleNotificationEvent-»
«EXPAND xpt::diagram::editparts::Common::labelFigure FOR viewmap-»
diff --git a/plugins/org.eclipse.gmf.codegen/templates/diagram/editparts/NodeEditPart.xpt b/plugins/org.eclipse.gmf.codegen/templates/diagram/editparts/NodeEditPart.xpt
index 7ec30ea..806c3c4 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/diagram/editparts/NodeEditPart.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/diagram/editparts/NodeEditPart.xpt
@@ -66,20 +66,6 @@ public class «editPartClassName» «EXPAND extendsList» «EXPAND implementsLis
«EXPAND impl::diagram::editparts::NodeEditPart::getPrimaryChildEditPart-»
-«IF getAssistantOutgoingLinks(self)->size() > 0-»
- «EXPAND impl::diagram::editparts::NodeEditPart::getMARelTypesOnSource-»
-
- «EXPAND impl::diagram::editparts::NodeEditPart::getMARelTypesOnSourceAndTarget-»
-
- «EXPAND impl::diagram::editparts::NodeEditPart::getMATypesForTarget-»
-«ENDIF-»
-
-«IF getAssistantIncomingLinks(self)->size() > 0-»
- «EXPAND impl::diagram::editparts::NodeEditPart::getMARelTypesOnTarget-»
-
- «EXPAND impl::diagram::editparts::NodeEditPart::getMATypesForSource-»
-«ENDIF-»
-
«IF hasChildrenInListCompartments(self)-»
«EXPAND impl::diagram::editparts::NodeEditPart::getTargetEditPartMethod-»
«ENDIF-»
diff --git a/plugins/org.eclipse.gmf.codegen/templates/impl/diagram/editparts/NodeEditPart.xpt b/plugins/org.eclipse.gmf.codegen/templates/impl/diagram/editparts/NodeEditPart.xpt
index f7c44be..6bc9690 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/impl/diagram/editparts/NodeEditPart.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/impl/diagram/editparts/NodeEditPart.xpt
@@ -478,78 +478,6 @@ new org.eclipse.gmf.runtime.diagram.ui.editpolicies.BorderItemSelectionEditPolic
«ENDIF-»
«ENDDEFINE»
-// pre: getAssistantOutgoingLinks(this).size() > 0
-«DEFINE getMARelTypesOnSource FOR gmfgen::GenNode-»
- «EXPAND xpt::Common::generatedMemberComment»
- public «EXPAND CodeStyle::G('java.util.List', 'org.eclipse.gmf.runtime.emf.type.core.IElementType')» getMARelTypesOnSource() {
- «EXPAND CodeStyle::newGenericInstance('types', 'java.util.ArrayList', 'org.eclipse.gmf.runtime.emf.type.core.IElementType')»(«getAssistantOutgoingLinks(self)->size()»);
- «FOREACH getAssistantOutgoingLinks(self) AS link-»
- types.add(«EXPAND xpt::providers::ElementTypes::accessElementType FOR link»);
- «ENDFOREACH-»
- return types;
- }
-«ENDDEFINE»
-
-// pre: getAssistantIncomingLinks(this).size() > 0
-«DEFINE getMARelTypesOnTarget FOR gmfgen::GenNode-»
- «EXPAND xpt::Common::generatedMemberComment»
- public «EXPAND CodeStyle::G('java.util.List', 'org.eclipse.gmf.runtime.emf.type.core.IElementType')» getMARelTypesOnTarget() {
- «EXPAND CodeStyle::newGenericInstance('types', 'java.util.ArrayList', 'org.eclipse.gmf.runtime.emf.type.core.IElementType')»(«getAssistantIncomingLinks(self)->size()»);
- «FOREACH getAssistantIncomingLinks(self) AS link-»
- types.add(«EXPAND xpt::providers::ElementTypes::accessElementType FOR link»);
- «ENDFOREACH-»
- return types;
- }
-«ENDDEFINE»
-
-// pre: getAssistantOutgoingLinks(this).size() > 0
-«DEFINE getMARelTypesOnSourceAndTarget FOR gmfgen::GenNode-»
- «EXPAND xpt::Common::generatedMemberComment»
- public «EXPAND CodeStyle::G('java.util.List', 'org.eclipse.gmf.runtime.emf.type.core.IElementType')» getMARelTypesOnSourceAndTarget(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart targetEditPart) {
- «EXPAND CodeStyle::newGenericInstance('types', 'java.util.LinkedList', 'org.eclipse.gmf.runtime.emf.type.core.IElementType')»();
- «FOREACH getAssistantOutgoingLinks(self) AS link-»
- «FOREACH selectGenNodes(link.targets) AS target-»
- if (targetEditPart instanceof «target.getEditPartQualifiedClassName()») {
- types.add(«EXPAND xpt::providers::ElementTypes::accessElementType FOR link»);
- }
- «ENDFOREACH-»
- «ENDFOREACH-»
- return types;
- }
-«ENDDEFINE»
-
-// pre: getAssistantIncomingLinks(this).size() > 0
-«DEFINE getMATypesForSource FOR gmfgen::GenNode-»
- «EXPAND xpt::Common::generatedMemberComment»
- public «EXPAND CodeStyle::G('java.util.List', 'org.eclipse.gmf.runtime.emf.type.core.IElementType')» getMATypesForSource(org.eclipse.gmf.runtime.emf.type.core.IElementType relationshipType) {
- «EXPAND CodeStyle::newGenericInstance('types', 'java.util.LinkedList', 'org.eclipse.gmf.runtime.emf.type.core.IElementType')»();
- «FOREACH getAssistantIncomingLinks(self) AS link SEPARATOR ' else '-»
- if (relationshipType == «EXPAND xpt::providers::ElementTypes::accessElementType FOR link») {
- «FOREACH selectGenNodes(link.sources) AS source-»
- types.add(«EXPAND xpt::providers::ElementTypes::accessElementType FOR source»);
- «ENDFOREACH-»
- }
- «ENDFOREACH-»
- return types;
- }
-«ENDDEFINE»
-
-// pre: getAssistantOutgoingLinks(this).size() > 0
-«DEFINE getMATypesForTarget FOR gmfgen::GenNode-»
- «EXPAND xpt::Common::generatedMemberComment»
- public «EXPAND CodeStyle::G('java.util.List', 'org.eclipse.gmf.runtime.emf.type.core.IElementType')» getMATypesForTarget(org.eclipse.gmf.runtime.emf.type.core.IElementType relationshipType) {
- «EXPAND CodeStyle::newGenericInstance('types', 'java.util.LinkedList', 'org.eclipse.gmf.runtime.emf.type.core.IElementType')»();
- «FOREACH getAssistantOutgoingLinks(self) AS link SEPARATOR ' else '-»
- if (relationshipType == «EXPAND xpt::providers::ElementTypes::accessElementType FOR link») {
- «FOREACH selectGenNodes(link.targets) AS target-»
- types.add(«EXPAND xpt::providers::ElementTypes::accessElementType FOR target»);
- «ENDFOREACH-»
- }
- «ENDFOREACH-»
- return types;
- }
-«ENDDEFINE»
-
«DEFINE handleNotificationEventBody FOR gmfgen::GenTopLevelNode-»
if (event.getNotifier() == getModel() && org.eclipse.emf.ecore.EcorePackage.eINSTANCE.getEModelElement_EAnnotations().equals(event.getFeature())) {
handleMajorSemanticChange();
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/providers/EditPartModelingAssistantProvider.xpt b/plugins/org.eclipse.gmf.codegen/templates/xpt/providers/EditPartModelingAssistantProvider.xpt
new file mode 100644
index 0000000..123bb9d
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/providers/EditPartModelingAssistantProvider.xpt
@@ -0,0 +1,198 @@
+«IMPORT 'http://www.eclipse.org/gmf/2009/GenModel'»
+
+«EXTENSION xpt::diagram::editparts::Utils»
+
+«DEFINE Main FOR gmfgen::GenContainerBase-»
+«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «EXPAND packageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «EXPAND className»
+ extends «getDiagram().providersPackageName».«getDiagram().modelingAssistantProviderClassName» {
+
+ «EXPAND getTypesForPopupBar-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE className FOR gmfgen::GenContainerBase»«getDiagram().modelingAssistantProviderClassName»Of«editPartClassName»«ENDDEFINE»
+
+«DEFINE packageName FOR gmfgen::GenContainerBase»«getDiagram().providersPackageName»«ENDDEFINE»
+
+«DEFINE qualifiedClassName FOR gmfgen::GenContainerBase»«EXPAND packageName».«EXPAND className»«ENDDEFINE»
+
+«DEFINE getTypesForPopupBar FOR gmfgen::GenContainerBase-»
+ «LET self AS container-»
+ «IF container.getAssistantNodes()->size() > 0-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public java.util.List getTypesForPopupBar(org.eclipse.core.runtime.IAdaptable host) {
+ «EXPAND CodeStyle::newGenericInstance('types', 'java.util.ArrayList', 'org.eclipse.gmf.runtime.emf.type.core.IElementType')»(«container.getAssistantNodes()->size()»);
+ «FOREACH container.getAssistantNodes()->asSequence() AS node-»
+ types.add(«EXPAND xpt::providers::ElementTypes::accessElementType FOR node»);
+ «ENDFOREACH-»
+ return types;
+ }
+ «ENDIF-»
+ «ENDLET-»
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenContainerBase»«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenNode-»
+«IF getAssistantOutgoingLinks(self)->size() > 0-»
+ «EXPAND getRelTypesOnSource-»
+
+ «EXPAND doGetRelTypesOnSource-»
+
+ «EXPAND getRelTypesOnSourceAndTarget-»
+
+ «EXPAND doGetRelTypesOnSourceAndTarget-»
+
+ «EXPAND getTypesForTarget-»
+
+ «EXPAND doGetTypesForTarget-»
+«ENDIF-»
+
+«IF getAssistantIncomingLinks(self)->size() > 0-»
+ «EXPAND getRelTypesOnTarget-»
+
+ «EXPAND doGetRelTypesOnTarget-»
+
+ «EXPAND getTypesForSource-»
+
+ «EXPAND doGetTypesForSource-»
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE getRelTypesOnSource FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public java.util.List getRelTypesOnSource(org.eclipse.core.runtime.IAdaptable source) {
+ org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart sourceEditPart =
+ (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) source.getAdapter(
+ org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart.class);
+ return doGetRelTypesOnSource((«getEditPartQualifiedClassName()») sourceEditPart);
+ }
+«ENDDEFINE»
+
+«DEFINE getRelTypesOnTarget FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public java.util.List getRelTypesOnTarget(org.eclipse.core.runtime.IAdaptable target) {
+ org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart targetEditPart =
+ (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) target.getAdapter(
+ org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart.class);
+ return doGetRelTypesOnTarget((«getEditPartQualifiedClassName()») targetEditPart);
+ }
+«ENDDEFINE»
+
+«DEFINE getRelTypesOnSourceAndTarget FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public java.util.List getRelTypesOnSourceAndTarget(
+ org.eclipse.core.runtime.IAdaptable source, org.eclipse.core.runtime.IAdaptable target) {
+ org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart sourceEditPart =
+ (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) source.getAdapter(
+ org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart.class);
+ org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart targetEditPart =
+ (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) target.getAdapter(
+ org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart.class);
+ return doGetRelTypesOnSourceAndTarget((«getEditPartQualifiedClassName()») sourceEditPart, targetEditPart);
+ }
+«ENDDEFINE»
+
+«DEFINE getTypesForSource FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public java.util.List getTypesForSource(org.eclipse.core.runtime.IAdaptable target,
+ org.eclipse.gmf.runtime.emf.type.core.IElementType relationshipType) {
+ org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart targetEditPart =
+ (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) target.getAdapter(
+ org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart.class);
+ return doGetTypesForSource((«getEditPartQualifiedClassName()») targetEditPart, relationshipType);
+ }
+«ENDDEFINE»
+
+«DEFINE getTypesForTarget FOR gmfgen::GenNode-»
+ «IF getAssistantOutgoingLinks(self)->size() > 0-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public java.util.List getTypesForTarget(org.eclipse.core.runtime.IAdaptable source,
+ org.eclipse.gmf.runtime.emf.type.core.IElementType relationshipType) {
+ org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart sourceEditPart =
+ (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) source.getAdapter(
+ org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart.class);
+ return doGetTypesForTarget((«getEditPartQualifiedClassName()») sourceEditPart, relationshipType);
+ }
+ «ENDIF-»
+«ENDDEFINE»
+
+// pre: getAssistantOutgoingLinks(this).size() > 0
+«DEFINE doGetRelTypesOnSource FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «EXPAND CodeStyle::G('java.util.List', 'org.eclipse.gmf.runtime.emf.type.core.IElementType')» doGetRelTypesOnSource(«getEditPartQualifiedClassName()» source) {
+ «EXPAND CodeStyle::newGenericInstance('types', 'java.util.ArrayList', 'org.eclipse.gmf.runtime.emf.type.core.IElementType')»(«getAssistantOutgoingLinks(self)->size()»);
+ «FOREACH getAssistantOutgoingLinks(self) AS link-»
+ types.add(«EXPAND xpt::providers::ElementTypes::accessElementType FOR link»);
+ «ENDFOREACH-»
+ return types;
+ }
+«ENDDEFINE»
+
+// pre: getAssistantIncomingLinks(this).size() > 0
+«DEFINE doGetRelTypesOnTarget FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «EXPAND CodeStyle::G('java.util.List', 'org.eclipse.gmf.runtime.emf.type.core.IElementType')» doGetRelTypesOnTarget(«getEditPartQualifiedClassName()» target) {
+ «EXPAND CodeStyle::newGenericInstance('types', 'java.util.ArrayList', 'org.eclipse.gmf.runtime.emf.type.core.IElementType')»(«getAssistantIncomingLinks(self)->size()»);
+ «FOREACH getAssistantIncomingLinks(self) AS link-»
+ types.add(«EXPAND xpt::providers::ElementTypes::accessElementType FOR link»);
+ «ENDFOREACH-»
+ return types;
+ }
+«ENDDEFINE»
+
+// pre: getAssistantOutgoingLinks(this).size() > 0
+«DEFINE doGetRelTypesOnSourceAndTarget FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «EXPAND CodeStyle::G('java.util.List', 'org.eclipse.gmf.runtime.emf.type.core.IElementType')» doGetRelTypesOnSourceAndTarget(«getEditPartQualifiedClassName()» source, org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart targetEditPart) {
+ «EXPAND CodeStyle::newGenericInstance('types', 'java.util.LinkedList', 'org.eclipse.gmf.runtime.emf.type.core.IElementType')»();
+ «FOREACH getAssistantOutgoingLinks(self) AS link-»
+ «FOREACH selectGenNodes(link.targets) AS target-»
+ if (targetEditPart instanceof «target.getEditPartQualifiedClassName()») {
+ types.add(«EXPAND xpt::providers::ElementTypes::accessElementType FOR link»);
+ }
+ «ENDFOREACH-»
+ «ENDFOREACH-»
+ return types;
+ }
+«ENDDEFINE»
+
+// pre: getAssistantIncomingLinks(this).size() > 0
+«DEFINE doGetTypesForSource FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «EXPAND CodeStyle::G('java.util.List', 'org.eclipse.gmf.runtime.emf.type.core.IElementType')» doGetTypesForSource(«getEditPartQualifiedClassName()» target, org.eclipse.gmf.runtime.emf.type.core.IElementType relationshipType) {
+ «EXPAND CodeStyle::newGenericInstance('types', 'java.util.LinkedList', 'org.eclipse.gmf.runtime.emf.type.core.IElementType')»();
+ «FOREACH getAssistantIncomingLinks(self) AS link SEPARATOR ' else '-»
+ if (relationshipType == «EXPAND xpt::providers::ElementTypes::accessElementType FOR link») {
+ «FOREACH selectGenNodes(link.sources) AS source-»
+ types.add(«EXPAND xpt::providers::ElementTypes::accessElementType FOR source»);
+ «ENDFOREACH-»
+ }
+ «ENDFOREACH-»
+ return types;
+ }
+«ENDDEFINE»
+
+// pre: getAssistantOutgoingLinks(this).size() > 0
+«DEFINE doGetTypesForTarget FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «EXPAND CodeStyle::G('java.util.List', 'org.eclipse.gmf.runtime.emf.type.core.IElementType')» doGetTypesForTarget(«getEditPartQualifiedClassName()» source, org.eclipse.gmf.runtime.emf.type.core.IElementType relationshipType) {
+ «EXPAND CodeStyle::newGenericInstance('types', 'java.util.LinkedList', 'org.eclipse.gmf.runtime.emf.type.core.IElementType')»();
+ «FOREACH getAssistantOutgoingLinks(self) AS link SEPARATOR ' else '-»
+ if (relationshipType == «EXPAND xpt::providers::ElementTypes::accessElementType FOR link») {
+ «FOREACH selectGenNodes(link.targets) AS target-»
+ types.add(«EXPAND xpt::providers::ElementTypes::accessElementType FOR target»);
+ «ENDFOREACH-»
+ }
+ «ENDFOREACH-»
+ return types;
+ }
+«ENDDEFINE»
+
+
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/providers/ModelingAssistantProvider.xpt b/plugins/org.eclipse.gmf.codegen/templates/xpt/providers/ModelingAssistantProvider.xpt
index 9cd68cb..443b79f 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/xpt/providers/ModelingAssistantProvider.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/providers/ModelingAssistantProvider.xpt
@@ -13,7 +13,6 @@
«IMPORT 'http://www.eclipse.org/gmf/2009/GenModel'»
-«EXTENSION xpt::diagram::editparts::Utils»
«EXTENSION xpt::providers::i18n»
«DEFINE ModelingAssistantProvider FOR gmfgen::GenDiagram-»
@@ -24,18 +23,6 @@ package «providersPackageName»;
public class «modelingAssistantProviderClassName»
extends org.eclipse.gmf.runtime.emf.ui.services.modelingassistant.ModelingAssistantProvider {
- «EXPAND getTypesForPopupBar-»
-
- «EXPAND getRelTypesOnSource-»
-
- «EXPAND getRelTypesOnTarget-»
-
- «EXPAND getRelTypesOnSourceAndTarget-»
-
- «EXPAND getTypesForSource-»
-
- «EXPAND getTypesForTarget-»
-
«EXPAND selectExistingElementForSource-»
«EXPAND selectExistingElementForTarget-»
@@ -49,118 +36,6 @@ public class «modelingAssistantProviderClassName»
}
«ENDDEFINE»
-«DEFINE getTypesForPopupBar FOR gmfgen::GenDiagram-»
- «EXPAND xpt::Common::generatedMemberComment»
- public java.util.List getTypesForPopupBar(org.eclipse.core.runtime.IAdaptable host) {
- org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart editPart =
- (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) host.getAdapter(
- org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart.class);
- «FOREACH getAllContainers() AS container-»
- «IF container.getAssistantNodes()->size() > 0-»
- if (editPart instanceof «container.getEditPartQualifiedClassName()») {
- «EXPAND CodeStyle::newGenericInstance('types', 'java.util.ArrayList', 'org.eclipse.gmf.runtime.emf.type.core.IElementType')»(«container.getAssistantNodes()->size()»);
- «FOREACH container.getAssistantNodes()->asSequence() AS node-»
- types.add(«EXPAND xpt::providers::ElementTypes::accessElementType FOR node»);
- «ENDFOREACH-»
- return types;
- }
- «ENDIF-»
- «ENDFOREACH-»
- return java.util.Collections.EMPTY_LIST;
- }
-«ENDDEFINE»
-
-«DEFINE getRelTypesOnSource FOR gmfgen::GenDiagram-»
- «EXPAND xpt::Common::generatedMemberComment»
- public java.util.List getRelTypesOnSource(org.eclipse.core.runtime.IAdaptable source) {
- org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart sourceEditPart =
- (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) source.getAdapter(
- org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart.class);
- «FOREACH getAllNodes() AS source-»
- «IF getAssistantOutgoingLinks(source)->size() > 0-»
- if (sourceEditPart instanceof «source.getEditPartQualifiedClassName()») {
- return ((«source.getEditPartQualifiedClassName()») sourceEditPart).getMARelTypesOnSource();
- }
- «ENDIF-»
- «ENDFOREACH-»
- return java.util.Collections.EMPTY_LIST;
- }
-«ENDDEFINE»
-
-«DEFINE getRelTypesOnTarget FOR gmfgen::GenDiagram-»
- «EXPAND xpt::Common::generatedMemberComment»
- public java.util.List getRelTypesOnTarget(org.eclipse.core.runtime.IAdaptable target) {
- org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart targetEditPart =
- (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) target.getAdapter(
- org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart.class);
- «FOREACH getAllNodes() AS target-»
- «IF getAssistantIncomingLinks(target)->size() > 0-»
- if (targetEditPart instanceof «target.getEditPartQualifiedClassName()») {
- return ((«target.getEditPartQualifiedClassName()») targetEditPart).getMARelTypesOnTarget();
- }
- «ENDIF-»
- «ENDFOREACH-»
- return java.util.Collections.EMPTY_LIST;
- }
-«ENDDEFINE»
-
-«DEFINE getRelTypesOnSourceAndTarget FOR gmfgen::GenDiagram-»
- «EXPAND xpt::Common::generatedMemberComment»
- public java.util.List getRelTypesOnSourceAndTarget(
- org.eclipse.core.runtime.IAdaptable source, org.eclipse.core.runtime.IAdaptable target) {
- org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart sourceEditPart =
- (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) source.getAdapter(
- org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart.class);
- org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart targetEditPart =
- (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) target.getAdapter(
- org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart.class);
- «FOREACH getAllNodes() AS source-»
- «IF getAssistantOutgoingLinks(source)->size() > 0-»
- if (sourceEditPart instanceof «source.getEditPartQualifiedClassName()») {
- return ((«source.getEditPartQualifiedClassName()») sourceEditPart).getMARelTypesOnSourceAndTarget(targetEditPart);
- }
- «ENDIF-»
- «ENDFOREACH-»
- return java.util.Collections.EMPTY_LIST;
- }
-«ENDDEFINE»
-
-«DEFINE getTypesForSource FOR gmfgen::GenDiagram-»
- «EXPAND xpt::Common::generatedMemberComment»
- public java.util.List getTypesForSource(org.eclipse.core.runtime.IAdaptable target,
- org.eclipse.gmf.runtime.emf.type.core.IElementType relationshipType) {
- org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart targetEditPart =
- (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) target.getAdapter(
- org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart.class);
- «FOREACH getAllNodes() AS target-»
- «IF getAssistantIncomingLinks(target)->size() > 0-»
- if (targetEditPart instanceof «target.getEditPartQualifiedClassName()») {
- return ((«target.getEditPartQualifiedClassName()») targetEditPart).getMATypesForSource(relationshipType);
- }
- «ENDIF-»
- «ENDFOREACH-»
- return java.util.Collections.EMPTY_LIST;
- }
-«ENDDEFINE»
-
-«DEFINE getTypesForTarget FOR gmfgen::GenDiagram-»
- «EXPAND xpt::Common::generatedMemberComment»
- public java.util.List getTypesForTarget(org.eclipse.core.runtime.IAdaptable source,
- org.eclipse.gmf.runtime.emf.type.core.IElementType relationshipType) {
- org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart sourceEditPart =
- (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) source.getAdapter(
- org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart.class);
- «FOREACH getAllNodes() AS source-»
- «IF getAssistantOutgoingLinks(source)->size() > 0-»
- if (sourceEditPart instanceof «source.getEditPartQualifiedClassName()») {
- return ((«source.getEditPartQualifiedClassName()») sourceEditPart).getMATypesForTarget(relationshipType);
- }
- «ENDIF-»
- «ENDFOREACH-»
- return java.util.Collections.EMPTY_LIST;
- }
-«ENDDEFINE»
-
«DEFINE selectExistingElementForSource FOR gmfgen::GenDiagram-»
«EXPAND xpt::Common::generatedMemberComment»
public org.eclipse.emf.ecore.EObject selectExistingElementForSource(
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/providers/extensions.xpt b/plugins/org.eclipse.gmf.codegen/templates/xpt/providers/extensions.xpt
index b6241b5..ee5b478 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/xpt/providers/extensions.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/providers/extensions.xpt
@@ -56,20 +56,10 @@
</editpartProvider>
</extension>
- <extension point="org.eclipse.gmf.runtime.emf.ui.modelingAssistantProviders" id="modelassist-provider">
- «EXPAND xpt::Common::xmlGeneratedTag»
- <modelingAssistantProvider class="«getModelingAssistantProviderQualifiedClassName()»">
- <Priority name="«modelingAssistantProviderPriority»"/>
- <object class="«getEditPartQualifiedClassName()»" id="«getUniqueIdentifier()»"/>
-«FOREACH topLevelNodes AS n-»
- <object class="«n.getEditPartQualifiedClassName()»" id="«n.getUniqueIdentifier()»"/>
-«ENDFOREACH-»
-«FOREACH childNodes AS n-»
- <object class="«n.getEditPartQualifiedClassName()»" id="«n.getUniqueIdentifier()»"/>
+«EXPAND modelingAssistantProvider»
+«FOREACH getAllNodes() AS n-»
+ «EXPAND modelingAssistantProvider FOR n»
«ENDFOREACH-»
- <context elements="«getUniqueIdentifier()»,«FOREACH topLevelNodes AS n SEPARATOR ','»«n.getUniqueIdentifier()»«ENDFOREACH»,«FOREACH childNodes AS n SEPARATOR ','»«n.getUniqueIdentifier()»«ENDFOREACH»"/>
- </modelingAssistantProvider>
- </extension>
<extension point="org.eclipse.gmf.runtime.common.ui.services.iconProviders" id="icon-provider">
«EXPAND xpt::Common::xmlGeneratedTag»
@@ -192,3 +182,22 @@
«DEFINE internal_i18n FOR gmfgen::ElementType-»
«IF null <> displayName and not definedExternally»metatype.name.«diagramElement.getUniqueIdentifier()»=«displayName»«ENDIF»
«ENDDEFINE»
+
+«DEFINE modelingAssistantProvider FOR gmfgen::GenContainerBase»
+ <extension point="org.eclipse.gmf.runtime.emf.ui.modelingAssistantProviders" id="modelassist-provider-«visualID»">
+ «EXPAND xpt::Common::xmlGeneratedTag»
+ <modelingAssistantProvider class="«EXPAND modelingAssistantProviderQualifiedClassName»">
+ <Priority name="«getDiagram().modelingAssistantProviderPriority»"/>
+ <object class="«getEditPartQualifiedClassName()»" id="«getUniqueIdentifier()»"/>
+ <context elements="«getUniqueIdentifier()»»"/>
+ </modelingAssistantProvider>
+ </extension>
+«ENDDEFINE»
+
+«DEFINE modelingAssistantProviderQualifiedClassName FOR gmfgen::GenContainerBase»«REM»NO-OP, all specific subclasses should be handled«ENDREM»«ENDDEFINE»
+
+«DEFINE modelingAssistantProviderQualifiedClassName FOR gmfgen::GenDiagram»«getModelingAssistantProviderQualifiedClassName()»«ENDDEFINE»
+
+«DEFINE modelingAssistantProviderQualifiedClassName FOR gmfgen::GenNode»«EXPAND xpt::providers::EditPartModelingAssistantProvider::qualifiedClassName»«ENDDEFINE»
+
+
diff --git a/plugins/org.eclipse.gmf.common/src/org/eclipse/gmf/internal/common/codegen/ClassEmitter.java b/plugins/org.eclipse.gmf.common/src/org/eclipse/gmf/internal/common/codegen/ClassEmitter.java
new file mode 100644
index 0000000..ea7e503
--- /dev/null
+++ b/plugins/org.eclipse.gmf.common/src/org/eclipse/gmf/internal/common/codegen/ClassEmitter.java
@@ -0,0 +1,12 @@
+package org.eclipse.gmf.internal.common.codegen;
+
+import org.eclipse.gmf.common.UnexpectedBehaviourException;
+
+public interface ClassEmitter {
+
+ public TextEmitter getTextEmitter();
+
+ public String getPackageName(Object... input) throws UnexpectedBehaviourException;
+
+ public String getClassName(Object... input) throws UnexpectedBehaviourException;
+}