Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Fluegge2010-10-08 16:50:42 +0000
committerMartin Fluegge2010-10-08 16:50:42 +0000
commit01700460fd91df78dc01bd6f026f7077fe98fa5a (patch)
treee6ba381e5d16f66d0ae28ee41d2d65c43f4ce0f1 /plugins/org.eclipse.emf.cdo.dawn.codegen/src
parent7bfe12fe5466a6f34e467252dcac8839ac3f1e4e (diff)
downloadcdo-01700460fd91df78dc01bd6f026f7077fe98fa5a.tar.gz
cdo-01700460fd91df78dc01bd6f026f7077fe98fa5a.tar.xz
cdo-01700460fd91df78dc01bd6f026f7077fe98fa5a.zip
[323828] [Dawn] Provide collaborative EMF editors on CDO
https://bugs.eclipse.org/bugs/show_bug.cgi?id=323828
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.dawn.codegen/src')
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.codegen/src/metamodel/DawnCodeGen.ecore12
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/actions/GenerateClientCodeAction.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/actions/GenerateDawnGenModelAction.java171
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/actions/GenerateEMFFragmentAction.java85
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/creators/impl/EMFFragmentCreator.java148
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/creators/impl/GMFFragmentCreator.java14
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/messages/Messages.java35
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/messages/messages.properties2
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/util/Utils.ext4
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/util/Utils.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.codegen/src/template/EMFFragmentTemplate.xpt398
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.codegen/src/template/GMFFragmentTemplate.xpt32
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.codegen/src/workflow/emfFragmentGenerator.oaw89
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.codegen/src/workflow/gmfFragmentGenerator.oaw2
14 files changed, 933 insertions, 74 deletions
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 1fa1b67a82..e49cb3d16b 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
@@ -3,9 +3,18 @@
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="DawnGMFGenerator">
+ <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"
@@ -25,4 +34,5 @@
<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>
diff --git a/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/actions/GenerateClientCodeAction.java b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/actions/GenerateClientCodeAction.java
index 9c465b1298..8922751eb2 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/actions/GenerateClientCodeAction.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/actions/GenerateClientCodeAction.java
@@ -12,6 +12,7 @@ package org.eclipse.emf.cdo.dawn.codegen.actions;
import org.eclipse.emf.cdo.dawn.codegen.creators.Creator;
import org.eclipse.emf.cdo.dawn.codegen.creators.impl.GMFFragmentCreator;
+import org.eclipse.emf.cdo.dawn.codegen.messages.Messages;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -49,7 +50,7 @@ public class GenerateClientCodeAction implements IObjectActionDelegate
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException
{
- monitor.beginTask("Generating Dawn Code...", 1000);
+ monitor.beginTask(Messages.GenerateClientCodeAction_0, 1000);
ArrayList<Creator> creators = new ArrayList<Creator>();
creators.add(new GMFFragmentCreator(selectedElement));
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 c7544b2d85..85157774e3 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,10 +10,13 @@
*/
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.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;
@@ -63,54 +66,32 @@ public class GenerateDawnGenModelAction implements IObjectActionDelegate
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException
{
monitor.beginTask("Generate Dawn Code", 1000);
- IFile gmfGen = (IFile)selectedElement;
-
- String gmfGenModelFile = gmfGen.getRawLocationURI().toString();
- String path = gmfGenModelFile.replace(gmfGen.getName(), "");
- String modelname = gmfGen.getName().replace(".gmfgen", "");
-
- 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());
-
- URI gmfGenModelResourceUri = URI.createURI(gmfGenModelFile);
- Resource gmfGenModelResource = resourceSet.getResource(gmfGenModelResourceUri, true);
-
- String dawnGenModelResourcePath = path + "" + modelname + "." + dawngenmodelFileExtension;
- Resource dawnGenModelResource = resourceSet.createResource(URI.createURI(dawnGenModelResourcePath));
-
- 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);
-
- dawnGenModelResource.getContents().add(dawnGMFGenerator);
+ IFile genFile = (IFile)selectedElement;
+
+ String genModelFile = genFile.getRawLocationURI().toString();
+ String path = genModelFile.replace(genFile.getName(), "");
+
+ ResourceSet resourceSet = createResourceSet();
+
+ String modelname = "default";
+
+ modelname = getModelName(genFile);
+
+ Resource dawnGenModelResource = getDawnGenModelResource(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);
+ }
+
+ dawnGenModelResource.getContents().add(dawnGenerator);
try
{
@@ -123,6 +104,22 @@ public class GenerateDawnGenModelAction implements IObjectActionDelegate
ProjectCreationHelper.refreshProject(null, monitor);
}
+
+ private DawnGenerator getDawngenerator(Resource dawnGenModelResource)
+ {
+ DawnGenerator dawnGenerator;
+
+ if (dawnGenModelResource.getContents().size() != 0)
+ {
+ dawnGenerator = (DawnGenerator)dawnGenModelResource.getContents().get(0);
+ }
+ else
+ {
+ dawnGenerator = DawngenmodelFactory.eINSTANCE.createDawnGenerator();
+ }
+ return dawnGenerator;
+ }
+
});
}
catch (InvocationTargetException e)
@@ -146,6 +143,84 @@ public class GenerateDawnGenModelAction implements IObjectActionDelegate
return dawnEditorClassName;
}
+ private DawnEMFGenerator createDawnEMFGenerator(String genModelFile, ResourceSet resourceSet)
+ {
+ DawnEMFGenerator dawnEMFGenerator = DawngenmodelFactory.eINSTANCE.createDawnEMFGenerator();
+
+ 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;
+ }
+
+ private String getModelName(IFile genFile)
+ {
+ int lastIndexOf = genFile.getName().lastIndexOf(".");
+ 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)
+ {
+ String dawnGenModelResourcePath = path + "" + modelname + "." + dawngenmodelFileExtension;
+ URI uri = URI.createURI(dawnGenModelResourcePath);
+ Resource dawnGenModelResource = resourceSet.getResource(uri, true);
+
+ if (dawnGenModelResource == null)
+ {
+ dawnGenModelResource = resourceSet.createResource(uri);
+ }
+ return dawnGenModelResource;
+ }
+
+ private 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;
+ }
+
public void selectionChanged(IAction action, ISelection selection)
{
if (selection instanceof IStructuredSelection)
diff --git a/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/actions/GenerateEMFFragmentAction.java b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/actions/GenerateEMFFragmentAction.java
new file mode 100644
index 0000000000..b9a9868756
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/actions/GenerateEMFFragmentAction.java
@@ -0,0 +1,85 @@
+/**
+ * Copyright (c) 2004 - 2010 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.actions;
+
+import org.eclipse.emf.cdo.dawn.codegen.creators.Creator;
+import org.eclipse.emf.cdo.dawn.codegen.creators.impl.EMFFragmentCreator;
+import org.eclipse.emf.cdo.dawn.codegen.messages.Messages;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+
+/**
+ * @author Martin Fluegge
+ * @since 0.3
+ */
+public class GenerateEMFFragmentAction implements IObjectActionDelegate
+{
+ private IResource selectedElement;
+
+ public void setActivePart(IAction action, IWorkbenchPart targetPart)
+ {
+ }
+
+ public void run(IAction action)
+ {
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ try
+ {
+ window.run(true, true, new IRunnableWithProgress()
+ {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException
+ {
+ monitor.beginTask(Messages.GenerateEMFFragmentAction_0, 1000);
+ ArrayList<Creator> creators = new ArrayList<Creator>();
+ creators.add(new EMFFragmentCreator(selectedElement));
+
+ for (Creator creator : creators)
+ {
+ creator.create(new SubProgressMonitor(monitor, 1000 / creators.size()));
+ }
+ }
+ });
+ }
+ catch (InvocationTargetException e)
+ {
+ e.printStackTrace();
+ }
+ catch (InterruptedException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void selectionChanged(IAction action, ISelection selection)
+ {
+ if (selection instanceof IStructuredSelection)
+ {
+ Object sel = ((IStructuredSelection)selection).getFirstElement();
+ if (sel instanceof IResource)
+ {
+ selectedElement = (IResource)sel;
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/creators/impl/EMFFragmentCreator.java b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/creators/impl/EMFFragmentCreator.java
new file mode 100644
index 0000000000..0d6bf019c3
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/creators/impl/EMFFragmentCreator.java
@@ -0,0 +1,148 @@
+/**
+ * Copyright (c) 2004 - 2010 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.DawnEMFGenerator;
+import org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.DawnGenerator;
+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.WorkflowRunner;
+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 class EMFFragmentCreator implements Creator
+{
+ private final IResource selectedElement;
+
+ private final String PLUGIN_NATURE = "org.eclipse.pde.PluginNature";
+
+ private final String JAVA_NATURE = JavaCore.NATURE_ID;
+
+ public EMFFragmentCreator(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);
+
+ DawnGenerator dawnGenerator = (DawnGenerator)dawnGenModelResource.getContents().get(0);
+ DawnEMFGenerator dawnEMFGenerator = dawnGenerator.getEmfFragmentgenerator();
+
+ 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(dawnEMFGenerator.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 e1)
+ {
+ e1.printStackTrace();
+ }
+ catch (InvocationTargetException e)
+ {
+ e.printStackTrace();
+ }
+ catch (InterruptedException e)
+ {
+ e.printStackTrace();
+ }
+
+ monitor.done();
+ }
+
+ private 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 = this.getClass().getClassLoader().getResource("/workflow/emfFragmentGenerator.oaw");
+ WorkflowRunner workflowRunner = new WorkflowRunner();
+ String workflow = FileLocator.toFileURL(workFlowURL).getFile();
+
+ workflowRunner.run(workflow, new NullProgressMonitor(), properties, slotMap);
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/creators/impl/GMFFragmentCreator.java b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/creators/impl/GMFFragmentCreator.java
index 82ae82dd28..af1e467cbd 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/creators/impl/GMFFragmentCreator.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/creators/impl/GMFFragmentCreator.java
@@ -13,6 +13,7 @@ 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.DawnGMFGenerator;
+import org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.DawnGenerator;
import org.eclipse.emf.cdo.dawn.codegen.util.ProjectCreationHelper;
import org.eclipse.emf.cdo.dawn.codegen.util.Utils;
@@ -60,14 +61,14 @@ public class GMFFragmentCreator implements Creator
IFile dawnGenModelFile = (IFile)selectedElement;
ResourceSet resourceSet = new ResourceSetImpl();
- resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
- GenerateDawnGenModelAction.dawngenmodelFileExtension, new XMIResourceFactoryImpl());
+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
+ .put(GenerateDawnGenModelAction.dawngenmodelFileExtension, new XMIResourceFactoryImpl());
- Resource dawnGenModelResource = resourceSet.getResource(URI.createURI(dawnGenModelFile.getRawLocationURI()
- .toString()), true);
-
- DawnGMFGenerator dawnGMFGenerator = (DawnGMFGenerator)dawnGenModelResource.getContents().get(0);
+ Resource dawnGenModelResource = resourceSet.getResource(
+ URI.createURI(dawnGenModelFile.getRawLocationURI().toString()), true);
+ DawnGenerator dawnGenerator = (DawnGenerator)dawnGenModelResource.getContents().get(0);
+ DawnGMFGenerator dawnGMFGenerator = dawnGenerator.getGmfFragmentgenerator();
monitor.subTask("Create client fragment's basic structure");
// String[] natures = new String[] { JavaCore.NATURE_ID, PDE.PLUGIN_NATURE };
@@ -109,7 +110,6 @@ public class GMFFragmentCreator implements Creator
}
monitor.worked(100);
-
}
private void createGenericContent(IProgressMonitor monitor, IPath location)
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
new file mode 100644
index 0000000000..f073ad68c3
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/messages/Messages.java
@@ -0,0 +1,35 @@
+/**
+ * Copyright (c) 2004 - 2010 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.messages;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @author Martin Fluegge
+ * @since 0.3
+ */
+public class Messages extends NLS
+{
+ private static final String BUNDLE_NAME = "org.eclipse.emf.cdo.dawn.codegen.messages"; //$NON-NLS-1$
+
+ public static String GenerateClientCodeAction_0;
+
+ public static String GenerateEMFFragmentAction_0;
+ static
+ {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages()
+ {
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/messages/messages.properties b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/messages/messages.properties
new file mode 100644
index 0000000000..2b7322ab2c
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/messages/messages.properties
@@ -0,0 +1,2 @@
+GenerateEMFFragmentAction_0=Generating Dawn EMF fragment...
+GenerateClientCodeAction_0=Generating Dawn GMF fragment...
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 1eedfc4b77..9be7f3abf0 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
@@ -49,4 +49,8 @@ String timestamp() :
String toModelNameFromGetterName(String s ) :
JAVA org.eclipse.emf.cdo.dawn.codegen.util.Utils.toModelNameFromGetterName(java.lang.String);
+
+ String getEMFFileName(List genPackages) :
+ JAVA org.eclipse.emf.cdo.dawn.codegen.util.Utils.getEMFFileName(java.util.List);
+
\ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/util/Utils.java b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/util/Utils.java
index 584eccfe6d..0cc522fcfa 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/util/Utils.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/org/eclipse/emf/cdo/dawn/codegen/util/Utils.java
@@ -10,8 +10,12 @@
*/
package org.eclipse.emf.cdo.dawn.codegen.util;
+import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
+
import org.eclipse.swt.widgets.Canvas;
+import java.util.List;
+
/**
* @author Martin Fluegge
*/
@@ -100,4 +104,12 @@ public class Utils
String ret = uniqueIdentifier.replace("getFigure", "");
return ret;
}
+
+ /**
+ * @since 1.0
+ */
+ public static String getEMFFileName(List<GenPackage> genPackages)
+ {
+ return genPackages.get(0).getFileExtension();
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.codegen/src/template/EMFFragmentTemplate.xpt b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/template/EMFFragmentTemplate.xpt
new file mode 100644
index 0000000000..67c9011f9b
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/template/EMFFragmentTemplate.xpt
@@ -0,0 +1,398 @@
+«REM»
+ Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany).
+ 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
+
+«ENDREM»
+
+«IMPORT gmfgen»
+«IMPORT gmfgraph»
+«IMPORT emf»
+«IMPORT genmodel»
+«IMPORT ecore»
+«IMPORT dawngenmodel»
+
+«EXTENSION org::eclipse::emf::cdo::dawn::codegen::util::Utils»
+
+«DEFINE main FOR DawnGenerator»
+
+ «setDiagramPackage(this.emfFragmentgenerator.emfGenModel.modelPluginID)»
+
+ «EXPAND dawnEditor FOR this.emfFragmentgenerator»
+ «EXPAND dawnWizard FOR this.emfFragmentgenerator»
+ «EXPAND fragmentXML FOR this.emfFragmentgenerator»
+ «EXPAND manifestMF FOR this.emfFragmentgenerator»
+ «EXPAND buildPROPERTIES FOR this.emfFragmentgenerator»
+ «EXPAND classpath FOR this.emfFragmentgenerator»
+«ENDDEFINE»
+
+«REM»############################################ Extended Editor ##################################################################«ENDREM»
+«DEFINE dawnEditor FOR DawnEMFGenerator»
+«FILE "src/"+getDiagramPackagePath()+"/presentation/"+this.dawnEditorClassName+".java"»
+package «this.emfGenModel.modelPluginID».presentation;
+
+import «this.emfGenModel.modelPluginID».presentation.«this.emfGenModel.modelName»Editor;
+
+import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
+import org.eclipse.emf.cdo.dawn.editors.IDawnEditorSupport;
+import org.eclipse.emf.cdo.dawn.editors.impl.DawnEMFEditorSupport;
+import org.eclipse.emf.cdo.dawn.ui.DawnEditorInput;
+import org.eclipse.emf.cdo.dawn.ui.DawnLabelProvider;
+import org.eclipse.emf.cdo.dawn.ui.DawnSelectionViewerAdapterFactoryContentProvider;
+import org.eclipse.emf.cdo.dawn.util.connection.CDOConnectionUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorInput;
+
+public class «this.dawnEditorClassName» extends «this.emfGenModel.modelName»Editor implements IDawnEditor
+{
+ private IDawnEditorSupport dawnEditorSupport;
+
+ public static String ID = "«this.emfGenModel.modelPluginID».presentation.«this.dawnEditorClassName»ID";
+
+ public «this.dawnEditorClassName»()
+ {
+ super();
+ dawnEditorSupport = new DawnEMFEditorSupport(this);
+ }
+
+ @Override
+ protected void setInput(IEditorInput input)
+ {
+ super.setInput(input);
+ if (input instanceof DawnEditorInput)
+ {
+ dawnEditorSupport.setView(((DawnEditorInput)input).getView());
+ dawnEditorSupport.registerListeners();
+ }
+ }
+
+ @Override
+ protected void setInputWithNotify(IEditorInput input)
+ {
+ super.setInput(input);
+ if (input instanceof DawnEditorInput)
+ {
+ CDOResource resource = ((DawnEditorInput)input).getResource();
+ URI uri = URI.createURI(((DawnEditorInput)input).getURI().toString());
+
+ if (resource == null || resource.cdoView() == null)
+ {
+ ResourceSet resourceSet = editingDomain.getResourceSet();
+ CDOTransaction transaction = CDOConnectionUtil.instance.openCurrentTransaction(resourceSet, uri.toString());
+
+ resource = (CDOResource)resourceSet.getResource(uri, true);
+
+ if (resource == null || resource.cdoView() == null)
+ {
+ resource = transaction.getOrCreateResource(uri.toString());
+ }
+ }
+
+ ((DawnEditorInput)input).setResource(resource);
+ dawnEditorSupport.setView(((DawnEditorInput)input).getView());
+ dawnEditorSupport.registerListeners();
+ }
+ }
+
+ @Override
+ public void createPages()
+ {
+ super.createPages();
+
+ selectionViewer.setContentProvider(new DawnSelectionViewerAdapterFactoryContentProvider(adapterFactory,
+ ((DawnEditorInput)getEditorInput()).getResource()));
+ selectionViewer
+ .setLabelProvider(new DawnLabelProvider(adapterFactory, dawnEditorSupport.getView(), selectionViewer));
+ parentViewer.setLabelProvider(new DawnLabelProvider(adapterFactory, dawnEditorSupport.getView(), selectionViewer));
+ listViewer.setLabelProvider(new DawnLabelProvider(adapterFactory, dawnEditorSupport.getView(), selectionViewer));
+ treeViewer.setLabelProvider(new DawnLabelProvider(adapterFactory, dawnEditorSupport.getView(), selectionViewer));
+ tableViewer.setLabelProvider(new DawnLabelProvider(adapterFactory, dawnEditorSupport.getView(), selectionViewer));
+ treeViewerWithColumns.setLabelProvider(new DawnLabelProvider(adapterFactory, dawnEditorSupport.getView(),
+ selectionViewer));
+
+ CDOResource resource = ((DawnEditorInput)getEditorInput()).getResource();
+
+ selectionViewer.setInput(resource.getResourceSet());
+ selectionViewer.setSelection(new StructuredSelection(resource), true);
+
+ parentViewer.setContentProvider(new ReverseAdapterFactoryContentProvider(adapterFactory));
+ }
+
+ @Override
+ public void doSave(IProgressMonitor progressMonitor)
+ {
+ CDOView view = dawnEditorSupport.getView();
+ if (view instanceof CDOTransaction)
+ {
+ if (view.hasConflict())
+ {
+ MessageDialog.openError(Display.getDefault().getActiveShell(), "conflict",
+ "Your Resource is in conflict and cannot be committed");
+ }
+ else
+ {
+ super.doSave(progressMonitor);
+ }
+ }
+ }
+
+ public String getContributorID()
+ {
+ return null;
+ }
+
+ public CDOView getView()
+ {
+ return dawnEditorSupport.getView();
+ }
+
+ public void setDirty()
+ {
+ dawnEditorSupport.setDirty(true);
+ }
+
+ @Override
+ public void dispose()
+ {
+ try
+ {
+ super.dispose();
+ }
+ finally
+ {
+ dawnEditorSupport.close();
+ }
+ }
+
+ public String getContributorId()
+ {
+ return ID;
+ }
+
+ public IDawnEditorSupport getDawnEditorSupport()
+ {
+ return dawnEditorSupport;
+ }
+}
+«ENDFILE»
+«ENDDEFINE»
+«REM»############################################ Extended Wizard ##################################################################«ENDREM»
+«DEFINE dawnWizard FOR DawnEMFGenerator»
+«FILE "src/"+getDiagramPackagePath()+"/presentation/"+"Dawn"+this.emfGenModel.modelName+"ModelWizard.java"»
+package «this.emfGenModel.modelPluginID».presentation;
+
+import org.eclipse.emf.cdo.dawn.preferences.PreferenceConstants;
+import org.eclipse.emf.cdo.dawn.ui.DawnEditorInput;
+import org.eclipse.emf.cdo.dawn.ui.wizards.DawnCreateNewResourceWizardPage;
+import org.eclipse.emf.cdo.dawn.util.connection.CDOConnectionUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+
+import java.util.Collections;
+
+public class Dawn«this.emfGenModel.modelName»ModelWizard extends «this.emfGenModel.modelName»ModelWizard implements INewWizard
+{
+ private DawnCreateNewResourceWizardPage newResourceCreationPage;
+
+ private CDOView view;
+
+ private CDOResource resource;
+
+ public Dawn«this.emfGenModel.modelName»ModelWizard()
+ {
+ super();
+ CDOConnectionUtil.instance.init(PreferenceConstants.getRepositoryName(), PreferenceConstants.getProtocol(),
+ PreferenceConstants.getServerName());
+ CDOSession session = CDOConnectionUtil.instance.openSession();
+ view = CDOConnectionUtil.instance.openView(session);
+ }
+
+ @Override
+ public void addPages()
+ {
+ newResourceCreationPage = new DawnCreateNewResourceWizardPage("«getEMFFileName(this.emfGenModel.genPackages)»", true, view);
+ addPage(newResourceCreationPage);
+
+ initialObjectCreationPage = new «this.emfGenModel.modelName»ModelWizardInitialObjectCreationPage("Whatever2");
+ initialObjectCreationPage.setTitle(«this.emfGenModel.modelName»EditorPlugin.INSTANCE.getString("_UI_«this.emfGenModel.modelName»ModelWizard_label"));
+ initialObjectCreationPage.setDescription(«this.emfGenModel.modelName»EditorPlugin.INSTANCE
+ .getString("_UI_Wizard_initial_object_description"));
+ addPage(initialObjectCreationPage);
+ }
+
+ @Override
+ public boolean performFinish()
+ {
+ try
+ {
+ // Do the work within an operation.
+ //
+ WorkspaceModifyOperation operation = new WorkspaceModifyOperation()
+ {
+
+ @Override
+ protected void execute(IProgressMonitor progressMonitor)
+ {
+ try
+ {
+ ResourceSet resourceSet = new ResourceSetImpl();
+
+ URI resourceURI = newResourceCreationPage.getURI();
+
+ CDOTransaction transaction = CDOConnectionUtil.instance.openCurrentTransaction(resourceSet,
+ resourceURI.toString());
+
+ resource = transaction.getOrCreateResource(resourceURI.path());
+
+ EObject rootObject = createInitialModel();
+ if (rootObject != null)
+ {
+ resource.getContents().add(rootObject);
+ }
+
+ resource.save(Collections.EMPTY_MAP);
+ transaction.close();
+ }
+ catch (Exception exception)
+ {
+ «this.emfGenModel.modelName»EditorPlugin.INSTANCE.log(exception);
+ throw new RuntimeException(exception);
+ }
+ finally
+ {
+ progressMonitor.done();
+ }
+ }
+ };
+
+ getContainer().run(false, false, operation);
+
+ openEditor(newResourceCreationPage.getURI());
+
+ return true;
+ }
+ catch (Exception exception)
+ {
+ «this.emfGenModel.modelName»EditorPlugin.INSTANCE.log(exception);
+ return false;
+ }
+ }
+
+ private void openEditor(URI uri)
+ {
+ IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
+ IWorkbenchPage page = workbenchWindow.getActivePage();
+ DawnEditorInput dawnEditorInput = new DawnEditorInput(uri);
+ try
+ {
+ page.openEditor(dawnEditorInput, «this.dawnEditorClassName».ID);
+ }
+ catch (PartInitException exception)
+ {
+ MessageDialog.openError(workbenchWindow.getShell(),
+ «this.emfGenModel.modelName»EditorPlugin.INSTANCE.getString("_UI_OpenEditorError_label"), exception.getMessage());
+ throw new RuntimeException(exception);
+ }
+ }
+}
+«ENDFILE»
+«ENDDEFINE»
+«REM»########################################## fragment.xml ####################################################################«ENDREM»
+«DEFINE fragmentXML FOR DawnEMFGenerator»
+«FILE "fragment.xml"»<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<fragment>
+ <extension point="org.eclipse.ui.newWizards">
+ <wizard
+ id="«this.emfGenModel.modelPluginID».presentation.Dawn«this.emfGenModel.modelName»ModelWizardID"
+ name="Dawn «this.emfGenModel.modelName» Model"
+ class="«this.emfGenModel.modelPluginID».presentation.Dawn«this.emfGenModel.modelName»ModelWizard"
+ category="org.eclipse.emf.cdo.dawn.ui.category.examples"
+ icon="platform:/plugin/«this.emfGenModel.editPluginID»/icons/full/obj16/«this.emfGenModel.modelName»ModelFile.gif">
+ <description>A Dawn editor for «this.emfGenModel.modelName» models</description>
+ <selection class="org.eclipse.core.resources.IResource"/>
+ </wizard>
+ </extension>
+
+ <extension point="org.eclipse.ui.editors">
+ <editor
+ id="«this.emfGenModel.modelPluginID».presentation.«this.dawnEditorClassName»ID"
+ name="Dawn «this.emfGenModel.modelName» model Editor"
+ icon="platform:/plugin/«this.emfGenModel.editPluginID»/icons/full/obj16/«this.emfGenModel.modelName»ModelFile.gif"
+ extensions="«getEMFFileName(this.emfGenModel.genPackages)»"
+ class="«this.emfGenModel.modelPluginID».presentation.«this.dawnEditorClassName»"
+ contributorClass="«this.emfGenModel.modelPluginID».presentation.«this.emfGenModel.modelName»ActionBarContributor">
+ </editor>
+ </extension>
+</fragment>
+
+«ENDFILE»
+«ENDDEFINE»
+«REM»##############################################################################################################«ENDREM»
+«DEFINE manifestMF FOR DawnEMFGenerator»
+«FILE "META-INF/MANIFEST.MF"»Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Dawn
+Bundle-SymbolicName: «this.fragmentName»;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Fragment-Host: «this.emfGenModel.editorPluginID»
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Require-Bundle: org.eclipse.emf.cdo.dawn;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.emf.cdo.dawn.ui;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.emf.cdo.dawn.util;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.emf.cdo.ui;bundle-version="[4.0.0,5.0.0)"
+«ENDFILE»
+«ENDDEFINE»
+
+
+«DEFINE buildPROPERTIES FOR DawnEMFGenerator»
+«FILE "build.properties"»source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ fragment.xml
+«ENDFILE»
+«ENDDEFINE»
+«REM»################################### . classpath ###########################################################################«ENDREM»
+
+«DEFINE classpath FOR DawnEMFGenerator»
+«FILE ".classpath"»<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
+«ENDFILE»
+«ENDDEFINE»
+
diff --git a/plugins/org.eclipse.emf.cdo.dawn.codegen/src/template/GMFFragmentTemplate.xpt b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/template/GMFFragmentTemplate.xpt
index 89ea0199c9..ce2fc1e73a 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.codegen/src/template/GMFFragmentTemplate.xpt
+++ b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/template/GMFFragmentTemplate.xpt
@@ -19,22 +19,22 @@
«EXTENSION org::eclipse::emf::cdo::dawn::codegen::util::Utils»
-«DEFINE main FOR DawnGMFGenerator»
- «setDiagramPackage(this.GMFGenEditorGenerator.packageNamePrefix)»
-
- «EXPAND dawnEditor FOR this»
- «EXPAND dawnEditPart FOR this»
- «EXPAND dawnEditPartFactory FOR this»
- «EXPAND dawnCanonicalEditingPolicy FOR this»
- «EXPAND dawnCreationWizard FOR this»
- «EXPAND dawnEditorUtil FOR this»
- «EXPAND dawnDocumentProvider FOR this»
- «EXPAND dawnEditPartProvider FOR this»
- «EXPAND fragmentXML FOR this»
- «EXPAND dawnEditPolicyProvider FOR this»
- «EXPAND manifestMF FOR this»
- «EXPAND buildPROPERTIES FOR this.GMFGenEditorGenerator»
- «EXPAND classpath FOR this.GMFGenEditorGenerator»
+«DEFINE main FOR DawnGenerator»
+ «setDiagramPackage(this.gmfFragmentgenerator.GMFGenEditorGenerator.packageNamePrefix)»
+
+ «EXPAND dawnEditor FOR this.gmfFragmentgenerator»
+ «EXPAND dawnEditPart FOR this.gmfFragmentgenerator»
+ «EXPAND dawnEditPartFactory FOR this.gmfFragmentgenerator»
+ «EXPAND dawnCanonicalEditingPolicy FOR this.gmfFragmentgenerator»
+ «EXPAND dawnCreationWizard FOR this.gmfFragmentgenerator»
+ «EXPAND dawnEditorUtil FOR this.gmfFragmentgenerator»
+ «EXPAND dawnDocumentProvider FOR this.gmfFragmentgenerator»
+ «EXPAND dawnEditPartProvider FOR this.gmfFragmentgenerator»
+ «EXPAND fragmentXML FOR this.gmfFragmentgenerator»
+ «EXPAND dawnEditPolicyProvider FOR this.gmfFragmentgenerator»
+ «EXPAND manifestMF FOR this.gmfFragmentgenerator»
+ «EXPAND buildPROPERTIES FOR this.gmfFragmentgenerator.GMFGenEditorGenerator»
+ «EXPAND classpath FOR this.gmfFragmentgenerator.GMFGenEditorGenerator»
«ENDDEFINE»
diff --git a/plugins/org.eclipse.emf.cdo.dawn.codegen/src/workflow/emfFragmentGenerator.oaw b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/workflow/emfFragmentGenerator.oaw
new file mode 100644
index 0000000000..fa83aef725
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/workflow/emfFragmentGenerator.oaw
@@ -0,0 +1,89 @@
+<?xml version="1.0"?>
+<!--
+ Copyright (c) 2004 - 2010 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
+-->
+
+<workflow>
+
+ <property name="model" value="file:/D:/Development/INSTANCES/Dawn_Instance1/org.eclipse.emf.cdo.dawn.examples.acore/model/acore.dawngenmodel" />
+
+ <property name="src-gen" value="d:/temp/source" />
+
+ <!-- set up EMF for standalone execution -->
+ <bean class="org.eclipse.emf.mwe.utils.StandaloneSetup" >
+ <platformUri value=".."/>
+ </bean>
+
+ <!-- load model and store it in slot 'model' -->
+ <component class="org.eclipse.emf.mwe.utils.Reader">
+ <uri value="${model}" />
+ <modelSlot value="model" />
+ </component>
+
+
+
+ <!-- check model -->
+ <!--loads different metamodels-->
+ <component class="org.eclipse.xtend.check.CheckComponent">
+ <metaModel id="ecore" class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
+ <metaModelPackage value="org.eclipse.emf.ecore.EcorePackage"/>
+ </metaModel>
+
+ <metaModel id="genmodel" class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
+ <metaModelPackage value="org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage"/>
+ </metaModel>
+
+ <metaModel id="dawngenmodel" class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
+ <metaModelPackage value="org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.DawngenmodelPackage"/>
+ </metaModel>
+
+ <metaModel id="mmGGr" class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
+ <metaModelPackage value="org.eclipse.gmf.gmfgraph.GMFGraphPackage"/>
+ </metaModel>
+
+ <metaModel id="mmGGen" class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
+ <metaModelPackage value="org.eclipse.gmf.codegen.gmfgen.GMFGenPackage"/>
+ </metaModel>
+ <checkFile value="metamodel::Checks" />
+ <emfAllChildrenSlot value="model" />
+ </component>
+
+ <!-- generate code for the meta specified templates -->
+ <component class="org.eclipse.xpand2.Generator">
+
+ <metaModel id="ecore" class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
+ <metaModelPackage value="org.eclipse.emf.ecore.EcorePackage"/>
+ </metaModel>
+
+ <metaModel id="genmodel" class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
+ <metaModelPackage value="org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage"/>
+ </metaModel>
+
+ <metaModel id="dawngenmodel" class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
+ <metaModelPackage value="org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.DawngenmodelPackage"/>
+ </metaModel>
+
+ <metaModel id="mmGGr" class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
+ <metaModelPackage value="org.eclipse.gmf.gmfgraph.GMFGraphPackage"/>
+ </metaModel>
+
+ <metaModel id="mmGGen" class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
+ <metaModelPackage value="org.eclipse.gmf.codegen.gmfgen.GMFGenPackage"/>
+ </metaModel>
+
+ <expand value="template::EMFFragmentTemplate::main FOR model" />
+ <outlet path="${src-gen}" >
+ <postprocessor class="org.eclipse.xpand2.output.JavaBeautifier" />
+ </outlet>
+
+ <!--<prSrcPaths value="${src-gen}"/>
+ <prExcludes value=", *.xml, *.hbm"/>-->
+ </component>
+</workflow>
diff --git a/plugins/org.eclipse.emf.cdo.dawn.codegen/src/workflow/gmfFragmentGenerator.oaw b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/workflow/gmfFragmentGenerator.oaw
index d97c55da1d..a507e7a27e 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.codegen/src/workflow/gmfFragmentGenerator.oaw
+++ b/plugins/org.eclipse.emf.cdo.dawn.codegen/src/workflow/gmfFragmentGenerator.oaw
@@ -13,7 +13,7 @@
<workflow>
<!--<property name="model" value="file:/D:/Development/CDO/org.eclipse.emf.cdo.dawn.examples.acore/model/classdiagram.gmfgen" />-->
- <property name="model" value="file:/D:/Development/INSTANCES/Dawn_Instance1/Dawn/model/classdiagram.dawngenmodel" />
+ <property name="model" value="file:/D:/Development/INSTANCES/Dawn_Instance1/org.eclipse.emf.cdo.dawn.examples.acore/model/acore.dawngenmodel" />
<property name="src-gen" value="d:/temp/source" />
<!--<property name="src-gen" /> --> <!--just declare it to make it accessable -->

Back to the top