Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Fluegge2011-05-09 12:39:20 -0400
committerMartin Fluegge2011-05-09 12:39:20 -0400
commit637bbeff72e4c82953be6bf019e14da6c95a2557 (patch)
treeaed5b41ab4d09ffecfb7684083d8c0ae8c01d58d /plugins/org.eclipse.emf.cdo.dawn.codegen
parenta5c1ac1dbe2bcd33af49c034b8d74222c081528f (diff)
downloadcdo-637bbeff72e4c82953be6bf019e14da6c95a2557.tar.gz
cdo-637bbeff72e4c82953be6bf019e14da6c95a2557.tar.xz
cdo-637bbeff72e4c82953be6bf019e14da6c95a2557.zip
[344403] [Dawn] Separated Dawn Codegen from specific implementations
https://bugs.eclipse.org/bugs/show_bug.cgi?id=344403
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.dawn.codegen')
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.codegen/META-INF/MANIFEST.MF20
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.codegen/about.properties2
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.codegen/build.properties1
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.codegen/plugin.properties7
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.codegen/plugin.xml57
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.codegen/src/metamodel/DawnCodeGen.ecore57
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/actions/GenerateDawnGenModelAction.java143
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/creators/impl/AbstractFragmentCreator.java158
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/messages/Messages.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/util/DawnWorkflowUtil.java22
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/util/Utils.ext5
11 files changed, 258 insertions, 216 deletions
diff --git a/plugins/org.eclipse.emf.cdo.dawn.codegen/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.dawn.codegen/META-INF/MANIFEST.MF
index b29d08b49f..c50c48ee52 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.codegen/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.dawn.codegen/META-INF/MANIFEST.MF
@@ -11,32 +11,26 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)",
org.eclipse.jdt.launching;bundle-version="[3.4.0,4.0.0)",
org.eclipse.emf.ecore;bundle-version="[2.5.0,3.0.0)",
org.eclipse.emf.ecore.xmi;bundle-version="[2.5.0,3.0.0)",
- org.eclipse.emf.codegen.ecore;bundle-version="[2.6.0,3.0.0)",
- org.eclipse.emf.codegen;bundle-version="[2.6.0,3.0.0)",
org.eclipse.emf.mwe.core;bundle-version="[1.0.0,2.0.0)",
org.eclipse.emf.mwe.utils;bundle-version="[0.7.0,2.0.0)",
org.eclipse.jdt.core;bundle-version="[3.4.0,4.0.0)",
org.eclipse.pde;bundle-version="[3.4.0,4.0.0)",
org.eclipse.pde.core;bundle-version="[3.4.0,4.0.0)",
org.eclipse.jface.text;bundle-version="[3.5.0,4.0.0)",
- org.eclipse.xpand;bundle-version="[0.7.0,2.0.0)",
- org.eclipse.xtend;bundle-version="[0.7.0,2.0.0)",
+ org.eclipse.xpand;bundle-version="[1.1.0,2.0.0)",
org.eclipse.xtend.typesystem.emf;bundle-version="[0.7.0,2.0.0)",
- org.eclipse.gmf.codegen;bundle-version="[2.2.0,3.0.0)",
- org.eclipse.gmf.graphdef.codegen;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.gmf.validate;bundle-version="[1.2.0,2.0.0)",
- org.eclipse.emf.cdo.dawn.codegen.dawngenmodel;bundle-version="[1.0.0,2.0.0)"
+ org.eclipse.emf.cdo.dawn.codegen.dawngenmodel;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.emf.codegen.ecore;bundle-version="[2.6.0,3.0.0)"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Export-Package: metamodel;version="1.0.0";x-internal:=true,
+Export-Package: metamodel;version="1.0.0",
org.eclipse.emf.cdo.dawn.codegen;version="1.0.0",
- org.eclipse.emf.cdo.dawn.codegen.actions;version="1.0.0";x-internal:=true,
+ org.eclipse.emf.cdo.dawn.codegen.actions;version="1.0.0",
org.eclipse.emf.cdo.dawn.codegen.creators;version="1.0.0",
org.eclipse.emf.cdo.dawn.codegen.creators.impl;version="1.0.0",
- org.eclipse.emf.cdo.dawn.codegen.messages;version="1.0.0";x-internal:=true,
+ org.eclipse.emf.cdo.dawn.codegen.messages;version="1.0.0",
org.eclipse.emf.cdo.dawn.codegen.util;version="1.0.0",
- template;version="1.0.0";x-internal:=true,
- workflow;version="1.0.0";x-internal:=true
+ template;version="1.0.0"
Bundle-Localization: plugin
Bundle-Vendor: %providerName
Import-Package: org.antlr.runtime;version="[3.0.0,4.0.0)",
diff --git a/plugins/org.eclipse.emf.cdo.dawn.codegen/about.properties b/plugins/org.eclipse.emf.cdo.dawn.codegen/about.properties
index 1e377256a3..2bdbe44042 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.codegen/about.properties
+++ b/plugins/org.eclipse.emf.cdo.dawn.codegen/about.properties
@@ -5,7 +5,7 @@
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
-# Eike Stepper - initial API and implementation
+# Martin Fluegge - initial API and implementation
# NLS_MESSAGEFORMAT_VAR
diff --git a/plugins/org.eclipse.emf.cdo.dawn.codegen/build.properties b/plugins/org.eclipse.emf.cdo.dawn.codegen/build.properties
index d76fed7390..f05f39c7ee 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.codegen/build.properties
+++ b/plugins/org.eclipse.emf.cdo.dawn.codegen/build.properties
@@ -12,7 +12,6 @@ source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
- plugin.xml,\
about.html,\
copyright.txt,\
plugin.properties,\
diff --git a/plugins/org.eclipse.emf.cdo.dawn.codegen/plugin.properties b/plugins/org.eclipse.emf.cdo.dawn.codegen/plugin.properties
index fac752abf5..925beaf0f0 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.codegen/plugin.properties
+++ b/plugins/org.eclipse.emf.cdo.dawn.codegen/plugin.properties
@@ -5,10 +5,9 @@
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
-# Eike Stepper - initial API and implementation
+# Martin Fluegge - initial API and implementation
pluginName = CDO Dawn Codegen
providerName = Eclipse Modeling Project
-generate.emf.label = Generate Dawn EMF Fragment
-generate.gmf.label = Generate Dawn GMF Fragment
-generate.genmodel.label = Generate Dawn GenModel
+
+
diff --git a/plugins/org.eclipse.emf.cdo.dawn.codegen/plugin.xml b/plugins/org.eclipse.emf.cdo.dawn.codegen/plugin.xml
deleted file mode 100644
index dc119483ca..0000000000
--- a/plugins/org.eclipse.emf.cdo.dawn.codegen/plugin.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<!--
- Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- 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:
- Eike Stepper - initial API and implementation
--->
-
-<plugin>
- <extension
- point="org.eclipse.ui.popupMenus">
- <objectContribution
- adaptable="false"
- id="org.eclipse.emf.cdo.dawn.codegen.generate"
- nameFilter="*.dawngenmodel"
- objectClass="org.eclipse.core.resources.IFile">
- <action
- class="org.eclipse.emf.cdo.dawn.codegen.actions.GenerateEMFFragmentAction"
- id="org.eclipse.emf.cdo.dawn.codegen.generateClientaction"
- label="%generate.emf.label">
- </action>
- <action
- class="org.eclipse.emf.cdo.dawn.codegen.actions.GenerateClientCodeAction"
- id="org.eclipse.emf.cdo.dawn.codegen.generateClientaction"
- label="%generate.gmf.label">
- </action>
- </objectContribution>
- <objectContribution
- adaptable="false"
- id="org.eclipse.emf.cdo.dawn.codegen.generate.client"
- nameFilter="*.gmfgen"
- objectClass="org.eclipse.core.resources.IFile">
- <action
- class="org.eclipse.emf.cdo.dawn.codegen.actions.GenerateDawnGenModelAction"
- id="org.eclipse.emf.cdo.dawn.codegen.dawngenmodelaction"
- label="%generate.genmodel.label">
- </action>
- </objectContribution>
- <objectContribution
- adaptable="false"
- id="org.eclipse.emf.cdo.dawn.codegen.generate.emf"
- nameFilter="*.genmodel"
- objectClass="org.eclipse.core.resources.IFile">
- <action
- class="org.eclipse.emf.cdo.dawn.codegen.actions.GenerateDawnGenModelAction"
- id="org.eclipse.emf.cdo.dawn.codegen.dawngenmodelaction"
- label="%generate.genmodel.label">
- </action>
- </objectContribution>
- </extension>
-
-</plugin>
diff --git a/plugins/org.eclipse.emf.cdo.dawn.codegen/src/metamodel/DawnCodeGen.ecore b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/metamodel/DawnCodeGen.ecore
index e49cb3d16b..a21790619b 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.codegen/src/metamodel/DawnCodeGen.ecore
+++ b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/metamodel/DawnCodeGen.ecore
@@ -1,38 +1,19 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ecore:EPackage xmi:version="2.0"
- xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="dawngenmodel"
- nsURI="http://www.eclipse.org/emf/cdo/dawn/2010/GenModel" nsPrefix="dawngenmodel">
- <eClassifiers xsi:type="ecore:EClass" name="DawnGenerator">
- <eStructuralFeatures xsi:type="ecore:EReference" name="emfFragmentgenerator" eType="#//DawnEMFGenerator"
- containment="true"/>
- <eStructuralFeatures xsi:type="ecore:EReference" name="gmfFragmentgenerator" eType="#//DawnGMFGenerator"
- containment="true"/>
- </eClassifiers>
- <eClassifiers xsi:type="ecore:EClass" name="DawnFragmentGenerator">
- <eStructuralFeatures xsi:type="ecore:EAttribute" name="fragmentName" eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
- <eStructuralFeatures xsi:type="ecore:EAttribute" name="dawnEditorClassName" eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
- <eStructuralFeatures xsi:type="ecore:EReference" name="emfGenModel" eType="ecore:EClass platform:/plugin/org.eclipse.emf.codegen.ecore/model/GenModel.ecore#//GenModel"/>
- </eClassifiers>
- <eClassifiers xsi:type="ecore:EClass" name="DawnGMFGenerator" eSuperTypes="#//DawnFragmentGenerator">
- <eStructuralFeatures xsi:type="ecore:EAttribute" name="dawnDocumentProviderClassName"
- eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
- <eStructuralFeatures xsi:type="ecore:EAttribute" name="dawnEditorUtilClassName"
- eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
- <eStructuralFeatures xsi:type="ecore:EAttribute" name="dawnCreationWizardClassName"
- eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
- <eStructuralFeatures xsi:type="ecore:EAttribute" name="dawnCanonicalEditingPolicyClassName"
- eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
- <eStructuralFeatures xsi:type="ecore:EAttribute" name="dawnDiagramEditPartClassName"
- eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
- <eStructuralFeatures xsi:type="ecore:EAttribute" name="dawnEditPartFactoryClassName"
- eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
- <eStructuralFeatures xsi:type="ecore:EAttribute" name="dawnEditPartProviderClassName"
- eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
- <eStructuralFeatures xsi:type="ecore:EAttribute" name="dawnEditPolicyProviderClassName"
- eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
- <eStructuralFeatures xsi:type="ecore:EReference" name="GMFGenEditorGenerator"
- eType="ecore:EClass platform:/plugin/org.eclipse.gmf.codegen/models/gmfgen.ecore#//GenEditorGenerator"/>
- </eClassifiers>
- <eClassifiers xsi:type="ecore:EClass" name="DawnEMFGenerator" eSuperTypes="#//DawnFragmentGenerator"/>
-</ecore:EPackage>
+<?xml version="1.0" encoding="UTF-8"?>
+<ecore:EPackage xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="dawngenmodel"
+ nsURI="http://www.eclipse.org/emf/cdo/dawn/2010/GenModel" nsPrefix="dawngenmodel">
+ <eClassifiers xsi:type="ecore:EClass" name="DawnGenerator">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="conflictColor" eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="localLockColor" eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="remoteLockColor" eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="fragmentGenerators" upperBound="-1"
+ eType="#//DawnFragmentGenerator" eOpposite="#//DawnFragmentGenerator/dawnGenerator"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="DawnFragmentGenerator">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="fragmentName" eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="dawnEditorClassName" eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="dawnGenerator" eType="#//DawnGenerator"
+ eOpposite="#//DawnGenerator/fragmentGenerators"/>
+ </eClassifiers>
+</ecore:EPackage>
diff --git a/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/actions/GenerateDawnGenModelAction.java b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/actions/GenerateDawnGenModelAction.java
index 701bc6fe0b..e5ef1ca375 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/actions/GenerateDawnGenModelAction.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/actions/GenerateDawnGenModelAction.java
@@ -10,13 +10,11 @@
*/
package org.eclipse.emf.cdo.dawn.codegen.actions;
-import org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.DawnEMFGenerator;
-import org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.DawnGMFGenerator;
+import org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.DawnFragmentGenerator;
import org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.DawnGenerator;
import org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.DawngenmodelFactory;
import org.eclipse.emf.cdo.dawn.codegen.util.ProjectCreationHelper;
-import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
@@ -26,7 +24,6 @@ import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.gmf.codegen.gmfgen.GenEditorGenerator;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ISelection;
@@ -43,13 +40,19 @@ import java.util.Collections;
/**
* @author Martin Fluegge
*/
-public class GenerateDawnGenModelAction implements IObjectActionDelegate
+public abstract class GenerateDawnGenModelAction implements IObjectActionDelegate
{
- private IResource selectedElement;
+ /**
+ * @since 1.0
+ */
+ protected IResource selectedElement;
- public static final String dawngenmodelFileExtension = "dawngenmodel";
+ public final static String dawngenmodelFileExtension = "dawngenmodel";
- private final String generalPrefix = "Dawn";
+ /**
+ * @since 1.0
+ */
+ protected final String generalPrefix = "Dawn";
public void setActivePart(IAction action, IWorkbenchPart targetPart)
{
@@ -71,34 +74,28 @@ public class GenerateDawnGenModelAction implements IObjectActionDelegate
String path = genModelFile.replace(genFile.getName(), "");
ResourceSet resourceSet = createResourceSet();
-
String modelname = "default";
-
modelname = getModelName(genFile);
- Resource dawnGenModelResource = getDawnGenModelResource(path, modelname, resourceSet);
+ Resource dawnGenModelResource = getResource(path, modelname, resourceSet, dawngenmodelFileExtension);
+ Resource dawnFragmentModelResource = getDawnFragmentModelResource(path, modelname, resourceSet);
+
DawnGenerator dawnGenerator = getDawngenerator(dawnGenModelResource);
- if (genFile.getName().endsWith(".gmfgen"))
- {
- DawnGMFGenerator dawnGMFGenerator = createDawnGMFGenerator(genModelFile, resourceSet);
- dawnGenerator.setGmfFragmentgenerator(dawnGMFGenerator);
- }
- else if (genFile.getName().endsWith(".genmodel"))
- {
- DawnEMFGenerator dawnEMFGenerator = createDawnEMFGenerator(genModelFile, resourceSet);
- dawnGenerator.setEmfFragmentgenerator(dawnEMFGenerator);
- }
+ DawnFragmentGenerator fragmentGenerator = getDawnFragmentGenerator(genFile, resourceSet);
+ fragmentGenerator.setDawnGenerator(dawnGenerator);
dawnGenModelResource.getContents().add(dawnGenerator);
+ dawnFragmentModelResource.getContents().add(fragmentGenerator);
try
{
dawnGenModelResource.save(Collections.EMPTY_MAP);
+ dawnFragmentModelResource.save(Collections.EMPTY_MAP);
}
- catch (IOException e)
+ catch (IOException ex)
{
- e.printStackTrace();
+ throw new RuntimeException(ex);
}
ProjectCreationHelper.refreshProject(null, monitor);
@@ -121,41 +118,25 @@ public class GenerateDawnGenModelAction implements IObjectActionDelegate
});
}
- catch (InvocationTargetException e)
+ catch (InvocationTargetException ex)
{
- e.printStackTrace();
+ throw new RuntimeException(ex);
}
- catch (InterruptedException e)
+ catch (InterruptedException ex)
{
- e.printStackTrace();
+ throw new RuntimeException(ex);
}
}
- private String getDawnEditorClassName(GenEditorGenerator editorGenerator)
- {
- String dawnEditorClassName = editorGenerator.getEditor().getClassName();
- if (dawnEditorClassName == null || dawnEditorClassName.equals(""))
- {
- dawnEditorClassName = "Dawn" + editorGenerator.getDomainGenModel() + "DiagramEditor";
- }
- dawnEditorClassName = generalPrefix + dawnEditorClassName;
- return dawnEditorClassName;
- }
-
- private DawnEMFGenerator createDawnEMFGenerator(String genModelFile, ResourceSet resourceSet)
- {
- DawnEMFGenerator dawnEMFGenerator = DawngenmodelFactory.eINSTANCE.createDawnEMFGenerator();
+ /**
+ * @since 1.0
+ */
+ protected abstract Resource getDawnFragmentModelResource(String path, String modelname, ResourceSet resourceSet);
- URI emfGenModelResourceUri = URI.createURI(genModelFile);
- Resource emfGenModelResource = resourceSet.getResource(emfGenModelResourceUri, true);
-
- GenModel genModel = (GenModel)emfGenModelResource.getContents().get(0);
-
- dawnEMFGenerator.setEmfGenModel(genModel);
- dawnEMFGenerator.setDawnEditorClassName("Dawn" + genModel.getModelName() + "Editor");
- dawnEMFGenerator.setFragmentName(genModel.getEditorPluginID() + ".dawn");
- return dawnEMFGenerator;
- }
+ /**
+ * @since 1.0
+ */
+ protected abstract DawnFragmentGenerator getDawnFragmentGenerator(IFile genFile, ResourceSet resourceSet);
private String getModelName(IFile genFile)
{
@@ -163,66 +144,36 @@ public class GenerateDawnGenModelAction implements IObjectActionDelegate
return genFile.getName().substring(0, lastIndexOf);
}
- private DawnGMFGenerator createDawnGMFGenerator(String gmfGenModelFile, ResourceSet resourceSet)
- {
- URI gmfGenModelResourceUri = URI.createURI(gmfGenModelFile);
- Resource gmfGenModelResource = resourceSet.getResource(gmfGenModelResourceUri, true);
-
- GenEditorGenerator editorGenerator = (GenEditorGenerator)gmfGenModelResource.getContents().get(0);
-
- DawnGMFGenerator dawnGMFGenerator = DawngenmodelFactory.eINSTANCE.createDawnGMFGenerator();
-
- String dawnEditorClassName = getDawnEditorClassName(editorGenerator);
-
- dawnGMFGenerator.setDawnEditorClassName(dawnEditorClassName);
- dawnGMFGenerator.setFragmentName(editorGenerator.getPlugin().getID() + ".dawn");
- dawnGMFGenerator.setDawnCanonicalEditingPolicyClassName(generalPrefix
- + editorGenerator.getDiagram().getCanonicalEditPolicyClassName());
- dawnGMFGenerator.setDawnCreationWizardClassName(generalPrefix
- + editorGenerator.getDiagram().getCreationWizardClassName());
- dawnGMFGenerator.setDawnDiagramEditPartClassName(generalPrefix
- + editorGenerator.getDiagram().getEditPartClassName());
- dawnGMFGenerator.setDawnDocumentProviderClassName(generalPrefix
- + editorGenerator.getDiagram().getDocumentProviderClassName());
- dawnGMFGenerator.setDawnEditorUtilClassName(generalPrefix
- + editorGenerator.getDiagram().getDiagramEditorUtilClassName());
- dawnGMFGenerator.setDawnEditPartFactoryClassName(generalPrefix
- + editorGenerator.getDiagram().getEditPartFactoryClassName());
- dawnGMFGenerator.setDawnEditPartProviderClassName(generalPrefix
- + editorGenerator.getDiagram().getEditPartProviderClassName());
- dawnGMFGenerator.setDawnEditPolicyProviderClassName(generalPrefix
- + editorGenerator.getDiagram().getEditPartProviderClassName().replace("EditPart", "EditPolicy"));
-
- dawnGMFGenerator.setGMFGenEditorGenerator(editorGenerator);
- return dawnGMFGenerator;
- }
-
- private Resource getDawnGenModelResource(String path, String modelname, ResourceSet resourceSet)
+ /**
+ * @since 1.0
+ */
+ protected Resource getResource(String path, String modelname, ResourceSet resourceSet, String extension)
{
- String dawnGenModelResourcePath = path + "" + modelname + "." + dawngenmodelFileExtension;
- URI uri = URI.createURI(dawnGenModelResourcePath);
- Resource dawnGenModelResource = null;
+ String resourcePath = path + "" + modelname + "." + extension;
+ URI uri = URI.createURI(resourcePath);
+ Resource resource = null;
try
{
- dawnGenModelResource = resourceSet.getResource(uri, true);
+ resource = resourceSet.getResource(uri, true);
}
catch (Exception ignore)
{
// ignore
}
- if (dawnGenModelResource == null)
+ if (resource == null)
{
- dawnGenModelResource = resourceSet.createResource(uri);
+ resource = resourceSet.createResource(uri);
}
- return dawnGenModelResource;
+ return resource;
}
- private ResourceSet createResourceSet()
+ /**
+ * @since 1.0
+ */
+ protected ResourceSet createResourceSet()
{
ResourceSet resourceSet = new ResourceSetImpl();
- resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("gmfgen", new XMIResourceFactoryImpl());
- resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("genmodel", new XMIResourceFactoryImpl());
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
.put(dawngenmodelFileExtension, new XMIResourceFactoryImpl());
return resourceSet;
diff --git a/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/creators/impl/AbstractFragmentCreator.java b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/creators/impl/AbstractFragmentCreator.java
new file mode 100644
index 0000000000..30b33b0ba7
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/creators/impl/AbstractFragmentCreator.java
@@ -0,0 +1,158 @@
+/**
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.codegen.creators.impl;
+
+import org.eclipse.emf.cdo.dawn.codegen.actions.GenerateDawnGenModelAction;
+import org.eclipse.emf.cdo.dawn.codegen.creators.Creator;
+import org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.DawnFragmentGenerator;
+import org.eclipse.emf.cdo.dawn.codegen.util.ProjectCreationHelper;
+import org.eclipse.emf.cdo.dawn.codegen.util.Utils;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
+import org.eclipse.emf.mwe.core.WorkflowEngine;
+import org.eclipse.emf.mwe.core.monitor.NullProgressMonitor;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.core.JavaCore;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Martin Fluegge
+ * @since 1.0
+ */
+public abstract class AbstractFragmentCreator implements Creator
+{
+ protected final IResource selectedElement;
+
+ protected final String PLUGIN_NATURE = "org.eclipse.pde.PluginNature";
+
+ protected final String JAVA_NATURE = JavaCore.NATURE_ID;
+
+ public AbstractFragmentCreator(IResource selectedElement)
+ {
+ this.selectedElement = selectedElement;
+ }
+
+ public void create(IProgressMonitor monitor)
+ {
+ IFile dawnGenModelFile = (IFile)selectedElement;
+
+ ResourceSet resourceSet = new ResourceSetImpl();
+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
+ .put(GenerateDawnGenModelAction.dawngenmodelFileExtension, new XMIResourceFactoryImpl());
+
+ Resource dawnGenModelResource = resourceSet.getResource(
+ URI.createURI(dawnGenModelFile.getRawLocationURI().toString()), true);
+
+ DawnFragmentGenerator dawnFragmentGenerator = (DawnFragmentGenerator)dawnGenModelResource.getContents().get(0);
+ // DawnGenerator dawnGenerator = dawnFragmentGenerator.getDawnGenerator();
+
+ if (dawnFragmentGenerator != null)
+ {
+ monitor.subTask("Create client fragment's basic structure");
+
+ // String[] natures = new String[] { JavaCore.NATURE_ID, PDE.PLUGIN_NATURE };
+ String[] natures = new String[] { JAVA_NATURE, PLUGIN_NATURE };
+
+ ProjectCreationHelper projectCreationHelper = new ProjectCreationHelper();
+ projectCreationHelper.setName(dawnFragmentGenerator.getFragmentName());
+ projectCreationHelper.setNatures(natures);
+ IProject project;
+ try
+ {
+ project = projectCreationHelper.createProject();
+ projectCreationHelper.createJavaProject(project);
+
+ monitor.worked(100);
+
+ monitor.subTask("Creating folder structure...");
+ projectCreationHelper.createFolder("lib", project);
+ projectCreationHelper.createFolder("META-INF", project);
+ projectCreationHelper.createFolder("icons", project);
+
+ monitor.worked(100);
+
+ monitor.subTask("Creating generic content...");
+ createGenericContent(monitor, project.getLocation());
+ ProjectCreationHelper.refreshProject(project, monitor);
+ }
+ catch (CoreException ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ catch (InvocationTargetException ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ catch (InterruptedException ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ }
+ else
+ {
+ throw new RuntimeException("Could not find DawnFragmentGenerator for " + selectedElement);
+ }
+
+ monitor.worked(100);
+ }
+
+ protected abstract URL getWorkflowURL();
+
+ protected void createGenericContent(IProgressMonitor monitor, IPath location)
+ {
+ IFile file = (IFile)selectedElement;
+ Map<String, String> properties = new HashMap<String, String>();
+
+ Map<String, ?> slotMap = new HashMap<String, Object>();
+ try
+ {
+ String dawnGenFile = file.getRawLocationURI().toString();// ;file.getLocation().toFile().getAbsoluteFile().toURI().toURL().toString();
+
+ IFile dawnGen = (IFile)selectedElement;
+ IProject hostProject = dawnGen.getProject();
+
+ Utils.setPackage(hostProject.getName());
+
+ String ouputFolder = location.toFile().getAbsoluteFile().toString();// + "/" + hostProject.getName()+".diagram";
+
+ properties.put("model", dawnGenFile);
+ properties.put("src-gen", ouputFolder);
+
+ URL workFlowURL = getWorkflowURL();
+ // WorkflowRunner workflowRunner = new WorkflowRunner();
+ String workflow = FileLocator.toFileURL(workFlowURL).getFile();
+
+ // workflowRunner.run(workflow, , properties, slotMap);
+
+ new WorkflowEngine().run(workflow, new NullProgressMonitor(), properties, slotMap);
+ }
+ catch (IOException ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/messages/Messages.java b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/messages/Messages.java
index c287a1e4b4..2493d5d842 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/messages/Messages.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/messages/Messages.java
@@ -14,7 +14,7 @@ import org.eclipse.osgi.util.NLS;
/**
* @author Martin Fluegge
- * @since 0.3
+ * @since 1.0
*/
public class Messages extends NLS
{
diff --git a/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/util/DawnWorkflowUtil.java b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/util/DawnWorkflowUtil.java
new file mode 100644
index 0000000000..534cbcd090
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/util/DawnWorkflowUtil.java
@@ -0,0 +1,22 @@
+/**
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.codegen.util;
+
+import java.net.URL;
+
+/**
+ * @author Martin Fluegge
+ * @since 1.0
+ */
+public interface DawnWorkflowUtil
+{
+ public URL getWorkFlow();
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/util/Utils.ext b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/util/Utils.ext
index 215c491149..dedcbcad36 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/util/Utils.ext
+++ b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/util/Utils.ext
@@ -8,8 +8,6 @@
* Contributors:
* Martin Fluegge - initial API and implementation
*/
-import gmfgraph;
-import gmfgen;
import emf;
import genmodel;
import ecore;
@@ -17,9 +15,6 @@ import ecore;
String timestamp() :
JAVA org.eclipse.emf.cdo.dawn.codegen.util.Utils.timestamp();
- String setGlobals( Canvas e ) :
- JAVA org.eclipse.emf.cdo.dawn.codegen.util.Utils.setGlobals(org.eclipse.gmf.gmfgraph.Canvas);
-
String getPackagePath() :
JAVA org.eclipse.emf.cdo.dawn.codegen.util.Utils.getPackagePath();

Back to the top