Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Fluegge2010-12-29 10:17:28 +0000
committerMartin Fluegge2010-12-29 10:17:28 +0000
commit023b6362edd531cf241e5ffeb792944108df615a (patch)
tree23fcc41f93867236fb59b37aee832c4c9ddbe105 /plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn
parent7a082956c2927599f9def4d66a3106c080ad27af (diff)
downloadcdo-023b6362edd531cf241e5ffeb792944108df615a.tar.gz
cdo-023b6362edd531cf241e5ffeb792944108df615a.tar.xz
cdo-023b6362edd531cf241e5ffeb792944108df615a.zip
NEW - bug 333291: [Dawn] Provide extension for Ecore Editor
https://bugs.eclipse.org/bugs/show_bug.cgi?id=333291
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn')
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/.classpath7
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/.cvsignore3
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/.options4
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/.project28
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/META-INF/MANIFEST.MF13
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/about.html28
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/about.ini15
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/about.mappings6
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/about.properties31
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/build.properties5
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/copyright.txt8
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/fragment.xml27
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/plugin.properties11
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/src/org/eclipse/emf/cdo/dawn/ecore/presentation/DawnEcoreEditor.java144
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/src/org/eclipse/emf/cdo/dawn/ecore/presentation/DawnEcoreModelWizard.java123
15 files changed, 453 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/.classpath b/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/.classpath
new file mode 100644
index 0000000000..64c5e31b7a
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/.classpath
@@ -0,0 +1,7 @@
+<?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>
diff --git a/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/.cvsignore b/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/.cvsignore
new file mode 100644
index 0000000000..345ba90b5a
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/.cvsignore
@@ -0,0 +1,3 @@
+bin
+tmp
+text
diff --git a/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/.options b/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/.options
new file mode 100644
index 0000000000..390dcf5301
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/.options
@@ -0,0 +1,4 @@
+# Debugging and tracing options
+
+org.eclipse.emf.cdo.dawn.ecore/debug = true
+
diff --git a/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/.project b/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/.project
new file mode 100644
index 0000000000..0615b98453
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.emf.cdo.dawn.ecore.editor.dawn</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..e6385ad847
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/META-INF/MANIFEST.MF
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.emf.cdo.dawn.ecore.editor.dawn;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Fragment-Host: org.eclipse.emf.ecore.editor
+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)"
+Import-Package: org.eclipse.emf.ecore.presentation
+Bundle-Vendor: %providerName
diff --git a/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/about.html b/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/about.html
new file mode 100644
index 0000000000..d35d5aed64
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2007</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html>
diff --git a/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/about.ini b/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/about.ini
new file mode 100644
index 0000000000..32006ae5d6
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/about.ini
@@ -0,0 +1,15 @@
+# about.ini
+# contains information about a feature
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# "%key" are externalized strings defined in about.properties
+# This file does not need to be translated.
+
+# Property "aboutText" contains blurb for "About" dialog (translated)
+aboutText=%featureText
+
+# Property "featureImage" contains path to feature image (32x32)
+featureImage=modeling32.png
+
+# Property "appName" contains name of the application (translated)
+appName=%featureName
+
diff --git a/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/about.mappings b/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/about.mappings
new file mode 100644
index 0000000000..bddaab4310
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/about.mappings
@@ -0,0 +1,6 @@
+# about.mappings
+# contains fill-ins for about.properties
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# This file does not need to be translated.
+
+0=@build@ \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/about.properties b/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/about.properties
new file mode 100644
index 0000000000..314286b3ac
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/about.properties
@@ -0,0 +1,31 @@
+# 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:
+# Eike Stepper - initial API and implementation
+
+# NLS_MESSAGEFORMAT_VAR
+
+# ==============================================================================
+# Do not change the properties between this line and the last line containing:
+# %%% END OF TRANSLATED PROPERTIES %%%
+# Instead, either redefine an existing property, or create a new property,
+# append it to the end of the file, and change the code to use the new name.
+# ==============================================================================
+
+featureName = CDO Dawn Runtime (Experimental)
+featureText = CDO Dawn Runtime (Experimental)\n\
+Version: {featureVersion}\n\
+Build id: {0}\n\
+\n\
+Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others. All rights reserved.\n\
+\n\
+Visit http://wiki.eclipse.org/CDO
+
+# ==============================================================================
+# %%% END OF TRANSLATED PROPERTIES %%%
+# The above properties have been shipped for translation.
+# ==============================================================================
diff --git a/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/build.properties b/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/build.properties
new file mode 100644
index 0000000000..e3023e14e9
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ fragment.xml
diff --git a/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/copyright.txt b/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/copyright.txt
new file mode 100644
index 0000000000..d350ced838
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/copyright.txt
@@ -0,0 +1,8 @@
+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 \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/fragment.xml b/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/fragment.xml
new file mode 100644
index 0000000000..9ce2dce14c
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/fragment.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<fragment>
+ <extension point="org.eclipse.ui.newWizards">
+ <wizard
+ id="org.eclipse.emf.cdo.dawn.ecore.presentation.DawnEcoreModelWizardID"
+ name="Dawn Ecore Model"
+ class="org.eclipse.emf.cdo.dawn.ecore.presentation.DawnEcoreModelWizard"
+ category="org.eclipse.emf.cdo.dawn.ui.category.examples"
+ icon="platform:/plugin/org.eclipse.emf.ecore.editor/icons/full/obj16/EcoreModelFile.gif">
+ <description>A Dawn editor for Ecore models</description>
+ <selection class="org.eclipse.core.resources.IResource"/>
+ </wizard>
+ </extension>
+
+ <extension point="org.eclipse.ui.editors">
+ <editor
+ id="org.eclipse.emf.cdo.dawn.ecore.presentation.DawnEcoreEditorID"
+ name="Dawn Ecore model Editor"
+ icon="platform:/plugin/org.eclipse.emf.ecore.editor/icons/full/obj16/EcoreModelFile.gif"
+ extensions="ecore"
+ class="org.eclipse.emf.cdo.dawn.ecore.presentation.DawnEcoreEditor"
+ contributorClass="org.eclipse.emf.ecore.presentation.EcoreActionBarContributor">
+ </editor>
+ </extension>
+</fragment>
+
diff --git a/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/plugin.properties b/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/plugin.properties
new file mode 100644
index 0000000000..77f752b349
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/plugin.properties
@@ -0,0 +1,11 @@
+# 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
+
+pluginName = CDO Dawn Ecore Editor Extension (Experimental)
+providerName = Eclipse Modeling Project
diff --git a/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/src/org/eclipse/emf/cdo/dawn/ecore/presentation/DawnEcoreEditor.java b/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/src/org/eclipse/emf/cdo/dawn/ecore/presentation/DawnEcoreEditor.java
new file mode 100644
index 0000000000..8653f1c169
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/src/org/eclipse/emf/cdo/dawn/ecore/presentation/DawnEcoreEditor.java
@@ -0,0 +1,144 @@
+package org.eclipse.emf.cdo.dawn.ecore.presentation;
+
+import org.eclipse.emf.ecore.presentation.EcoreEditor;
+
+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 DawnEcoreEditor extends EcoreEditor implements IDawnEditor {
+ private IDawnEditorSupport dawnEditorSupport;
+
+ public static String ID = "org.eclipse.emf.ecore.presentation.DawnEcoreEditorID";
+
+ public DawnEcoreEditor() {
+ 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;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/src/org/eclipse/emf/cdo/dawn/ecore/presentation/DawnEcoreModelWizard.java b/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/src/org/eclipse/emf/cdo/dawn/ecore/presentation/DawnEcoreModelWizard.java
new file mode 100644
index 0000000000..fd27ef6b61
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.ecore.editor.dawn/src/org/eclipse/emf/cdo/dawn/ecore/presentation/DawnEcoreModelWizard.java
@@ -0,0 +1,123 @@
+package org.eclipse.emf.cdo.dawn.ecore.presentation;
+
+import java.util.Collections;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+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.presentation.EcoreEditorPlugin;
+import org.eclipse.emf.ecore.presentation.EcoreModelWizard;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+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;
+
+public class DawnEcoreModelWizard extends EcoreModelWizard
+ implements
+ INewWizard {
+ private DawnCreateNewResourceWizardPage newResourceCreationPage;
+
+ private CDOView view;
+
+ private CDOResource resource;
+
+ public DawnEcoreModelWizard() {
+ 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("ecore",
+ true, view);
+ addPage(newResourceCreationPage);
+
+ initialObjectCreationPage = new EcoreModelWizardInitialObjectCreationPage(
+ "Whatever2");
+ initialObjectCreationPage.setTitle(EcoreEditorPlugin.INSTANCE
+ .getString("_UI_EcoreModelWizard_label"));
+ initialObjectCreationPage.setDescription(EcoreEditorPlugin.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) {
+ EcoreEditorPlugin.INSTANCE.log(exception);
+ throw new RuntimeException(exception);
+ } finally {
+ progressMonitor.done();
+ }
+ }
+ };
+
+ getContainer().run(false, false, operation);
+
+ openEditor(newResourceCreationPage.getURI());
+
+ return true;
+ } catch (Exception exception) {
+ EcoreEditorPlugin.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, DawnEcoreEditor.ID);
+ } catch (PartInitException exception) {
+ MessageDialog.openError(workbenchWindow.getShell(),
+ EcoreEditorPlugin.INSTANCE
+ .getString("_UI_OpenEditorError_label"), exception
+ .getMessage());
+ throw new RuntimeException(exception);
+ }
+ }
+}

Back to the top