diff options
author | Eike Stepper | 2012-07-19 08:22:04 +0000 |
---|---|---|
committer | Eike Stepper | 2012-07-19 08:22:04 +0000 |
commit | 1460904fd3c193ffaf809913b2983a400fce9d94 (patch) | |
tree | 72f3a17b75fedba3ae1060df1d32c9c7889be954 /plugins/org.eclipse.emf.cdo.dawn.graphiti | |
parent | 5f360965ae87478e0681899bf310a210cafc2c44 (diff) | |
download | cdo-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.graphiti')
18 files changed, 1521 insertions, 1521 deletions
diff --git a/plugins/org.eclipse.emf.cdo.dawn.graphiti/.classpath b/plugins/org.eclipse.emf.cdo.dawn.graphiti/.classpath index 2d1a4302f0..64c5e31b7a 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.graphiti/.classpath +++ b/plugins/org.eclipse.emf.cdo.dawn.graphiti/.classpath @@ -1,7 +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>
+<?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.graphiti/.project b/plugins/org.eclipse.emf.cdo.dawn.graphiti/.project index 7cf18e7fd3..fc0b94032b 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.graphiti/.project +++ b/plugins/org.eclipse.emf.cdo.dawn.graphiti/.project @@ -1,44 +1,44 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.emf.cdo.dawn.graphiti</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>
- <buildCommand>
- <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.emf.cdo.releng.version.VersionBuilder</name>
- <arguments>
- <dictionary>
- <key>release.path</key>
- <value>/org.eclipse.emf.cdo.releng/release.xml</value>
- </dictionary>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
- <nature>org.eclipse.emf.cdo.releng.version.VersionNature</nature>
- </natures>
-</projectDescription>
+<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.emf.cdo.dawn.graphiti</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> + <buildCommand> + <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.emf.cdo.releng.version.VersionBuilder</name> + <arguments> + <dictionary> + <key>release.path</key> + <value>/org.eclipse.emf.cdo.releng/release.xml</value> + </dictionary> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature> + <nature>org.eclipse.emf.cdo.releng.version.VersionNature</nature> + </natures> +</projectDescription> diff --git a/plugins/org.eclipse.emf.cdo.dawn.graphiti/.settings/org.eclipse.core.resources.prefs b/plugins/org.eclipse.emf.cdo.dawn.graphiti/.settings/org.eclipse.core.resources.prefs index 76131b5e41..00ad708cfa 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.graphiti/.settings/org.eclipse.core.resources.prefs +++ b/plugins/org.eclipse.emf.cdo.dawn.graphiti/.settings/org.eclipse.core.resources.prefs @@ -1,3 +1,3 @@ -#Mon Jul 04 12:54:56 CEST 2011
-eclipse.preferences.version=1
-encoding//model/org.eclipse.emf.cdo.defs.ecorediag=UTF-8
+#Mon Jul 04 12:54:56 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.graphiti/copyright.txt b/plugins/org.eclipse.emf.cdo.dawn.graphiti/copyright.txt index 9cbb3ba084..cea141de92 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.graphiti/copyright.txt +++ b/plugins/org.eclipse.emf.cdo.dawn.graphiti/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.graphiti/plugin.properties b/plugins/org.eclipse.emf.cdo.dawn.graphiti/plugin.properties index 5af89be90e..1cda9b3d4e 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.graphiti/plugin.properties +++ b/plugins/org.eclipse.emf.cdo.dawn.graphiti/plugin.properties @@ -1,11 +1,11 @@ -# 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
-
-pluginName = CDO Dawn Runtime Graphiti
-providerName = Eclipse Modeling Project
+# 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 + +pluginName = CDO Dawn Runtime Graphiti +providerName = Eclipse Modeling Project diff --git a/plugins/org.eclipse.emf.cdo.dawn.graphiti/plugin.xml b/plugins/org.eclipse.emf.cdo.dawn.graphiti/plugin.xml index ac185f4aef..fbe2762a1b 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.graphiti/plugin.xml +++ b/plugins/org.eclipse.emf.cdo.dawn.graphiti/plugin.xml @@ -1,39 +1,39 @@ -<?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
--->
-<plugin>
- <extension
- point="org.eclipse.ui.newWizards">
- <wizard
- category="org.eclipse.emf.cdo.dawn.ui.category.dawn"
- class="org.eclipse.emf.cdo.dawn.graphiti.wizards.DawnGenericGraphitiWizard"
- icon="icons/dawn_graphiti_editor.gif"
- id="org.eclipse.emf.cdo.dawn.graphiti.wizard1"
- name="Dawn Generic Graphiti Diagram">
- </wizard>
- </extension>
- <extension
- point="org.eclipse.ui.editors">
- <editor
- class="org.eclipse.emf.cdo.dawn.graphiti.editors.DawnGraphitiDiagramEditor"
- default="false"
- extensions="graphiti"
- icon="icons/dawn_graphiti_editor.gif"
- id="org.eclipse.emf.cdo.dawn.graphiti.editor"
- name="Dawn Graphiti Editor">
- </editor>
- </extension>
- <extension point="org.eclipse.ui.elementFactories" id=".DiagramEditorFactory" name="%_diagram_editor_factory">
- <factory class="org.eclipse.emf.cdo.dawn.graphiti.editors.DawnGraphitiDiagramEditorInputFactory" id="org.eclipse.emf.cdo.dawn.graphiti.editors.DawnGraphitiDiagramEditorFactory">
- </factory>
- </extension>
-</plugin>
+<?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 +--> +<plugin> + <extension + point="org.eclipse.ui.newWizards"> + <wizard + category="org.eclipse.emf.cdo.dawn.ui.category.dawn" + class="org.eclipse.emf.cdo.dawn.graphiti.wizards.DawnGenericGraphitiWizard" + icon="icons/dawn_graphiti_editor.gif" + id="org.eclipse.emf.cdo.dawn.graphiti.wizard1" + name="Dawn Generic Graphiti Diagram"> + </wizard> + </extension> + <extension + point="org.eclipse.ui.editors"> + <editor + class="org.eclipse.emf.cdo.dawn.graphiti.editors.DawnGraphitiDiagramEditor" + default="false" + extensions="graphiti" + icon="icons/dawn_graphiti_editor.gif" + id="org.eclipse.emf.cdo.dawn.graphiti.editor" + name="Dawn Graphiti Editor"> + </editor> + </extension> + <extension point="org.eclipse.ui.elementFactories" id=".DiagramEditorFactory" name="%_diagram_editor_factory"> + <factory class="org.eclipse.emf.cdo.dawn.graphiti.editors.DawnGraphitiDiagramEditorInputFactory" id="org.eclipse.emf.cdo.dawn.graphiti.editors.DawnGraphitiDiagramEditorFactory"> + </factory> + </extension> +</plugin> diff --git a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/DawnGraphitiUIPlugin.java b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/DawnGraphitiUIPlugin.java index 075081a7a5..cd39b9141b 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/DawnGraphitiUIPlugin.java +++ b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/DawnGraphitiUIPlugin.java @@ -1,48 +1,48 @@ -/*
- * 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.graphiti;
-
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-
-import org.osgi.framework.BundleContext;
-
-/**
- * @author Martin Fluegge
- */
-public class DawnGraphitiUIPlugin extends AbstractUIPlugin
-{
- public static final String ID = "org.eclipse.emf.cdo.dawn.emf"; //$NON-NLS-1$
-
- private static DawnGraphitiUIPlugin plugin;
-
- public DawnGraphitiUIPlugin()
- {
- }
-
- @Override
- public void start(BundleContext context) throws Exception
- {
- super.start(context);
- plugin = this;
- }
-
- @Override
- public void stop(BundleContext context) throws Exception
- {
- plugin = null;
- super.stop(context);
- }
-
- public static DawnGraphitiUIPlugin getDefault()
- {
- return plugin;
- }
-}
+/* + * 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.graphiti; + +import org.eclipse.ui.plugin.AbstractUIPlugin; + +import org.osgi.framework.BundleContext; + +/** + * @author Martin Fluegge + */ +public class DawnGraphitiUIPlugin extends AbstractUIPlugin +{ + public static final String ID = "org.eclipse.emf.cdo.dawn.emf"; //$NON-NLS-1$ + + private static DawnGraphitiUIPlugin plugin; + + public DawnGraphitiUIPlugin() + { + } + + @Override + public void start(BundleContext context) throws Exception + { + super.start(context); + plugin = this; + } + + @Override + public void stop(BundleContext context) throws Exception + { + plugin = null; + super.stop(context); + } + + public static DawnGraphitiUIPlugin getDefault() + { + return plugin; + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/editors/DawnGraphitiDiagramEditor.java b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/editors/DawnGraphitiDiagramEditor.java index a1fef4d90c..f1bdbd8ab2 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/editors/DawnGraphitiDiagramEditor.java +++ b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/editors/DawnGraphitiDiagramEditor.java @@ -1,159 +1,159 @@ -/*
- * 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.graphiti.editors;
-
-import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
-import org.eclipse.emf.cdo.dawn.editors.IDawnEditorSupport;
-import org.eclipse.emf.cdo.dawn.util.connection.CDOConnectionUtil;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.common.ui.URIEditorInput;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.graphiti.mm.pictograms.Diagram;
-import org.eclipse.graphiti.ui.editor.DefaultPersistencyBehavior;
-import org.eclipse.graphiti.ui.editor.DiagramEditor;
-import org.eclipse.graphiti.ui.editor.IDiagramEditorInput;
-import org.eclipse.graphiti.ui.internal.services.GraphitiUiInternal;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.PartInitException;
-
-/**
- * @author Martin Fluegge
- */
-/*
- * TODO remove this suppress warning as soon as I have found a way to workaround the problem that the Graphiti editor
- * which is extended is internal
- */
-@SuppressWarnings("restriction")
-public class DawnGraphitiDiagramEditor extends DiagramEditor implements IDawnEditor
-{
- public static final String ID = "org.eclipse.emf.cdo.dawn.graphiti.editor";
-
- private IDawnEditorSupport dawnEditorSupport;
-
- private DefaultPersistencyBehavior persistencyBehavior;
-
- public DawnGraphitiDiagramEditor()
- {
- dawnEditorSupport = new DawnGraphitiEditorSupport(this);
- }
-
- @Override
- public void init(IEditorSite site, IEditorInput input) throws PartInitException
- {
- if (input instanceof URIEditorInput)
- {
- CDOConnectionUtil.instance.getCurrentSession();
- final URIEditorInput uriInput = (URIEditorInput)input;
-
- // TODO Check, if needed:
- // final TransactionalEditingDomain domain = DawnGraphitiUtil.createResourceSetAndEditingDomain();
-
- URI diagramFileUri = uriInput.getURI();
- if (diagramFileUri != null)
- {
- // the file's first base node has to be a diagram
-
- URI diagramUri = GraphitiUiInternal.getEmfService().mapDiagramFileUriToDiagramUri(diagramFileUri);
- input = new DawnGraphitiEditorInput(diagramUri, null);
- }
- }
-
- super.init(site, input);
- }
-
- @Override
- public void setInput(IEditorInput input)
- {
- super.setInput(input);
- IDiagramEditorInput diagramEditorInput = (IDiagramEditorInput)input;
-
- Diagram diagram = persistencyBehavior.loadDiagram(diagramEditorInput.getUri());
- Resource eResource = diagram.eResource();
-
- /**
- * TODO check if this can be always done this way and if the view can be canceled from the DawnEditorInput or if
- * there is a better way to put in the view to the editor input.
- */
- if (eResource instanceof CDOResource)
- {
- dawnEditorSupport.setView(((CDOResource)eResource).cdoView());
- }
- }
-
- @Override
- protected void initializeGraphicalViewer()
- {
- super.initializeGraphicalViewer();
- dawnEditorSupport.registerListeners();
- }
-
- public CDOView getView()
- {
- return dawnEditorSupport.getView();
- }
-
- public IDawnEditorSupport getDawnEditorSupport()
- {
- return dawnEditorSupport;
- }
-
- public String getContributorID()
- {
- return ID;
- }
-
- @Override
- public boolean isDirty()
- {
- // return super.isDirty() || dawnEditorSupport.isDirty();
- return dawnEditorSupport.isDirty();
- }
-
- public void setDirty()
- {
- dawnEditorSupport.setDirty(true);
- }
-
- @Override
- protected DefaultPersistencyBehavior createPersistencyBehavior()
- {
- persistencyBehavior = new DefaultPersistencyBehavior(this)
- {
- @Override
- public void saveDiagram(IProgressMonitor monitor)
- {
- dawnEditorSupport.setDirty(false);
- super.saveDiagram(monitor);
- }
- };
-
- return persistencyBehavior;
- }
-
- @Override
- public void dispose()
- {
- try
- {
- super.dispose();
- }
- finally
- {
- dawnEditorSupport.close();
- }
- }
-}
+/* + * 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.graphiti.editors; + +import org.eclipse.emf.cdo.dawn.editors.IDawnEditor; +import org.eclipse.emf.cdo.dawn.editors.IDawnEditorSupport; +import org.eclipse.emf.cdo.dawn.util.connection.CDOConnectionUtil; +import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.emf.common.ui.URIEditorInput; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.Resource; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.graphiti.mm.pictograms.Diagram; +import org.eclipse.graphiti.ui.editor.DefaultPersistencyBehavior; +import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorInput; +import org.eclipse.graphiti.ui.internal.services.GraphitiUiInternal; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorSite; +import org.eclipse.ui.PartInitException; + +/** + * @author Martin Fluegge + */ +/* + * TODO remove this suppress warning as soon as I have found a way to workaround the problem that the Graphiti editor + * which is extended is internal + */ +@SuppressWarnings("restriction") +public class DawnGraphitiDiagramEditor extends DiagramEditor implements IDawnEditor +{ + public static final String ID = "org.eclipse.emf.cdo.dawn.graphiti.editor"; + + private IDawnEditorSupport dawnEditorSupport; + + private DefaultPersistencyBehavior persistencyBehavior; + + public DawnGraphitiDiagramEditor() + { + dawnEditorSupport = new DawnGraphitiEditorSupport(this); + } + + @Override + public void init(IEditorSite site, IEditorInput input) throws PartInitException + { + if (input instanceof URIEditorInput) + { + CDOConnectionUtil.instance.getCurrentSession(); + final URIEditorInput uriInput = (URIEditorInput)input; + + // TODO Check, if needed: + // final TransactionalEditingDomain domain = DawnGraphitiUtil.createResourceSetAndEditingDomain(); + + URI diagramFileUri = uriInput.getURI(); + if (diagramFileUri != null) + { + // the file's first base node has to be a diagram + + URI diagramUri = GraphitiUiInternal.getEmfService().mapDiagramFileUriToDiagramUri(diagramFileUri); + input = new DawnGraphitiEditorInput(diagramUri, null); + } + } + + super.init(site, input); + } + + @Override + public void setInput(IEditorInput input) + { + super.setInput(input); + IDiagramEditorInput diagramEditorInput = (IDiagramEditorInput)input; + + Diagram diagram = persistencyBehavior.loadDiagram(diagramEditorInput.getUri()); + Resource eResource = diagram.eResource(); + + /** + * TODO check if this can be always done this way and if the view can be canceled from the DawnEditorInput or if + * there is a better way to put in the view to the editor input. + */ + if (eResource instanceof CDOResource) + { + dawnEditorSupport.setView(((CDOResource)eResource).cdoView()); + } + } + + @Override + protected void initializeGraphicalViewer() + { + super.initializeGraphicalViewer(); + dawnEditorSupport.registerListeners(); + } + + public CDOView getView() + { + return dawnEditorSupport.getView(); + } + + public IDawnEditorSupport getDawnEditorSupport() + { + return dawnEditorSupport; + } + + public String getContributorID() + { + return ID; + } + + @Override + public boolean isDirty() + { + // return super.isDirty() || dawnEditorSupport.isDirty(); + return dawnEditorSupport.isDirty(); + } + + public void setDirty() + { + dawnEditorSupport.setDirty(true); + } + + @Override + protected DefaultPersistencyBehavior createPersistencyBehavior() + { + persistencyBehavior = new DefaultPersistencyBehavior(this) + { + @Override + public void saveDiagram(IProgressMonitor monitor) + { + dawnEditorSupport.setDirty(false); + super.saveDiagram(monitor); + } + }; + + return persistencyBehavior; + } + + @Override + public void dispose() + { + try + { + super.dispose(); + } + finally + { + dawnEditorSupport.close(); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/editors/DawnGraphitiDiagramEditorInputFactory.java b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/editors/DawnGraphitiDiagramEditorInputFactory.java index 118b810618..8aef743ce0 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/editors/DawnGraphitiDiagramEditorInputFactory.java +++ b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/editors/DawnGraphitiDiagramEditorInputFactory.java @@ -1,41 +1,41 @@ -/*
- * 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.graphiti.editors;
-
-import org.eclipse.emf.common.util.URI;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.graphiti.ui.editor.DiagramEditorInput;
-import org.eclipse.graphiti.ui.editor.DiagramEditorInputFactory;
-import org.eclipse.ui.IMemento;
-
-/**
- * @author Martin Fluegge
- */
-public class DawnGraphitiDiagramEditorInputFactory extends DiagramEditorInputFactory
-{
- @Override
- public IAdaptable createElement(IMemento memento)
- {
- final String diagramUriString = memento.getString(DiagramEditorInput.KEY_URI);
- if (diagramUriString == null)
- {
- return null;
- }
-
- final String providerID = memento.getString(DiagramEditorInput.KEY_PROVIDER_ID);
-
- // TODO Check, if needed:
- // final TransactionalEditingDomain domain = createResourceSetAndEditingDomain();
-
- return new DawnGraphitiEditorInput(URI.createURI(diagramUriString), providerID);
- }
-}
+/* + * 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.graphiti.editors; + +import org.eclipse.emf.common.util.URI; + +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.graphiti.ui.editor.DiagramEditorInput; +import org.eclipse.graphiti.ui.editor.DiagramEditorInputFactory; +import org.eclipse.ui.IMemento; + +/** + * @author Martin Fluegge + */ +public class DawnGraphitiDiagramEditorInputFactory extends DiagramEditorInputFactory +{ + @Override + public IAdaptable createElement(IMemento memento) + { + final String diagramUriString = memento.getString(DiagramEditorInput.KEY_URI); + if (diagramUriString == null) + { + return null; + } + + final String providerID = memento.getString(DiagramEditorInput.KEY_PROVIDER_ID); + + // TODO Check, if needed: + // final TransactionalEditingDomain domain = createResourceSetAndEditingDomain(); + + return new DawnGraphitiEditorInput(URI.createURI(diagramUriString), providerID); + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/editors/DawnGraphitiEditorInput.java b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/editors/DawnGraphitiEditorInput.java index a68b0a682f..09c50bc7c6 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/editors/DawnGraphitiEditorInput.java +++ b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/editors/DawnGraphitiEditorInput.java @@ -1,67 +1,67 @@ -/*
- * 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.graphiti.editors;
-
-import org.eclipse.emf.cdo.dawn.ui.DawnEditorInput;
-import org.eclipse.emf.cdo.dawn.ui.IDawnEditorInput;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-
-import org.eclipse.graphiti.ui.editor.DiagramEditorInput;
-
-/**
- * @author Martin Fluegge
- */
-public class DawnGraphitiEditorInput extends DiagramEditorInput implements IDawnEditorInput
-{
- private DawnEditorInput input;
-
- public DawnGraphitiEditorInput(URI uri, String providerId)
- {
- super(uri, providerId);
- input = new DawnEditorInput(uri);
- }
-
- public DawnGraphitiEditorInput(URI uri, String providerId, Resource resource)
- {
- this(uri, providerId);
- input.setResource((CDOResource)resource);
- }
-
- public CDOView getView()
- {
- return input.getView();
- }
-
- public boolean isViewOwned()
- {
- return input.isViewOwned();
- }
-
- public String getResourcePath()
- {
- return input.getResourcePath();
- }
-
- /**
- * This id is needed to provide the correct IElementFactory to the framework and allow to create a
- * DawnGraphitiEditorInput from the persisted state on restoring an editor. See extension point
- * org.eclipse.ui.elementFactories.
- */
- @Override
- public String getFactoryId()
- {
- return DawnGraphitiDiagramEditorInputFactory.class.getName();
- }
-}
+/* + * 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.graphiti.editors; + +import org.eclipse.emf.cdo.dawn.ui.DawnEditorInput; +import org.eclipse.emf.cdo.dawn.ui.IDawnEditorInput; +import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.Resource; + +import org.eclipse.graphiti.ui.editor.DiagramEditorInput; + +/** + * @author Martin Fluegge + */ +public class DawnGraphitiEditorInput extends DiagramEditorInput implements IDawnEditorInput +{ + private DawnEditorInput input; + + public DawnGraphitiEditorInput(URI uri, String providerId) + { + super(uri, providerId); + input = new DawnEditorInput(uri); + } + + public DawnGraphitiEditorInput(URI uri, String providerId, Resource resource) + { + this(uri, providerId); + input.setResource((CDOResource)resource); + } + + public CDOView getView() + { + return input.getView(); + } + + public boolean isViewOwned() + { + return input.isViewOwned(); + } + + public String getResourcePath() + { + return input.getResourcePath(); + } + + /** + * This id is needed to provide the correct IElementFactory to the framework and allow to create a + * DawnGraphitiEditorInput from the persisted state on restoring an editor. See extension point + * org.eclipse.ui.elementFactories. + */ + @Override + public String getFactoryId() + { + return DawnGraphitiDiagramEditorInputFactory.class.getName(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/editors/DawnGraphitiEditorSupport.java b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/editors/DawnGraphitiEditorSupport.java index 4b68967356..b6178c53ba 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/editors/DawnGraphitiEditorSupport.java +++ b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/editors/DawnGraphitiEditorSupport.java @@ -1,229 +1,229 @@ -/*
- * 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.graphiti.editors;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.dawn.appearance.DawnElementStylizer;
-import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
-import org.eclipse.emf.cdo.dawn.editors.impl.DawnAbstractEditorSupport;
-import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnAppearancer;
-import org.eclipse.emf.cdo.dawn.gmf.synchronize.DawnChangeHelper;
-import org.eclipse.emf.cdo.dawn.gmf.util.DawnDiagramUpdater;
-import org.eclipse.emf.cdo.dawn.graphiti.notifications.DawnGraphitiHandler;
-import org.eclipse.emf.cdo.dawn.graphiti.notifications.DawnGraphitiLockingHandler;
-import org.eclipse.emf.cdo.dawn.graphiti.util.DawnGraphitiUtil;
-import org.eclipse.emf.cdo.dawn.helper.DawnEditorHelper;
-import org.eclipse.emf.cdo.dawn.notifications.BasicDawnListener;
-import org.eclipse.emf.cdo.dawn.spi.DawnState;
-import org.eclipse.emf.cdo.dawn.ui.stylizer.DawnElementStylizerRegistry;
-import org.eclipse.emf.cdo.transaction.CDOTransactionHandlerBase;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.RootEditPart;
-import org.eclipse.graphiti.mm.pictograms.PictogramElement;
-import org.eclipse.graphiti.ui.editor.DiagramEditor;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Martin Fluegge
- */
-/*
- * TODO remove this suppress warning as soon as I have found a way to workaround the problem that the Graphiti editor
- * which is extended is internal
- */
-public class DawnGraphitiEditorSupport extends DawnAbstractEditorSupport
-{
- private DawnGraphitiHandler dawnGraphitiHandler;
-
- public DawnGraphitiEditorSupport(IDawnEditor editor)
- {
- super(editor);
- dawnGraphitiHandler = new DawnGraphitiHandler(getEditor());
- }
-
- public void close()
- {
- CDOView view = getView();
- if (view != null && !view.isClosed())
- {
- view.close();
- }
- }
-
- @Override
- protected BasicDawnListener getBasicHandler()
- {
- return dawnGraphitiHandler;
- }
-
- @Override
- protected BasicDawnListener getLockingHandler()
- {
- return new DawnGraphitiLockingHandler(getEditor());
- }
-
- @Override
- protected CDOTransactionHandlerBase getTransactionHandler()
- {
- return dawnGraphitiHandler;
- }
-
- @Override
- // TODO: try to move this method to a common base class for Graphiti and GMF
- public void rollback()
- {
- super.rollback();
- final DiagramEditor diagramDocumentEditor = (DiagramEditor)getEditor();
- TransactionalEditingDomain editingDomain = diagramDocumentEditor.getEditingDomain();
- editingDomain.getCommandStack().execute(new RecordingCommand(editingDomain)
- {
- @Override
- public void doExecute()
- {
- RootEditPart rootEditPart = diagramDocumentEditor.getGraphicalViewer().getRootEditPart();
- DawnAppearancer.setEditPartDefaultAllChildren(rootEditPart);
- DawnDiagramUpdater.refreshEditPart(rootEditPart);
- }
- });
- }
-
- public void refresh()
- {
- DawnEditorHelper.getDisplay().asyncExec(new Runnable()
- {
- public void run()
- {
- RootEditPart rootEditPart = ((DiagramEditor)getEditor()).getGraphicalViewer().getRootEditPart();
- DawnDiagramUpdater.refreshEditPart(rootEditPart);
- }
- });
- }
-
- public void lockObject(Object objectToBeLocked)
- {
- if (objectToBeLocked instanceof EditPart)
- {
- EditPart editPart = (EditPart)objectToBeLocked;
- Object model = editPart.getModel();
-
- if (model instanceof EObject)
- {
- CDOUtil.getCDOObject((EObject)model).cdoWriteLock().lock();
- if (model instanceof PictogramElement)
- {
- EList<EObject> businessObjects = ((PictogramElement)model).getLink().getBusinessObjects();
- for (EObject element : businessObjects)
- {
- CDOUtil.getCDOObject(element).cdoWriteLock().lock();
- }
- }
- }
- DawnElementStylizer stylizer = DawnElementStylizerRegistry.instance.getStylizer(editPart);
- if (stylizer != null)
- {
- stylizer.setLocked(editPart, DawnAppearancer.TYPE_LOCKED_LOCALLY);
- }
- }
- refresh();
- }
-
- public void unlockObject(Object objectToBeUnlocked)
- {
- if (objectToBeUnlocked instanceof EditPart)
- {
- EditPart editPart = (EditPart)objectToBeUnlocked;
-
- Object model = editPart.getModel();
-
- if (model instanceof EObject)
- {
- CDOUtil.getCDOObject((EObject)model).cdoWriteLock().unlock();
- if (model instanceof PictogramElement)
- {
- if (model instanceof PictogramElement)
- {
- EList<EObject> businessObjects = ((PictogramElement)model).getLink().getBusinessObjects();
- for (EObject element : businessObjects)
- {
- CDOUtil.getCDOObject(element).cdoWriteLock().unlock();
- }
- }
- }
- }
- DawnElementStylizer stylizer = DawnElementStylizerRegistry.instance.getStylizer(editPart);
- if (stylizer != null)
- {
- stylizer.setDefault(editPart);
- }
- }
- refresh();
- }
-
- public void handleRemoteLockChanges(final Map<Object, DawnState> changedObjects)
- {
- DawnEditorHelper.getDisplay().asyncExec(new Runnable()
- {
- public void run()
- {
- for (Object o : changedObjects.keySet())
- {
- handleLock((CDOObject)o, getView());
- }
- }
- });
-
- refresh();
- }
-
- private void handleLock(CDOObject object, CDOView cdoView)
- {
- EObject element = CDOUtil.getEObject(object); // either semantic object or notational
-
- DiagramEditor editor = (DiagramEditor)getEditor();
-
- List<PictogramElement> pictogramElements = DawnGraphitiUtil.getPictgramElements(editor.getDiagramTypeProvider()
- .getDiagram(), element);
-
- for (PictogramElement pictogramElement : pictogramElements)
- {
- EditPart editPart = DawnGraphitiUtil.getEditpart(pictogramElement, editor.getGraphicalViewer().getRootEditPart());
-
- if (editPart == null)
- {
- continue;
- }
-
- if (object.cdoWriteLock().isLocked())
- {
- DawnAppearancer.setEditPartLocked(editPart, DawnAppearancer.TYPE_LOCKED_LOCALLY);
- }
- else if (object.cdoWriteLock().isLockedByOthers())
- {
- DawnAppearancer.setEditPartLocked(editPart, DawnAppearancer.TYPE_LOCKED_GLOBALLY);
- DawnChangeHelper.deactivateEditPart(editPart);
- }
- else
- {
- DawnAppearancer.setEditPartDefault(editPart);
- DawnChangeHelper.activateEditPart(editPart);
- }
- }
- }
-}
+/* + * 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.graphiti.editors; + +import org.eclipse.emf.cdo.CDOObject; +import org.eclipse.emf.cdo.dawn.appearance.DawnElementStylizer; +import org.eclipse.emf.cdo.dawn.editors.IDawnEditor; +import org.eclipse.emf.cdo.dawn.editors.impl.DawnAbstractEditorSupport; +import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnAppearancer; +import org.eclipse.emf.cdo.dawn.gmf.synchronize.DawnChangeHelper; +import org.eclipse.emf.cdo.dawn.gmf.util.DawnDiagramUpdater; +import org.eclipse.emf.cdo.dawn.graphiti.notifications.DawnGraphitiHandler; +import org.eclipse.emf.cdo.dawn.graphiti.notifications.DawnGraphitiLockingHandler; +import org.eclipse.emf.cdo.dawn.graphiti.util.DawnGraphitiUtil; +import org.eclipse.emf.cdo.dawn.helper.DawnEditorHelper; +import org.eclipse.emf.cdo.dawn.notifications.BasicDawnListener; +import org.eclipse.emf.cdo.dawn.spi.DawnState; +import org.eclipse.emf.cdo.dawn.ui.stylizer.DawnElementStylizerRegistry; +import org.eclipse.emf.cdo.transaction.CDOTransactionHandlerBase; +import org.eclipse.emf.cdo.util.CDOUtil; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; + +import org.eclipse.gef.EditPart; +import org.eclipse.gef.RootEditPart; +import org.eclipse.graphiti.mm.pictograms.PictogramElement; +import org.eclipse.graphiti.ui.editor.DiagramEditor; + +import java.util.List; +import java.util.Map; + +/** + * @author Martin Fluegge + */ +/* + * TODO remove this suppress warning as soon as I have found a way to workaround the problem that the Graphiti editor + * which is extended is internal + */ +public class DawnGraphitiEditorSupport extends DawnAbstractEditorSupport +{ + private DawnGraphitiHandler dawnGraphitiHandler; + + public DawnGraphitiEditorSupport(IDawnEditor editor) + { + super(editor); + dawnGraphitiHandler = new DawnGraphitiHandler(getEditor()); + } + + public void close() + { + CDOView view = getView(); + if (view != null && !view.isClosed()) + { + view.close(); + } + } + + @Override + protected BasicDawnListener getBasicHandler() + { + return dawnGraphitiHandler; + } + + @Override + protected BasicDawnListener getLockingHandler() + { + return new DawnGraphitiLockingHandler(getEditor()); + } + + @Override + protected CDOTransactionHandlerBase getTransactionHandler() + { + return dawnGraphitiHandler; + } + + @Override + // TODO: try to move this method to a common base class for Graphiti and GMF + public void rollback() + { + super.rollback(); + final DiagramEditor diagramDocumentEditor = (DiagramEditor)getEditor(); + TransactionalEditingDomain editingDomain = diagramDocumentEditor.getEditingDomain(); + editingDomain.getCommandStack().execute(new RecordingCommand(editingDomain) + { + @Override + public void doExecute() + { + RootEditPart rootEditPart = diagramDocumentEditor.getGraphicalViewer().getRootEditPart(); + DawnAppearancer.setEditPartDefaultAllChildren(rootEditPart); + DawnDiagramUpdater.refreshEditPart(rootEditPart); + } + }); + } + + public void refresh() + { + DawnEditorHelper.getDisplay().asyncExec(new Runnable() + { + public void run() + { + RootEditPart rootEditPart = ((DiagramEditor)getEditor()).getGraphicalViewer().getRootEditPart(); + DawnDiagramUpdater.refreshEditPart(rootEditPart); + } + }); + } + + public void lockObject(Object objectToBeLocked) + { + if (objectToBeLocked instanceof EditPart) + { + EditPart editPart = (EditPart)objectToBeLocked; + Object model = editPart.getModel(); + + if (model instanceof EObject) + { + CDOUtil.getCDOObject((EObject)model).cdoWriteLock().lock(); + if (model instanceof PictogramElement) + { + EList<EObject> businessObjects = ((PictogramElement)model).getLink().getBusinessObjects(); + for (EObject element : businessObjects) + { + CDOUtil.getCDOObject(element).cdoWriteLock().lock(); + } + } + } + DawnElementStylizer stylizer = DawnElementStylizerRegistry.instance.getStylizer(editPart); + if (stylizer != null) + { + stylizer.setLocked(editPart, DawnAppearancer.TYPE_LOCKED_LOCALLY); + } + } + refresh(); + } + + public void unlockObject(Object objectToBeUnlocked) + { + if (objectToBeUnlocked instanceof EditPart) + { + EditPart editPart = (EditPart)objectToBeUnlocked; + + Object model = editPart.getModel(); + + if (model instanceof EObject) + { + CDOUtil.getCDOObject((EObject)model).cdoWriteLock().unlock(); + if (model instanceof PictogramElement) + { + if (model instanceof PictogramElement) + { + EList<EObject> businessObjects = ((PictogramElement)model).getLink().getBusinessObjects(); + for (EObject element : businessObjects) + { + CDOUtil.getCDOObject(element).cdoWriteLock().unlock(); + } + } + } + } + DawnElementStylizer stylizer = DawnElementStylizerRegistry.instance.getStylizer(editPart); + if (stylizer != null) + { + stylizer.setDefault(editPart); + } + } + refresh(); + } + + public void handleRemoteLockChanges(final Map<Object, DawnState> changedObjects) + { + DawnEditorHelper.getDisplay().asyncExec(new Runnable() + { + public void run() + { + for (Object o : changedObjects.keySet()) + { + handleLock((CDOObject)o, getView()); + } + } + }); + + refresh(); + } + + private void handleLock(CDOObject object, CDOView cdoView) + { + EObject element = CDOUtil.getEObject(object); // either semantic object or notational + + DiagramEditor editor = (DiagramEditor)getEditor(); + + List<PictogramElement> pictogramElements = DawnGraphitiUtil.getPictgramElements(editor.getDiagramTypeProvider() + .getDiagram(), element); + + for (PictogramElement pictogramElement : pictogramElements) + { + EditPart editPart = DawnGraphitiUtil.getEditpart(pictogramElement, editor.getGraphicalViewer().getRootEditPart()); + + if (editPart == null) + { + continue; + } + + if (object.cdoWriteLock().isLocked()) + { + DawnAppearancer.setEditPartLocked(editPart, DawnAppearancer.TYPE_LOCKED_LOCALLY); + } + else if (object.cdoWriteLock().isLockedByOthers()) + { + DawnAppearancer.setEditPartLocked(editPart, DawnAppearancer.TYPE_LOCKED_GLOBALLY); + DawnChangeHelper.deactivateEditPart(editPart); + } + else + { + DawnAppearancer.setEditPartDefault(editPart); + DawnChangeHelper.activateEditPart(editPart); + } + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/notifications/DawnGraphitiHandler.java b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/notifications/DawnGraphitiHandler.java index 18e59317c8..8c1cbc720d 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/notifications/DawnGraphitiHandler.java +++ b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/notifications/DawnGraphitiHandler.java @@ -1,220 +1,220 @@ -/*
- * 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.graphiti.notifications;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
-import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnAppearancer;
-import org.eclipse.emf.cdo.dawn.gmf.synchronize.DawnConflictHelper;
-import org.eclipse.emf.cdo.dawn.gmf.util.DawnDiagramUpdater;
-import org.eclipse.emf.cdo.dawn.graphiti.util.DawnGraphitiUtil;
-import org.eclipse.emf.cdo.dawn.helper.DawnEditorHelper;
-import org.eclipse.emf.cdo.dawn.notifications.BasicDawnTransactionHandler;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.transaction.CDOTransactionConflictEvent;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.InvalidObjectException;
-import org.eclipse.emf.cdo.view.CDOViewInvalidationEvent;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.edit.domain.IEditingDomainProvider;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-
-import org.eclipse.draw2d.graph.Edge;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.GraphicalViewer;
-import org.eclipse.gef.RootEditPart;
-import org.eclipse.graphiti.mm.pictograms.PictogramElement;
-import org.eclipse.graphiti.ui.editor.DiagramEditor;
-import org.eclipse.swt.widgets.Display;
-
-import java.util.List;
-
-/**
- * @author Martin Fluegge
- */
-public class DawnGraphitiHandler extends BasicDawnTransactionHandler
-{
- public DawnGraphitiHandler(IDawnEditor editor)
- {
- super(editor);
- }
-
- /**
- * @since 2.0
- */
- @Override
- public void handleViewInvalidationEvent(CDOViewInvalidationEvent event)
- {
- editor.getDawnEditorSupport().refresh();
- }
-
- /**
- * @since 2.0
- */
- @Override
- public void handleTransactionConflictEvent(CDOTransactionConflictEvent event)
- {
- CDOTransactionConflictEvent cdoTransactionConflictEvent = event;
-
- CDOObject cdoObject = cdoTransactionConflictEvent.getConflictingObject();
-
- EObject element = CDOUtil.getEObject(cdoObject); // either semantic object or notational
-
- List<PictogramElement> pictgramElements = DawnGraphitiUtil.getPictgramElements(((DiagramEditor)editor)
- .getDiagramTypeProvider().getDiagram(), element);
-
- GraphicalViewer graphicalViewer = ((DiagramEditor)editor).getGraphicalViewer();
-
- for (PictogramElement pictgramElement : pictgramElements)
- {
- final EditPart editpart = DawnGraphitiUtil.getEditpart(pictgramElement, graphicalViewer.getRootEditPart());
-
- if (DawnConflictHelper.isConflicted(cdoObject))
- {
- DawnEditorHelper.getDisplay().syncExec(new Runnable()
- {
- public void run()
- {
- int typeConflictLocallyDeleted = DawnAppearancer.TYPE_CONFLICT_REMOTELY_DELETED;
- DawnAppearancer.setEditPartConflicted(editpart, typeConflictLocallyDeleted);
- }
- });
- }
- }
- }
-
- @Override
- public void modifyingObject(CDOTransaction transaction, final CDOObject object, CDOFeatureDelta featureDelta)
- {
- super.modifyingObject(transaction, object, featureDelta);
- editor.getDawnEditorSupport().refresh();
- }
-
- /**
- * @since 2.0
- */
- @Override
- public void attachingObject(CDOTransaction transaction, CDOObject object)
- {
- super.attachingObject(transaction, object);
- editor.getDawnEditorSupport().refresh();
- }
-
- /**
- * Edges must be adjusted because of the transience of the Node source/targetEdges CDO cannot see this because
- * removing an edges just removes the edge from the diagram. CDO just notices the change in the diagram but not in the
- * (detached) edge. The other site (node) is transient and will not be part of the notification. So I must adjust this
- * later. CDOLEgacy Wrapper breakes because it only adjusts the changes in the diagram and not the removed edge. So I
- * cannot adjust this in the Wrapper. Maybe there is another more generic way.
- */
- public void adjustDeletedEdges(final CDOViewInvalidationEvent e)
- {
- Display.getDefault().asyncExec(new Runnable()
- {
- public void run()
- {
- for (CDOObject obj : e.getDetachedObjects())
- {
- final EObject view = CDOUtil.getEObject(obj);
- if (view instanceof Edge)
- {
- EditingDomain editingDomain = ((IEditingDomainProvider)view.eResource().getResourceSet())
- .getEditingDomain();
- editingDomain.getCommandStack().execute(new RecordingCommand((TransactionalEditingDomain)editingDomain)
- {
- @Override
- protected void doExecute()
- {
- try
- {
- ((Edge)view).setTarget(null);
- }
- catch (InvalidObjectException ignore)
- {
- }
-
- try
- {
- ((Edge)view).setSource(null);
- }
- catch (InvalidObjectException ignore)
- {
- }
- }
- });
- }
- }
- }
- });
- }
-
- @SuppressWarnings("unused")
- private void handleObject(CDOObject dirtyObject)
- {
- if (dirtyObject.cdoInvalid())
- {
- return;
- }
- EObject element = CDOUtil.getEObject(dirtyObject); // either sementic object or notational
-
- // EditingDomain editingDomain = ((DiagramEditor)editor).getEditingDomain();
- // editingDomain.getCommandStack().execute(new RecordingCommand((TransactionalEditingDomain)editingDomain)
- // {
- // @Override
- // protected void doExecute()
- // {
- // RootEditPart rootEditPart = ((DiagramEditor)editor).getGraphicalViewer().getRootEditPart();
- // DawnDiagramUpdater.refreshEditPart(rootEditPart);
- // }
- // });
-
- Display.getDefault().asyncExec(new Runnable()
- {
- public void run()
- {
- RootEditPart rootEditPart = ((DiagramEditor)editor).getGraphicalViewer().getRootEditPart();
- DawnDiagramUpdater.refreshEditPart(rootEditPart);
- }
- });
-
- // View view = DawnDiagramUpdater.findView(element);
-
- if (DawnConflictHelper.isConflicted(dirtyObject))
- {
- // DawnConflictHelper.handleConflictedView(dirtyObject, view, editor);
- return;
- }
-
- // EditPart relatedEditPart = DawnDiagramUpdater.findEditPart(view, ((DiagramEditor)editor).getGraphicalViewer()
- // .getRootEditPart().getViewer());
- // if (relatedEditPart != null)
- // {
- // DawnDiagramUpdater.refreshEditPart(relatedEditPart.getParent());
- // }
- // else
- // {
- // if (TRACER.isEnabled())
- // {
- // TRACER.format("Updating DiagramEditPart {0} ", ((DiagramEditor)editor).getDiagramEditPart()); //$NON-NLS-1$
- // }
- // DawnDiagramUpdater.refreshEditPart(((DiagramEditor)editor).getDiagramEditPart(), (DiagramDocumentEditor)editor);
- // }
- }
-
- protected void refresh(CDOObject object)
- {
- DawnDiagramUpdater.refreshEditPart(((DiagramEditor)editor).getGraphicalViewer().getRootEditPart());
- }
-}
+/* + * 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.graphiti.notifications; + +import org.eclipse.emf.cdo.CDOObject; +import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta; +import org.eclipse.emf.cdo.dawn.editors.IDawnEditor; +import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnAppearancer; +import org.eclipse.emf.cdo.dawn.gmf.synchronize.DawnConflictHelper; +import org.eclipse.emf.cdo.dawn.gmf.util.DawnDiagramUpdater; +import org.eclipse.emf.cdo.dawn.graphiti.util.DawnGraphitiUtil; +import org.eclipse.emf.cdo.dawn.helper.DawnEditorHelper; +import org.eclipse.emf.cdo.dawn.notifications.BasicDawnTransactionHandler; +import org.eclipse.emf.cdo.transaction.CDOTransaction; +import org.eclipse.emf.cdo.transaction.CDOTransactionConflictEvent; +import org.eclipse.emf.cdo.util.CDOUtil; +import org.eclipse.emf.cdo.util.InvalidObjectException; +import org.eclipse.emf.cdo.view.CDOViewInvalidationEvent; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.emf.edit.domain.IEditingDomainProvider; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; + +import org.eclipse.draw2d.graph.Edge; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.GraphicalViewer; +import org.eclipse.gef.RootEditPart; +import org.eclipse.graphiti.mm.pictograms.PictogramElement; +import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.swt.widgets.Display; + +import java.util.List; + +/** + * @author Martin Fluegge + */ +public class DawnGraphitiHandler extends BasicDawnTransactionHandler +{ + public DawnGraphitiHandler(IDawnEditor editor) + { + super(editor); + } + + /** + * @since 2.0 + */ + @Override + public void handleViewInvalidationEvent(CDOViewInvalidationEvent event) + { + editor.getDawnEditorSupport().refresh(); + } + + /** + * @since 2.0 + */ + @Override + public void handleTransactionConflictEvent(CDOTransactionConflictEvent event) + { + CDOTransactionConflictEvent cdoTransactionConflictEvent = event; + + CDOObject cdoObject = cdoTransactionConflictEvent.getConflictingObject(); + + EObject element = CDOUtil.getEObject(cdoObject); // either semantic object or notational + + List<PictogramElement> pictgramElements = DawnGraphitiUtil.getPictgramElements(((DiagramEditor)editor) + .getDiagramTypeProvider().getDiagram(), element); + + GraphicalViewer graphicalViewer = ((DiagramEditor)editor).getGraphicalViewer(); + + for (PictogramElement pictgramElement : pictgramElements) + { + final EditPart editpart = DawnGraphitiUtil.getEditpart(pictgramElement, graphicalViewer.getRootEditPart()); + + if (DawnConflictHelper.isConflicted(cdoObject)) + { + DawnEditorHelper.getDisplay().syncExec(new Runnable() + { + public void run() + { + int typeConflictLocallyDeleted = DawnAppearancer.TYPE_CONFLICT_REMOTELY_DELETED; + DawnAppearancer.setEditPartConflicted(editpart, typeConflictLocallyDeleted); + } + }); + } + } + } + + @Override + public void modifyingObject(CDOTransaction transaction, final CDOObject object, CDOFeatureDelta featureDelta) + { + super.modifyingObject(transaction, object, featureDelta); + editor.getDawnEditorSupport().refresh(); + } + + /** + * @since 2.0 + */ + @Override + public void attachingObject(CDOTransaction transaction, CDOObject object) + { + super.attachingObject(transaction, object); + editor.getDawnEditorSupport().refresh(); + } + + /** + * Edges must be adjusted because of the transience of the Node source/targetEdges CDO cannot see this because + * removing an edges just removes the edge from the diagram. CDO just notices the change in the diagram but not in the + * (detached) edge. The other site (node) is transient and will not be part of the notification. So I must adjust this + * later. CDOLEgacy Wrapper breakes because it only adjusts the changes in the diagram and not the removed edge. So I + * cannot adjust this in the Wrapper. Maybe there is another more generic way. + */ + public void adjustDeletedEdges(final CDOViewInvalidationEvent e) + { + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + for (CDOObject obj : e.getDetachedObjects()) + { + final EObject view = CDOUtil.getEObject(obj); + if (view instanceof Edge) + { + EditingDomain editingDomain = ((IEditingDomainProvider)view.eResource().getResourceSet()) + .getEditingDomain(); + editingDomain.getCommandStack().execute(new RecordingCommand((TransactionalEditingDomain)editingDomain) + { + @Override + protected void doExecute() + { + try + { + ((Edge)view).setTarget(null); + } + catch (InvalidObjectException ignore) + { + } + + try + { + ((Edge)view).setSource(null); + } + catch (InvalidObjectException ignore) + { + } + } + }); + } + } + } + }); + } + + @SuppressWarnings("unused") + private void handleObject(CDOObject dirtyObject) + { + if (dirtyObject.cdoInvalid()) + { + return; + } + EObject element = CDOUtil.getEObject(dirtyObject); // either sementic object or notational + + // EditingDomain editingDomain = ((DiagramEditor)editor).getEditingDomain(); + // editingDomain.getCommandStack().execute(new RecordingCommand((TransactionalEditingDomain)editingDomain) + // { + // @Override + // protected void doExecute() + // { + // RootEditPart rootEditPart = ((DiagramEditor)editor).getGraphicalViewer().getRootEditPart(); + // DawnDiagramUpdater.refreshEditPart(rootEditPart); + // } + // }); + + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + RootEditPart rootEditPart = ((DiagramEditor)editor).getGraphicalViewer().getRootEditPart(); + DawnDiagramUpdater.refreshEditPart(rootEditPart); + } + }); + + // View view = DawnDiagramUpdater.findView(element); + + if (DawnConflictHelper.isConflicted(dirtyObject)) + { + // DawnConflictHelper.handleConflictedView(dirtyObject, view, editor); + return; + } + + // EditPart relatedEditPart = DawnDiagramUpdater.findEditPart(view, ((DiagramEditor)editor).getGraphicalViewer() + // .getRootEditPart().getViewer()); + // if (relatedEditPart != null) + // { + // DawnDiagramUpdater.refreshEditPart(relatedEditPart.getParent()); + // } + // else + // { + // if (TRACER.isEnabled()) + // { + // TRACER.format("Updating DiagramEditPart {0} ", ((DiagramEditor)editor).getDiagramEditPart()); //$NON-NLS-1$ + // } + // DawnDiagramUpdater.refreshEditPart(((DiagramEditor)editor).getDiagramEditPart(), (DiagramDocumentEditor)editor); + // } + } + + protected void refresh(CDOObject object) + { + DawnDiagramUpdater.refreshEditPart(((DiagramEditor)editor).getGraphicalViewer().getRootEditPart()); + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/notifications/DawnGraphitiLockingHandler.java b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/notifications/DawnGraphitiLockingHandler.java index 26ed10903a..7ee2a7c400 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/notifications/DawnGraphitiLockingHandler.java +++ b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/notifications/DawnGraphitiLockingHandler.java @@ -1,25 +1,25 @@ -/*
- * 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.graphiti.notifications;
-
-import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
-import org.eclipse.emf.cdo.dawn.notifications.BasicDawnLockingHandler;
-
-/**
- * @author Martin Fluegge
- */
-public class DawnGraphitiLockingHandler extends BasicDawnLockingHandler
-{
- public DawnGraphitiLockingHandler(IDawnEditor editor)
- {
- super(editor);
- }
-}
+/* + * 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.graphiti.notifications; + +import org.eclipse.emf.cdo.dawn.editors.IDawnEditor; +import org.eclipse.emf.cdo.dawn.notifications.BasicDawnLockingHandler; + +/** + * @author Martin Fluegge + */ +public class DawnGraphitiLockingHandler extends BasicDawnLockingHandler +{ + public DawnGraphitiLockingHandler(IDawnEditor editor) + { + super(editor); + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/util/DawnGraphitiUtil.java b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/util/DawnGraphitiUtil.java index e44eda3ea5..681b17b649 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/util/DawnGraphitiUtil.java +++ b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/util/DawnGraphitiUtil.java @@ -1,124 +1,124 @@ -/*
- * 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.graphiti.util;
-
-import org.eclipse.emf.cdo.dawn.preferences.PreferenceConstants;
-import org.eclipse.emf.cdo.dawn.transaction.DawnTransactionalEditingDomainImpl;
-import org.eclipse.emf.cdo.dawn.util.connection.CDOConnectionUtil;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
-import org.eclipse.emf.transaction.TransactionalCommandStack;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl;
-import org.eclipse.emf.workspace.WorkspaceEditingDomainFactory;
-
-import org.eclipse.core.commands.operations.DefaultOperationHistory;
-import org.eclipse.gef.EditPart;
-import org.eclipse.graphiti.mm.pictograms.Diagram;
-import org.eclipse.graphiti.mm.pictograms.PictogramElement;
-import org.eclipse.graphiti.services.Graphiti;
-
-import java.util.Collections;
-import java.util.List;
-
-/**
- * @author Martin Fluegge
- */
-public class DawnGraphitiUtil
-{
- public static TransactionalEditingDomain createResourceSetAndEditingDomain()
- {
- // TODO check if this is still needed here
- CDOConnectionUtil.instance.init(PreferenceConstants.getRepositoryName(), PreferenceConstants.getProtocol(),
- PreferenceConstants.getServerName());
- CDOConnectionUtil.instance.getCurrentSession();
-
- final ResourceSet resourceSet = new ResourceSetImpl();
-
- @SuppressWarnings("restriction")
- final TransactionalCommandStack workspaceCommandStack = new org.eclipse.graphiti.ui.internal.editor.GFWorkspaceCommandStackImpl(
- new DefaultOperationHistory());
-
- final TransactionalEditingDomainImpl editingDomain = new DawnTransactionalEditingDomainImpl(
- new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE), workspaceCommandStack,
- resourceSet);
- WorkspaceEditingDomainFactory.INSTANCE.mapResourceSet(editingDomain);
- return editingDomain;
- }
-
- /**
- * This method tries to find an editpart for a given pictogram element. It recursivly searches all children for the
- * given editpart if the model matches to pictogramElement.
- */
- public static EditPart getEditpart(PictogramElement pictogramElement, EditPart part)
- {
- for (Object object : part.getChildren())
- {
- EditPart child = (EditPart)object;
- if (child.getModel().equals(pictogramElement))
- {
- return child;
- }
-
- EditPart childEditPart = getEditpart(pictogramElement, child);
- if (childEditPart != null)
- {
- return childEditPart;
- }
- }
- return null;
- }
-
- public static List<PictogramElement> getPictgramElements(Diagram diagram, EObject element)
- {
- PictogramElement pictgramElement = getPictgramElement(element);
-
- if (element instanceof PictogramElement)
- {
- return Collections.singletonList((PictogramElement)element);
- }
-
- if (pictgramElement != null)
- {
- return Collections.singletonList(pictgramElement);
- }
-
- return Graphiti.getLinkService().getPictogramElements(diagram, element);
- }
-
- /**
- * Tries to retriev the pictogram element from a given element. If the element itself is a PictogramElement, the
- * element will be returned. Otherwise all eContainers will be checked until a PictogramElement is found.
- */
- public static PictogramElement getPictgramElement(EObject element)
- {
- if (element == null)
- {
- return null;
- }
-
- if (element instanceof PictogramElement)
- {
- return (PictogramElement)element;
- }
-
- EObject eContainer = element.eContainer();
-
- if (eContainer instanceof PictogramElement)
- {
- return (PictogramElement)eContainer;
- }
- return getPictgramElement(eContainer);
- }
-}
+/* + * 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.graphiti.util; + +import org.eclipse.emf.cdo.dawn.preferences.PreferenceConstants; +import org.eclipse.emf.cdo.dawn.transaction.DawnTransactionalEditingDomainImpl; +import org.eclipse.emf.cdo.dawn.util.connection.CDOConnectionUtil; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.edit.provider.ComposedAdapterFactory; +import org.eclipse.emf.transaction.TransactionalCommandStack; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl; +import org.eclipse.emf.workspace.WorkspaceEditingDomainFactory; + +import org.eclipse.core.commands.operations.DefaultOperationHistory; +import org.eclipse.gef.EditPart; +import org.eclipse.graphiti.mm.pictograms.Diagram; +import org.eclipse.graphiti.mm.pictograms.PictogramElement; +import org.eclipse.graphiti.services.Graphiti; + +import java.util.Collections; +import java.util.List; + +/** + * @author Martin Fluegge + */ +public class DawnGraphitiUtil +{ + public static TransactionalEditingDomain createResourceSetAndEditingDomain() + { + // TODO check if this is still needed here + CDOConnectionUtil.instance.init(PreferenceConstants.getRepositoryName(), PreferenceConstants.getProtocol(), + PreferenceConstants.getServerName()); + CDOConnectionUtil.instance.getCurrentSession(); + + final ResourceSet resourceSet = new ResourceSetImpl(); + + @SuppressWarnings("restriction") + final TransactionalCommandStack workspaceCommandStack = new org.eclipse.graphiti.ui.internal.editor.GFWorkspaceCommandStackImpl( + new DefaultOperationHistory()); + + final TransactionalEditingDomainImpl editingDomain = new DawnTransactionalEditingDomainImpl( + new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE), workspaceCommandStack, + resourceSet); + WorkspaceEditingDomainFactory.INSTANCE.mapResourceSet(editingDomain); + return editingDomain; + } + + /** + * This method tries to find an editpart for a given pictogram element. It recursivly searches all children for the + * given editpart if the model matches to pictogramElement. + */ + public static EditPart getEditpart(PictogramElement pictogramElement, EditPart part) + { + for (Object object : part.getChildren()) + { + EditPart child = (EditPart)object; + if (child.getModel().equals(pictogramElement)) + { + return child; + } + + EditPart childEditPart = getEditpart(pictogramElement, child); + if (childEditPart != null) + { + return childEditPart; + } + } + return null; + } + + public static List<PictogramElement> getPictgramElements(Diagram diagram, EObject element) + { + PictogramElement pictgramElement = getPictgramElement(element); + + if (element instanceof PictogramElement) + { + return Collections.singletonList((PictogramElement)element); + } + + if (pictgramElement != null) + { + return Collections.singletonList(pictgramElement); + } + + return Graphiti.getLinkService().getPictogramElements(diagram, element); + } + + /** + * Tries to retriev the pictogram element from a given element. If the element itself is a PictogramElement, the + * element will be returned. Otherwise all eContainers will be checked until a PictogramElement is found. + */ + public static PictogramElement getPictgramElement(EObject element) + { + if (element == null) + { + return null; + } + + if (element instanceof PictogramElement) + { + return (PictogramElement)element; + } + + EObject eContainer = element.eContainer(); + + if (eContainer instanceof PictogramElement) + { + return (PictogramElement)eContainer; + } + return getPictgramElement(eContainer); + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/wizards/AbstractDawnGraphitiWizardPage.java b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/wizards/AbstractDawnGraphitiWizardPage.java index 7bf10f19d9..8ef2b162f4 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/wizards/AbstractDawnGraphitiWizardPage.java +++ b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/wizards/AbstractDawnGraphitiWizardPage.java @@ -1,54 +1,54 @@ -/*
- * 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.graphiti.wizards;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * @author Martin Fluegge
- */
-public abstract class AbstractDawnGraphitiWizardPage extends WizardPage
-{
- public AbstractDawnGraphitiWizardPage(String pageName, String title, ImageDescriptor titleImage)
- {
- super(pageName, title, titleImage);
- }
-
- protected AbstractDawnGraphitiWizardPage(String pageName)
- {
- super(pageName);
- }
-
- public void createControl(Composite parent)
- {
- Composite composite = new Composite(parent, SWT.NULL);
- composite.setFont(parent.getFont());
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- createWizardContents(composite);
-
- setPageComplete(true);
-
- // Show description on opening
- setErrorMessage(null);
- setMessage(null);
- setControl(composite);
- }
-
- abstract protected void createWizardContents(Composite parent);
-
-}
+/* + * 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.graphiti.wizards; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; + +/** + * @author Martin Fluegge + */ +public abstract class AbstractDawnGraphitiWizardPage extends WizardPage +{ + public AbstractDawnGraphitiWizardPage(String pageName, String title, ImageDescriptor titleImage) + { + super(pageName, title, titleImage); + } + + protected AbstractDawnGraphitiWizardPage(String pageName) + { + super(pageName); + } + + public void createControl(Composite parent) + { + Composite composite = new Composite(parent, SWT.NULL); + composite.setFont(parent.getFont()); + composite.setLayout(new GridLayout()); + composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + + createWizardContents(composite); + + setPageComplete(true); + + // Show description on opening + setErrorMessage(null); + setMessage(null); + setControl(composite); + } + + abstract protected void createWizardContents(Composite parent); + +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/wizards/DawnBasicGraphitiWizard.java b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/wizards/DawnBasicGraphitiWizard.java index 8554c27864..1407f3cb33 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/wizards/DawnBasicGraphitiWizard.java +++ b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/wizards/DawnBasicGraphitiWizard.java @@ -1,220 +1,220 @@ -/*
- * 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.graphiti.wizards;
-
-import org.eclipse.emf.cdo.dawn.graphiti.DawnGraphitiUIPlugin;
-import org.eclipse.emf.cdo.dawn.graphiti.editors.DawnGraphitiDiagramEditor;
-import org.eclipse.emf.cdo.dawn.graphiti.editors.DawnGraphitiEditorInput;
-import org.eclipse.emf.cdo.dawn.graphiti.util.DawnGraphitiUtil;
-import org.eclipse.emf.cdo.dawn.preferences.PreferenceConstants;
-import org.eclipse.emf.cdo.dawn.ui.composites.CDOResourceNodeChooserComposite.ResourceChooserValidator;
-import org.eclipse.emf.cdo.dawn.ui.wizards.DawnCreateNewDiagramResourceWizardPage;
-import org.eclipse.emf.cdo.dawn.ui.wizards.DawnCreateNewResourceWizardPage;
-import org.eclipse.emf.cdo.dawn.util.connection.CDOConnectionUtil;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.common.command.CommandStack;
-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.util.EcoreUtil;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.graphiti.mm.pictograms.Diagram;
-import org.eclipse.graphiti.services.Graphiti;
-import org.eclipse.graphiti.ui.editor.DiagramEditorInput;
-import org.eclipse.graphiti.ui.services.GraphitiUi;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.ui.INewWizard;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-
-import java.io.IOException;
-
-/**
- * @author Martin Fluegge
- */
-public class DawnBasicGraphitiWizard extends Wizard implements INewWizard
-{
- protected CDOView view;
-
- protected DawnCreateNewDiagramResourceWizardPage dawnDiagramModelFilePage;
-
- protected DawnCreateNewResourceWizardPage dawnDomainModelFilePage;
-
- protected String diagramExtension = "model_graphiti";
-
- protected String modelExtension = "model";
-
- public DawnBasicGraphitiWizard()
- {
- super();
- CDOConnectionUtil.instance.init(PreferenceConstants.getRepositoryName(), PreferenceConstants.getProtocol(),
- PreferenceConstants.getServerName());
- CDOSession session = CDOConnectionUtil.instance.openSession();
- view = CDOConnectionUtil.instance.openView(session);
- }
-
- public DawnBasicGraphitiWizard(String modelExtension, String diagramExtension)
- {
- this();
- this.diagramExtension = diagramExtension;
- this.modelExtension = modelExtension;
- }
-
- public void init(IWorkbench workbench, IStructuredSelection selection)
- {
- }
-
- @Override
- public void addPages()
- {
- dawnDiagramModelFilePage = new DawnCreateNewDiagramResourceWizardPage(diagramExtension, false, view);
- dawnDiagramModelFilePage.setTitle("");
- dawnDiagramModelFilePage.setDescription("");
- dawnDiagramModelFilePage.setCreateAutomaticResourceName(true);
- addPage(dawnDiagramModelFilePage);
-
- dawnDomainModelFilePage = new DawnCreateNewResourceWizardPage(modelExtension, true, view)
- {
- @Override
- public void setVisible(boolean visible)
- {
- if (visible)
- {
- URI uri = dawnDiagramModelFilePage.getURI();
- String fileName = uri.lastSegment();
- fileName = fileName.substring(0, fileName.length() - ("." + diagramExtension).length()); //$NON-NLS-1$
- fileName += ".acore";
- dawnDomainModelFilePage.setResourceNamePrefix(fileName);
- dawnDomainModelFilePage.setResourcePath(dawnDiagramModelFilePage.getResourcePath());
- }
- super.setVisible(visible);
- }
- };
- dawnDomainModelFilePage.setTitle("");
- dawnDomainModelFilePage.setDescription("");
-
- // allows to connect to an existing resource
- dawnDomainModelFilePage.setResourceValidationType(ResourceChooserValidator.VALIDATION_WARN);
- addPage(dawnDomainModelFilePage);
- }
-
- @Override
- public boolean performFinish()
- {
- String diagramTypeId = geTypeId();
-
- URI diagramResourceURI = dawnDiagramModelFilePage.getURI();
- URI domainModelResourceURI = dawnDomainModelFilePage.getURI();
-
- Diagram diagram = Graphiti.getPeCreateService()
- .createDiagram(diagramTypeId, diagramResourceURI.lastSegment(), true);
-
- String editorID = DawnGraphitiDiagramEditor.ID;
-
- TransactionalEditingDomain editingDomain = createEditingDomain(diagramResourceURI, diagram);
-
- createModelResource(domainModelResourceURI, editingDomain.getResourceSet());
-
- Resource diagramResource = createDiagramResource(diagramResourceURI, diagram, editingDomain);
-
- String providerId = GraphitiUi.getExtensionManager().getDiagramTypeProviderId(diagram.getDiagramTypeId());
- DiagramEditorInput editorInput = new DawnGraphitiEditorInput(EcoreUtil.getURI(diagram), providerId, diagramResource);
-
- try
- {
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(editorInput, editorID);
- }
- catch (PartInitException e)
- {
- String error = "Error opening diagram";
- IStatus status = new Status(IStatus.ERROR, DawnGraphitiUIPlugin.ID, error, e);
- ErrorDialog.openError(getShell(), "Error", null, status);
- return false;
- }
-
- return true;
- }
-
- protected String geTypeId()
- {
- return modelExtension;
- }
-
- private Resource createModelResource(URI uri, ResourceSet resourceSet)
- {
- Resource resource = null;
-
- // try
- // {
- // resource = resourceSet.getResource(uri, true);
- // }
- // catch (Exception ex)
- // {
- // // ignore
- // }
- //
- // if (resource == null)
- // {
- resource = resourceSet.createResource(uri);
- // }
-
- return resource;
- }
-
- private TransactionalEditingDomain createEditingDomain(URI diagramResourceURI, final Diagram diagram)
- {
- final TransactionalEditingDomain editingDomain = DawnGraphitiUtil.createResourceSetAndEditingDomain();
-
- return editingDomain;
- }
-
- private Resource createDiagramResource(URI diagramResourceURI, final Diagram diagram,
- final TransactionalEditingDomain editingDomain)
- {
- final ResourceSet resourceSet = editingDomain.getResourceSet();
- final Resource resource = createModelResource(diagramResourceURI, resourceSet);
-
- final CommandStack commandStack = editingDomain.getCommandStack();
- commandStack.execute(new RecordingCommand(editingDomain)
- {
- @Override
- protected void doExecute()
- {
- resource.getContents().add(diagram);
- }
- });
-
- try
- {
- resource.save(null);
- }
- catch (IOException ex)
- {
- throw new RuntimeException(ex);
- }
- return resource;
- }
-
- @Override
- public void dispose()
- {
- view.close();
- }
-}
+/* + * 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.graphiti.wizards; + +import org.eclipse.emf.cdo.dawn.graphiti.DawnGraphitiUIPlugin; +import org.eclipse.emf.cdo.dawn.graphiti.editors.DawnGraphitiDiagramEditor; +import org.eclipse.emf.cdo.dawn.graphiti.editors.DawnGraphitiEditorInput; +import org.eclipse.emf.cdo.dawn.graphiti.util.DawnGraphitiUtil; +import org.eclipse.emf.cdo.dawn.preferences.PreferenceConstants; +import org.eclipse.emf.cdo.dawn.ui.composites.CDOResourceNodeChooserComposite.ResourceChooserValidator; +import org.eclipse.emf.cdo.dawn.ui.wizards.DawnCreateNewDiagramResourceWizardPage; +import org.eclipse.emf.cdo.dawn.ui.wizards.DawnCreateNewResourceWizardPage; +import org.eclipse.emf.cdo.dawn.util.connection.CDOConnectionUtil; +import org.eclipse.emf.cdo.session.CDOSession; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.emf.common.command.CommandStack; +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.util.EcoreUtil; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.graphiti.mm.pictograms.Diagram; +import org.eclipse.graphiti.services.Graphiti; +import org.eclipse.graphiti.ui.editor.DiagramEditorInput; +import org.eclipse.graphiti.ui.services.GraphitiUi; +import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.ui.INewWizard; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; + +import java.io.IOException; + +/** + * @author Martin Fluegge + */ +public class DawnBasicGraphitiWizard extends Wizard implements INewWizard +{ + protected CDOView view; + + protected DawnCreateNewDiagramResourceWizardPage dawnDiagramModelFilePage; + + protected DawnCreateNewResourceWizardPage dawnDomainModelFilePage; + + protected String diagramExtension = "model_graphiti"; + + protected String modelExtension = "model"; + + public DawnBasicGraphitiWizard() + { + super(); + CDOConnectionUtil.instance.init(PreferenceConstants.getRepositoryName(), PreferenceConstants.getProtocol(), + PreferenceConstants.getServerName()); + CDOSession session = CDOConnectionUtil.instance.openSession(); + view = CDOConnectionUtil.instance.openView(session); + } + + public DawnBasicGraphitiWizard(String modelExtension, String diagramExtension) + { + this(); + this.diagramExtension = diagramExtension; + this.modelExtension = modelExtension; + } + + public void init(IWorkbench workbench, IStructuredSelection selection) + { + } + + @Override + public void addPages() + { + dawnDiagramModelFilePage = new DawnCreateNewDiagramResourceWizardPage(diagramExtension, false, view); + dawnDiagramModelFilePage.setTitle(""); + dawnDiagramModelFilePage.setDescription(""); + dawnDiagramModelFilePage.setCreateAutomaticResourceName(true); + addPage(dawnDiagramModelFilePage); + + dawnDomainModelFilePage = new DawnCreateNewResourceWizardPage(modelExtension, true, view) + { + @Override + public void setVisible(boolean visible) + { + if (visible) + { + URI uri = dawnDiagramModelFilePage.getURI(); + String fileName = uri.lastSegment(); + fileName = fileName.substring(0, fileName.length() - ("." + diagramExtension).length()); //$NON-NLS-1$ + fileName += ".acore"; + dawnDomainModelFilePage.setResourceNamePrefix(fileName); + dawnDomainModelFilePage.setResourcePath(dawnDiagramModelFilePage.getResourcePath()); + } + super.setVisible(visible); + } + }; + dawnDomainModelFilePage.setTitle(""); + dawnDomainModelFilePage.setDescription(""); + + // allows to connect to an existing resource + dawnDomainModelFilePage.setResourceValidationType(ResourceChooserValidator.VALIDATION_WARN); + addPage(dawnDomainModelFilePage); + } + + @Override + public boolean performFinish() + { + String diagramTypeId = geTypeId(); + + URI diagramResourceURI = dawnDiagramModelFilePage.getURI(); + URI domainModelResourceURI = dawnDomainModelFilePage.getURI(); + + Diagram diagram = Graphiti.getPeCreateService() + .createDiagram(diagramTypeId, diagramResourceURI.lastSegment(), true); + + String editorID = DawnGraphitiDiagramEditor.ID; + + TransactionalEditingDomain editingDomain = createEditingDomain(diagramResourceURI, diagram); + + createModelResource(domainModelResourceURI, editingDomain.getResourceSet()); + + Resource diagramResource = createDiagramResource(diagramResourceURI, diagram, editingDomain); + + String providerId = GraphitiUi.getExtensionManager().getDiagramTypeProviderId(diagram.getDiagramTypeId()); + DiagramEditorInput editorInput = new DawnGraphitiEditorInput(EcoreUtil.getURI(diagram), providerId, diagramResource); + + try + { + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(editorInput, editorID); + } + catch (PartInitException e) + { + String error = "Error opening diagram"; + IStatus status = new Status(IStatus.ERROR, DawnGraphitiUIPlugin.ID, error, e); + ErrorDialog.openError(getShell(), "Error", null, status); + return false; + } + + return true; + } + + protected String geTypeId() + { + return modelExtension; + } + + private Resource createModelResource(URI uri, ResourceSet resourceSet) + { + Resource resource = null; + + // try + // { + // resource = resourceSet.getResource(uri, true); + // } + // catch (Exception ex) + // { + // // ignore + // } + // + // if (resource == null) + // { + resource = resourceSet.createResource(uri); + // } + + return resource; + } + + private TransactionalEditingDomain createEditingDomain(URI diagramResourceURI, final Diagram diagram) + { + final TransactionalEditingDomain editingDomain = DawnGraphitiUtil.createResourceSetAndEditingDomain(); + + return editingDomain; + } + + private Resource createDiagramResource(URI diagramResourceURI, final Diagram diagram, + final TransactionalEditingDomain editingDomain) + { + final ResourceSet resourceSet = editingDomain.getResourceSet(); + final Resource resource = createModelResource(diagramResourceURI, resourceSet); + + final CommandStack commandStack = editingDomain.getCommandStack(); + commandStack.execute(new RecordingCommand(editingDomain) + { + @Override + protected void doExecute() + { + resource.getContents().add(diagram); + } + }); + + try + { + resource.save(null); + } + catch (IOException ex) + { + throw new RuntimeException(ex); + } + return resource; + } + + @Override + public void dispose() + { + view.close(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/wizards/DawnGenericGraphitiWizard.java b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/wizards/DawnGenericGraphitiWizard.java index 6a27444575..58ef3c1767 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/wizards/DawnGenericGraphitiWizard.java +++ b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/wizards/DawnGenericGraphitiWizard.java @@ -1,91 +1,91 @@ -/*
- * 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.graphiti.wizards;
-
-import org.eclipse.emf.cdo.dawn.ui.composites.CDOResourceNodeChooserComposite.ResourceChooserValidator;
-import org.eclipse.emf.cdo.dawn.ui.wizards.DawnCreateNewDiagramResourceWizardPage;
-import org.eclipse.emf.cdo.dawn.ui.wizards.DawnCreateNewResourceWizardPage;
-
-import org.eclipse.emf.common.util.URI;
-
-/**
- * @author Martin Fluegge
- */
-public class DawnGenericGraphitiWizard extends DawnBasicGraphitiWizard
-{
- private DawnGraphitiyDiagramTypeSelectionWizardPage dawnSelectModelPage;
-
- public DawnGenericGraphitiWizard()
- {
- super("", "graphiti");
- }
-
- @Override
- public void addPages()
- {
- dawnSelectModelPage = new DawnGraphitiyDiagramTypeSelectionWizardPage("title");
- addPage(dawnSelectModelPage);
-
- dawnDiagramModelFilePage = new DawnCreateNewDiagramResourceWizardPage(diagramExtension, false, view)
- {
- @Override
- public void setVisible(boolean visible)
- {
- if (visible)
- {
- URI uri = dawnDiagramModelFilePage.getURI();
- String fileName = uri.lastSegment();
- fileName = fileName.substring(0, fileName.length() - ("." + diagramExtension).length()); //$NON-NLS-1$
- fileName += "." + diagramExtension;
- dawnDomainModelFilePage.setResourceNamePrefix(fileName);
- dawnDomainModelFilePage.setResourcePath(dawnDiagramModelFilePage.getResourcePath());
- }
- super.setVisible(visible);
- }
- };
-
- dawnDiagramModelFilePage.setTitle("");
- dawnDiagramModelFilePage.setDescription("");
- dawnDiagramModelFilePage.setCreateAutomaticResourceName(true);
- addPage(dawnDiagramModelFilePage);
-
- dawnDomainModelFilePage = new DawnCreateNewResourceWizardPage("", true, view)
- {
- @Override
- public void setVisible(boolean visible)
- {
- if (visible)
- {
- String extension = dawnSelectModelPage.getText();
- URI uri = dawnDiagramModelFilePage.getURI();
- String fileName = uri.lastSegment();
- fileName = fileName.substring(0, fileName.length() - ("." + diagramExtension).length()); //$NON-NLS-1$
- fileName += "." + extension;
- dawnDomainModelFilePage.setResourceNamePrefix(fileName);
- dawnDomainModelFilePage.setResourcePath(dawnDiagramModelFilePage.getResourcePath());
- }
- super.setVisible(visible);
- }
- };
- dawnDomainModelFilePage.setTitle("");
- dawnDomainModelFilePage.setDescription("");
-
- // allows to connect to an existing resource
- dawnDomainModelFilePage.setResourceValidationType(ResourceChooserValidator.VALIDATION_WARN);
- addPage(dawnDomainModelFilePage);
- }
-
- @Override
- protected String geTypeId()
- {
- return dawnSelectModelPage.getText();
- }
-}
+/* + * 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.graphiti.wizards; + +import org.eclipse.emf.cdo.dawn.ui.composites.CDOResourceNodeChooserComposite.ResourceChooserValidator; +import org.eclipse.emf.cdo.dawn.ui.wizards.DawnCreateNewDiagramResourceWizardPage; +import org.eclipse.emf.cdo.dawn.ui.wizards.DawnCreateNewResourceWizardPage; + +import org.eclipse.emf.common.util.URI; + +/** + * @author Martin Fluegge + */ +public class DawnGenericGraphitiWizard extends DawnBasicGraphitiWizard +{ + private DawnGraphitiyDiagramTypeSelectionWizardPage dawnSelectModelPage; + + public DawnGenericGraphitiWizard() + { + super("", "graphiti"); + } + + @Override + public void addPages() + { + dawnSelectModelPage = new DawnGraphitiyDiagramTypeSelectionWizardPage("title"); + addPage(dawnSelectModelPage); + + dawnDiagramModelFilePage = new DawnCreateNewDiagramResourceWizardPage(diagramExtension, false, view) + { + @Override + public void setVisible(boolean visible) + { + if (visible) + { + URI uri = dawnDiagramModelFilePage.getURI(); + String fileName = uri.lastSegment(); + fileName = fileName.substring(0, fileName.length() - ("." + diagramExtension).length()); //$NON-NLS-1$ + fileName += "." + diagramExtension; + dawnDomainModelFilePage.setResourceNamePrefix(fileName); + dawnDomainModelFilePage.setResourcePath(dawnDiagramModelFilePage.getResourcePath()); + } + super.setVisible(visible); + } + }; + + dawnDiagramModelFilePage.setTitle(""); + dawnDiagramModelFilePage.setDescription(""); + dawnDiagramModelFilePage.setCreateAutomaticResourceName(true); + addPage(dawnDiagramModelFilePage); + + dawnDomainModelFilePage = new DawnCreateNewResourceWizardPage("", true, view) + { + @Override + public void setVisible(boolean visible) + { + if (visible) + { + String extension = dawnSelectModelPage.getText(); + URI uri = dawnDiagramModelFilePage.getURI(); + String fileName = uri.lastSegment(); + fileName = fileName.substring(0, fileName.length() - ("." + diagramExtension).length()); //$NON-NLS-1$ + fileName += "." + extension; + dawnDomainModelFilePage.setResourceNamePrefix(fileName); + dawnDomainModelFilePage.setResourcePath(dawnDiagramModelFilePage.getResourcePath()); + } + super.setVisible(visible); + } + }; + dawnDomainModelFilePage.setTitle(""); + dawnDomainModelFilePage.setDescription(""); + + // allows to connect to an existing resource + dawnDomainModelFilePage.setResourceValidationType(ResourceChooserValidator.VALIDATION_WARN); + addPage(dawnDomainModelFilePage); + } + + @Override + protected String geTypeId() + { + return dawnSelectModelPage.getText(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/wizards/DawnGraphitiyDiagramTypeSelectionWizardPage.java b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/wizards/DawnGraphitiyDiagramTypeSelectionWizardPage.java index dc079f831c..31f776e2b7 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/wizards/DawnGraphitiyDiagramTypeSelectionWizardPage.java +++ b/plugins/org.eclipse.emf.cdo.dawn.graphiti/src/org/eclipse/emf/cdo/dawn/graphiti/wizards/DawnGraphitiyDiagramTypeSelectionWizardPage.java @@ -1,132 +1,132 @@ -/*
- * 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.graphiti.wizards;
-
-import org.eclipse.emf.cdo.dawn.graphiti.DawnGraphitiUIPlugin;
-
-import org.eclipse.graphiti.dt.IDiagramType;
-import org.eclipse.graphiti.ui.services.GraphitiUi;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Vector;
-
-/**
- * @author Martin Fluegge
- */
-public class DawnGraphitiyDiagramTypeSelectionWizardPage extends AbstractDawnGraphitiWizardPage
-{
- private static final String PAGE_DESC = "description";
-
- private static final String PAGE_TITLE = "title";
-
- private static final String DEFAULT_TYPE = "tutorial"; //$NON-NLS-1$
-
- private static final String SELECTED_TYPE = "selectedtype"; //$NON-NLS-1$
-
- private Combo comboBox;
-
- public DawnGraphitiyDiagramTypeSelectionWizardPage(String pageName, String title, ImageDescriptor titleImage)
- {
- super(pageName, title, titleImage);
- }
-
- protected DawnGraphitiyDiagramTypeSelectionWizardPage(String pageName)
- {
- super(pageName);
- setTitle(PAGE_TITLE);
- setDescription(PAGE_DESC);
- }
-
- @Override
- protected void createWizardContents(Composite parent)
- {
- // project specification group
- Composite projectGroup = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- projectGroup.setLayout(layout);
- projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // new project label
- Label projectLabel = new Label(projectGroup, SWT.NONE);
- projectLabel.setFont(parent.getFont());
- projectLabel.setText("set text");
-
- // new project name entry field
- comboBox = new Combo(projectGroup, SWT.READ_ONLY | SWT.BORDER);
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = 250;
- comboBox.setLayoutData(data);
- comboBox.setFont(parent.getFont());
- comboBox.setVisibleItemCount(12);
- comboBox.addSelectionListener(new SelectionAdapter()
- {
-
- @Override
- public void widgetSelected(SelectionEvent e)
- {
- IDialogSettings dialogSettings = DawnGraphitiUIPlugin.getDefault().getDialogSettings();
- dialogSettings.put(SELECTED_TYPE, comboBox.getText());
- }
- });
-
- // set the contents of the Combo-widget
- comboBox.setItems(getAllAvailableDiagramTypes());
- if (getInitialValue() != null)
- {
- comboBox.setText(getInitialValue());
- }
- }
-
- protected String[] getAllAvailableDiagramTypes()
- {
- Vector<String> diagramIds = new Vector<String>();
- for (IDiagramType diagramType : GraphitiUi.getExtensionManager().getDiagramTypes())
- {
- diagramIds.add(diagramType.getId());
- }
-
- return diagramIds.toArray(new String[] {});
- }
-
- protected String getInitialValue()
- {
- // Get last choice
- IDialogSettings dialogSettings = DawnGraphitiUIPlugin.getDefault().getDialogSettings();
- String selType = dialogSettings.get(SELECTED_TYPE);
- List<String> asList = Arrays.asList(comboBox.getItems());
- if (asList.contains(selType))
- {
- return selType;
- }
- else if (asList.contains(DEFAULT_TYPE))
- {
- return DEFAULT_TYPE;
- }
- return null;
- }
-
- public String getText()
- {
- return comboBox.getText();
- }
-}
+/* + * 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.graphiti.wizards; + +import org.eclipse.emf.cdo.dawn.graphiti.DawnGraphitiUIPlugin; + +import org.eclipse.graphiti.dt.IDiagramType; +import org.eclipse.graphiti.ui.services.GraphitiUi; +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; + +import java.util.Arrays; +import java.util.List; +import java.util.Vector; + +/** + * @author Martin Fluegge + */ +public class DawnGraphitiyDiagramTypeSelectionWizardPage extends AbstractDawnGraphitiWizardPage +{ + private static final String PAGE_DESC = "description"; + + private static final String PAGE_TITLE = "title"; + + private static final String DEFAULT_TYPE = "tutorial"; //$NON-NLS-1$ + + private static final String SELECTED_TYPE = "selectedtype"; //$NON-NLS-1$ + + private Combo comboBox; + + public DawnGraphitiyDiagramTypeSelectionWizardPage(String pageName, String title, ImageDescriptor titleImage) + { + super(pageName, title, titleImage); + } + + protected DawnGraphitiyDiagramTypeSelectionWizardPage(String pageName) + { + super(pageName); + setTitle(PAGE_TITLE); + setDescription(PAGE_DESC); + } + + @Override + protected void createWizardContents(Composite parent) + { + // project specification group + Composite projectGroup = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + projectGroup.setLayout(layout); + projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + // new project label + Label projectLabel = new Label(projectGroup, SWT.NONE); + projectLabel.setFont(parent.getFont()); + projectLabel.setText("set text"); + + // new project name entry field + comboBox = new Combo(projectGroup, SWT.READ_ONLY | SWT.BORDER); + GridData data = new GridData(GridData.FILL_HORIZONTAL); + data.widthHint = 250; + comboBox.setLayoutData(data); + comboBox.setFont(parent.getFont()); + comboBox.setVisibleItemCount(12); + comboBox.addSelectionListener(new SelectionAdapter() + { + + @Override + public void widgetSelected(SelectionEvent e) + { + IDialogSettings dialogSettings = DawnGraphitiUIPlugin.getDefault().getDialogSettings(); + dialogSettings.put(SELECTED_TYPE, comboBox.getText()); + } + }); + + // set the contents of the Combo-widget + comboBox.setItems(getAllAvailableDiagramTypes()); + if (getInitialValue() != null) + { + comboBox.setText(getInitialValue()); + } + } + + protected String[] getAllAvailableDiagramTypes() + { + Vector<String> diagramIds = new Vector<String>(); + for (IDiagramType diagramType : GraphitiUi.getExtensionManager().getDiagramTypes()) + { + diagramIds.add(diagramType.getId()); + } + + return diagramIds.toArray(new String[] {}); + } + + protected String getInitialValue() + { + // Get last choice + IDialogSettings dialogSettings = DawnGraphitiUIPlugin.getDefault().getDialogSettings(); + String selType = dialogSettings.get(SELECTED_TYPE); + List<String> asList = Arrays.asList(comboBox.getItems()); + if (asList.contains(selType)) + { + return selType; + } + else if (asList.contains(DEFAULT_TYPE)) + { + return DEFAULT_TYPE; + } + return null; + } + + public String getText() + { + return comboBox.getText(); + } +} |