Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-07-19 08:22:04 +0000
committerEike Stepper2012-07-19 08:22:04 +0000
commit1460904fd3c193ffaf809913b2983a400fce9d94 (patch)
tree72f3a17b75fedba3ae1060df1d32c9c7889be954 /plugins/org.eclipse.emf.cdo.dawn.examples.acore.editor.dawn
parent5f360965ae87478e0681899bf310a210cafc2c44 (diff)
downloadcdo-1460904fd3c193ffaf809913b2983a400fce9d94.tar.gz
cdo-1460904fd3c193ffaf809913b2983a400fce9d94.tar.xz
cdo-1460904fd3c193ffaf809913b2983a400fce9d94.zip
Fix line endings in master (dos2unix)
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.dawn.examples.acore.editor.dawn')
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.editor.dawn/.settings/org.eclipse.core.resources.prefs6
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.editor.dawn/copyright.txt14
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.editor.dawn/fragment.xml74
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.editor.dawn/src/org/eclipse/emf/cdo/dawn/examples/acore/presentation/DawnAcoreEditor.java340
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.editor.dawn/src/org/eclipse/emf/cdo/dawn/examples/acore/presentation/DawnAcoreModelWizard.java300
5 files changed, 367 insertions, 367 deletions
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.editor.dawn/.settings/org.eclipse.core.resources.prefs b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.editor.dawn/.settings/org.eclipse.core.resources.prefs
index f8829d1f7c..6e3842c3b1 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.editor.dawn/.settings/org.eclipse.core.resources.prefs
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.editor.dawn/.settings/org.eclipse.core.resources.prefs
@@ -1,3 +1,3 @@
-#Mon Jul 04 13:04:09 CEST 2011
-eclipse.preferences.version=1
-encoding//model/org.eclipse.emf.cdo.defs.ecorediag=UTF-8
+#Mon Jul 04 13:04:09 CEST 2011
+eclipse.preferences.version=1
+encoding//model/org.eclipse.emf.cdo.defs.ecorediag=UTF-8
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.editor.dawn/copyright.txt b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.editor.dawn/copyright.txt
index 9cbb3ba084..cea141de92 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.editor.dawn/copyright.txt
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.editor.dawn/copyright.txt
@@ -1,8 +1,8 @@
-Copyright (c) 2004 - 2012 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:
+Copyright (c) 2004 - 2012 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.examples.acore.editor.dawn/fragment.xml b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.editor.dawn/fragment.xml
index 72ede8fda5..72945edaba 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.editor.dawn/fragment.xml
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.editor.dawn/fragment.xml
@@ -1,37 +1,37 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<!--
- Copyright (c) 2004 - 2012 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
--->
-
-<fragment>
- <extension point="org.eclipse.ui.newWizards">
- <wizard
- id="org.eclipse.emf.cdo.dawn.examples.acore.presentation.DawnAcoreModelWizardID"
- name="Dawn Acore Model"
- class="org.eclipse.emf.cdo.dawn.examples.acore.presentation.DawnAcoreModelWizard"
- category="org.eclipse.emf.cdo.dawn.ui.category.examples"
- icon="platform:/plugin/org.eclipse.emf.cdo.dawn.examples.acore.editor/icons/full/obj16/AcoreModelFile.gif">
- <description>A Dawn editor for Acore models</description>
- <selection class="org.eclipse.core.resources.IResource"/>
- </wizard>
- </extension>
-
- <extension point="org.eclipse.ui.editors">
- <editor
- id="org.eclipse.emf.cdo.dawn.examples.acore.presentation.DawnAcoreEditorID"
- name="Dawn Acore model Editor"
- icon="platform:/plugin/org.eclipse.emf.cdo.dawn.examples.acore.editor/icons/full/obj16/AcoreModelFile.gif"
- extensions="acore"
- class="org.eclipse.emf.cdo.dawn.examples.acore.presentation.DawnAcoreEditor"
- contributorClass="org.eclipse.emf.cdo.dawn.examples.acore.presentation.AcoreActionBarContributor">
- </editor>
- </extension>
-</fragment>
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<!--
+ Copyright (c) 2004 - 2012 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
+-->
+
+<fragment>
+ <extension point="org.eclipse.ui.newWizards">
+ <wizard
+ id="org.eclipse.emf.cdo.dawn.examples.acore.presentation.DawnAcoreModelWizardID"
+ name="Dawn Acore Model"
+ class="org.eclipse.emf.cdo.dawn.examples.acore.presentation.DawnAcoreModelWizard"
+ category="org.eclipse.emf.cdo.dawn.ui.category.examples"
+ icon="platform:/plugin/org.eclipse.emf.cdo.dawn.examples.acore.editor/icons/full/obj16/AcoreModelFile.gif">
+ <description>A Dawn editor for Acore models</description>
+ <selection class="org.eclipse.core.resources.IResource"/>
+ </wizard>
+ </extension>
+
+ <extension point="org.eclipse.ui.editors">
+ <editor
+ id="org.eclipse.emf.cdo.dawn.examples.acore.presentation.DawnAcoreEditorID"
+ name="Dawn Acore model Editor"
+ icon="platform:/plugin/org.eclipse.emf.cdo.dawn.examples.acore.editor/icons/full/obj16/AcoreModelFile.gif"
+ extensions="acore"
+ class="org.eclipse.emf.cdo.dawn.examples.acore.presentation.DawnAcoreEditor"
+ contributorClass="org.eclipse.emf.cdo.dawn.examples.acore.presentation.AcoreActionBarContributor">
+ </editor>
+ </extension>
+</fragment>
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.editor.dawn/src/org/eclipse/emf/cdo/dawn/examples/acore/presentation/DawnAcoreEditor.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.editor.dawn/src/org/eclipse/emf/cdo/dawn/examples/acore/presentation/DawnAcoreEditor.java
index 37215a6984..8057d8e05f 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.editor.dawn/src/org/eclipse/emf/cdo/dawn/examples/acore/presentation/DawnAcoreEditor.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.editor.dawn/src/org/eclipse/emf/cdo/dawn/examples/acore/presentation/DawnAcoreEditor.java
@@ -1,170 +1,170 @@
-/*
- * Copyright (c) 2004 - 2012 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.examples.acore.presentation;
-
-import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
-import org.eclipse.emf.cdo.dawn.editors.IDawnEditorSupport;
-import org.eclipse.emf.cdo.dawn.emf.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;
-
-/**
- * This is an example of a Acore model editor. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
-public class DawnAcoreEditor extends AcoreEditor implements IDawnEditor
-{
- private IDawnEditorSupport dawnEditorSupport;
-
- public static String ID = "org.eclipse.emf.cdo.dawn.examples.acore.presentation.DawnAcoreEditorID";
-
- public DawnAcoreEditor()
- {
- 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;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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.examples.acore.presentation;
+
+import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
+import org.eclipse.emf.cdo.dawn.editors.IDawnEditorSupport;
+import org.eclipse.emf.cdo.dawn.emf.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;
+
+/**
+ * This is an example of a Acore model editor. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+public class DawnAcoreEditor extends AcoreEditor implements IDawnEditor
+{
+ private IDawnEditorSupport dawnEditorSupport;
+
+ public static String ID = "org.eclipse.emf.cdo.dawn.examples.acore.presentation.DawnAcoreEditorID";
+
+ public DawnAcoreEditor()
+ {
+ 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.examples.acore.editor.dawn/src/org/eclipse/emf/cdo/dawn/examples/acore/presentation/DawnAcoreModelWizard.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.editor.dawn/src/org/eclipse/emf/cdo/dawn/examples/acore/presentation/DawnAcoreModelWizard.java
index 0bf50d3e34..9a6e3e0467 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.editor.dawn/src/org/eclipse/emf/cdo/dawn/examples/acore/presentation/DawnAcoreModelWizard.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.editor.dawn/src/org/eclipse/emf/cdo/dawn/examples/acore/presentation/DawnAcoreModelWizard.java
@@ -1,150 +1,150 @@
-/*
- * Copyright (c) 2004 - 2012 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.examples.acore.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;
-
-/**
- * @author Martin Fluegge
- */
-public class DawnAcoreModelWizard extends AcoreModelWizard implements INewWizard
-{
- private DawnCreateNewResourceWizardPage newResourceCreationPage;
-
- private CDOView view;
-
- private CDOResource resource;
-
- public DawnAcoreModelWizard()
- {
- 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("acore", true, view);
- addPage(newResourceCreationPage);
-
- initialObjectCreationPage = new AcoreModelWizardInitialObjectCreationPage("Whatever2");
- initialObjectCreationPage.setTitle(AcoreEditorPlugin.INSTANCE.getString("_UI_AcoreModelWizard_label"));
- initialObjectCreationPage.setDescription(AcoreEditorPlugin.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);
- }
-
- // Save the contents of the resource to the file system.
- //
- // Map<Object, Object> options = new HashMap<Object, Object>();
- // options.put(XMLResource.OPTION_ENCODING, initialObjectCreationPage.getEncoding());
- // resource.save(options);
- resource.save(Collections.EMPTY_MAP);
- transaction.close();
- }
- catch (Exception exception)
- {
- AcoreEditorPlugin.INSTANCE.log(exception);
- throw new RuntimeException(exception);
- }
- finally
- {
- progressMonitor.done();
- }
- }
- };
-
- getContainer().run(false, false, operation);
-
- openEditor(newResourceCreationPage.getURI());
-
- return true;
- }
- catch (Exception exception)
- {
- AcoreEditorPlugin.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, DawnAcoreEditor.ID);
- }
- catch (PartInitException exception)
- {
- MessageDialog.openError(workbenchWindow.getShell(),
- AcoreEditorPlugin.INSTANCE.getString("_UI_OpenEditorError_label"), exception.getMessage());
- throw new RuntimeException(exception);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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.examples.acore.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;
+
+/**
+ * @author Martin Fluegge
+ */
+public class DawnAcoreModelWizard extends AcoreModelWizard implements INewWizard
+{
+ private DawnCreateNewResourceWizardPage newResourceCreationPage;
+
+ private CDOView view;
+
+ private CDOResource resource;
+
+ public DawnAcoreModelWizard()
+ {
+ 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("acore", true, view);
+ addPage(newResourceCreationPage);
+
+ initialObjectCreationPage = new AcoreModelWizardInitialObjectCreationPage("Whatever2");
+ initialObjectCreationPage.setTitle(AcoreEditorPlugin.INSTANCE.getString("_UI_AcoreModelWizard_label"));
+ initialObjectCreationPage.setDescription(AcoreEditorPlugin.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);
+ }
+
+ // Save the contents of the resource to the file system.
+ //
+ // Map<Object, Object> options = new HashMap<Object, Object>();
+ // options.put(XMLResource.OPTION_ENCODING, initialObjectCreationPage.getEncoding());
+ // resource.save(options);
+ resource.save(Collections.EMPTY_MAP);
+ transaction.close();
+ }
+ catch (Exception exception)
+ {
+ AcoreEditorPlugin.INSTANCE.log(exception);
+ throw new RuntimeException(exception);
+ }
+ finally
+ {
+ progressMonitor.done();
+ }
+ }
+ };
+
+ getContainer().run(false, false, operation);
+
+ openEditor(newResourceCreationPage.getURI());
+
+ return true;
+ }
+ catch (Exception exception)
+ {
+ AcoreEditorPlugin.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, DawnAcoreEditor.ID);
+ }
+ catch (PartInitException exception)
+ {
+ MessageDialog.openError(workbenchWindow.getShell(),
+ AcoreEditorPlugin.INSTANCE.getString("_UI_OpenEditorError_label"), exception.getMessage());
+ throw new RuntimeException(exception);
+ }
+ }
+}

Back to the top