Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorashatalin2008-07-15 05:51:28 -0400
committerashatalin2008-07-15 05:51:28 -0400
commit9890cfadd1f09d999577f71a7ab247b707a35d42 (patch)
treee488161f62301ab677bbc90004ef32d4cac28fca
parentc6dd288a90572f30df88110cd9e35bc77059ccbc (diff)
downloadorg.eclipse.gmf-tooling-9890cfadd1f09d999577f71a7ab247b707a35d42.tar.gz
org.eclipse.gmf-tooling-9890cfadd1f09d999577f71a7ab247b707a35d42.tar.xz
org.eclipse.gmf-tooling-9890cfadd1f09d999577f71a7ab247b707a35d42.zip
[234562] - Adding child elements into a shortcut causes stack overflow
-rw-r--r--tests/org.eclipse.gmf.tests/.project5
-rw-r--r--tests/org.eclipse.gmf.tests/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--tests/org.eclipse.gmf.tests/.xpand-root1
-rw-r--r--tests/org.eclipse.gmf.tests/META-INF/MANIFEST.MF3
-rw-r--r--tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/AllTests.java6
-rw-r--r--tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/rt/EditHelpersTest.java454
-rw-r--r--tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/setup/GenProjectBaseSetup.java2
-rw-r--r--tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/setup/GenProjectSetup.java2
-rw-r--r--tests/org.eclipse.gmf.tests/templates/edithelpers/edithelper.xpt52
-rw-r--r--tests/org.eclipse.gmf.tests/templates/edithelpers/manifest.xpt30
-rw-r--r--tests/org.eclipse.gmf.tests/templates/edithelpers/plugin.xpt44
11 files changed, 599 insertions, 3 deletions
diff --git a/tests/org.eclipse.gmf.tests/.project b/tests/org.eclipse.gmf.tests/.project
index 51dd73abd..bec5d9d59 100644
--- a/tests/org.eclipse.gmf.tests/.project
+++ b/tests/org.eclipse.gmf.tests/.project
@@ -20,6 +20,11 @@
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>org.eclipse.gmf.xpand.oawBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
diff --git a/tests/org.eclipse.gmf.tests/.settings/org.eclipse.core.resources.prefs b/tests/org.eclipse.gmf.tests/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 000000000..2403c9cb5
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,3 @@
+#Sat Jul 12 20:08:29 CEST 2008
+eclipse.preferences.version=1
+encoding/templates=ISO-8859-1
diff --git a/tests/org.eclipse.gmf.tests/.xpand-root b/tests/org.eclipse.gmf.tests/.xpand-root
new file mode 100644
index 000000000..3baa5f364
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/.xpand-root
@@ -0,0 +1 @@
+templates/edithelpers
diff --git a/tests/org.eclipse.gmf.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.gmf.tests/META-INF/MANIFEST.MF
index 3344f5da7..51ec05833 100644
--- a/tests/org.eclipse.gmf.tests/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.gmf.tests/META-INF/MANIFEST.MF
@@ -20,7 +20,8 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.3.0,4.0.0)",
org.eclipse.gmf.tooldef;bundle-version="[2.0.0,3.0.0)",
org.eclipse.gmf.validate;bundle-version="[1.1.0,2.0.0)",
org.eclipse.gmf.map.edit;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.gmf.codegen;bundle-version="[2.0.0,3.0.0)"
+ org.eclipse.gmf.codegen;bundle-version="[2.0.0,3.0.0)",
+ org.eclipse.gmf.xpand;bundle-version="1.1.100"
Bundle-Activator: org.eclipse.gmf.tests.Plugin
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.gmf.tests;x-friends:="org.eclipse.gmf.tests.lite",
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/AllTests.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/AllTests.java
index 37800e8e0..c13015fe8 100644
--- a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/AllTests.java
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/AllTests.java
@@ -46,6 +46,7 @@ import org.eclipse.gmf.tests.gen.ToolDefHandocodedImplTest;
import org.eclipse.gmf.tests.gen.ViewmapProducersTest;
import org.eclipse.gmf.tests.migration.AllMigrationTests;
import org.eclipse.gmf.tests.rt.AuditRulesTest;
+import org.eclipse.gmf.tests.rt.EditHelpersTest;
import org.eclipse.gmf.tests.rt.LinkChildMetaFeatureNotFromContainerTest;
import org.eclipse.gmf.tests.rt.ElementInitializerTest;
import org.eclipse.gmf.tests.rt.LinkCreationConstraintsTest;
@@ -94,6 +95,7 @@ public class AllTests {
sessionSetup2.getGeneratedPlugin();
LinkChildMetaFeatureNotFromContainerTest.setup.getGeneratedPlugin();
LinkEcoreConstraintsTest.setup.getGeneratedPlugin();
+ EditHelpersTest.setup.getGeneratedPlugin();
} catch (final Exception e) {
suite.addTest(new TestCase("Session setup initialization problem") {
protected void runTest() throws Throwable {
@@ -165,12 +167,16 @@ public class AllTests {
suite.addTest(feed(MetricRulesTest.class, sessionSetup2));
suite.addTestSuite(GenFeatureSeqInitializerTest.class);
suite.addTestSuite(GenModelGraphAnalyzerTest.class);
+ suite.addTestSuite(EditHelpersTest.class);
//$JUnit-END$
suite.addTest(new CleanupTest("testCleanup") {
protected void performCleanup() throws Exception {
sessionSetup.cleanup();
sessionSetup2.cleanup();
+ LinkChildMetaFeatureNotFromContainerTest.setup.cleanup();
+ LinkEcoreConstraintsTest.setup.cleanup();
+ EditHelpersTest.setup.cleanup();
}
});
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/rt/EditHelpersTest.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/rt/EditHelpersTest.java
new file mode 100644
index 000000000..bd1f925c5
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/rt/EditHelpersTest.java
@@ -0,0 +1,454 @@
+/**
+ * Copyright (c) 2008 Borland Software Corp.
+ *
+ * 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:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.tests.rt;
+
+import java.io.ByteArrayInputStream;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.codegen.ecore.Generator;
+import org.eclipse.emf.codegen.util.CodeGenUtil.EclipseUtil;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.resource.impl.ResourceImpl;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.CompoundCommand;
+import org.eclipse.gmf.codegen.gmfgen.ElementType;
+import org.eclipse.gmf.codegen.gmfgen.GenDiagram;
+import org.eclipse.gmf.codegen.gmfgen.GenNode;
+import org.eclipse.gmf.codegen.gmfgen.GenTopLevelNode;
+import org.eclipse.gmf.codegen.gmfgen.MetamodelType;
+import org.eclipse.gmf.codegen.gmfgen.SpecializationType;
+import org.eclipse.gmf.common.UnexpectedBehaviourException;
+import org.eclipse.gmf.internal.common.codegen.TextEmitter;
+import org.eclipse.gmf.internal.common.codegen.XpandTextEmitter;
+import org.eclipse.gmf.internal.xpand.util.BundleResourceManager;
+import org.eclipse.gmf.mappings.Constraint;
+import org.eclipse.gmf.mappings.FeatureSeqInitializer;
+import org.eclipse.gmf.mappings.FeatureValueSpec;
+import org.eclipse.gmf.mappings.GMFMapFactory;
+import org.eclipse.gmf.mappings.Language;
+import org.eclipse.gmf.mappings.NodeMapping;
+import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
+import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
+import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.tests.Plugin;
+import org.eclipse.gmf.tests.Utils;
+import org.eclipse.gmf.tests.gef.AbstractDiagramEditorTest;
+import org.eclipse.gmf.tests.setup.DiaDefSource;
+import org.eclipse.gmf.tests.setup.DomainModelSource;
+import org.eclipse.gmf.tests.setup.GenProjectSetup;
+import org.eclipse.gmf.tests.setup.GeneratorConfiguration;
+import org.eclipse.gmf.tests.setup.MapDefSource;
+import org.eclipse.gmf.tests.setup.MapSetup;
+import org.eclipse.gmf.tests.setup.RuntimeBasedGeneratorConfiguration;
+import org.eclipse.gmf.tests.setup.SessionSetup;
+import org.eclipse.gmf.tests.setup.ToolDefSource;
+import org.osgi.framework.BundleException;
+
+public class EditHelpersTest extends AbstractDiagramEditorTest {
+
+ private static final String BEFORE_PREFIX = "before";
+
+ private static final String AFTER_PREFIX = "after";
+
+ private static final String MARKER_COMMAND_LABEL = "MarkerCommand";
+
+ public static final SessionSetup setup = new EditHelpersSessionSetup();
+
+ public EditHelpersTest(String name) {
+ super(name);
+ configure(setup);
+ }
+
+ public void testSingleEditHelperAdviceNode() {
+ Command command = getSetNewTopLeveNodeNameCommand(getSetup().getGenModel().getNodeA(), getSetup().getDomainModel().getNodeA().getNameAttr().getName());
+ Collection<IUndoableOperation> allMarkerCommands = getAllMarkerCommands(command);
+ Collection<IUndoableOperation> beforeCommands = getBeforeCommands(allMarkerCommands);
+ Collection<IUndoableOperation> afterCommands = getAfterCommands(allMarkerCommands);
+ // One before and one after command should be associated with this
+ // element type
+ assertTrue(beforeCommands.size() == 1);
+ assertTrue(getEditHelperVisualID(beforeCommands.iterator().next()) == getSetup().getGenModel().getNodeA().getVisualID());
+ assertTrue(afterCommands.size() == 1);
+ assertTrue(getEditHelperVisualID(afterCommands.iterator().next()) == getSetup().getGenModel().getNodeA().getVisualID());
+ }
+
+ public void testTwoEditHelperAdvicesNode() {
+ Command command = getSetNewTopLeveNodeNameCommand(getSetup().getGenModel().getNodeB(), getSetup().getDomainModel().getNodeB().getNameAttr().getName());
+ Collection<IUndoableOperation> allMarkerCommands = getAllMarkerCommands(command);
+ Collection<IUndoableOperation> beforeCommands = getBeforeCommands(allMarkerCommands);
+ Collection<IUndoableOperation> afterCommands = getAfterCommands(allMarkerCommands);
+ // Two before and two after commands should be associated with this
+ // element type
+ assertTrue(beforeCommands.size() == 2);
+ assertTrue(hasCommand(beforeCommands, getSetup().getGenModel().getNodeA().getVisualID()));
+ assertTrue(hasCommand(beforeCommands, getSetup().getGenModel().getNodeB().getVisualID()));
+
+ assertTrue(afterCommands.size() == 2);
+ assertTrue(hasCommand(afterCommands, getSetup().getGenModel().getNodeA().getVisualID()));
+ assertTrue(hasCommand(afterCommands, getSetup().getGenModel().getNodeB().getVisualID()));
+ }
+
+ private boolean hasCommand(Collection<IUndoableOperation> beforeCommands, int visualID) {
+ for (IUndoableOperation operation : beforeCommands) {
+ if (getEditHelperVisualID(operation) == visualID) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private Command getSetNewTopLeveNodeNameCommand(GenNode genNode, String nameAttribute) {
+ Node node = createNode(genNode, getDiagram());
+ assertNotNull(node);
+ EditPart nodeEditPart = getViewerConfiguration().findEditPart(node);
+ assertNotNull(nodeEditPart);
+ EObject nodeElement = node.getElement();
+ SetRequest setReq = new SetRequest(nodeElement, nodeElement.eClass().getEStructuralFeature(nameAttribute), "newName");
+ Command command = nodeEditPart.getCommand(new EditCommandRequestWrapper(setReq));
+ assertNotNull(command);
+ assertTrue(command.canExecute());
+ return command;
+ }
+
+ private Collection<IUndoableOperation> getAllMarkerCommands(Command command) {
+ if (command instanceof CompoundCommand) {
+ Collection<IUndoableOperation> result = new ArrayList<IUndoableOperation>();
+ for (Object object : ((CompoundCommand) command).getCommands()) {
+ result.addAll(getAllMarkerCommands((Command) object));
+ }
+ return result;
+ }
+ if (command instanceof ICommandProxy) {
+ ICommandProxy commandProxy = (ICommandProxy) command;
+ return getAllMarkerCommands(commandProxy.getICommand());
+ }
+ return Collections.emptyList();
+ }
+
+ private Collection<IUndoableOperation> getAllMarkerCommands(IUndoableOperation operation) {
+ if (operation instanceof ICompositeCommand) {
+ ICompositeCommand compositeCommand = (ICompositeCommand) operation;
+ Collection<IUndoableOperation> result = new ArrayList<IUndoableOperation>();
+ for (Iterator it = compositeCommand.iterator(); it.hasNext();) {
+ result.addAll(getAllMarkerCommands((IUndoableOperation) it.next()));
+ }
+ return result;
+ }
+ if (isMarkerCommand(operation)) {
+ return Collections.singletonList(operation);
+ }
+ return Collections.emptyList();
+ }
+
+ private boolean isMarkerCommand(IUndoableOperation operation) {
+ String label = operation.getLabel();
+ return label != null && label.indexOf(MARKER_COMMAND_LABEL) > -1;
+ }
+
+ private Collection<IUndoableOperation> getBeforeCommands(Collection<IUndoableOperation> markerCommands) {
+ Collection<IUndoableOperation> result = new ArrayList<IUndoableOperation>();
+ for (IUndoableOperation command : markerCommands) {
+ if (isBeforeMarkerCommand(command)) {
+ result.add(command);
+ }
+ }
+ return result;
+ }
+
+ private Collection<IUndoableOperation> getAfterCommands(Collection<IUndoableOperation> markerCommands) {
+ Collection<IUndoableOperation> result = new ArrayList<IUndoableOperation>();
+ for (IUndoableOperation command : markerCommands) {
+ if (isAfterMarkerCommand(command)) {
+ result.add(command);
+ }
+ }
+ return result;
+ }
+
+ private boolean isBeforeMarkerCommand(IUndoableOperation operation) {
+ assertTrue("Should be marker operation", isMarkerCommand(operation));
+ String label = operation.getLabel();
+ return BEFORE_PREFIX.equals(label.substring(0, label.indexOf(MARKER_COMMAND_LABEL)));
+ }
+
+ private boolean isAfterMarkerCommand(IUndoableOperation operation) {
+ assertTrue("Should be marker operation", isMarkerCommand(operation));
+ String label = operation.getLabel();
+ return AFTER_PREFIX.equals(label.substring(0, label.indexOf(MARKER_COMMAND_LABEL)));
+ }
+
+ private int getEditHelperVisualID(IUndoableOperation operation) {
+ assertTrue("Should be marker operation", isMarkerCommand(operation));
+ String label = operation.getLabel();
+ return Integer.valueOf(label.substring(label.indexOf(MARKER_COMMAND_LABEL) + MARKER_COMMAND_LABEL.length()));
+ }
+
+ private static final class EditHelpersSessionSetup extends SessionSetup {
+
+ private EditHelpersSessionSetup() {
+ super(new RuntimeBasedGeneratorConfiguration());
+ }
+
+ @Override
+ protected DomainModelSource createDomainModel() {
+ return new EditHelpersModelSource();
+ }
+
+ @Override
+ protected GenProjectSetup createGenProject() throws BundleException, Exception {
+ return new EditHelpersProjectSetup(getGeneratorConfiguration()).init(getGenModel());
+ }
+
+ @Override
+ public MapDefSource createMapModel() {
+ return new EditHelpersMapSetup().init(getGraphDefModel(), getDomainModel(), getToolDefModel());
+ }
+ }
+
+ private static final class EditHelpersMapSetup extends MapSetup {
+
+ @Override
+ public MapSetup init(DiaDefSource ddSource, DomainModelSource domainSource, ToolDefSource toolDef) {
+ super.init(ddSource, domainSource, toolDef);
+ addConstraint(getNodeA(), "nodeName2.oclIsUndefined()");
+ addNameInitializer(getNodeA(), domainSource.getNodeA().getNameAttr(), "'name'");
+ addConstraint(getNodeB(), "nodeName1.oclIsUndefined()");
+ addNameInitializer(getNodeB(), domainSource.getNodeB().getNameAttr(), "'name'");
+ return this;
+ }
+
+ private void addConstraint(NodeMapping node, String body) {
+ node.setDomainSpecialization(GMFMapFactory.eINSTANCE.createConstraint());
+ node.getDomainSpecialization().setLanguage(Language.OCL_LITERAL);
+ node.getDomainSpecialization().setBody(body);
+ }
+
+ private void addNameInitializer(NodeMapping node, EStructuralFeature feature, String value) {
+ FeatureSeqInitializer root = GMFMapFactory.eINSTANCE.createFeatureSeqInitializer();
+ node.setDomainInitializer(root);
+ FeatureValueSpec nameSpecification = GMFMapFactory.eINSTANCE.createFeatureValueSpec();
+ root.getInitializers().add(nameSpecification);
+ nameSpecification.setFeature(feature);
+ Constraint valueExpr = GMFMapFactory.eINSTANCE.createConstraint();
+ nameSpecification.setValue(valueExpr);
+ valueExpr.setBody(value);
+ valueExpr.setLanguage(Language.OCL_LITERAL);
+ }
+
+ }
+
+ private static final class EditHelpersProjectSetup extends GenProjectSetup {
+
+ private String myBundleName;
+
+ private BundleResourceManager myResourceManager;
+
+ private EditHelpersProjectSetup(GeneratorConfiguration generatorFactory) {
+ super(generatorFactory);
+ URL templatesURL = Plugin.getBundleContext().getBundle().getEntry("templates/edithelpers");
+ myResourceManager = new BundleResourceManager(templatesURL);
+ }
+
+ @Override
+ protected void generateDiagramPrerequisites(GenDiagram d) throws Exception {
+ super.generateDiagramPrerequisites(d);
+ generateEditHelpersProject(d);
+ }
+
+ private void generateEditHelpersProject(GenDiagram d) {
+ myBundleName = Utils.createUniquePluginID() + ".edithelpers";
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(myBundleName);
+ final Path srcPath = new Path('/' + project.getName() + "/src"); //$NON-NLS-1$
+ final int style = Generator.EMF_PLUGIN_PROJECT_STYLE;
+ final List<?> pluginVariables = null;
+ Generator.createEMFProject(srcPath, null, Collections.<IProject> emptyList(), new NullProgressMonitor(), style, pluginVariables);
+ createManifestMF();
+ for (GenTopLevelNode node : d.getTopLevelNodes()) {
+ if (node.getElementType() == null) {
+ continue;
+ }
+ createEditHelper(node.getElementType());
+ }
+ createPluginXML(d);
+ projectsToInit.add(myBundleName);
+ }
+
+ public void createManifestMF() {
+ XpandTextEmitter emiter = new XpandTextEmitter(myResourceManager, "manifest::main", getClass().getClassLoader(), null);
+ doGenerateFile(emiter, new Path("/" + myBundleName + "/META-INF/MANIFEST.MF"), myBundleName);
+ }
+
+ public void createEditHelper(ElementType elementType) {
+ String className;
+ if (elementType instanceof MetamodelType) {
+ className = ((MetamodelType) elementType).getEditHelperClassName() + "ExternalAdvice";
+ } else if (elementType instanceof SpecializationType) {
+ className = ((SpecializationType) elementType).getEditHelperAdviceClassName() + "ExternalAdvice";
+ } else {
+ return;
+ }
+ XpandTextEmitter emiter = new XpandTextEmitter(myResourceManager, "edithelper::main", getClass().getClassLoader(), null);
+ doGenerateFile(emiter, new Path("/" + myBundleName + "/src/" + className + ".java"), elementType);
+ }
+
+ public void createPluginXML(GenDiagram d) {
+ XpandTextEmitter emiter = new XpandTextEmitter(myResourceManager, "plugin::main", getClass().getClassLoader(), null);
+ doGenerateFile(emiter, new Path("/" + myBundleName + "/plugin.xml"), d);
+ }
+
+ private void doGenerateFile(TextEmitter emitter, IPath filePath, Object... param) {
+ try {
+ IPath containerPath = filePath.removeLastSegments(1);
+ EclipseUtil.findOrCreateContainer(containerPath, false, (IPath) null, new NullProgressMonitor());
+ String genText = emitter.generate(new NullProgressMonitor(), param);
+ IFile f = ResourcesPlugin.getWorkspace().getRoot().getFile(filePath);
+ f.create(new ByteArrayInputStream(genText.getBytes(f.getCharset())), true, new NullProgressMonitor());
+ } catch (InvocationTargetException ex) {
+ fail(ex.getMessage());
+ } catch (UnexpectedBehaviourException ex) {
+ fail(ex.getMessage());
+ } catch (CoreException ex) {
+ fail(ex.getMessage());
+ } catch (UnsupportedEncodingException ex) {
+ fail(ex.getMessage());
+ } catch (InterruptedException ex) {
+ fail(ex.getMessage());
+ }
+ }
+ }
+
+ private static final class EditHelpersModelSource implements DomainModelSource {
+
+ private EClass myDiagramElement;
+
+ private EPackage myPackage;
+
+ private NodeData myNode1;
+
+ private LinkData myClassLink;
+
+ private NodeData myNode2;
+
+ private EReference myRefLink;
+ {
+ myPackage = EcoreFactory.eINSTANCE.createEPackage();
+ myPackage.setName("eh");
+ myPackage.setNsPrefix("sampleEH");
+ Calendar c = Calendar.getInstance();
+ myPackage.setNsURI("uri://eclipse/gmf/tests/sample/eh/" + c.get(Calendar.HOUR_OF_DAY) + '/' + c.get(Calendar.MINUTE) + '/');
+
+ myDiagramElement = EcoreFactory.eINSTANCE.createEClass();
+ myDiagramElement.setName("DiagramElement");
+ myPackage.getEClassifiers().add(myDiagramElement);
+
+ EClass node = EcoreFactory.eINSTANCE.createEClass();
+ node.setName("Node");
+ myPackage.getEClassifiers().add(node);
+ EAttribute node1Name = EcoreFactory.eINSTANCE.createEAttribute();
+ node1Name.setName("nodeName1");
+ node1Name.setEType(EcorePackage.eINSTANCE.getEString());
+ node.getEStructuralFeatures().add(node1Name);
+ EAttribute node2Name = EcoreFactory.eINSTANCE.createEAttribute();
+ node2Name.setName("nodeName2");
+ node2Name.setEType(EcorePackage.eINSTANCE.getEString());
+ node.getEStructuralFeatures().add(node2Name);
+
+ EReference nodeContainment = EcoreFactory.eINSTANCE.createEReference();
+ nodeContainment.setName("nodeContainment");
+ nodeContainment.setContainment(true);
+ nodeContainment.setUpperBound(-1);
+ nodeContainment.setEType(node);
+ myDiagramElement.getEStructuralFeatures().add(nodeContainment);
+
+ EClass classLink = EcoreFactory.eINSTANCE.createEClass();
+ classLink.setName("Link");
+ myPackage.getEClassifiers().add(classLink);
+
+ EReference linkContainment = EcoreFactory.eINSTANCE.createEReference();
+ linkContainment.setName("linkContainment");
+ linkContainment.setEType(classLink);
+ linkContainment.setUpperBound(-1);
+ linkContainment.setContainment(true);
+ node.getEStructuralFeatures().add(linkContainment);
+
+ EReference linkTarget = EcoreFactory.eINSTANCE.createEReference();
+ linkTarget.setName("target");
+ linkTarget.setEType(node);
+ linkTarget.setUpperBound(1);
+ classLink.getEStructuralFeatures().add(linkTarget);
+
+ myRefLink = EcoreFactory.eINSTANCE.createEReference();
+ myRefLink.setName("refLink");
+ myRefLink.setEType(node);
+ myRefLink.setUpperBound(-1);
+ node.getEStructuralFeatures().add(myRefLink);
+
+ new ResourceImpl(URI.createURI("uri://org.eclipse.gmf.eh/tests/DomainModelSetup")).getContents().add(myPackage);
+
+ myNode1 = new NodeData(node, node1Name, nodeContainment);
+ myNode2 = new NodeData(node, node2Name, nodeContainment);
+ myClassLink = new LinkData(classLink, linkTarget, linkContainment);
+ }
+
+ public EClass getDiagramElement() {
+ return myDiagramElement;
+ }
+
+ public LinkData getLinkAsClass() {
+ return myClassLink;
+ }
+
+ public EReference getLinkAsRef() {
+ return myRefLink;
+ }
+
+ public EPackage getModel() {
+ return myPackage;
+ }
+
+ public NodeData getNodeA() {
+ return myNode1;
+ }
+
+ public NodeData getNodeB() {
+ return myNode2;
+ }
+ }
+
+}
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/setup/GenProjectBaseSetup.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/setup/GenProjectBaseSetup.java
index 7645e8e83..8a79954d4 100644
--- a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/setup/GenProjectBaseSetup.java
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/setup/GenProjectBaseSetup.java
@@ -55,7 +55,7 @@ import org.osgi.framework.Constants;
* @author artem
*/
public class GenProjectBaseSetup {
- private final Set<String> projectsToInit = new LinkedHashSet<String>();
+ protected final Set<String> projectsToInit = new LinkedHashSet<String>();
private CompileUtil compileUtil;
private GeneratorConfiguration myGeneratorFactory;
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/setup/GenProjectSetup.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/setup/GenProjectSetup.java
index 4c297bfc3..c2daf9512 100644
--- a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/setup/GenProjectSetup.java
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/setup/GenProjectSetup.java
@@ -73,7 +73,7 @@ public class GenProjectSetup extends GenProjectBaseSetup {
RegistryFactory.getRegistry().addRegistryChangeListener(listener, "org.eclipse.ui");
}
myBundle = null;
- super.generateAndCompile(diaGenSource);
+ generateAndCompile(diaGenSource);
myBundle.start();
registerExtensions(myBundle);
registerEMFEditExtensions();
diff --git a/tests/org.eclipse.gmf.tests/templates/edithelpers/edithelper.xpt b/tests/org.eclipse.gmf.tests/templates/edithelpers/edithelper.xpt
new file mode 100644
index 000000000..9f2032671
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/templates/edithelpers/edithelper.xpt
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2006, 2007 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:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT "http://www.eclipse.org/gmf/2008/GenModel"»
+
+«DEFINE main FOR gmfgen::ElementType-»
+public class «EXPAND className» extends org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice {
+
+ public org.eclipse.gmf.runtime.common.core.command.ICommand getBeforeEditCommand(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest request) {
+ return new MarkerCommand("before");
+ }
+
+ public org.eclipse.gmf.runtime.common.core.command.ICommand getAfterEditCommand(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest request) {
+ return new MarkerCommand("after");
+ }
+
+ private class MarkerCommand extends org.eclipse.gmf.runtime.common.core.command.AbstractCommand {
+ public MarkerCommand(String name) {
+ super(name + "MarkerCommand«diagramElement.visualID»");
+ }
+
+ protected org.eclipse.gmf.runtime.common.core.command.CommandResult doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor progressMonitor, org.eclipse.core.runtime.IAdaptable info) {
+ return null;
+ }
+
+ protected org.eclipse.gmf.runtime.common.core.command.CommandResult doRedoWithResult(org.eclipse.core.runtime.IProgressMonitor progressMonitor, org.eclipse.core.runtime.IAdaptable info) {
+ return null;
+ }
+
+ protected org.eclipse.gmf.runtime.common.core.command.CommandResult doUndoWithResult(org.eclipse.core.runtime.IProgressMonitor progressMonitor, org.eclipse.core.runtime.IAdaptable info) {
+ return null;
+ }
+ }
+}
+«ENDDEFINE»
+
+«DEFINE className FOR gmfgen::ElementType-»
+ «ERROR "Should never be called"-»
+«ENDDEFINE»
+
+«DEFINE className FOR gmfgen::MetamodelType»«editHelperClassName»ExternalAdvice«ENDDEFINE»
+
+«DEFINE className FOR gmfgen::SpecializationType»«editHelperAdviceClassName»ExternalAdvice«ENDDEFINE» \ No newline at end of file
diff --git a/tests/org.eclipse.gmf.tests/templates/edithelpers/manifest.xpt b/tests/org.eclipse.gmf.tests/templates/edithelpers/manifest.xpt
new file mode 100644
index 000000000..08489374f
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/templates/edithelpers/manifest.xpt
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2006, 2007 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:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
+
+«DEFINE main FOR String-»
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: editHelpers
+Bundle-SymbolicName: «this»;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-ClassPath: ., bin/
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.gmf.runtime.emf.type.core,
+ org.eclipse.gmf.runtime.common.core,
+ org.eclipse.gmf.runtime.emf.type.core,
+ org.eclipse.core.runtime
+Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy
+«ENDDEFINE» \ No newline at end of file
diff --git a/tests/org.eclipse.gmf.tests/templates/edithelpers/plugin.xpt b/tests/org.eclipse.gmf.tests/templates/edithelpers/plugin.xpt
new file mode 100644
index 000000000..2ab4c831b
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/templates/edithelpers/plugin.xpt
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2006, 2007 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:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT "http://www.eclipse.org/gmf/2008/GenModel"»
+
+«DEFINE main FOR gmfgen::GenDiagram-»
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin>
+ <extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypes">
+«EXPAND registerHelperAdvice FOREACH topLevelNodes.select(n|n.elementType != null)-»
+ </extension>
+ <extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings">
+ <binding context="«editorGen.plugin.iD».TypeContext">
+«EXPAND registerHelperAdviceBinding FOREACH topLevelNodes.select(n|n.elementType != null)-»
+ </binding>
+ </extension>
+</plugin>
+«ENDDEFINE»
+
+«DEFINE registerHelperAdvice FOR gmfgen::GenTopLevelNode-»
+ <metamodel nsURI="«modelFacet.metaClass.genPackage.ecorePackage.nsURI»">
+ <adviceBinding
+ class="«EXPAND edithelper::className FOR elementType»"
+ id="«EXPAND id FOR elementType»"
+ inheritance="none"
+ typeId="«elementType.uniqueIdentifier»"/>
+ </metamodel>
+«ENDDEFINE»
+
+«DEFINE id FOR gmfgen::ElementType»«uniqueIdentifier»_ExternalAdvice«ENDDEFINE»
+
+«DEFINE registerHelperAdviceBinding FOR gmfgen::GenTopLevelNode-»
+ <advice ref="«EXPAND id FOR elementType»"/>
+«ENDDEFINE» \ No newline at end of file

Back to the top