diff options
author | Partrick Paulin | 2013-02-22 15:00:38 +0000 |
---|---|---|
committer | mwenz | 2013-02-22 15:00:38 +0000 |
commit | ee66d6fbdd543128e31e0724fce6333457fd2682 (patch) | |
tree | 12c560201291f6179d77b66a0cb183b94074576e | |
parent | 7e6f854578e9be635b745ead43bebf1e72d8dca3 (diff) | |
download | org.eclipse.graphiti-ee66d6fbdd543128e31e0724fce6333457fd2682.tar.gz org.eclipse.graphiti-ee66d6fbdd543128e31e0724fce6333457fd2682.tar.xz org.eclipse.graphiti-ee66d6fbdd543128e31e0724fce6333457fd2682.zip |
Bug 352120 - Renamed interface to IDiagramEditorUI. The concrete editor
class is now back to DiagramEditor so that existing extension classes
will not break
Change-Id: I84d2f5affcb4a2018acc33688ed7a865c874c0ae
66 files changed, 1895 insertions, 1748 deletions
diff --git a/examples/org.eclipse.graphiti.examples.common/src/org/eclipse/graphiti/examples/common/ExamplesCommonPlugin.java b/examples/org.eclipse.graphiti.examples.common/src/org/eclipse/graphiti/examples/common/ExamplesCommonPlugin.java index c42a61f2..dcb27efc 100644 --- a/examples/org.eclipse.graphiti.examples.common/src/org/eclipse/graphiti/examples/common/ExamplesCommonPlugin.java +++ b/examples/org.eclipse.graphiti.examples.common/src/org/eclipse/graphiti/examples/common/ExamplesCommonPlugin.java @@ -1,7 +1,7 @@ /******************************************************************************* * <copyright> * - * Copyright (c) 2005, 2010 SAP AG. + * Copyright (c) 2005, 2013 SAP AG. * 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 @@ -22,7 +22,7 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IAdapterManager; import org.eclipse.core.runtime.Platform; import org.eclipse.graphiti.examples.common.outline.ContentOutlinePageAdapterFactory; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; @@ -58,7 +58,7 @@ public class ExamplesCommonPlugin extends AbstractUIPlugin { super.start(context); IAdapterManager manager = Platform.getAdapterManager(); - manager.registerAdapters(new ContentOutlinePageAdapterFactory(), DiagramEditor.class); + manager.registerAdapters(new ContentOutlinePageAdapterFactory(), IDiagramEditorUI.class); } // ======================== static access methods ========================== diff --git a/examples/org.eclipse.graphiti.examples.common/src/org/eclipse/graphiti/examples/common/outline/ContentOutlinePageAdapterFactory.java b/examples/org.eclipse.graphiti.examples.common/src/org/eclipse/graphiti/examples/common/outline/ContentOutlinePageAdapterFactory.java index e1122bae..0d33075f 100644 --- a/examples/org.eclipse.graphiti.examples.common/src/org/eclipse/graphiti/examples/common/outline/ContentOutlinePageAdapterFactory.java +++ b/examples/org.eclipse.graphiti.examples.common/src/org/eclipse/graphiti/examples/common/outline/ContentOutlinePageAdapterFactory.java @@ -18,7 +18,7 @@ package org.eclipse.graphiti.examples.common.outline; import org.eclipse.core.runtime.IAdapterFactory; import org.eclipse.graphiti.internal.pref.GFPreferences; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.ui.views.contentoutline.IContentOutlinePage; // The generic outline uses internal functionality of Graphiti. For concrete @@ -31,8 +31,8 @@ public class ContentOutlinePageAdapterFactory implements IAdapterFactory { public Object getAdapter(Object adaptableObject, @SuppressWarnings("rawtypes") Class adapterType) { if (GFPreferences.getInstance().isGenericOutlineActive()) { if (IContentOutlinePage.class.equals(adapterType)) { - if (adaptableObject instanceof DiagramEditor) { - DiagramEditor diagramEditor = (DiagramEditor) adaptableObject; + if (adaptableObject instanceof IDiagramEditorUI) { + IDiagramEditorUI diagramEditor = (IDiagramEditorUI) adaptableObject; if (diagramEditor.getDiagramTypeProvider() != null) { // diagram // editor // initialized? diff --git a/examples/org.eclipse.graphiti.examples.common/src/org/eclipse/graphiti/examples/common/outline/GraphicsEditorOutlinePage.java b/examples/org.eclipse.graphiti.examples.common/src/org/eclipse/graphiti/examples/common/outline/GraphicsEditorOutlinePage.java index c7cfc285..d03aee07 100644 --- a/examples/org.eclipse.graphiti.examples.common/src/org/eclipse/graphiti/examples/common/outline/GraphicsEditorOutlinePage.java +++ b/examples/org.eclipse.graphiti.examples.common/src/org/eclipse/graphiti/examples/common/outline/GraphicsEditorOutlinePage.java @@ -1,7 +1,7 @@ /******************************************************************************* * <copyright> * - * Copyright (c) 2005, 2010 SAP AG. + * Copyright (c) 2005, 2013 SAP AG. * 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 @@ -35,7 +35,7 @@ import org.eclipse.gef.ui.parts.TreeViewer; import org.eclipse.graphiti.examples.common.IExampleImageConstants; import org.eclipse.graphiti.examples.common.outline.tree.PictogramsTreeEditPartFactory; import org.eclipse.graphiti.mm.pictograms.Diagram; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.internal.fixed.FixedScrollableThumbnail; import org.eclipse.graphiti.ui.services.GraphitiUi; import org.eclipse.jface.action.Action; @@ -81,7 +81,7 @@ public class GraphicsEditorOutlinePage extends ContentOutlinePage implements IPr private SelectionSynchronizer _selectionSynchronizer; - private DiagramEditor _diagramEditor; + private IDiagramEditorUI _diagramEditor; // The thumbnail to display private FixedScrollableThumbnail _thumbnail; @@ -107,9 +107,9 @@ public class GraphicsEditorOutlinePage extends ContentOutlinePage implements IPr * * @param diagramEditor * the attached diagram editor - * @since 0.9 + * @since 0.10 */ - public GraphicsEditorOutlinePage(DiagramEditor diagramEditor) { + public GraphicsEditorOutlinePage(IDiagramEditorUI diagramEditor) { super(new TreeViewer()); _graphicalViewer = diagramEditor.getGraphicalViewer(); _actionRegistry = (ActionRegistry) diagramEditor.getAdapter(ActionRegistry.class); diff --git a/examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/property/EReferencePropertySource.java b/examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/property/EReferencePropertySource.java index 5dd0ec57..78311824 100644 --- a/examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/property/EReferencePropertySource.java +++ b/examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/property/EReferencePropertySource.java @@ -9,6 +9,7 @@ *
* Contributors:
* SAP AG - initial API, implementation and documentation
+ * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface
*
* </copyright>
*
@@ -16,14 +17,14 @@ package org.eclipse.graphiti.examples.tutorial.property;
import org.eclipse.emf.ecore.EReference;
-import org.eclipse.graphiti.ui.editor.DiagramEditor;
+import org.eclipse.graphiti.ui.editor.IDiagramEditorUI;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.PropertyDescriptor;
/**
* Defines the properties that shall be displayed for {@link EReference}s
- * selected in the {@link DiagramEditor}.
+ * selected in the {@link IDiagramEditorUI}.
*/
public class EReferencePropertySource implements IPropertySource {
diff --git a/examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/property/GraphitiEditPartToIPropertySourceAdapterFactory.java b/examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/property/GraphitiEditPartToIPropertySourceAdapterFactory.java index 2eb54821..115a518f 100644 --- a/examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/property/GraphitiEditPartToIPropertySourceAdapterFactory.java +++ b/examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/property/GraphitiEditPartToIPropertySourceAdapterFactory.java @@ -9,6 +9,7 @@ *
* Contributors:
* SAP AG - initial API, implementation and documentation
+ * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface
*
* </copyright>
*
@@ -18,13 +19,13 @@ package org.eclipse.graphiti.examples.tutorial.property; import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
-import org.eclipse.graphiti.ui.editor.DiagramEditor;
+import org.eclipse.graphiti.ui.editor.IDiagramEditorUI;
import org.eclipse.graphiti.ui.platform.GraphitiConnectionEditPart;
import org.eclipse.ui.views.properties.IPropertySource;
/**
* Registered to adapt an {@link EditPart} that gets selected in the
- * {@link DiagramEditor} to A {@link IPropertySource} object that is used as
+ * {@link IDiagramEditorUI} to A {@link IPropertySource} object that is used as
* input for the properties view.
*/
public class GraphitiEditPartToIPropertySourceAdapterFactory implements IAdapterFactory {
diff --git a/examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/property/TutorialEReferenceFilter.java b/examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/property/TutorialEReferenceFilter.java index 41299ad9..418c82f4 100644 --- a/examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/property/TutorialEReferenceFilter.java +++ b/examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/property/TutorialEReferenceFilter.java @@ -9,6 +9,7 @@ * * Contributors: * SAP AG - initial API, implementation and documentation + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -19,12 +20,12 @@ import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EReference; import org.eclipse.graphiti.mm.pictograms.PictogramElement; import org.eclipse.graphiti.services.Graphiti; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.platform.AbstractPropertySectionFilter; /** * Filters out all other object than {@link EReference}s that get selected in - * the {@link DiagramEditor} for displaying properties. + * the {@link IDiagramEditorUI} for displaying properties. */ public class TutorialEReferenceFilter extends AbstractPropertySectionFilter { diff --git a/plugins/org.eclipse.graphiti.ui/.settings/.api_filters b/plugins/org.eclipse.graphiti.ui/.settings/.api_filters index 215c1045..875b0681 100644 --- a/plugins/org.eclipse.graphiti.ui/.settings/.api_filters +++ b/plugins/org.eclipse.graphiti.ui/.settings/.api_filters @@ -1,25 +1,117 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.graphiti.ui" version="2">
+ <resource path="META-INF/MANIFEST.MF">
+ <filter id="923795461">
+ <message_arguments>
+ <message_argument value="0.10.0"/>
+ <message_argument value="0.9.0"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/org/eclipse/graphiti/ui/editor/DefaultMarkerBehavior.java" type="org.eclipse.graphiti.ui.editor.DefaultMarkerBehavior">
+ <filter id="338722907">
+ <message_arguments>
+ <message_argument value="org.eclipse.graphiti.ui.editor.DefaultMarkerBehavior"/>
+ <message_argument value="DefaultMarkerBehavior(DiagramEditor)"/>
+ </message_arguments>
+ </filter>
+ <filter id="388161617">
+ <message_arguments>
+ <message_argument value="org.eclipse.graphiti.ui.editor.DefaultMarkerBehavior"/>
+ <message_argument value="diagramEditor"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/org/eclipse/graphiti/ui/editor/DefaultPaletteBehavior.java" type="org.eclipse.graphiti.ui.editor.DefaultPaletteBehavior">
+ <filter id="338722907">
+ <message_arguments>
+ <message_argument value="org.eclipse.graphiti.ui.editor.DefaultPaletteBehavior"/>
+ <message_argument value="DefaultPaletteBehavior(DiagramEditor)"/>
+ </message_arguments>
+ </filter>
+ <filter id="338792546">
+ <message_arguments>
+ <message_argument value="org.eclipse.graphiti.ui.editor.DefaultPaletteBehavior"/>
+ <message_argument value="getDiagramEditor()"/>
+ </message_arguments>
+ </filter>
+ <filter id="388161617">
+ <message_arguments>
+ <message_argument value="org.eclipse.graphiti.ui.editor.DefaultPaletteBehavior"/>
+ <message_argument value="diagramEditor"/>
+ </message_arguments>
+ </filter>
+ </resource>
<resource path="src/org/eclipse/graphiti/ui/editor/DefaultPersistencyBehavior.java" type="org.eclipse.graphiti.ui.editor.DefaultPersistencyBehavior">
+ <filter id="338722907">
+ <message_arguments>
+ <message_argument value="org.eclipse.graphiti.ui.editor.DefaultPersistencyBehavior"/>
+ <message_argument value="DefaultPersistencyBehavior(DiagramEditor)"/>
+ </message_arguments>
+ </filter>
<filter id="338792546">
<message_arguments>
<message_argument value="org.eclipse.graphiti.ui.editor.DefaultPersistencyBehavior"/>
<message_argument value="save(TransactionalEditingDomain, Map<Resource,Map<?,?>>)"/>
</message_arguments>
</filter>
+ <filter id="388161617">
+ <message_arguments>
+ <message_argument value="org.eclipse.graphiti.ui.editor.DefaultPersistencyBehavior"/>
+ <message_argument value="diagramEditor"/>
+ </message_arguments>
+ </filter>
</resource>
- <resource path="src/org/eclipse/graphiti/ui/editor/DiagramEditor.java" type="org.eclipse.graphiti.ui.editor.DiagramEditor">
- <filter comment="Changing from a class to an interface. Need to explore other options." id="337809484">
+ <resource path="src/org/eclipse/graphiti/ui/editor/DefaultRefreshBehavior.java" type="org.eclipse.graphiti.ui.editor.DefaultRefreshBehavior">
+ <filter id="338722907">
<message_arguments>
- <message_argument value="org.eclipse.graphiti.ui.editor.DiagramEditor"/>
- <message_argument value="4"/>
- <message_argument value="8"/>
+ <message_argument value="org.eclipse.graphiti.ui.editor.DefaultRefreshBehavior"/>
+ <message_argument value="DefaultRefreshBehavior(DiagramEditor)"/>
</message_arguments>
</filter>
- <filter id="574619656">
+ <filter id="388161617">
+ <message_arguments>
+ <message_argument value="org.eclipse.graphiti.ui.editor.DefaultRefreshBehavior"/>
+ <message_argument value="diagramEditor"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/org/eclipse/graphiti/ui/editor/DefaultUpdateBehavior.java" type="org.eclipse.graphiti.ui.editor.DefaultUpdateBehavior">
+ <filter id="338722907">
+ <message_arguments>
+ <message_argument value="org.eclipse.graphiti.ui.editor.DefaultUpdateBehavior"/>
+ <message_argument value="DefaultUpdateBehavior(DiagramEditor)"/>
+ </message_arguments>
+ </filter>
+ <filter id="388161617">
<message_arguments>
+ <message_argument value="org.eclipse.graphiti.ui.editor.DefaultUpdateBehavior"/>
+ <message_argument value="diagramEditor"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/org/eclipse/graphiti/ui/editor/DiagramComposite.java" type="org.eclipse.graphiti.ui.editor.DiagramComposite">
+ <filter id="574660632">
+ <message_arguments>
+ <message_argument value="IDiagramEditorUI"/>
<message_argument value="IDiagramEditor"/>
- <message_argument value="DiagramEditor"/>
+ <message_argument value="DiagramComposite"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/org/eclipse/graphiti/ui/editor/ElementDeleteListener.java" type="org.eclipse.graphiti.ui.editor.ElementDeleteListener">
+ <filter id="338722907">
+ <message_arguments>
+ <message_argument value="org.eclipse.graphiti.ui.editor.ElementDeleteListener"/>
+ <message_argument value="ElementDeleteListener(DiagramEditor)"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/org/eclipse/graphiti/ui/editor/IDiagramEditorUI.java" type="org.eclipse.graphiti.ui.editor.IDiagramEditorUI">
+ <filter id="571473929">
+ <message_arguments>
+ <message_argument value="IDiagramEditor"/>
+ <message_argument value="IDiagramEditorUI"/>
</message_arguments>
</filter>
</resource>
@@ -73,7 +165,7 @@ </filter>
</resource>
<resource path="src/org/eclipse/graphiti/ui/internal/editor/DiagramEditorDummy.java" type="org.eclipse.graphiti.ui.internal.editor.DiagramEditorDummy">
- <filter comment="Allow direct implementation accross Graphiti projects to make dummy editor available" id="574619656">
+ <filter id="574619656">
<message_arguments>
<message_argument value="IDiagramEditor"/>
<message_argument value="DiagramEditorDummy"/>
diff --git a/plugins/org.eclipse.graphiti.ui/plugin.xml b/plugins/org.eclipse.graphiti.ui/plugin.xml index e62c926b..eb3609cc 100644 --- a/plugins/org.eclipse.graphiti.ui/plugin.xml +++ b/plugins/org.eclipse.graphiti.ui/plugin.xml @@ -39,7 +39,7 @@ <extension point="org.eclipse.ui.editors"> <editor - class="org.eclipse.graphiti.ui.editor.DiagramEditorImpl" + class="org.eclipse.graphiti.ui.editor.DiagramEditor" contributorClass="org.eclipse.graphiti.ui.editor.DiagramEditorActionBarContributor" default="true" extensions="diagram" diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DefaultMarkerBehavior.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DefaultMarkerBehavior.java index f73757eb..abb22bfe 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DefaultMarkerBehavior.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DefaultMarkerBehavior.java @@ -10,6 +10,7 @@ * Contributors:
* Bug 336488 - DiagramEditor API
* Felix Velasco - mwenz - Bug 379788 - Memory leak in DefaultMarkerBehavior
+ * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface
*
* </copyright>
*
@@ -38,20 +39,20 @@ import org.eclipse.graphiti.ui.internal.services.GraphitiUiInternal; import org.eclipse.swt.widgets.Display;
/**
- * The default implementation for the {@link DiagramEditor} behavior extension
+ * The default implementation for the {@link IDiagramEditorUI} behavior extension
* that controls how markers are handled in the editor. Clients may subclass to
- * change the marker behavior; use {@link DiagramEditor#createMarkerBehavior()}
+ * change the marker behavior; use {@link IDiagramEditorUI#createMarkerBehavior()}
* to return the instance that shall be used.<br>
- * Note that there is always a 1:1 relation with a {@link DiagramEditor}.
+ * Note that there is always a 1:1 relation with a {@link IDiagramEditorUI}.
*
* @since 0.9
*/
public class DefaultMarkerBehavior {
/**
- * The associated {@link DiagramEditor}
+ * The associated {@link IDiagramEditorUI}
*/
- protected DiagramEditor diagramEditor;
+ protected IDiagramEditorUI diagramEditor;
/**
* The marker helper instance is responsible for creating workspace resource
@@ -71,12 +72,13 @@ public class DefaultMarkerBehavior { /**
* Creates a new instance of {@link DefaultMarkerBehavior} that is
- * associated with the given {@link DiagramEditor}.
+ * associated with the given {@link IDiagramEditorUI}.
*
* @param diagramEditor
- * the associated {@link DiagramEditor}
+ * the associated {@link IDiagramEditorUI}
+ * @since 0.10
*/
- public DefaultMarkerBehavior(DiagramEditor diagramEditor) {
+ public DefaultMarkerBehavior(IDiagramEditorUI diagramEditor) {
super();
this.diagramEditor = diagramEditor;
}
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DefaultPaletteBehavior.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DefaultPaletteBehavior.java index 804b731e..1516660e 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DefaultPaletteBehavior.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DefaultPaletteBehavior.java @@ -9,6 +9,7 @@ *
* Contributors:
* Bug 336488 - DiagramEditor API
+ * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface
*
* </copyright>
*
@@ -40,8 +41,8 @@ import org.eclipse.swt.events.KeyEvent; * the way GEF handles the palette within its editors, see
* {@link GraphicalEditorWithFlyoutPalette} for more information on that. To
* exchange the default implementation you have to return an instance of your
- * subclass in the method {@link DiagramEditor#createPaletteBehaviour()}.<br>
- * Note that there is always a 1:1 relation with a {@link DiagramEditor}.
+ * subclass in the method {@link IDiagramEditorUI#createPaletteBehaviour()}.<br>
+ * Note that there is always a 1:1 relation with a {@link IDiagramEditorUI}.
*
* @since 0.9
*/
@@ -71,21 +72,22 @@ public class DefaultPaletteBehavior { protected static final int DEFAULT_PALETTE_SIZE = 130;
/**
- * The associated {@link DiagramEditor}
+ * The associated {@link IDiagramEditorUI}
*/
- protected final DiagramEditor diagramEditor;
+ protected final IDiagramEditorUI diagramEditor;
private PaletteRoot paletteRoot;
/**
* Creates a new standard palette behaviour for a Graphiti diagram editor.
- * The passed {@link DiagramEditor} is closely linked to this instance (1:1
- * relation) and both instances will have a common lifecycle.
+ * The passed {@link IDiagramEditorUI} is closely linked to this instance
+ * (1:1 relation) and both instances will have a common lifecycle.
*
* @param diagramEditor
- * The associated {@link DiagramEditor}.
+ * The associated {@link IDiagramEditorUI}.
+ * @since 0.10
*/
- public DefaultPaletteBehavior(DiagramEditor diagramEditor) {
+ public DefaultPaletteBehavior(IDiagramEditorUI diagramEditor) {
super();
this.diagramEditor = diagramEditor;
}
@@ -105,7 +107,7 @@ public class DefaultPaletteBehavior { /**
* Returns the already existing {@link PaletteRoot} instance for the
- * {@link DiagramEditor} associated the this palette behavior or creates a
+ * {@link IDiagramEditorUI} associated the this palette behavior or creates a
* new {@link PaletteRoot} instance in case none exists.
*
* @return a new Graphiti specific {@link PaletteRoot} instance
@@ -261,9 +263,10 @@ public class DefaultPaletteBehavior { /**
* Returns the associated Graphiti diagram editor.
*
- * @return the associated {@link DiagramEditor} instance
+ * @return the associated {@link IDiagramEditorUI} instance
+ * @since 0.10
*/
- protected DiagramEditor getDiagramEditor() {
+ protected IDiagramEditorUI getDiagramEditor() {
return diagramEditor;
}
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DefaultPersistencyBehavior.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DefaultPersistencyBehavior.java index d8485dd3..c71e1010 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DefaultPersistencyBehavior.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DefaultPersistencyBehavior.java @@ -12,6 +12,7 @@ * mwenz - Bug 372753 - save shouldn't (necessarily) flush the command stack
* mwenz - Bug 376008 - Iterating through navigation history causes exceptions
* mwenz - Bug 393074 - Save Editor Progress Monitor Argument
+ * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface
*
* </copyright>
*
@@ -49,21 +50,21 @@ import org.eclipse.jface.operation.ModalContext; import org.eclipse.swt.widgets.Display;
/**
- * The default implementation for the {@link DiagramEditor} behavior extension
+ * The default implementation for the {@link IDiagramEditorUI} behavior extension
* that controls the persistence behavior of the Graphiti diagram Editor.
* Clients may subclass to change the behavior; use
- * {@link DiagramEditor#createPersistencyBehavior()} to return the instance that
+ * {@link IDiagramEditorUI#createPersistencyBehavior()} to return the instance that
* shall be used.<br>
- * Note that there is always a 1:1 relation with a {@link DiagramEditor}.
+ * Note that there is always a 1:1 relation with a {@link IDiagramEditorUI}.
*
* @since 0.9
*/
public class DefaultPersistencyBehavior {
/**
- * The associated {@link DiagramEditor}
+ * The associated {@link IDiagramEditorUI}
*/
- protected final DiagramEditor diagramEditor;
+ protected final IDiagramEditorUI diagramEditor;
/**
* Used to store the command that was executed before the editor was saved.
@@ -74,12 +75,13 @@ public class DefaultPersistencyBehavior { /**
* Creates a new instance of {@link DefaultPersistencyBehavior} that is
- * associated with the given {@link DiagramEditor}.
+ * associated with the given {@link IDiagramEditorUI}.
*
* @param diagramEditor
- * the associated {@link DiagramEditor}
+ * the associated {@link IDiagramEditorUI}
+ * @since 0.10
*/
- public DefaultPersistencyBehavior(DiagramEditor diagramEditor) {
+ public DefaultPersistencyBehavior(IDiagramEditorUI diagramEditor) {
this.diagramEditor = diagramEditor;
}
@@ -133,14 +135,14 @@ public class DefaultPersistencyBehavior { /**
* This method is called to save a diagram. The default implementation here
* saves all changes done to any of the EMF resources loaded within the
- * {@link DiagramEditor} so that the complete state of all modified objects
+ * {@link IDiagramEditorUI} so that the complete state of all modified objects
* will be persisted in the file system.<br>
* The default implementation also sets the current version information
* (currently 0.10.0) to the diagram before saving it and wraps the save
* operation inside a {@link IRunnableWithProgress} that cares about sending
* only one {@link Resource} change event holding all modified files.
* Besides also all adapters are temporarily switched off (see
- * {@link DiagramEditor#disableAdapters()}).<br>
+ * {@link IDiagramEditorUI#disableAdapters()}).<br>
* To only modify the actual saving clients should rather override
* {@link #save(TransactionalEditingDomain, Map)}.
*
@@ -189,7 +191,7 @@ public class DefaultPersistencyBehavior { /**
* Returns if the editor needs to be saved or not. Is queried by the
- * {@link DiagramEditor#isDirty()} method. The default implementation checks
+ * {@link IDiagramEditorUI#isDirty()} method. The default implementation checks
* if the top of the current undo stack is equal to the stored top command
* of the undo stack at the time of the last saving of the editor.
*
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DefaultRefreshBehavior.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DefaultRefreshBehavior.java index ae870020..9694f47a 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DefaultRefreshBehavior.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DefaultRefreshBehavior.java @@ -9,6 +9,7 @@ *
* Contributors:
* Bug 336488 - DiagramEditor API
+ * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface
*
* </copyright>
*
@@ -38,33 +39,34 @@ import org.eclipse.graphiti.ui.internal.parts.ShapeEditPart; import org.eclipse.swt.widgets.Display;
/**
- * The default implementation for the {@link DiagramEditor} behavior extension
+ * The default implementation for the {@link IDiagramEditorUI} behavior extension
* that controls the refresh behavior of the Graphiti diagram editor. Clients
* may subclass to change the behavior; use
- * {@link DiagramEditor#createRefreshBehavior()} to return the instance that
+ * {@link IDiagramEditorUI#createRefreshBehavior()} to return the instance that
* shall be used.<br>
- * Note that there is always a 1:1 relation with a {@link DiagramEditor}.
+ * Note that there is always a 1:1 relation with a {@link IDiagramEditorUI}.
*
* @since 0.9
*/
public class DefaultRefreshBehavior {
/**
- * The associated {@link DiagramEditor}. Set on construction of this class.
+ * The associated {@link IDiagramEditorUI}. Set on construction of this class.
*/
- protected final DiagramEditor diagramEditor;
+ protected final IDiagramEditorUI diagramEditor;
private RefreshPerformanceCache refreshPerformanceCache = new RefreshPerformanceCache();
/**
* Creates a new standard refresh behaviour for a Graphiti diagram editor.
- * The passed {@link DiagramEditor} is closely linked to this instance (1:1
- * relation) and both instances will have a common lifecycle.
+ * The passed {@link IDiagramEditorUI} is closely linked to this instance
+ * (1:1 relation) and both instances will have a common lifecycle.
*
* @param diagramEditor
- * The associated {@link DiagramEditor}.
+ * The associated {@link IDiagramEditorUI}.
+ * @since 0.10
*/
- public DefaultRefreshBehavior(DiagramEditor diagramEditor) {
+ public DefaultRefreshBehavior(IDiagramEditorUI diagramEditor) {
super();
this.diagramEditor = diagramEditor;
}
@@ -82,8 +84,8 @@ public class DefaultRefreshBehavior { /**
* Handles the auto update at startup of the editor and is called by the
- * Graphiti {@link DiagramEditor} when the input is set (
- * {@link DiagramEditor#setInput(org.eclipse.ui.IEditorInput)}). The default
+ * Graphiti {@link IDiagramEditorUI} when the input is set (
+ * {@link IDiagramEditorUI#setInput(org.eclipse.ui.IEditorInput)}). The default
* implementation checks the desired behavior as defined in
* {@link IDiagramTypeProvider#isAutoUpdateAtStartup()} and calls
* {@link #autoUpdate(Diagram, IDiagramTypeProvider)} in case an update
@@ -102,7 +104,7 @@ public class DefaultRefreshBehavior { * Handles the auto update at rest of the editor (the editor performs a
* reload of the EMF resources because e.g. the underlying file has been
* changed by another editor) and is called by the Graphiti
- * {@link DiagramEditor} after the {@link Diagram} has been reloaded. The
+ * {@link IDiagramEditorUI} after the {@link Diagram} has been reloaded. The
* default implementation checks the desired behavior as defined in
* {@link IDiagramTypeProvider#isAutoUpdateAtReset()} and calls
* {@link #autoUpdate(Diagram, IDiagramTypeProvider)} in case an update
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DefaultUpdateBehavior.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DefaultUpdateBehavior.java index 0f6bf73e..5bd11997 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DefaultUpdateBehavior.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DefaultUpdateBehavior.java @@ -15,6 +15,7 @@ * Bug 336488 - DiagramEditor API - Rename from DiagramEditorBehavior to DefaultUpdateBehavior * mwenz - Bug 389426 - Add factory method for creating EMF workspace synchronizer delegate * pjpaulin - Bug 352120 - Eliminated assumption that diagram is in an IEditorPart + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -52,24 +53,24 @@ import org.eclipse.ui.IWorkbenchPartSite; import org.eclipse.ui.PlatformUI; /** - * The default implementation for the {@link DiagramEditor} behavior extension + * The default implementation for the {@link IDiagramEditorUI} behavior extension * that controls update behavior of the editor and defines the EMF adapters that * watch over model object modifications. Clients may subclass to change the - * behavior; use {@link DiagramEditor#createUpdateBehavior()} to return the + * behavior; use {@link IDiagramEditorUI#createUpdateBehavior()} to return the * instance that shall be used.<br> - * Note that there is always a 1:1 relation with a {@link DiagramEditor}. + * Note that there is always a 1:1 relation with a {@link IDiagramEditorUI}. * * @since 0.9 */ public class DefaultUpdateBehavior extends PlatformObject implements IEditingDomainProvider, IOperationHistoryListener { /** - * The associated {@link DiagramEditor} + * The associated {@link IDiagramEditorUI} */ - protected final DiagramEditor diagramEditor; + protected final IDiagramEditorUI diagramEditor; /** - * The editing domain that is used throughout the {@link DiagramEditor} is + * The editing domain that is used throughout the {@link IDiagramEditorUI} is * kept here and only here. */ private TransactionalEditingDomain editingDomain; @@ -179,12 +180,13 @@ public class DefaultUpdateBehavior extends PlatformObject implements IEditingDom /** * Creates a new {@link DefaultUpdateBehavior} instance associated with the - * given {@link DiagramEditor}. + * given {@link IDiagramEditorUI}. * * @param diagramEditor * the part this model editor works on + * @since 0.10 */ - public DefaultUpdateBehavior(DiagramEditor diagramEditor) { + public DefaultUpdateBehavior(IDiagramEditorUI diagramEditor) { super(); this.diagramEditor = diagramEditor; } diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramComposite.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramComposite.java index 3c0330da..31fba490 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramComposite.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramComposite.java @@ -9,6 +9,7 @@ * * Contributors: * pjpaulin - initial API, implementation and documentation + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -56,7 +57,7 @@ import org.eclipse.ui.IWorkbenchPartSite; * * @since 0.10 */ -public class DiagramComposite extends GraphicalComposite implements DiagramEditor { +public class DiagramComposite extends GraphicalComposite implements IDiagramEditorUI { private DiagramSupport diagramSupport; diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramEditor.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramEditor.java index 3bfb311f..57fac728 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramEditor.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramEditor.java @@ -30,84 +30,472 @@ * mwenz - Bug 387971 - Features cant't be invoked from contextMenu * fvelasco - Bug 323349 - Enable external invocation of features * mwenz - Bug 393113 - Auto-focus does not work for connections - * pjpaulin - Bug 352120 - Changed from a class to an interface - API BREAKAGE HERE + * pjpaulin - Bug 352120 - Main implementation of DiagramEditor - API BREAKAGE HERE + * pjpaulin - Bug 352120 - Renamed from DiagramEditorImpl so that classes extending DiagramEditor do not break * * </copyright> * *******************************************************************************/ - package org.eclipse.graphiti.ui.editor; +import java.util.ArrayList; import java.util.EventObject; +import java.util.Iterator; import java.util.List; +import org.eclipse.core.runtime.AssertionFailedException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.geometry.Point; +import org.eclipse.emf.common.ui.URIEditorInput; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.edit.domain.IEditingDomainProvider; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gef.ContextMenuProvider; import org.eclipse.gef.DefaultEditDomain; import org.eclipse.gef.EditPart; import org.eclipse.gef.GraphicalEditPart; import org.eclipse.gef.GraphicalViewer; +import org.eclipse.gef.KeyHandler; +import org.eclipse.gef.KeyStroke; +import org.eclipse.gef.editparts.ZoomManager; +import org.eclipse.gef.palette.PaletteRoot; import org.eclipse.gef.ui.actions.ActionRegistry; +import org.eclipse.gef.ui.actions.GEFActionConstants; +import org.eclipse.gef.ui.palette.FlyoutPaletteComposite.FlyoutPreferences; +import org.eclipse.gef.ui.palette.PaletteViewerProvider; import org.eclipse.gef.ui.parts.GraphicalEditor; +import org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalette; import org.eclipse.gef.ui.parts.SelectionSynchronizer; +import org.eclipse.graphiti.dt.IDiagramTypeProvider; +import org.eclipse.graphiti.features.IAddFeature; +import org.eclipse.graphiti.features.IFeature; +import org.eclipse.graphiti.features.context.IAddContext; +import org.eclipse.graphiti.features.context.IContext; import org.eclipse.graphiti.mm.pictograms.PictogramElement; -import org.eclipse.graphiti.platform.IDiagramEditor; +import org.eclipse.graphiti.services.Graphiti; +import org.eclipse.graphiti.tb.IToolBehaviorProvider; +import org.eclipse.graphiti.ui.internal.action.RemoveAction; +import org.eclipse.graphiti.ui.internal.editor.DomainModelChangeListener; import org.eclipse.graphiti.ui.platform.IConfigurationProvider; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IPropertyListener; +import org.eclipse.ui.IEditorSite; import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchPartConstants; -import org.eclipse.ui.IWorkbenchPartSite; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.actions.ActionFactory; +import org.eclipse.ui.contexts.IContextService; +import org.eclipse.ui.navigator.CommonNavigator; +import org.eclipse.ui.part.MultiPageEditorPart; +import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor; /** - * This is the main interface for the Graphiti diagram editor. It can be - * implemented by any class that would like to display a Graphiti diagram. - * - * A DiagramEditor takes in a {@link DiagramEditorInput} that points to the - * diagram to display. This input is not technically an IEditorInput, as - * diagrams may be displayed in non-editor parts. + * This is the main class for the Graphiti diagram editor. It represents the + * editor to Eclipse and therefore implements {@link IEditorPart}. The + * implementation is based upon a GEF editor implementation ( + * {@link GraphicalEditorWithFlyoutPalette}) and enhances it with + * Graphiti-specific stuff.<br> + * This editor is registered as an Eclipse editor using the extension point + * org.eclipse.ui.editors. Therefore the Eclipse standard methods can be used to + * open a new diagram editor. The associated {@link IEditorInput} object is a + * subclass of {@link DiagramEditorInput}, but using another type of input is + * also ok as long as it can be adapted to an IFile that can be reolved within + * the workspace of is a {@link URIEditorInput}. These types of input objects + * will be converted to a corresponding {@link DiagramEditorInput} when the + * editor is initialized (see {@link #init(IEditorSite, IEditorInput)}).<br> + * Any clients extending this class should also contribute their editor to the + * Eclipse editor extension point to gain full advantage of the Eclipse editor + * integration of Graphiti.<br> + * There are a lot of aspects this class needs to deal with; the larger aspects + * are separated into other classes which share the lifecycle with the + * {@link DiagramEditor} instance. This means they are instantiated when a + * new diagram editor is created and exist until the editor is closed again. + * There are default implementations for all of these aspects, see the + * Default*Behavior classes in this package. The following aspects are + * separated: + * <ul> + * <li>Markers: Handles everything about markers in the editor. See + * {@link DefaultMarkerBehavior} for the default implementation. Override + * {@link #createMarkerBehavior()} to change the default behavior.</li> + * <li>Palette: Handles everything about the palette in the editor. See + * {@link DefaultPaletteBehavior} for the default implementation. Override + * {@link #createPaletteBehaviour()} to change the default behavior.</li> + * <li>Persistence: Handles everything about loading, saving and the dirty state + * in the editor. See {@link DefaultPersistencyBehavior} for the default + * implementation. Override {@link #createPersistencyBehavior()} to change the + * default behavior.</li> + * <li>Refreshing: Handles everything about refreshing the editor (refreshing + * means that the editor shows what's defined in the pictogram model). See + * {@link DefaultRefreshBehavior} for the default implementation. Override + * {@link #createRefreshBehavior()} to change the default behavior.</li> + * <li>Update: Handles everything about updating the editor (updating means that + * the pictogram model is updated to reflect any changes done to the domain + * model - your business objects - or to the way objects shall be visualized). + * See {@link DefaultMarkerBehavior} for the default implementation. Override + * {@link #createMarkerBehavior()} to change the default behavior.</li> + * </ul> + * All the other aspects are dealt with directly within this class. One of the + * larger aspects implemented here is selection handling, which would have been + * awkward if separated out. * * @since 0.10 + * */ -public interface DiagramEditor extends IDiagramEditor { +public class DiagramEditor extends GraphicalEditorWithFlyoutPalette implements IDiagramEditorUI, + ITabbedPropertySheetPageContributor, IEditingDomainProvider { + + private String contributorId; + private DiagramSupport diagramSupport; + + private KeyHandler keyHandler; /** - * The ID of the {@link DiagramEditorImpl} as it is registered with the + * The ID of the {@link DiagramEditor} as it is registered with the * org.eclipse.ui.editors extension point. */ public static final String DIAGRAM_EDITOR_ID = "org.eclipse.graphiti.ui.editor.DiagramEditor"; //$NON-NLS-1$ /** - * The ID of the context as it is registed with the org.eclipse.ui.contexts - * extension point. + * Creates a new diagram editor and cares about the creation of the + * different behavior extensions by delegating to the various + * create*Behavior() methods. + */ + public DiagramEditor() { + super(); + this.diagramSupport = new DiagramSupport(this); + } + + // ------------------ Behaviors -------------------------------------------- + + /** + * Creates the behavior extension that deals with markers. See + * {@link DefaultMarkerBehavior} for details and the default implementation. + * Override to change the marker behavior. * - * @since 0.10 + * @return a new instance of {@link DefaultMarkerBehavior} + * @since 0.9 */ - public static final String DIAGRAM_CONTEXT_ID = "org.eclipse.graphiti.ui.diagramEditor"; //$NON-NLS-1$ + protected DefaultMarkerBehavior createMarkerBehavior() { + return this.diagramSupport.createMarkerBehavior(); + } /** - * Returns the GEF edit domain as needed for some of the feature - * functionality in Graphiti; simply a public rewrite of the GEF editor - * super method. + * Creates the behavior extension that deals with the update handling. See + * {@link DefaultUpdateBehavior} for details and the default implementation. + * Override to change the update behavior. * - * @return the {@link DefaultEditDomain} used in this editor - * @see GraphicalEditor#getEditDomain() + * @return a new instance of {@link DefaultUpdateBehavior} + * @since 0.9 + */ + protected DefaultUpdateBehavior createUpdateBehavior() { + return this.diagramSupport.createUpdateBehavior(); + } + + /** + * Returns the instance of the update behavior that is used with this + * editor. To change the behavior override {@link #createUpdateBehavior()}. * + * @return the used instance of the update behavior, by default a + * {@link DefaultUpdateBehavior}. * @since 0.9 */ - DefaultEditDomain getEditDomain(); + public final DefaultUpdateBehavior getUpdateBehavior() { + return this.diagramSupport.getUpdateBehavior(); + } - void setGEFEditDomain(DefaultEditDomain editDomain); + /** + * Creates the behavior extension that deals with the palette handling. See + * {@link DefaultPaletteBehavior} for details and the default + * implementation. Override to change the palette behavior. + * + * @return a new instance of {@link DefaultPaletteBehavior} + * @since 0.9 + */ + protected DefaultPaletteBehavior createPaletteBehaviour() { + return this.diagramSupport.createPaletteBehaviour(); + } /** - * Returns the GEF {@link GraphicalViewer} as it is needed in some Graphiti - * feature implementations. This is simply a public rewrite of the according - * super method. + * Creates the behavior extension that deals with the persistence handling. + * See {@link DefaultPersistencyBehavior} for details and the default + * implementation. Override to change the persistence behavior. * - * @return the {@link GraphicalViewer} used within this editor instance - * @see GraphicalEditor#getGraphicalViewer() + * @return a new instance of {@link DefaultPersistencyBehavior} + * @since 0.9 + */ + protected DefaultPersistencyBehavior createPersistencyBehavior() { + return this.diagramSupport.createPersistencyBehavior(); + } + + /** + * Creates the behavior extension that deals with the refresh handling. See + * {@link DefaultRefreshBehavior} for details and the default + * implementation. Override to change the refresh behavior. + * + * @return a new instance of {@link DefaultRefreshBehavior} + * @since 0.9 + */ + protected DefaultRefreshBehavior createRefreshBehavior() { + return this.diagramSupport.createRefreshBehavior(); + } + + /** + * Returns the instance of the refresh behavior that is used with this + * editor. To change the behavior override {@link #createRefreshBehavior()}. + * + * @return the used instance of the refresh behavior, by default a + * {@link DefaultRefreshBehavior}. + * @since 0.9 + */ + public final DefaultRefreshBehavior getRefreshBehavior() { + return this.diagramSupport.getRefreshBehavior(); + } + + // ---------------------- Synchronization hooks between behaviors ------- // + + /** + * Hook that is called by the holder of the + * {@link TransactionalEditingDomain} ({@link DefaultUpdateBehavior} or a + * subclass of it) after the editing domain has been initialized. Can be + * used to e.g. register additional listeners on the domain.<br> + * The default implementation notifies the marker behavior extension to + * register its listeners. + * + * @since 0.9 + */ + public void editingDomainInitialized() { + this.diagramSupport.editingDomainInitialized(); + } + + /** + * Should be called (e.g. by the various behavior instances) before mass EMF + * resource operations are triggered (e.g. saving all resources). Can be + * used to disable eventing for performance reasons. See + * {@link #enableAdapters()} as well.<br> + * Important note: make sure that you re-enable eventing using + * {@link #enableAdapters()} after the operation has finished (best in a + * finally clause to do that also in case of exceptions), otherwise strange + * errors may happen. + * + * @since 0.9 + */ + public void disableAdapters() { + this.diagramSupport.disableAdapters(); + } + + /** + * Should be called by the various behavior instances after mass EMF + * resource operations have been triggered (e.g. saving all resources). Can + * be used to re-enable eventing after it was disabled for performance + * reasons. See {@link #disableAdapters()} as well.<br> + * Must be called after {@link #disableAdapters()} has been called and the + * operation has finshed (best in a finally clause to also enable the + * exception case), otherwise strange errors may occur within the editor. + * + * @since 0.9 + */ + public void enableAdapters() { + this.diagramSupport.enableAdapters(); + } + + // ------------------ Initializazion --------------------------------------- + + /** + * Does the initialization of the editor. The default implementation cares + * about: + * <ol> + * <li>converting the passed {@link IEditorInput} to a + * {@link DiagramEditorInput}. In case this fails, a + * {@link PartInitException} is thrown.</li> + * <li>creating the editing domain by delegating to the update behavior + * extension, see {@link DefaultUpdateBehavior#createEditingDomain()} for + * details</li> + * <li>initializing the underlying GEF editor by delegating to super</li> + * <li>initializing the update behavior extension (the order is important + * here as this must happen after initializing the GEF editor!)</li> + * <li>triggering the migration of diagram data if necessary</li> + * </ol> + * Any clients overriding this method have to make sure that they they + * always call <code>super.init(site, input)</code>. + * + * @see org.eclipse.ui.IEditorPart#init(IEditorSite, IEditorInput) + * @param site + * the Eclipse {@link IEditorSite} that will host this editor + * @param input + * the editor input that shall be used. Note that this method + * will exchange the input instance in case it is no + * {@link DiagramEditorInput}. + * + */ + public void init(IEditorSite site, IEditorInput input) throws PartInitException { + // Eclipse may call us with other inputs when a file is to be + // opened. Try to convert this to a valid diagram input. + if (!(input instanceof IDiagramEditorInput)) { + input = convertToDiagramEditorInput(input); + if (input == null) { + throw new PartInitException( + "No DiagramEditorInput instance is available but it is required. The method convertToDiagramEditorInput illegally returned null."); //$NON-NLS-1$ + } + } + + this.getUpdateBehavior().createEditingDomain(); + + // The GEF GraphicalEditor init(...) functionality, adapted to provide a + // nice error message to the user in case of an error when opening an + // editor with e.g. an invalid diagram, see Bug 376008 + setSite(site); + setInput(input); + if (this.diagramSupport.getEditorInitializationError() != null) { + // In case of error simply show an primitive editor with a label + return; + } + getCommandStack().addCommandStackListener(this); + getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(this); + initializeActionRegistry(); + // ... End of GEF functionality taken over + + getUpdateBehavior().init(); + this.diagramSupport.migrateDiagramModelIfNecessary(); + + migrateDiagramModelIfNecessary(); + IContextService contextService = (IContextService) getSite().getService(IContextService.class); + contextService.activateContext(getDiagramTypeProvider().getContextId()); + } + + /** + * Is called by the {@link #init(IEditorSite, IEditorInput)} method in case + * the {@link IEditorInput} instance passed is no {@link DiagramEditorInput} + * . This method should try to convert the passed input object to a + * {@link DiagramEditorInput} or throw an {@link PartInitException} in case + * the conversion can (or should) not be done for any reason. The default + * implementation uses the + * {@link EditorInputAdapter#adaptToDiagramEditorInput(IEditorInput)} method + * to do the conversion. Clients may adapt to do additional conversions or + * to prohibit any conversion by simply throwing a {@link PartInitException} + * . + * + * @param input + * the original input + * @return a {@link DiagramEditorInput} corresponding to the passed input + * instance in case a conversion is possible. This method must not + * return <code>null</code>, otherwise the editor initialization + * will fail. + * @throws PartInitException + * in case the passed input object cannot or should not be + * converted to a {@link DiagramEditorInput} instance. + * + * @since 0.9 + */ + protected DiagramEditorInput convertToDiagramEditorInput(IEditorInput input) throws PartInitException { + IEditorInput newInput = EditorInputAdapter.adaptToDiagramEditorInput(input); + if (!(newInput instanceof IDiagramEditorInput)) { + throw new PartInitException("Unknown editor input: " + input); //$NON-NLS-1$ + } + return (DiagramEditorInput) newInput; + } + + /** + * Sets the given {@link IEditorInput} object as the input for this editor. + * It must be of type {@link DiagramEditorInput} otherwise an + * {@link IllegalArgumentException} is thrown.<br> + * The default implementation here cares about loading the diagram from the + * EMF {@link Resource} the input points to, sets the ID of the + * {@link IDiagramTypeProvider} for the diagram given in the input, + * registers listeners (by delegating to + * {@link #registerDiagramResourceSetListener()} and + * {@link #registerBusinessObjectsListener()}) and does the refreshing of + * the editor UI. + * + * @param input + * the {@link DiagramEditorInput} instance to use within this + * editor. + */ + protected void setInput(IEditorInput input) { + super.setInput(input); + this.diagramSupport.setInput((IDiagramEditorInput) input); + } + + /** + * Initializes the action registry with the predefined actions (update, + * remove, delete, copy, paste, zooming, direct editing, alignment and + * toggling actions for the diagram grip and hiding of the context button + * pad. + * + * @param zoomManager + * the GEF zoom manager to use + * + * @since 0.9 + */ + protected void initActionRegistry(ZoomManager zoomManager) { + this.diagramSupport.initActionRegistry(zoomManager); + } + + /** + * Creates the UI of the editor by delegating to the + * <code>super.createPartControl</code> method. The default implementation + * here also registers the command stack listener to correctly reflect the + * dirty state of the editor. + */ + public void createPartControl(Composite parent) { + if (this.diagramSupport.getEditorInitializationError() != null) { + this.diagramSupport.createErrorPartControl(parent); + return; + } + super.createPartControl(parent); + this.diagramSupport.postCreatePartControl(); + } + + /** + * Creates the GraphicalViewer on the specified {@link Composite} and + * initializes it. + * + * @param parent + * the parent composite + */ + protected void createGraphicalViewer(Composite parent) { + this.diagramSupport.createGraphicalViewer(parent); + } + + /** + * Called to initialize the editor with its content. Here everything is + * done, which is dependent of the IConfigurationProviderInternal. + * + * @see org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalette#initializeGraphicalViewer() + */ + protected void initializeGraphicalViewer() { + + super.initializeGraphicalViewer(); + this.diagramSupport.initializeGraphicalViewer(); + + // this will cause the ActionBarContributor to refresh with the + // new actions (there is no specific refresh-action). + if (getEditorSite().getActionBarContributor() != null) + getEditorSite().getActionBarContributor().setActiveEditor(this); + } + + /** + * Called to configure the editor, before it receives its content. The + * default-implementation is for example doing the following: configure the + * ZoomManager, registering Actions... Here everything is done, which is + * independent of the IConfigurationProviderInternal. + * + * @see org.eclipse.gef.ui.parts.GraphicalEditor#configureGraphicalViewer() */ - GraphicalViewer getGraphicalViewer(); + protected void configureGraphicalViewer() { + super.configureGraphicalViewer(); + this.diagramSupport.configureGraphicalViewer(); + } + + // ------------------- Dirty state ----------------------------------------- /** * Updates the UI to correctly reflect the dirty state of the editor. The @@ -116,101 +504,513 @@ public interface DiagramEditor extends IDiagramEditor { * * @since 0.9 */ - void updateDirtyState(); + public void updateDirtyState() { + firePropertyChange(IEditorPart.PROP_DIRTY); + } - IConfigurationProvider getConfigurationProvider(); + /** + * Called to perform the saving of the editor. The default implementation + * delegates to + * {@link DefaultPersistencyBehavior#saveDiagram(IProgressMonitor)}. + * + * @param monitor + * the Eclipse progress monitor to report progress with. + */ + public void doSave(IProgressMonitor monitor) { + this.diagramSupport.getPersistencyBehavior().saveDiagram(monitor); + } /** - * Returns the contents {@link EditPart} of this Editor. This is the topmost - * EditPart in the {@link GraphicalViewer}. + * Returns if the editor is currently dirty and needs to be saved or not. + * The default implementation delegates to + * {@link DefaultPersistencyBehavior#isDirty()}. + * + * @return <code>true</code> in case the editor is dirty, <code>false</code> + * otherwise. + */ + public boolean isDirty() { + return this.diagramSupport.isDirty(); + } + + // ---------------------- Palette --------------------------------------- // + + /** + * Delegates to the method (or the method in a subclass of) + * {@link DefaultPaletteBehavior#createPaletteViewerProvider() + * #createPaletteViewerProvider()} to create the + * {@link PaletteViewerProvider} used inside the GEF editor. + * + * @return the {@link PaletteViewerProvider} to use + */ + protected final PaletteViewerProvider createPaletteViewerProvider() { + return this.diagramSupport.createPaletteViewerProvider(); + } + + /** + * Delegates to the method (or the method in a subclass of) + * {@link DefaultPaletteBehavior#getPalettePreferences()}. To change the + * palette override the behavior there. + * + * @return the {@link PaletteViewerProvider} preferences to use. + */ + protected final FlyoutPreferences getPalettePreferences() { + return this.diagramSupport.getPalettePreferences(); + } + + /** + * Returns the {@link PaletteRoot} to use in the GEF editor by delegating to + * {@link DefaultPaletteBehavior#getPaletteRoot()}. + * + * @return the {@link PaletteRoot} to use + */ + protected final PaletteRoot getPaletteRoot() { + return this.diagramSupport.getPaletteRoot(); + } + + /** + * Refreshes to palette to correctly reflect all available creation tools + * for the available create features and the currently enabled selection + * tools * - * @return The contents {@link EditPart} of this Editor. * @since 0.9 */ - EditPart getContentEditPart(); + public final void refreshPalette() { + this.diagramSupport.refreshPalette(); + } + + // ---------------------- Context Menu ---------------------------------- // /** - * Method to retrieve the GEF {@link EditPart} for a given - * {@link PictogramElement}. + * Returns a new {@link ContextMenuProvider}. Clients can return null, if no + * context-menu shall be displayed. * - * @param pe - * the {@link PictogramElement} to retrieve the GEF - * representation for - * @return the GEF {@link GraphicalEditPart} that represents the given - * {@link PictogramElement}. + * @return A new instance of {@link ContextMenuProvider}. * @since 0.9 */ - GraphicalEditPart getEditPartForPictogramElement(PictogramElement pe); + protected ContextMenuProvider createContextMenuProvider() { + return this.diagramSupport.createContextMenuProvider(); + } /** - * Gets the current mouse location as a {@link Point}. + * Allows subclasses to prevent that the diagram context menu should be + * registered for extensions at Eclipse. By default others can provide + * extensions to the menu (default return value of this method is + * <code>true</code>). By returning <code>false</code> any extension of the + * context menu can be prevented. + * <p> + * For details see Bugzilla 345347 + * (https://bugs.eclipse.org/bugs/show_bug.cgi?id=345347). * - * @return the mouse location + * @return <code>true</code> in case extensions shall be allowed (default), + * <code>false</code> otherwise. * @since 0.9 */ - Point getMouseLocation(); + protected boolean shouldRegisterContextMenu() { + return this.diagramSupport.shouldRegisterContextMenu(); + } + + // ---------------------- Listeners ------------------------------------- // /** - * @return the {@link IWorkbenchPart} that is displaying the diagram. + * Hook to register listeners for diagram changes. The listener will be + * notified with all events and has to filter for the ones regarding the + * diagram.<br> + * Note that additional listeners registered here should also be + * unregistered in {@link #unregisterDiagramResourceSetListener()}. + * + * @since 0.9 */ - IWorkbenchPart getWorkbenchPart(); + protected void registerDiagramResourceSetListener() { + this.diagramSupport.registerDiagramResourceSetListener(); + } /** - * @return the site for the {@link IWorkbenchPart} that is displaying the - * diagram. - * @since 0.10 + * Hook that is called to register listeners for changes of the business + * objects (domain objects) in the resource set of the editor. The default + * implementation registers the {@link DomainModelChangeListener}.<br> + * Note that additional listeners registered here should also be + * unregistered in {@link #unregisterBusinessObjectsListener()}. + * + * @since 0.9 */ - IWorkbenchPartSite getSite(); + protected void registerBusinessObjectsListener() { + this.diagramSupport.registerBusinessObjectsListener(); + } /** - * @return the title for the {@link IWorkbenchPart} that is displaying the - * diagram. - * @since 0.10 + * Hook to unregister the listeners for diagram changes. + * + * @see #registerDiagramResourceSetListener() + * @since 0.9 + */ + protected void unregisterDiagramResourceSetListener() { + this.diagramSupport.unregisterDiagramResourceSetListener(); + } + + /** + * Hook that is called to unregister the listeners for changes of the + * business objects (domain objects). + * + * @see DiagramEditor#registerBusinessObjectsListener() + * @since 0.9 + */ + protected void unregisterBusinessObjectsListener() { + this.diagramSupport.unregisterBusinessObjectsListener(); + } + + // ---------------------- Refresh --------------------------------------- // + + /** + * Refreshes the editor title to show the name of the diagram + * + * @since 0.9 + */ + public void refreshTitle() { + String name = getConfigurationProvider().getDiagramTypeProvider().getDiagramTitle(); + if (name == null || name.length() == 0) { + name = getConfigurationElement().getAttribute("name"); //$NON-NLS-1$ + } + if (name == null || name.length() == 0) { + name = URI.decode(getDiagramTypeProvider().getDiagram().eResource().getURI().lastSegment()); + } + setPartName(name); + } + + /** + * Refreshes the tooltip displayed for the editor title tab according to + * what is returned in {@link #getTitleToolTip()}. + * + * @since 0.9 + */ + public void refreshTitleToolTip() { + setTitleToolTip(getTitleToolTip()); + } + + /** + * Triggers a complete refresh of the editor (content, title, tooltip, + * palette and decorators) by delegating to + * {@link DefaultRefreshBehavior#refresh()}. + * + * @since 0.9 + */ + public void refresh() { + this.diagramSupport.refresh(); + } + + /** + * Refreshes the content of the editor (what's shown inside the diagram + * itself). + * + * @since 0.9 + */ + public void refreshContent() { + this.diagramSupport.refreshContent(); + } + + /** + * Refreshes the rendering decorators (image decorators and the like) by + * delegating to + * {@link DefaultRefreshBehavior#refreshRenderingDecorators(PictogramElement)} + * for the given {@link PictogramElement}. + * + * @param pe + * the {@link PictogramElement} for which the decorators shall be + * refreshed. + * + * @since 0.9 + */ + public void refreshRenderingDecorators(PictogramElement pe) { + this.diagramSupport.refreshRenderingDecorators(pe); + } + + // ====================== standard behaviour ============================== + + /** + * Implements the Eclipse {@link IAdaptable} interface. This implementation + * first delegates to the {@link IToolBehaviorProvider#getAdapter(Class)} + * method and checks if something is returned. In case the return value is + * <code>null</code> it returns adapters for ZoomManager, + * IPropertySheetPage, Diagram, KeyHandler, SelectionSynchronizer and + * IContextButtonManager. It also delegates to the super implementation in + * {@link GraphicalEditorWithFlyoutPalette#getAdapter(Class)}. + * + * @param type + * the type to which shall be adapted + * @return the adapter instance + */ + public Object getAdapter(@SuppressWarnings("rawtypes") Class type) { + Object returnObj = this.diagramSupport.getAdapter(type); + if (returnObj != null) + return returnObj; + return super.getAdapter(type); + } + + /** + * Disposes this {@link DiagramEditor} instance and frees all used resources + * and clears all references. Also delegates to all the behavior extensions + * to also free their resources (e.g. and most important is the + * {@link TransactionalEditingDomain} held by the + * {@link DefaultPersistencyBehavior}. Always delegate to + * <code>super.dispose()</code> in case you override this method! + */ + public void dispose() { + this.diagramSupport.preSuperDispose(); + + RuntimeException exc = null; + if (getEditDomain() != null) { + // Avoid exception in case an error during editor initialization + // happened + try { + super.dispose(); + } catch (RuntimeException e) { + exc = e; + } + } + + this.diagramSupport.postSuperDispose(); + + if (exc != null) { + throw exc; + } + } + + /** + * Sets the focus by delegating to the super class implementation in the GEF + * editor and additionally triggers a update of the diagram by delegating to + * {@link DefaultUpdateBehavior#handleActivate()}. + */ + public void setFocus() { + if (getGraphicalViewer() == null) { + return; + } + + super.setFocus(); + getUpdateBehavior().handleActivate(); + } + + // ---------------------- Selection ------------------------------------- // + + /** + * Returns the {@link PictogramElement}s that are currently selected in the + * diagram editor. + * + * @return an array of {@link PictogramElement}s. + * + * @since 0.9 */ - String getTitle(); + public PictogramElement[] getSelectedPictogramElements() { + return this.diagramSupport.getSelectedPictogramElements(); + } /** - * Adds a listener for changes to properties of this workbench part. Has no - * effect if an identical listener is already registered. + * Handles a selection changed event that is triggered by any selection + * source, e.g. a browser with "Link to Editor" enabled.<br> + * Checks if the currently active editor is a {@link MultiPageEditorPart} + * with an opened diagram editor inside, tries to find any + * {@link PictogramElement} for the objects in the selection and selects + * them in the diagram.<br> + * Note that in case of the {@link CommonNavigator} as event source, its + * editor linking mechanism must be enabled. + * + * @param part + * the source {@link IWorkbenchPart} that triggered the event + * @param selection + * the new selection (mostly a {@link IStructuredSelection} + * instance. + * + * @since 0.9 + */ + public void selectionChanged(IWorkbenchPart part, ISelection selection) { + // If not the active editor, ignore selection changed. + boolean editorIsActive = getSite().getPage().isPartVisible(this); + if (!editorIsActive) { + // Check if we are a page of the active multi page editor + IEditorPart activeEditor = getSite().getPage().getActiveEditor(); + if (activeEditor != null) { + if (activeEditor instanceof MultiPageEditorPart) { + Object selectedPage = ((MultiPageEditorPart) activeEditor).getAdapter(DiagramEditor.class); + if (selectedPage instanceof DiagramEditor) { + // Editor is active and diagram sub editor is its active + // page + editorIsActive = true; + } + } + } + } + if (editorIsActive) { + // long start = System.nanoTime(); + // this is where we should check the selection source (part) + // * for CNF view the link flag must be obeyed + // this would however require a dependency to + // org.eclipse.ui.navigator + if (part instanceof CommonNavigator) { + if (!((CommonNavigator) part).isLinkingEnabled()) { + return; + } + } + // useful selection ?? + if (selection instanceof IStructuredSelection) { + IStructuredSelection structuredSelection = (IStructuredSelection) selection; + List<PictogramElement> peList = new ArrayList<PictogramElement>(); + // Collect all Pictogram Elements for all selected domain + // objects into one list + for (Iterator<?> iterator = structuredSelection.iterator(); iterator.hasNext();) { + Object object = iterator.next(); + if (object instanceof EObject) { + // Find the Pictogram Elements for the given domain + // object via the standard link service + List<PictogramElement> referencingPes = Graphiti.getLinkService().getPictogramElements( + getDiagramTypeProvider().getDiagram(), (EObject) object); + if (referencingPes.size() > 0) { + peList.addAll(referencingPes); + } + } else { + // For non-EMF domain objects use the registered + // notification service for finding + PictogramElement[] relatedPictogramElements = getDiagramTypeProvider().getNotificationService() + .calculateRelatedPictogramElements(new Object[] { object }); + for (int i = 0; i < relatedPictogramElements.length; i++) { + peList.add(relatedPictogramElements[i]); + } + } + } + + // Do the selection in the diagram (in case there is something + // to select) + PictogramElement[] pes = null; + if (peList.size() > 0) { + pes = peList.toArray(new PictogramElement[peList.size()]); + } + if (pes != null && pes.length > 0) { + selectPictogramElements(pes); + } + } + /* + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=387971: When + * embedding a diagram editor inside a multi page editor the + * registered actions were not updated. The fix was simply not to + * delegate to super.selectionChange where a check for the editor + * being active only checks for the main editor (GEF editor is not + * embeddable inside another editor) but to trigger the action + * update ourself when our checks say the diagram editor is active. + */ + updateActions(getSelectionActions()); + } + + } + + /** + * Selects the given {@link PictogramElement}s in the diagram. + * + * @param pictogramElements + * an array of {@link PictogramElement}s to select. + * @since 0.9 + */ + public void selectPictogramElements(PictogramElement[] pictogramElements) { + this.diagramSupport.selectPictogramElements(pictogramElements); + } + + /** + * Returns the {@link PictogramElement}s that are set for later selection. * <p> - * The property ids are defined in {@link IWorkbenchPartConstants}. - * </p> + * The methods {@link #getPictogramElementsForSelection()}, + * {@link #setPictogramElementForSelection(PictogramElement)}, + * {@link #setPictogramElementsForSelection(PictogramElement[])} and + * {@link #selectBufferedPictogramElements()} offer the possibility to use a + * deferred selection mechanism: via the setters, {@link PictogramElement}s + * can be stored for a selection operation that is triggered lateron during + * a general refresh via the method + * {@link #selectBufferedPictogramElements()}. This mechanism is used e.g. + * in the Graphiti framework in direct editing to restore the previous + * selection, but can also be used by clients. * - * @param listener - * a property listener - * @since 0.10 + * @return the {@link PictogramElement}s stored for later selection + * @since 0.9 */ - public void addPropertyListener(IPropertyListener listener); + protected PictogramElement[] getPictogramElementsForSelection() { + return this.diagramSupport.getPictogramElementsForSelection(); + } /** - * Removes the given property listener from this workbench part. Has no - * effect if an identical listener is not registered. + * Sets one {@link PictogramElement} for later selection. + * <p> + * The methods {@link #getPictogramElementsForSelection()}, + * {@link #setPictogramElementForSelection(PictogramElement)}, + * {@link #setPictogramElementsForSelection(PictogramElement[])} and + * {@link #selectBufferedPictogramElements()} offer the possibility to use a + * deferred selection mechanism: via the setters, {@link PictogramElement}s + * can be stored for a selection operation that is triggered lateron during + * a general refresh via the method + * {@link #selectBufferedPictogramElements()}. This mechanism is used e.g. + * in the Graphiti framework in direct editing to restore the previous + * selection, but can also be used by clients. * - * @param listener - * a property listener - * @since 0.10 + * @param pictogramElement + * the {@link PictogramElement} that shall be stored for later + * selection + * @since 0.9 */ - public void removePropertyListener(IPropertyListener listener); + public void setPictogramElementForSelection(PictogramElement pictogramElement) { + this.diagramSupport.setPictogramElementForSelection(pictogramElement); + } /** - * Returns the instance of the update behavior that is used with this - * editor. To change the behavior override {@link #createUpdateBehavior()}. + * Sets {@link PictogramElement}s for later selection. + * <p> + * The methods {@link #getPictogramElementsForSelection()}, + * {@link #setPictogramElementForSelection(PictogramElement)}, + * {@link #setPictogramElementsForSelection(PictogramElement[])} and + * {@link #selectBufferedPictogramElements()} offer the possibility to use a + * deferred selection mechanism: via the setters, {@link PictogramElement}s + * can be stored for a selection operation that is triggered lateron during + * a general refresh via the method + * {@link #selectBufferedPictogramElements()}. This mechanism is used e.g. + * in the Graphiti framework in direct editing to restore the previous + * selection, but can also be used by clients. * - * @return the used instance of the update behavior, by default a - * {@link DefaultUpdateBehavior}. + * @param pictogramElements + * the {@link PictogramElement}s that shall be stored for later + * selection * @since 0.9 */ - DefaultUpdateBehavior getUpdateBehavior(); + public void setPictogramElementsForSelection(PictogramElement pictogramElements[]) { + this.diagramSupport.setPictogramElementsForSelection(pictogramElements); + } /** - * @return the input containing the model for the diagram + * Triggers the selection for the {@link PictogramElement}s that are stored + * for later selection. Can be called e.g during a general refresh of the + * editor or after another operation needing another selection is finished + * (an example in the framework is direct editing). + * <p> + * The methods {@link #getPictogramElementsForSelection()}, + * {@link #setPictogramElementForSelection(PictogramElement)}, + * {@link #setPictogramElementsForSelection(PictogramElement[])} and + * {@link #selectBufferedPictogramElements()} offer the possibility to use a + * deferred selection mechanism: via the setters, {@link PictogramElement}s + * can be stored for a selection operation that is triggered lateron during + * a general refresh via the method + * {@link #selectBufferedPictogramElements()}. This mechanism is used e.g. + * in the Graphiti framework in direct editing to restore the previous + * selection, but can also be used by clients. + * + * @since 0.9 */ - IDiagramEditorInput getDiagramEditorInput(); + public void selectBufferedPictogramElements() { + this.diagramSupport.selectBufferedPictogramElements(); + } + + // ---------------------- Mouse location -------------------------------- // /** - * Notify the container that it should shut down or clear it's state. + * Gets the current mouse location as a {@link Point}. + * + * @return the mouse location + * @since 0.9 */ - void shutdown(); + public Point getMouseLocation() { + return this.diagramSupport.getMouseLocation(); + } /** * Calculates the mouse location depending on scrollbars and zoom factor. @@ -220,17 +1020,213 @@ public interface DiagramEditor extends IDiagramEditor { * @return the {@link Point} of the real mouse location * @since 0.9 */ - Point calculateRealMouseLocation(Point nativeLocation); + public Point calculateRealMouseLocation(Point nativeLocation) { + return this.diagramSupport.calculateRealMouseLocation(nativeLocation); + } + + // ---------------------- Other ----------------------------------------- // /** - * Returns the instance of the refresh behavior that is used with this - * editor. To change the behavior override {@link #createRefreshBehavior()}. + * Returns the KeyHandler with common bindings to be used for both the + * Outline and the Graphical Viewer. * - * @return the used instance of the refresh behavior, by default a - * {@link DefaultRefreshBehavior}. + * @return The KeyHandler with common bindings for both the Outline and the + * Graphical Viewer. + * @since 0.9 + */ + protected KeyHandler getCommonKeyHandler() { + if (keyHandler == null) { + keyHandler = new KeyHandler(); + keyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0), + getActionRegistry().getAction(ActionFactory.DELETE.getId())); + keyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, SWT.SHIFT), + getActionRegistry().getAction(RemoveAction.ACTION_ID)); + keyHandler.put(KeyStroke.getPressed(SWT.F2, 0), + getActionRegistry().getAction(GEFActionConstants.DIRECT_EDIT)); + keyHandler.put(KeyStroke.getPressed('c', SWT.CTRL), + getActionRegistry().getAction(ActionFactory.COPY.getId())); + keyHandler.put(KeyStroke.getPressed('v', SWT.CTRL), + getActionRegistry().getAction(ActionFactory.PASTE.getId())); + // _keyHandler.put(KeyStroke.getPressed((char) 1, 'a', SWT.CTRL), + // getActionRegistry().getAction(ActionFactory.SELECT_ALL.getId())); + } + return keyHandler; + } + + /** + * @since 0.10 + */ + public IConfigurationProvider getConfigurationProvider() { + return this.diagramSupport.getConfigurationProvider(); + } + + /** + * Returns the contents {@link EditPart} of this Editor. This is the topmost + * EditPart in the {@link GraphicalViewer}. + * + * @return The contents {@link EditPart} of this Editor. + * @since 0.9 + */ + public EditPart getContentEditPart() { + return this.diagramSupport.getContentEditPart(); + } + + /** + * Returns the ID for contributions in the tabbed property sheets by + * delegating to the method {@link IToolBehaviorProvider#getContributorId()} + * . + * + * @return the contributor id as a {@link String} + * @since 0.9 + */ + public String getContributorId() { + + if (contributorId == null) { + IToolBehaviorProvider tbp = getToolBehaviorProvider(); + if (tbp != null) { + contributorId = tbp.getContributorId(); + } + } + return contributorId; + } + + /** + * Returns the {@link IDiagramTypeProvider} instance associated with this + * {@link DiagramEditor}. There is always a 1:1 relation between the editor + * and the provider. + * + * @return the associated {@link IDiagramTypeProvider} instance. + * + * @since 0.9 + */ + public IDiagramTypeProvider getDiagramTypeProvider() { + return this.diagramSupport.getDiagramTypeProvider(); + } + + /** + * Returns the GEF edit domain as needed for some of the feature + * functionality in Graphiti; simply a public rewrite of the GEF editor + * super method. + * + * @return the {@link DefaultEditDomain} used in this editor + * @see GraphicalEditor#getEditDomain() + * + * @since 0.9 + */ + public DefaultEditDomain getEditDomain() { + return super.getEditDomain(); + } + + /** + * Method to retrieve the GEF {@link EditPart} for a given + * {@link PictogramElement}. + * + * @param pe + * the {@link PictogramElement} to retrieve the GEF + * representation for + * @return the GEF {@link GraphicalEditPart} that represents the given + * {@link PictogramElement}. + * @since 0.9 + */ + public GraphicalEditPart getEditPartForPictogramElement(PictogramElement pe) { + return this.diagramSupport.getEditPartForPictogramElement(pe); + } + + /** + * Method to retrieve the Draw2D {@link IFigure} for a given + * {@link PictogramElement}. + * + * @param pe + * the {@link PictogramElement} to retrieve the Draw2D + * representation for + * @return the Draw2D {@link IFigure} that represents the given + * {@link PictogramElement}. + * + * @since 0.9 + */ + public IFigure getFigureForPictogramElement(PictogramElement pe) { + return this.diagramSupport.getFigureForPictogramElement(pe); + } + + /** + * Returns the GEF {@link GraphicalViewer} as it is needed in some Graphiti + * feature implementations. This is simply a public rewrite of the according + * super method. + * + * @return the {@link GraphicalViewer} used within this editor instance + * @see GraphicalEditor#getGraphicalViewer() + */ + public GraphicalViewer getGraphicalViewer() { + return super.getGraphicalViewer(); + } + + /** + * Returns the tooltip that shall be displayed when hovering over the editor + * title tab. + * + * @return the tooltip as a {@link String} + */ + public String getTitleToolTip() { + if (getDiagramTypeProvider() != null && getDiagramTypeProvider().getCurrentToolBehaviorProvider() != null) { + IToolBehaviorProvider tbp = getDiagramTypeProvider().getCurrentToolBehaviorProvider(); + String titleToolTip = tbp.getTitleToolTip(); + if (titleToolTip != null) { + return titleToolTip; + } + } + return super.getTitleToolTip(); + } + + private IToolBehaviorProvider getToolBehaviorProvider() { + IDiagramTypeProvider dtp = getDiagramTypeProvider(); + if (dtp != null) { + return dtp.getCurrentToolBehaviorProvider(); + } + return null; + } + + /** + * Returns the zoom level currently used in the editor. + * + * @return the zoom level + * @since 0.9 + */ + public double getZoomLevel() { + return this.diagramSupport.getZoomLevel(); + } + + /** + * We provide migration from 0.8.0 to 0.9.0. You can override if you want to + * migrate manually. WARNING: If your diagram is under version control, this + * method can cause a check out dialog to be opened etc. + * + * @since 0.9 + */ + protected void migrateDiagramModelIfNecessary() { + this.diagramSupport.migrateDiagramModelIfNecessary(); + } + + /** + * Checks if this editor is alive. + * + * @return <code>true</code>, if editor contains a model connector and a + * valid Diagram, <code>false</code> otherwise. + * @since 0.9 + */ + public boolean isAlive() { + return this.diagramSupport.isAlive(); + } + + /** + * Registers the given action with the Eclipse {@link ActionRegistry}. + * + * @param action + * the action to register * @since 0.9 */ - DefaultRefreshBehavior getRefreshBehavior(); + protected void registerAction(IAction action) { + this.diagramSupport.registerAction(action); + } /** * Returns if direct editing is currently active for this editor. @@ -240,7 +1236,9 @@ public interface DiagramEditor extends IDiagramEditor { * * @since 0.9 */ - boolean isDirectEditingActive(); + public boolean isDirectEditingActive() { + return this.diagramSupport.isDirectEditingActive(); + } /** * Sets that direct editing is now active in the editor or not. Note that @@ -254,45 +1252,127 @@ public interface DiagramEditor extends IDiagramEditor { * * @since 0.9 */ - void setDirectEditingActive(boolean directEditingActive); + public void setDirectEditingActive(boolean directEditingActive) { + this.diagramSupport.setDirectEditingActive(directEditingActive); + } /** - * Returns the zoom level currently used in the editor. + * Returns the EMF {@link TransactionalEditingDomain} used within this + * editor by delegating to the update behavior extension, by default + * {@link DefaultUpdateBehavior#getEditingDomain()}. + * + * @return the {@link TransactionalEditingDomain} instance used in the + * editor * - * @return the zoom level * @since 0.9 */ - double getZoomLevel(); + public TransactionalEditingDomain getEditingDomain() { + return this.diagramSupport.getEditingDomain(); + } /** - * Method to retrieve the Draw2D {@link IFigure} for a given - * {@link PictogramElement}. + * Executes the given {@link IFeature} with the given {@link IContext} in + * the scope of this {@link DiagramEditor}, meaning within its + * {@link TransactionalEditingDomain} and on its + * {@link org.eclipse.emf.common.command.CommandStack}. * - * @param pe - * the {@link PictogramElement} to retrieve the Draw2D - * representation for - * @return the Draw2D {@link IFigure} that represents the given - * {@link PictogramElement}. + * @param feature + * the feature to execute + * @param context + * the context to use. In case the passed feature is a + * {@link IAddFeature} this context needs to be an instance of + * {@link IAddContext}, otherwise an + * {@link AssertionFailedException} will be thrown. + * @return in case of an {@link IAddFeature} being passed as feature the + * newly added {@link PictogramElement} will be returned (in case + * the add method returning it), in all other cases + * <code>null</code> * * @since 0.9 */ - IFigure getFigureForPictogramElement(PictogramElement pe); + public Object executeFeature(IFeature feature, IContext context) { + return this.diagramSupport.executeFeature(feature, context); + } /** - * Public accessor that should redirect to protected method. + * The EMF {@link ResourceSet} used within this {@link DiagramEditor}. The + * resource set is always associated in a 1:1 releation to the + * {@link TransactionalEditingDomain}. + * + * @return the resource set used within this editor + * @since 0.9 */ - void initializeGEFGraphicalViewer(); + public ResourceSet getResourceSet() { + return this.diagramSupport.getResourceSet(); + } - ActionRegistry getActionRegistry(); + /** + * @since 0.10 + */ + public IDiagramEditorInput getDiagramEditorInput() { + return this.diagramSupport.getInput(); + } + + + /** + * @since 0.10 + */ + public IWorkbenchPart getWorkbenchPart() { + return this; + } + + /** + * @since 0.10 + */ + public void shutdown() { + getSite().getPage().closeEditor(this, false); + } + + /* GEF methods that need to be part of the IGEFDiagramContainer interface. */ + + /** + * @since 0.10 + */ + public void setGEFEditDomain(DefaultEditDomain editDomain) { + this.setEditDomain(editDomain); + } + + /** + * @since 0.10 + */ + public void initializeGEFGraphicalViewer() { + this.initializeGraphicalViewer(); + } + + public ActionRegistry getActionRegistry() { + return super.getActionRegistry(); + } @SuppressWarnings("rawtypes") - List getSelectionActions(); + public List getSelectionActions() { + return super.getSelectionActions(); + } + + public SelectionSynchronizer getSelectionSynchronizer() { + return super.getSelectionSynchronizer(); + } - SelectionSynchronizer getSelectionSynchronizer(); + public void commandStackChanged(EventObject event) { + super.commandStackChanged(event); + } - void commandStackChanged(EventObject event); + public void setGraphicalViewer(GraphicalViewer viewer) { + super.setGraphicalViewer(viewer); + } - void setGraphicalViewer(GraphicalViewer viewer); + public void hookGraphicalViewer() { + super.hookGraphicalViewer(); + } - void hookGraphicalViewer(); + /** + * @since 0.10 + */ + public boolean isLocalEditingDomain() { + return true; + } } diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramEditorContextMenuProvider.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramEditorContextMenuProvider.java index 73f97a4f..650c2019 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramEditorContextMenuProvider.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramEditorContextMenuProvider.java @@ -17,6 +17,7 @@ * cbrand - Bug 377783 - Dump for figures in connection layer needed * fvelasco - Bug 396247 - ImageDescriptor changes * pjpaulin - Bug 352120 - Add certain menu options only if local transaction + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -442,7 +443,7 @@ public class DiagramEditorContextMenuProvider extends ContextMenuProvider { return this.diagramTypeProvider; } - private DiagramEditor getEditor() { - return (DiagramEditor) getDiagramTypeProvider().getDiagramEditor(); + private IDiagramEditorUI getEditor() { + return (IDiagramEditorUI) getDiagramTypeProvider().getDiagramEditor(); } } diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramEditorImpl.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramEditorImpl.java deleted file mode 100644 index f1486616..00000000 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramEditorImpl.java +++ /dev/null @@ -1,1376 +0,0 @@ -/******************************************************************************* - * <copyright> - * - * Copyright (c) 2005, 2012 SAP AG. - * 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: - * SAP AG - initial API, implementation and documentation - * mwenz - Bug 331715: Support for rectangular grids in diagrams - * mwenz - Bug 332964: Enable setting selection for non-EMF domain models and - * when embedded into a multi-page editor - * mwenz - Bug 336075 - DiagramEditor accepts URIEditorInput - * mwenz - Bug 329523 - Add notification of DiagramTypeProvider after saving a diagram - * jpasch - Bug 323025 ActionBarContributor cleanup - * mwenz - Bug 345347 - There should be a way to not allow other plugins to contribute to the diagram context menu - * mwenz - Bug 346932 - Navigation history broken - * mwenz - Bug 356828 - Escaped diagram name is used as editor title - * mwenz - Bug 356218 - Added hasDoneChanges updates to update diagram feature - * and called features via editor command stack to check it - * Felix Velasco (mwenz) - Bug 323351 - Enable to suppress/reactivate the speed buttons - * Bug 336488 - DiagramEditor API - * mwenz - Bug 367204 - Correctly return the added PE inAbstractFeatureProvider's addIfPossible method - * mwenz - Bug 324556 - Prevent invisible shapes to be selected to avoid IllegalArgumentException - * mwenz - Bug 372753 - save shouldn't (necessarily) flush the command stack - * mwenz - Bug 376008 - Iterating through navigation history causes exceptions - * Felix Velasco - mwenz - Bug 379788 - Memory leak in DefaultMarkerBehavior - * mwenz - Bug 387971 - Features cant't be invoked from contextMenu - * fvelasco - Bug 323349 - Enable external invocation of features - * mwenz - Bug 393113 - Auto-focus does not work for connections - * pjpaulin - Bug 352120 - Main implementation of DiagramEditor - API BREAKAGE HERE - * - * </copyright> - * - *******************************************************************************/ -package org.eclipse.graphiti.ui.editor; - -import java.util.ArrayList; -import java.util.EventObject; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.runtime.AssertionFailedException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.emf.common.ui.URIEditorInput; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.edit.domain.IEditingDomainProvider; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gef.ContextMenuProvider; -import org.eclipse.gef.DefaultEditDomain; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.GraphicalViewer; -import org.eclipse.gef.KeyHandler; -import org.eclipse.gef.KeyStroke; -import org.eclipse.gef.editparts.ZoomManager; -import org.eclipse.gef.palette.PaletteRoot; -import org.eclipse.gef.ui.actions.ActionRegistry; -import org.eclipse.gef.ui.actions.GEFActionConstants; -import org.eclipse.gef.ui.palette.FlyoutPaletteComposite.FlyoutPreferences; -import org.eclipse.gef.ui.palette.PaletteViewerProvider; -import org.eclipse.gef.ui.parts.GraphicalEditor; -import org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalette; -import org.eclipse.gef.ui.parts.SelectionSynchronizer; -import org.eclipse.graphiti.dt.IDiagramTypeProvider; -import org.eclipse.graphiti.features.IAddFeature; -import org.eclipse.graphiti.features.IFeature; -import org.eclipse.graphiti.features.context.IAddContext; -import org.eclipse.graphiti.features.context.IContext; -import org.eclipse.graphiti.mm.pictograms.PictogramElement; -import org.eclipse.graphiti.services.Graphiti; -import org.eclipse.graphiti.tb.IToolBehaviorProvider; -import org.eclipse.graphiti.ui.internal.action.RemoveAction; -import org.eclipse.graphiti.ui.internal.editor.DomainModelChangeListener; -import org.eclipse.graphiti.ui.platform.IConfigurationProvider; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.contexts.IContextService; -import org.eclipse.ui.navigator.CommonNavigator; -import org.eclipse.ui.part.MultiPageEditorPart; -import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor; - -/** - * This is the main class for the Graphiti diagram editor. It represents the - * editor to Eclipse and therefore implements {@link IEditorPart}. The - * implementation is based upon a GEF editor implementation ( - * {@link GraphicalEditorWithFlyoutPalette}) and enhances it with - * Graphiti-specific stuff.<br> - * This editor is registered as an Eclipse editor using the extension point - * org.eclipse.ui.editors. Therefore the Eclipse standard methods can be used to - * open a new diagram editor. The associated {@link IEditorInput} object is a - * subclass of {@link DiagramEditorInput}, but using another type of input is - * also ok as long as it can be adapted to an IFile that can be reolved within - * the workspace of is a {@link URIEditorInput}. These types of input objects - * will be converted to a corresponding {@link DiagramEditorInput} when the - * editor is initialized (see {@link #init(IEditorSite, IEditorInput)}).<br> - * Any clients extending this class should also contribute their editor to the - * Eclipse editor extension point to gain full advantage of the Eclipse editor - * integration of Graphiti.<br> - * There are a lot of aspects this class needs to deal with; the larger aspects - * are separated into other classes which share the lifecycle with the - * {@link DiagramEditorImpl} instance. This means they are instantiated when a - * new diagram editor is created and exist until the editor is closed again. - * There are default implementations for all of these aspects, see the - * Default*Behavior classes in this package. The following aspects are - * separated: - * <ul> - * <li>Markers: Handles everything about markers in the editor. See - * {@link DefaultMarkerBehavior} for the default implementation. Override - * {@link #createMarkerBehavior()} to change the default behavior.</li> - * <li>Palette: Handles everything about the palette in the editor. See - * {@link DefaultPaletteBehavior} for the default implementation. Override - * {@link #createPaletteBehaviour()} to change the default behavior.</li> - * <li>Persistence: Handles everything about loading, saving and the dirty state - * in the editor. See {@link DefaultPersistencyBehavior} for the default - * implementation. Override {@link #createPersistencyBehavior()} to change the - * default behavior.</li> - * <li>Refreshing: Handles everything about refreshing the editor (refreshing - * means that the editor shows what's defined in the pictogram model). See - * {@link DefaultRefreshBehavior} for the default implementation. Override - * {@link #createRefreshBehavior()} to change the default behavior.</li> - * <li>Update: Handles everything about updating the editor (updating means that - * the pictogram model is updated to reflect any changes done to the domain - * model - your business objects - or to the way objects shall be visualized). - * See {@link DefaultMarkerBehavior} for the default implementation. Override - * {@link #createMarkerBehavior()} to change the default behavior.</li> - * </ul> - * All the other aspects are dealt with directly within this class. One of the - * larger aspects implemented here is selection handling, which would have been - * awkward if separated out. - * - * @since 0.10 - * - */ -public class DiagramEditorImpl extends GraphicalEditorWithFlyoutPalette implements DiagramEditor, - ITabbedPropertySheetPageContributor, IEditingDomainProvider { - - private String contributorId; - private DiagramSupport diagramSupport; - - /** - * The ID of the context as it is registered with the - * org.eclipse.ui.contexts extension point. - * - * @since 0.10 - */ - public static final String DIAGRAM_CONTEXT_ID = "org.eclipse.graphiti.ui.diagramEditor"; //$NON-NLS-1$ - - private KeyHandler keyHandler; - - /** - * Creates a new diagram editor and cares about the creation of the - * different behavior extensions by delegating to the various - * create*Behavior() methods. - */ - public DiagramEditorImpl() { - super(); - this.diagramSupport = new DiagramSupport(this); - } - - // ------------------ Behaviors -------------------------------------------- - - /** - * Creates the behavior extension that deals with markers. See - * {@link DefaultMarkerBehavior} for details and the default implementation. - * Override to change the marker behavior. - * - * @return a new instance of {@link DefaultMarkerBehavior} - * @since 0.9 - */ - protected DefaultMarkerBehavior createMarkerBehavior() { - return this.diagramSupport.createMarkerBehavior(); - } - - /** - * Creates the behavior extension that deals with the update handling. See - * {@link DefaultUpdateBehavior} for details and the default implementation. - * Override to change the update behavior. - * - * @return a new instance of {@link DefaultUpdateBehavior} - * @since 0.9 - */ - protected DefaultUpdateBehavior createUpdateBehavior() { - return this.diagramSupport.createUpdateBehavior(); - } - - /** - * Returns the instance of the update behavior that is used with this - * editor. To change the behavior override {@link #createUpdateBehavior()}. - * - * @return the used instance of the update behavior, by default a - * {@link DefaultUpdateBehavior}. - * @since 0.9 - */ - public final DefaultUpdateBehavior getUpdateBehavior() { - return this.diagramSupport.getUpdateBehavior(); - } - - /** - * Creates the behavior extension that deals with the palette handling. See - * {@link DefaultPaletteBehavior} for details and the default - * implementation. Override to change the palette behavior. - * - * @return a new instance of {@link DefaultPaletteBehavior} - * @since 0.9 - */ - protected DefaultPaletteBehavior createPaletteBehaviour() { - return this.diagramSupport.createPaletteBehaviour(); - } - - /** - * Creates the behavior extension that deals with the persistence handling. - * See {@link DefaultPersistencyBehavior} for details and the default - * implementation. Override to change the persistence behavior. - * - * @return a new instance of {@link DefaultPersistencyBehavior} - * @since 0.9 - */ - protected DefaultPersistencyBehavior createPersistencyBehavior() { - return this.diagramSupport.createPersistencyBehavior(); - } - - /** - * Creates the behavior extension that deals with the refresh handling. See - * {@link DefaultRefreshBehavior} for details and the default - * implementation. Override to change the refresh behavior. - * - * @return a new instance of {@link DefaultRefreshBehavior} - * @since 0.9 - */ - protected DefaultRefreshBehavior createRefreshBehavior() { - return this.diagramSupport.createRefreshBehavior(); - } - - /** - * Returns the instance of the refresh behavior that is used with this - * editor. To change the behavior override {@link #createRefreshBehavior()}. - * - * @return the used instance of the refresh behavior, by default a - * {@link DefaultRefreshBehavior}. - * @since 0.9 - */ - public final DefaultRefreshBehavior getRefreshBehavior() { - return this.diagramSupport.getRefreshBehavior(); - } - - // ---------------------- Synchronization hooks between behaviors ------- // - - /** - * Hook that is called by the holder of the - * {@link TransactionalEditingDomain} ({@link DefaultUpdateBehavior} or a - * subclass of it) after the editing domain has been initialized. Can be - * used to e.g. register additional listeners on the domain.<br> - * The default implementation notifies the marker behavior extension to - * register its listeners. - * - * @since 0.9 - */ - public void editingDomainInitialized() { - this.diagramSupport.editingDomainInitialized(); - } - - /** - * Should be called (e.g. by the various behavior instances) before mass EMF - * resource operations are triggered (e.g. saving all resources). Can be - * used to disable eventing for performance reasons. See - * {@link #enableAdapters()} as well.<br> - * Important note: make sure that you re-enable eventing using - * {@link #enableAdapters()} after the operation has finished (best in a - * finally clause to do that also in case of exceptions), otherwise strange - * errors may happen. - * - * @since 0.9 - */ - public void disableAdapters() { - this.diagramSupport.disableAdapters(); - } - - /** - * Should be called by the various behavior instances after mass EMF - * resource operations have been triggered (e.g. saving all resources). Can - * be used to re-enable eventing after it was disabled for performance - * reasons. See {@link #disableAdapters()} as well.<br> - * Must be called after {@link #disableAdapters()} has been called and the - * operation has finshed (best in a finally clause to also enable the - * exception case), otherwise strange errors may occur within the editor. - * - * @since 0.9 - */ - public void enableAdapters() { - this.diagramSupport.enableAdapters(); - } - - // ------------------ Initializazion --------------------------------------- - - /** - * Does the initialization of the editor. The default implementation cares - * about: - * <ol> - * <li>converting the passed {@link IEditorInput} to a - * {@link DiagramEditorInput}. In case this fails, a - * {@link PartInitException} is thrown.</li> - * <li>creating the editing domain by delegating to the update behavior - * extension, see {@link DefaultUpdateBehavior#createEditingDomain()} for - * details</li> - * <li>initializing the underlying GEF editor by delegating to super</li> - * <li>initializing the update behavior extension (the order is important - * here as this must happen after initializing the GEF editor!)</li> - * <li>triggering the migration of diagram data if necessary</li> - * </ol> - * Any clients overriding this method have to make sure that they they - * always call <code>super.init(site, input)</code>. - * - * @see org.eclipse.ui.IEditorPart#init(IEditorSite, IEditorInput) - * @param site - * the Eclipse {@link IEditorSite} that will host this editor - * @param input - * the editor input that shall be used. Note that this method - * will exchange the input instance in case it is no - * {@link DiagramEditorInput}. - * - */ - public void init(IEditorSite site, IEditorInput input) throws PartInitException { - // Eclipse may call us with other inputs when a file is to be - // opened. Try to convert this to a valid diagram input. - if (!(input instanceof IDiagramEditorInput)) { - input = convertToDiagramEditorInput(input); - if (input == null) { - throw new PartInitException( - "No DiagramEditorInput instance is available but it is required. The method convertToDiagramEditorInput illegally returned null."); //$NON-NLS-1$ - } - } - - this.getUpdateBehavior().createEditingDomain(); - - // The GEF GraphicalEditor init(...) functionality, adapted to provide a - // nice error message to the user in case of an error when opening an - // editor with e.g. an invalid diagram, see Bug 376008 - setSite(site); - setInput(input); - if (this.diagramSupport.getEditorInitializationError() != null) { - // In case of error simply show an primitive editor with a label - return; - } - getCommandStack().addCommandStackListener(this); - getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(this); - initializeActionRegistry(); - // ... End of GEF functionality taken over - - getUpdateBehavior().init(); - this.diagramSupport.migrateDiagramModelIfNecessary(); - - migrateDiagramModelIfNecessary(); - IContextService contextService = (IContextService) getSite().getService(IContextService.class); - contextService.activateContext(getDiagramTypeProvider().getContextId()); - } - - /** - * Is called by the {@link #init(IEditorSite, IEditorInput)} method in case - * the {@link IEditorInput} instance passed is no {@link DiagramEditorInput} - * . This method should try to convert the passed input object to a - * {@link DiagramEditorInput} or throw an {@link PartInitException} in case - * the conversion can (or should) not be done for any reason. The default - * implementation uses the - * {@link EditorInputAdapter#adaptToDiagramEditorInput(IEditorInput)} method - * to do the conversion. Clients may adapt to do additional conversions or - * to prohibit any conversion by simply throwing a {@link PartInitException} - * . - * - * @param input - * the original input - * @return a {@link DiagramEditorInput} corresponding to the passed input - * instance in case a conversion is possible. This method must not - * return <code>null</code>, otherwise the editor initialization - * will fail. - * @throws PartInitException - * in case the passed input object cannot or should not be - * converted to a {@link DiagramEditorInput} instance. - * - * @since 0.9 - */ - protected DiagramEditorInput convertToDiagramEditorInput(IEditorInput input) throws PartInitException { - IEditorInput newInput = EditorInputAdapter.adaptToDiagramEditorInput(input); - if (!(newInput instanceof IDiagramEditorInput)) { - throw new PartInitException("Unknown editor input: " + input); //$NON-NLS-1$ - } - return (DiagramEditorInput) newInput; - } - - /** - * Sets the given {@link IEditorInput} object as the input for this editor. - * It must be of type {@link DiagramEditorInput} otherwise an - * {@link IllegalArgumentException} is thrown.<br> - * The default implementation here cares about loading the diagram from the - * EMF {@link Resource} the input points to, sets the ID of the - * {@link IDiagramTypeProvider} for the diagram given in the input, - * registers listeners (by delegating to - * {@link #registerDiagramResourceSetListener()} and - * {@link #registerBusinessObjectsListener()}) and does the refreshing of - * the editor UI. - * - * @param input - * the {@link DiagramEditorInput} instance to use within this - * editor. - */ - protected void setInput(IEditorInput input) { - super.setInput(input); - this.diagramSupport.setInput((IDiagramEditorInput) input); - } - - /** - * Initializes the action registry with the predefined actions (update, - * remove, delete, copy, paste, zooming, direct editing, alignment and - * toggling actions for the diagram grip and hiding of the context button - * pad. - * - * @param zoomManager - * the GEF zoom manager to use - * - * @since 0.9 - */ - protected void initActionRegistry(ZoomManager zoomManager) { - this.diagramSupport.initActionRegistry(zoomManager); - } - - /** - * Creates the UI of the editor by delegating to the - * <code>super.createPartControl</code> method. The default implementation - * here also registers the command stack listener to correctly reflect the - * dirty state of the editor. - */ - public void createPartControl(Composite parent) { - if (this.diagramSupport.getEditorInitializationError() != null) { - this.diagramSupport.createErrorPartControl(parent); - return; - } - super.createPartControl(parent); - this.diagramSupport.postCreatePartControl(); - } - - /** - * Creates the GraphicalViewer on the specified {@link Composite} and - * initializes it. - * - * @param parent - * the parent composite - */ - protected void createGraphicalViewer(Composite parent) { - this.diagramSupport.createGraphicalViewer(parent); - } - - /** - * Called to initialize the editor with its content. Here everything is - * done, which is dependent of the IConfigurationProviderInternal. - * - * @see org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalette#initializeGraphicalViewer() - */ - protected void initializeGraphicalViewer() { - - super.initializeGraphicalViewer(); - this.diagramSupport.initializeGraphicalViewer(); - - // this will cause the ActionBarContributor to refresh with the - // new actions (there is no specific refresh-action). - if (getEditorSite().getActionBarContributor() != null) - getEditorSite().getActionBarContributor().setActiveEditor(this); - } - - /** - * Called to configure the editor, before it receives its content. The - * default-implementation is for example doing the following: configure the - * ZoomManager, registering Actions... Here everything is done, which is - * independent of the IConfigurationProviderInternal. - * - * @see org.eclipse.gef.ui.parts.GraphicalEditor#configureGraphicalViewer() - */ - protected void configureGraphicalViewer() { - super.configureGraphicalViewer(); - this.diagramSupport.configureGraphicalViewer(); - } - - // ------------------- Dirty state ----------------------------------------- - - /** - * Updates the UI to correctly reflect the dirty state of the editor. The - * default implementation does this by firing a - * {@link IEditorPart#PROP_DIRTY} property change. - * - * @since 0.9 - */ - public void updateDirtyState() { - firePropertyChange(IEditorPart.PROP_DIRTY); - } - - /** - * Called to perform the saving of the editor. The default implementation - * delegates to - * {@link DefaultPersistencyBehavior#saveDiagram(IProgressMonitor)}. - * - * @param monitor - * the Eclipse progress monitor to report progress with. - */ - public void doSave(IProgressMonitor monitor) { - this.diagramSupport.getPersistencyBehavior().saveDiagram(monitor); - } - - /** - * Returns if the editor is currently dirty and needs to be saved or not. - * The default implementation delegates to - * {@link DefaultPersistencyBehavior#isDirty()}. - * - * @return <code>true</code> in case the editor is dirty, <code>false</code> - * otherwise. - */ - public boolean isDirty() { - return this.diagramSupport.isDirty(); - } - - // ---------------------- Palette --------------------------------------- // - - /** - * Delegates to the method (or the method in a subclass of) - * {@link DefaultPaletteBehavior#createPaletteViewerProvider() - * #createPaletteViewerProvider()} to create the - * {@link PaletteViewerProvider} used inside the GEF editor. - * - * @return the {@link PaletteViewerProvider} to use - */ - protected final PaletteViewerProvider createPaletteViewerProvider() { - return this.diagramSupport.createPaletteViewerProvider(); - } - - /** - * Delegates to the method (or the method in a subclass of) - * {@link DefaultPaletteBehavior#getPalettePreferences()}. To change the - * palette override the behavior there. - * - * @return the {@link PaletteViewerProvider} preferences to use. - */ - protected final FlyoutPreferences getPalettePreferences() { - return this.diagramSupport.getPalettePreferences(); - } - - /** - * Returns the {@link PaletteRoot} to use in the GEF editor by delegating to - * {@link DefaultPaletteBehavior#getPaletteRoot()}. - * - * @return the {@link PaletteRoot} to use - */ - protected final PaletteRoot getPaletteRoot() { - return this.diagramSupport.getPaletteRoot(); - } - - /** - * Refreshes to palette to correctly reflect all available creation tools - * for the available create features and the currently enabled selection - * tools - * - * @since 0.9 - */ - public final void refreshPalette() { - this.diagramSupport.refreshPalette(); - } - - // ---------------------- Context Menu ---------------------------------- // - - /** - * Returns a new {@link ContextMenuProvider}. Clients can return null, if no - * context-menu shall be displayed. - * - * @return A new instance of {@link ContextMenuProvider}. - * @since 0.9 - */ - protected ContextMenuProvider createContextMenuProvider() { - return this.diagramSupport.createContextMenuProvider(); - } - - /** - * Allows subclasses to prevent that the diagram context menu should be - * registered for extensions at Eclipse. By default others can provide - * extensions to the menu (default return value of this method is - * <code>true</code>). By returning <code>false</code> any extension of the - * context menu can be prevented. - * <p> - * For details see Bugzilla 345347 - * (https://bugs.eclipse.org/bugs/show_bug.cgi?id=345347). - * - * @return <code>true</code> in case extensions shall be allowed (default), - * <code>false</code> otherwise. - * @since 0.9 - */ - protected boolean shouldRegisterContextMenu() { - return this.diagramSupport.shouldRegisterContextMenu(); - } - - // ---------------------- Listeners ------------------------------------- // - - /** - * Hook to register listeners for diagram changes. The listener will be - * notified with all events and has to filter for the ones regarding the - * diagram.<br> - * Note that additional listeners registered here should also be - * unregistered in {@link #unregisterDiagramResourceSetListener()}. - * - * @since 0.9 - */ - protected void registerDiagramResourceSetListener() { - this.diagramSupport.registerDiagramResourceSetListener(); - } - - /** - * Hook that is called to register listeners for changes of the business - * objects (domain objects) in the resource set of the editor. The default - * implementation registers the {@link DomainModelChangeListener}.<br> - * Note that additional listeners registered here should also be - * unregistered in {@link #unregisterBusinessObjectsListener()}. - * - * @since 0.9 - */ - protected void registerBusinessObjectsListener() { - this.diagramSupport.registerBusinessObjectsListener(); - } - - /** - * Hook to unregister the listeners for diagram changes. - * - * @see #registerDiagramResourceSetListener() - * @since 0.9 - */ - protected void unregisterDiagramResourceSetListener() { - this.diagramSupport.unregisterDiagramResourceSetListener(); - } - - /** - * Hook that is called to unregister the listeners for changes of the - * business objects (domain objects). - * - * @see DiagramEditorImpl#registerBusinessObjectsListener() - * @since 0.9 - */ - protected void unregisterBusinessObjectsListener() { - this.diagramSupport.unregisterBusinessObjectsListener(); - } - - // ---------------------- Refresh --------------------------------------- // - - /** - * Refreshes the editor title to show the name of the diagram - * - * @since 0.9 - */ - public void refreshTitle() { - String name = getConfigurationProvider().getDiagramTypeProvider().getDiagramTitle(); - if (name == null || name.length() == 0) { - name = getConfigurationElement().getAttribute("name"); //$NON-NLS-1$ - } - if (name == null || name.length() == 0) { - name = URI.decode(getDiagramTypeProvider().getDiagram().eResource().getURI().lastSegment()); - } - setPartName(name); - } - - /** - * Refreshes the tooltip displayed for the editor title tab according to - * what is returned in {@link #getTitleToolTip()}. - * - * @since 0.9 - */ - public void refreshTitleToolTip() { - setTitleToolTip(getTitleToolTip()); - } - - /** - * Triggers a complete refresh of the editor (content, title, tooltip, - * palette and decorators) by delegating to - * {@link DefaultRefreshBehavior#refresh()}. - * - * @since 0.9 - */ - public void refresh() { - this.diagramSupport.refresh(); - } - - /** - * Refreshes the content of the editor (what's shown inside the diagram - * itself). - * - * @since 0.9 - */ - public void refreshContent() { - this.diagramSupport.refreshContent(); - } - - /** - * Refreshes the rendering decorators (image decorators and the like) by - * delegating to - * {@link DefaultRefreshBehavior#refreshRenderingDecorators(PictogramElement)} - * for the given {@link PictogramElement}. - * - * @param pe - * the {@link PictogramElement} for which the decorators shall be - * refreshed. - * - * @since 0.9 - */ - public void refreshRenderingDecorators(PictogramElement pe) { - this.diagramSupport.refreshRenderingDecorators(pe); - } - - // ====================== standard behaviour ============================== - - /** - * Implements the Eclipse {@link IAdaptable} interface. This implementation - * first delegates to the {@link IToolBehaviorProvider#getAdapter(Class)} - * method and checks if something is returned. In case the return value is - * <code>null</code> it returns adapters for ZoomManager, - * IPropertySheetPage, Diagram, KeyHandler, SelectionSynchronizer and - * IContextButtonManager. It also delegates to the super implementation in - * {@link GraphicalEditorWithFlyoutPalette#getAdapter(Class)}. - * - * @param type - * the type to which shall be adapted - * @return the adapter instance - */ - public Object getAdapter(@SuppressWarnings("rawtypes") Class type) { - Object returnObj = this.diagramSupport.getAdapter(type); - if (returnObj != null) - return returnObj; - return super.getAdapter(type); - } - - /** - * Disposes this {@link DiagramEditorImpl} instance and frees all used resources - * and clears all references. Also delegates to all the behavior extensions - * to also free their resources (e.g. and most important is the - * {@link TransactionalEditingDomain} held by the - * {@link DefaultPersistencyBehavior}. Always delegate to - * <code>super.dispose()</code> in case you override this method! - */ - public void dispose() { - this.diagramSupport.preSuperDispose(); - - RuntimeException exc = null; - if (getEditDomain() != null) { - // Avoid exception in case an error during editor initialization - // happened - try { - super.dispose(); - } catch (RuntimeException e) { - exc = e; - } - } - - this.diagramSupport.postSuperDispose(); - - if (exc != null) { - throw exc; - } - } - - /** - * Sets the focus by delegating to the super class implementation in the GEF - * editor and additionally triggers a update of the diagram by delegating to - * {@link DefaultUpdateBehavior#handleActivate()}. - */ - public void setFocus() { - if (getGraphicalViewer() == null) { - return; - } - - super.setFocus(); - getUpdateBehavior().handleActivate(); - } - - // ---------------------- Selection ------------------------------------- // - - /** - * Returns the {@link PictogramElement}s that are currently selected in the - * diagram editor. - * - * @return an array of {@link PictogramElement}s. - * - * @since 0.9 - */ - public PictogramElement[] getSelectedPictogramElements() { - return this.diagramSupport.getSelectedPictogramElements(); - } - - /** - * Handles a selection changed event that is triggered by any selection - * source, e.g. a browser with "Link to Editor" enabled.<br> - * Checks if the currently active editor is a {@link MultiPageEditorPart} - * with an opened diagram editor inside, tries to find any - * {@link PictogramElement} for the objects in the selection and selects - * them in the diagram.<br> - * Note that in case of the {@link CommonNavigator} as event source, its - * editor linking mechanism must be enabled. - * - * @param part - * the source {@link IWorkbenchPart} that triggered the event - * @param selection - * the new selection (mostly a {@link IStructuredSelection} - * instance. - * - * @since 0.9 - */ - public void selectionChanged(IWorkbenchPart part, ISelection selection) { - // If not the active editor, ignore selection changed. - boolean editorIsActive = getSite().getPage().isPartVisible(this); - if (!editorIsActive) { - // Check if we are a page of the active multi page editor - IEditorPart activeEditor = getSite().getPage().getActiveEditor(); - if (activeEditor != null) { - if (activeEditor instanceof MultiPageEditorPart) { - Object selectedPage = ((MultiPageEditorPart) activeEditor).getAdapter(DiagramEditorImpl.class); - if (selectedPage instanceof DiagramEditorImpl) { - // Editor is active and diagram sub editor is its active - // page - editorIsActive = true; - } - } - } - } - if (editorIsActive) { - // long start = System.nanoTime(); - // this is where we should check the selection source (part) - // * for CNF view the link flag must be obeyed - // this would however require a dependency to - // org.eclipse.ui.navigator - if (part instanceof CommonNavigator) { - if (!((CommonNavigator) part).isLinkingEnabled()) { - return; - } - } - // useful selection ?? - if (selection instanceof IStructuredSelection) { - IStructuredSelection structuredSelection = (IStructuredSelection) selection; - List<PictogramElement> peList = new ArrayList<PictogramElement>(); - // Collect all Pictogram Elements for all selected domain - // objects into one list - for (Iterator<?> iterator = structuredSelection.iterator(); iterator.hasNext();) { - Object object = iterator.next(); - if (object instanceof EObject) { - // Find the Pictogram Elements for the given domain - // object via the standard link service - List<PictogramElement> referencingPes = Graphiti.getLinkService().getPictogramElements( - getDiagramTypeProvider().getDiagram(), (EObject) object); - if (referencingPes.size() > 0) { - peList.addAll(referencingPes); - } - } else { - // For non-EMF domain objects use the registered - // notification service for finding - PictogramElement[] relatedPictogramElements = getDiagramTypeProvider().getNotificationService() - .calculateRelatedPictogramElements(new Object[] { object }); - for (int i = 0; i < relatedPictogramElements.length; i++) { - peList.add(relatedPictogramElements[i]); - } - } - } - - // Do the selection in the diagram (in case there is something - // to select) - PictogramElement[] pes = null; - if (peList.size() > 0) { - pes = peList.toArray(new PictogramElement[peList.size()]); - } - if (pes != null && pes.length > 0) { - selectPictogramElements(pes); - } - } - /* - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=387971: When - * embedding a diagram editor inside a multi page editor the - * registered actions were not updated. The fix was simply not to - * delegate to super.selectionChange where a check for the editor - * being active only checks for the main editor (GEF editor is not - * embeddable inside another editor) but to trigger the action - * update ourself when our checks say the diagram editor is active. - */ - updateActions(getSelectionActions()); - } - - } - - /** - * Selects the given {@link PictogramElement}s in the diagram. - * - * @param pictogramElements - * an array of {@link PictogramElement}s to select. - * @since 0.9 - */ - public void selectPictogramElements(PictogramElement[] pictogramElements) { - this.diagramSupport.selectPictogramElements(pictogramElements); - } - - /** - * Returns the {@link PictogramElement}s that are set for later selection. - * <p> - * The methods {@link #getPictogramElementsForSelection()}, - * {@link #setPictogramElementForSelection(PictogramElement)}, - * {@link #setPictogramElementsForSelection(PictogramElement[])} and - * {@link #selectBufferedPictogramElements()} offer the possibility to use a - * deferred selection mechanism: via the setters, {@link PictogramElement}s - * can be stored for a selection operation that is triggered lateron during - * a general refresh via the method - * {@link #selectBufferedPictogramElements()}. This mechanism is used e.g. - * in the Graphiti framework in direct editing to restore the previous - * selection, but can also be used by clients. - * - * @return the {@link PictogramElement}s stored for later selection - * @since 0.9 - */ - protected PictogramElement[] getPictogramElementsForSelection() { - return this.diagramSupport.getPictogramElementsForSelection(); - } - - /** - * Sets one {@link PictogramElement} for later selection. - * <p> - * The methods {@link #getPictogramElementsForSelection()}, - * {@link #setPictogramElementForSelection(PictogramElement)}, - * {@link #setPictogramElementsForSelection(PictogramElement[])} and - * {@link #selectBufferedPictogramElements()} offer the possibility to use a - * deferred selection mechanism: via the setters, {@link PictogramElement}s - * can be stored for a selection operation that is triggered lateron during - * a general refresh via the method - * {@link #selectBufferedPictogramElements()}. This mechanism is used e.g. - * in the Graphiti framework in direct editing to restore the previous - * selection, but can also be used by clients. - * - * @param pictogramElement - * the {@link PictogramElement} that shall be stored for later - * selection - * @since 0.9 - */ - public void setPictogramElementForSelection(PictogramElement pictogramElement) { - this.diagramSupport.setPictogramElementForSelection(pictogramElement); - } - - /** - * Sets {@link PictogramElement}s for later selection. - * <p> - * The methods {@link #getPictogramElementsForSelection()}, - * {@link #setPictogramElementForSelection(PictogramElement)}, - * {@link #setPictogramElementsForSelection(PictogramElement[])} and - * {@link #selectBufferedPictogramElements()} offer the possibility to use a - * deferred selection mechanism: via the setters, {@link PictogramElement}s - * can be stored for a selection operation that is triggered lateron during - * a general refresh via the method - * {@link #selectBufferedPictogramElements()}. This mechanism is used e.g. - * in the Graphiti framework in direct editing to restore the previous - * selection, but can also be used by clients. - * - * @param pictogramElements - * the {@link PictogramElement}s that shall be stored for later - * selection - * @since 0.9 - */ - public void setPictogramElementsForSelection(PictogramElement pictogramElements[]) { - this.diagramSupport.setPictogramElementsForSelection(pictogramElements); - } - - /** - * Triggers the selection for the {@link PictogramElement}s that are stored - * for later selection. Can be called e.g during a general refresh of the - * editor or after another operation needing another selection is finished - * (an example in the framework is direct editing). - * <p> - * The methods {@link #getPictogramElementsForSelection()}, - * {@link #setPictogramElementForSelection(PictogramElement)}, - * {@link #setPictogramElementsForSelection(PictogramElement[])} and - * {@link #selectBufferedPictogramElements()} offer the possibility to use a - * deferred selection mechanism: via the setters, {@link PictogramElement}s - * can be stored for a selection operation that is triggered lateron during - * a general refresh via the method - * {@link #selectBufferedPictogramElements()}. This mechanism is used e.g. - * in the Graphiti framework in direct editing to restore the previous - * selection, but can also be used by clients. - * - * @since 0.9 - */ - public void selectBufferedPictogramElements() { - this.diagramSupport.selectBufferedPictogramElements(); - } - - // ---------------------- Mouse location -------------------------------- // - - /** - * Gets the current mouse location as a {@link Point}. - * - * @return the mouse location - * @since 0.9 - */ - public Point getMouseLocation() { - return this.diagramSupport.getMouseLocation(); - } - - /** - * Calculates the mouse location depending on scrollbars and zoom factor. - * - * @param nativeLocation - * the native location given as {@link Point} - * @return the {@link Point} of the real mouse location - * @since 0.9 - */ - public Point calculateRealMouseLocation(Point nativeLocation) { - return this.diagramSupport.calculateRealMouseLocation(nativeLocation); - } - - // ---------------------- Other ----------------------------------------- // - - /** - * Returns the KeyHandler with common bindings to be used for both the - * Outline and the Graphical Viewer. - * - * @return The KeyHandler with common bindings for both the Outline and the - * Graphical Viewer. - * @since 0.9 - */ - protected KeyHandler getCommonKeyHandler() { - if (keyHandler == null) { - keyHandler = new KeyHandler(); - keyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0), - getActionRegistry().getAction(ActionFactory.DELETE.getId())); - keyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, SWT.SHIFT), - getActionRegistry().getAction(RemoveAction.ACTION_ID)); - keyHandler.put(KeyStroke.getPressed(SWT.F2, 0), - getActionRegistry().getAction(GEFActionConstants.DIRECT_EDIT)); - keyHandler.put(KeyStroke.getPressed('c', SWT.CTRL), - getActionRegistry().getAction(ActionFactory.COPY.getId())); - keyHandler.put(KeyStroke.getPressed('v', SWT.CTRL), - getActionRegistry().getAction(ActionFactory.PASTE.getId())); - // _keyHandler.put(KeyStroke.getPressed((char) 1, 'a', SWT.CTRL), - // getActionRegistry().getAction(ActionFactory.SELECT_ALL.getId())); - } - return keyHandler; - } - - /** - * @since 0.10 - */ - public IConfigurationProvider getConfigurationProvider() { - return this.diagramSupport.getConfigurationProvider(); - } - - /** - * Returns the contents {@link EditPart} of this Editor. This is the topmost - * EditPart in the {@link GraphicalViewer}. - * - * @return The contents {@link EditPart} of this Editor. - * @since 0.9 - */ - public EditPart getContentEditPart() { - return this.diagramSupport.getContentEditPart(); - } - - /** - * Returns the ID for contributions in the tabbed property sheets by - * delegating to the method {@link IToolBehaviorProvider#getContributorId()} - * . - * - * @return the contributor id as a {@link String} - * @since 0.9 - */ - public String getContributorId() { - - if (contributorId == null) { - IToolBehaviorProvider tbp = getToolBehaviorProvider(); - if (tbp != null) { - contributorId = tbp.getContributorId(); - } - } - return contributorId; - } - - /** - * Returns the {@link IDiagramTypeProvider} instance associated with this - * {@link DiagramEditorImpl}. There is always a 1:1 relation between the editor - * and the provider. - * - * @return the associated {@link IDiagramTypeProvider} instance. - * - * @since 0.9 - */ - public IDiagramTypeProvider getDiagramTypeProvider() { - return this.diagramSupport.getDiagramTypeProvider(); - } - - /** - * Returns the GEF edit domain as needed for some of the feature - * functionality in Graphiti; simply a public rewrite of the GEF editor - * super method. - * - * @return the {@link DefaultEditDomain} used in this editor - * @see GraphicalEditor#getEditDomain() - * - * @since 0.9 - */ - public DefaultEditDomain getEditDomain() { - return super.getEditDomain(); - } - - /** - * Method to retrieve the GEF {@link EditPart} for a given - * {@link PictogramElement}. - * - * @param pe - * the {@link PictogramElement} to retrieve the GEF - * representation for - * @return the GEF {@link GraphicalEditPart} that represents the given - * {@link PictogramElement}. - * @since 0.9 - */ - public GraphicalEditPart getEditPartForPictogramElement(PictogramElement pe) { - return this.diagramSupport.getEditPartForPictogramElement(pe); - } - - /** - * Method to retrieve the Draw2D {@link IFigure} for a given - * {@link PictogramElement}. - * - * @param pe - * the {@link PictogramElement} to retrieve the Draw2D - * representation for - * @return the Draw2D {@link IFigure} that represents the given - * {@link PictogramElement}. - * - * @since 0.9 - */ - public IFigure getFigureForPictogramElement(PictogramElement pe) { - return this.diagramSupport.getFigureForPictogramElement(pe); - } - - /** - * Returns the GEF {@link GraphicalViewer} as it is needed in some Graphiti - * feature implementations. This is simply a public rewrite of the according - * super method. - * - * @return the {@link GraphicalViewer} used within this editor instance - * @see GraphicalEditor#getGraphicalViewer() - */ - public GraphicalViewer getGraphicalViewer() { - return super.getGraphicalViewer(); - } - - /** - * Returns the tooltip that shall be displayed when hovering over the editor - * title tab. - * - * @return the tooltip as a {@link String} - */ - public String getTitleToolTip() { - if (getDiagramTypeProvider() != null && getDiagramTypeProvider().getCurrentToolBehaviorProvider() != null) { - IToolBehaviorProvider tbp = getDiagramTypeProvider().getCurrentToolBehaviorProvider(); - String titleToolTip = tbp.getTitleToolTip(); - if (titleToolTip != null) { - return titleToolTip; - } - } - return super.getTitleToolTip(); - } - - private IToolBehaviorProvider getToolBehaviorProvider() { - IDiagramTypeProvider dtp = getDiagramTypeProvider(); - if (dtp != null) { - return dtp.getCurrentToolBehaviorProvider(); - } - return null; - } - - /** - * Returns the zoom level currently used in the editor. - * - * @return the zoom level - * @since 0.9 - */ - public double getZoomLevel() { - return this.diagramSupport.getZoomLevel(); - } - - /** - * We provide migration from 0.8.0 to 0.9.0. You can override if you want to - * migrate manually. WARNING: If your diagram is under version control, this - * method can cause a check out dialog to be opened etc. - * - * @since 0.9 - */ - protected void migrateDiagramModelIfNecessary() { - this.diagramSupport.migrateDiagramModelIfNecessary(); - } - - /** - * Checks if this editor is alive. - * - * @return <code>true</code>, if editor contains a model connector and a - * valid Diagram, <code>false</code> otherwise. - * @since 0.9 - */ - public boolean isAlive() { - return this.diagramSupport.isAlive(); - } - - /** - * Registers the given action with the Eclipse {@link ActionRegistry}. - * - * @param action - * the action to register - * @since 0.9 - */ - protected void registerAction(IAction action) { - this.diagramSupport.registerAction(action); - } - - /** - * Returns if direct editing is currently active for this editor. - * - * @return <code>true</code> in case direct editing is currently active - * within this editor, <code>false</code> otherwise. - * - * @since 0.9 - */ - public boolean isDirectEditingActive() { - return this.diagramSupport.isDirectEditingActive(); - } - - /** - * Sets that direct editing is now active in the editor or not. Note that - * this flag set to <code>true</code> does not actually start direct editing - * it is simply an indication that prevents certain operations from running - * (e.g. refresh) - * - * @param directEditingActive - * <code>true</code> to set the flag to direct editing currently - * active, <code>false</code> otherwise. - * - * @since 0.9 - */ - public void setDirectEditingActive(boolean directEditingActive) { - this.diagramSupport.setDirectEditingActive(directEditingActive); - } - - /** - * Returns the EMF {@link TransactionalEditingDomain} used within this - * editor by delegating to the update behavior extension, by default - * {@link DefaultUpdateBehavior#getEditingDomain()}. - * - * @return the {@link TransactionalEditingDomain} instance used in the - * editor - * - * @since 0.9 - */ - public TransactionalEditingDomain getEditingDomain() { - return this.diagramSupport.getEditingDomain(); - } - - /** - * Executes the given {@link IFeature} with the given {@link IContext} in - * the scope of this {@link DiagramEditorImpl}, meaning within its - * {@link TransactionalEditingDomain} and on its - * {@link org.eclipse.emf.common.command.CommandStack}. - * - * @param feature - * the feature to execute - * @param context - * the context to use. In case the passed feature is a - * {@link IAddFeature} this context needs to be an instance of - * {@link IAddContext}, otherwise an - * {@link AssertionFailedException} will be thrown. - * @return in case of an {@link IAddFeature} being passed as feature the - * newly added {@link PictogramElement} will be returned (in case - * the add method returning it), in all other cases - * <code>null</code> - * - * @since 0.9 - */ - public Object executeFeature(IFeature feature, IContext context) { - return this.diagramSupport.executeFeature(feature, context); - } - - /** - * The EMF {@link ResourceSet} used within this {@link DiagramEditorImpl}. The - * resource set is always associated in a 1:1 releation to the - * {@link TransactionalEditingDomain}. - * - * @return the resource set used within this editor - * @since 0.9 - */ - public ResourceSet getResourceSet() { - return this.diagramSupport.getResourceSet(); - } - - /** - * @since 0.10 - */ - public IDiagramEditorInput getDiagramEditorInput() { - return this.diagramSupport.getInput(); - } - - - /** - * @since 0.10 - */ - public IWorkbenchPart getWorkbenchPart() { - return this; - } - - /** - * @since 0.10 - */ - public void shutdown() { - getSite().getPage().closeEditor(this, false); - } - - /* GEF methods that need to be part of the IGEFDiagramContainer interface. */ - - /** - * @since 0.10 - */ - public void setGEFEditDomain(DefaultEditDomain editDomain) { - this.setEditDomain(editDomain); - } - - /** - * @since 0.10 - */ - public void initializeGEFGraphicalViewer() { - this.initializeGraphicalViewer(); - } - - public ActionRegistry getActionRegistry() { - return super.getActionRegistry(); - } - - @SuppressWarnings("rawtypes") - public List getSelectionActions() { - return super.getSelectionActions(); - } - - public SelectionSynchronizer getSelectionSynchronizer() { - return super.getSelectionSynchronizer(); - } - - public void commandStackChanged(EventObject event) { - super.commandStackChanged(event); - } - - public void setGraphicalViewer(GraphicalViewer viewer) { - super.setGraphicalViewer(viewer); - } - - public void hookGraphicalViewer() { - super.hookGraphicalViewer(); - } - - public boolean isLocalEditingDomain() { - return true; - } -} diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramEditorInput.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramEditorInput.java index 9cb423f4..81c39ea7 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramEditorInput.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramEditorInput.java @@ -12,6 +12,7 @@ * mwenz - Bug 346932 - Navigation history broken * Bug 336488 - DiagramEditor API * mwenz - Bug 378342 - Cannot store more than a diagram per file + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -35,14 +36,14 @@ import org.eclipse.ui.IMemento; import org.eclipse.ui.IPersistableElement; /** - * The editor input object for {@link DiagramEditor}s. Wraps the {@link URI} of + * The editor input object for {@link IDiagramEditorUI}s. Wraps the {@link URI} of * a {@link Diagram} and an ID of a diagram type provider for displaying it with * a Graphiti diagram editor.<br> * * @see {@link IEditorInput} * @see {@link IPersistableElement} * @see {@link DiagramEditorInputFactory} - * @see {@link DiagramEditor} + * @see {@link IDiagramEditorUI} */ public class DiagramEditorInput implements IEditorInput, IPersistableElement, IDiagramEditorInput { @@ -102,7 +103,7 @@ public class DiagramEditorInput implements IEditorInput, IPersistableElement, ID * @param providerId * A {@link String} which holds the diagram type id. When it is * null, it is set later in - * {@link DiagramEditor#setInput(IEditorInput)} + * {@link IDiagramEditorUI#setInput(IEditorInput)} * @throws IllegalArgumentException * if <code>uriString</code> parameter is null <br> * diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramSupport.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramSupport.java index dcf06373..f1c20920 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramSupport.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramSupport.java @@ -9,6 +9,7 @@ * * Contributors: * pjpaulin - initial API, implementation and documentation + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -144,7 +145,7 @@ import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; */ public class DiagramSupport { - private DiagramEditor container; + private IDiagramEditorUI container; private final DefaultUpdateBehavior updateBehavior; private final DefaultPaletteBehavior paletteBehaviour; @@ -167,7 +168,7 @@ public class DiagramSupport { private String editorInitializationError = null; - DiagramSupport(DiagramEditor container) { + DiagramSupport(IDiagramEditorUI container) { this.container = container; markerBehavior = createMarkerBehavior(); updateBehavior = createUpdateBehavior(); @@ -1010,7 +1011,7 @@ public class DiagramSupport { * Hook that is called to unregister the listeners for changes of the * business objects (domain objects). * - * @see DiagramEditorImpl#registerBusinessObjectsListener() + * @see DiagramEditor#registerBusinessObjectsListener() */ void unregisterBusinessObjectsListener() { if (domainModelListener != null) { @@ -1105,7 +1106,7 @@ public class DiagramSupport { } /** - * Disposes this {@link DiagramEditorImpl} instance and frees all used + * Disposes this {@link DiagramEditor} instance and frees all used * resources and clears all references. Also delegates to all the behavior * extensions to also free their resources (e.g. and most important is the * {@link TransactionalEditingDomain} held by the diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/ElementDeleteListener.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/ElementDeleteListener.java index eed9b1f2..3a1c6d38 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/ElementDeleteListener.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/ElementDeleteListener.java @@ -11,6 +11,7 @@ * SAP AG - initial API, implementation and documentation
* Bug 336488 - DiagramEditor API
* pjpaulin - Bug 352120 - Eliminated assumption that diagram is in an IEditorPart
+ * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface
*
* </copyright>
*
@@ -24,7 +25,6 @@ import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.ui.internal.T;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPartSite;
/**
@@ -36,9 +36,12 @@ import org.eclipse.ui.IWorkbenchPartSite; */
public final class ElementDeleteListener extends AdapterImpl {
- private DiagramEditor diagramEditor;
+ private IDiagramEditorUI diagramEditor;
- public ElementDeleteListener(DiagramEditor d) {
+ /**
+ * @since 0.10
+ */
+ public ElementDeleteListener(IDiagramEditorUI d) {
this.diagramEditor = d;
}
@@ -82,7 +85,6 @@ public final class ElementDeleteListener extends AdapterImpl { }
if (diagram == null || EcoreUtil.getRootContainer(diagram) == null) {
// diagram is gone so try to close
- final IWorkbenchPage page = site.getPage();
if (T.racer().debug()) {
final String editorName = diagramEditor.getTitle();
T.racer().debug("Closing editor " + editorName); //$NON-NLS-1$
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/IDiagramEditorUI.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/IDiagramEditorUI.java new file mode 100644 index 00000000..10f86307 --- /dev/null +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/IDiagramEditorUI.java @@ -0,0 +1,293 @@ +/******************************************************************************* + * <copyright> + * + * Copyright (c) 2005, 2012 SAP AG. + * 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: + * SAP AG - initial API, implementation and documentation + * mwenz - Bug 331715: Support for rectangular grids in diagrams + * mwenz - Bug 332964: Enable setting selection for non-EMF domain models and + * when embedded into a multi-page editor + * mwenz - Bug 336075 - DiagramEditor accepts URIEditorInput + * mwenz - Bug 329523 - Add notification of DiagramTypeProvider after saving a diagram + * jpasch - Bug 323025 ActionBarContributor cleanup + * mwenz - Bug 345347 - There should be a way to not allow other plugins to contribute to the diagram context menu + * mwenz - Bug 346932 - Navigation history broken + * mwenz - Bug 356828 - Escaped diagram name is used as editor title + * mwenz - Bug 356218 - Added hasDoneChanges updates to update diagram feature + * and called features via editor command stack to check it + * Felix Velasco (mwenz) - Bug 323351 - Enable to suppress/reactivate the speed buttons + * Bug 336488 - DiagramEditor API + * mwenz - Bug 367204 - Correctly return the added PE inAbstractFeatureProvider's addIfPossible method + * mwenz - Bug 324556 - Prevent invisible shapes to be selected to avoid IllegalArgumentException + * mwenz - Bug 372753 - save shouldn't (necessarily) flush the command stack + * mwenz - Bug 376008 - Iterating through navigation history causes exceptions + * Felix Velasco - mwenz - Bug 379788 - Memory leak in DefaultMarkerBehavior + * mwenz - Bug 387971 - Features cant't be invoked from contextMenu + * fvelasco - Bug 323349 - Enable external invocation of features + * mwenz - Bug 393113 - Auto-focus does not work for connections + * pjpaulin - Bug 352120 - Changed from a class to an interface - API BREAKAGE HERE + * pjpaulin - Bug 352120 - Renamed to IDiagramEditorUI so that DiagramEditor class can remain + * + * </copyright> + * + *******************************************************************************/ + +package org.eclipse.graphiti.ui.editor; + +import java.util.EventObject; +import java.util.List; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.gef.DefaultEditDomain; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gef.GraphicalViewer; +import org.eclipse.gef.ui.actions.ActionRegistry; +import org.eclipse.gef.ui.parts.GraphicalEditor; +import org.eclipse.gef.ui.parts.SelectionSynchronizer; +import org.eclipse.graphiti.mm.pictograms.PictogramElement; +import org.eclipse.graphiti.platform.IDiagramEditor; +import org.eclipse.graphiti.ui.platform.IConfigurationProvider; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IPropertyListener; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchPartConstants; +import org.eclipse.ui.IWorkbenchPartSite; + +/** + * This is the main interface for the Graphiti diagram editor. It can be + * implemented by any class that would like to display a Graphiti diagram. + * + * A DiagramEditor takes in a {@link DiagramEditorInput} that points to the + * diagram to display. This input is not technically an IEditorInput, as + * diagrams may be displayed in non-editor parts. + * + * @since 0.10 + */ +public interface IDiagramEditorUI extends IDiagramEditor { + + /** + * The ID of the context as it is registed with the org.eclipse.ui.contexts + * extension point. + * + * @since 0.10 + */ + public static final String DIAGRAM_CONTEXT_ID = "org.eclipse.graphiti.ui.diagramEditor"; //$NON-NLS-1$ + + /** + * Returns the GEF edit domain as needed for some of the feature + * functionality in Graphiti; simply a public rewrite of the GEF editor + * super method. + * + * @return the {@link DefaultEditDomain} used in this editor + * @see GraphicalEditor#getEditDomain() + * + * @since 0.9 + */ + DefaultEditDomain getEditDomain(); + + void setGEFEditDomain(DefaultEditDomain editDomain); + + /** + * Returns the GEF {@link GraphicalViewer} as it is needed in some Graphiti + * feature implementations. This is simply a public rewrite of the according + * super method. + * + * @return the {@link GraphicalViewer} used within this editor instance + * @see GraphicalEditor#getGraphicalViewer() + */ + GraphicalViewer getGraphicalViewer(); + + /** + * Updates the UI to correctly reflect the dirty state of the editor. The + * default implementation does this by firing a + * {@link IEditorPart#PROP_DIRTY} property change. + * + * @since 0.9 + */ + void updateDirtyState(); + + IConfigurationProvider getConfigurationProvider(); + + /** + * Returns the contents {@link EditPart} of this Editor. This is the topmost + * EditPart in the {@link GraphicalViewer}. + * + * @return The contents {@link EditPart} of this Editor. + * @since 0.9 + */ + EditPart getContentEditPart(); + + /** + * Method to retrieve the GEF {@link EditPart} for a given + * {@link PictogramElement}. + * + * @param pe + * the {@link PictogramElement} to retrieve the GEF + * representation for + * @return the GEF {@link GraphicalEditPart} that represents the given + * {@link PictogramElement}. + * @since 0.9 + */ + GraphicalEditPart getEditPartForPictogramElement(PictogramElement pe); + + /** + * Gets the current mouse location as a {@link Point}. + * + * @return the mouse location + * @since 0.9 + */ + Point getMouseLocation(); + + /** + * @return the {@link IWorkbenchPart} that is displaying the diagram. + */ + IWorkbenchPart getWorkbenchPart(); + + /** + * @return the site for the {@link IWorkbenchPart} that is displaying the + * diagram. + * @since 0.10 + */ + IWorkbenchPartSite getSite(); + + /** + * @return the title for the {@link IWorkbenchPart} that is displaying the + * diagram. + * @since 0.10 + */ + String getTitle(); + + /** + * Adds a listener for changes to properties of this workbench part. Has no + * effect if an identical listener is already registered. + * <p> + * The property ids are defined in {@link IWorkbenchPartConstants}. + * </p> + * + * @param listener + * a property listener + * @since 0.10 + */ + public void addPropertyListener(IPropertyListener listener); + + /** + * Removes the given property listener from this workbench part. Has no + * effect if an identical listener is not registered. + * + * @param listener + * a property listener + * @since 0.10 + */ + public void removePropertyListener(IPropertyListener listener); + + /** + * Returns the instance of the update behavior that is used with this + * editor. To change the behavior override {@link #createUpdateBehavior()}. + * + * @return the used instance of the update behavior, by default a + * {@link DefaultUpdateBehavior}. + * @since 0.9 + */ + DefaultUpdateBehavior getUpdateBehavior(); + + /** + * @return the input containing the model for the diagram + */ + IDiagramEditorInput getDiagramEditorInput(); + + /** + * Notify the container that it should shut down or clear it's state. + */ + void shutdown(); + + /** + * Calculates the mouse location depending on scrollbars and zoom factor. + * + * @param nativeLocation + * the native location given as {@link Point} + * @return the {@link Point} of the real mouse location + * @since 0.9 + */ + Point calculateRealMouseLocation(Point nativeLocation); + + /** + * Returns the instance of the refresh behavior that is used with this + * editor. To change the behavior override {@link #createRefreshBehavior()}. + * + * @return the used instance of the refresh behavior, by default a + * {@link DefaultRefreshBehavior}. + * @since 0.9 + */ + DefaultRefreshBehavior getRefreshBehavior(); + + /** + * Returns if direct editing is currently active for this editor. + * + * @return <code>true</code> in case direct editing is currently active + * within this editor, <code>false</code> otherwise. + * + * @since 0.9 + */ + boolean isDirectEditingActive(); + + /** + * Sets that direct editing is now active in the editor or not. Note that + * this flag set to <code>true</code> does not actually start direct editing + * it is simply an indication that prevents certain operations from running + * (e.g. refresh) + * + * @param directEditingActive + * <code>true</code> to set the flag to direct editing currently + * active, <code>false</code> otherwise. + * + * @since 0.9 + */ + void setDirectEditingActive(boolean directEditingActive); + + /** + * Returns the zoom level currently used in the editor. + * + * @return the zoom level + * @since 0.9 + */ + double getZoomLevel(); + + /** + * Method to retrieve the Draw2D {@link IFigure} for a given + * {@link PictogramElement}. + * + * @param pe + * the {@link PictogramElement} to retrieve the Draw2D + * representation for + * @return the Draw2D {@link IFigure} that represents the given + * {@link PictogramElement}. + * + * @since 0.9 + */ + IFigure getFigureForPictogramElement(PictogramElement pe); + + /** + * Public accessor that should redirect to protected method. + */ + void initializeGEFGraphicalViewer(); + + ActionRegistry getActionRegistry(); + + @SuppressWarnings("rawtypes") + List getSelectionActions(); + + SelectionSynchronizer getSelectionSynchronizer(); + + void commandStackChanged(EventObject event); + + void setGraphicalViewer(GraphicalViewer viewer); + + void hookGraphicalViewer(); +} diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/features/AbstractDrillDownFeature.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/features/AbstractDrillDownFeature.java index 2165372a..8086e33c 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/features/AbstractDrillDownFeature.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/features/AbstractDrillDownFeature.java @@ -15,6 +15,7 @@ * Bug 336488 - DiagramEditor API * cbrand - Bug 377475 - Fix AbstractCustomFeature.execute and canExecute * fvelasco - Bug 396247 - ImageDescriptor changes + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -34,6 +35,7 @@ import org.eclipse.graphiti.mm.pictograms.Diagram; import org.eclipse.graphiti.mm.pictograms.PictogramElement; import org.eclipse.graphiti.platform.IPlatformImageConstants; import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.internal.services.GraphitiUiInternal; import org.eclipse.graphiti.ui.services.GraphitiUi; import org.eclipse.jface.viewers.IStructuredContentProvider; @@ -127,7 +129,7 @@ public abstract class AbstractDrillDownFeature extends AbstractCustomFeature { * Returns the editor id of the diagram editor to open by default * {@link DiagramEditor#DIAGRAM_EDITOR_ID}. Users can override and return a * different editor id, must be the id of a subclass of - * {@link DiagramEditor}. + * {@link IDiagramEditorUI}. * * @param diagram * the diagram for which the editor will be opened diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/features/AbstractPasteFeature.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/features/AbstractPasteFeature.java index 14902d39..dfff6592 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/features/AbstractPasteFeature.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/features/AbstractPasteFeature.java @@ -10,6 +10,7 @@ * Contributors: * SAP AG - initial API, implementation and documentation * mwenz - Bug 375533 - Problems with copy&paste in the tutorial + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -29,7 +30,7 @@ import org.eclipse.graphiti.features.context.IContext; import org.eclipse.graphiti.features.context.IPasteContext; import org.eclipse.graphiti.features.impl.AbstractFeature; import org.eclipse.graphiti.internal.Messages; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.internal.util.clipboard.ModelClipboard; /** @@ -114,7 +115,7 @@ public abstract class AbstractPasteFeature extends AbstractFeature implements IP /** * Checks if the given {@link EObject} can be resolved in the local - * {@link EditingDomain} of the current {@link DiagramEditor}. Pasting an + * {@link EditingDomain} of the current {@link IDiagramEditorUI}. Pasting an * EObject that is not resolvable (e.g. it was just created in another * editor and has not yet been persisted) may cause issues with the * graphical presentation of the new object: the Graphiti update will not diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/action/CustomAction.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/action/CustomAction.java index 229e1d5f..20ef4929 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/action/CustomAction.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/action/CustomAction.java @@ -10,6 +10,7 @@ * Contributors: * SAP AG - initial API, implementation and documentation * Bug 336488 - DiagramEditor API + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -22,7 +23,7 @@ import org.eclipse.graphiti.features.custom.ICustomFeature; import org.eclipse.graphiti.internal.command.CommandContainer; import org.eclipse.graphiti.internal.command.GenericFeatureCommandWithContext; import org.eclipse.graphiti.internal.command.ICommand; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.internal.command.GefCommandWrapper; import org.eclipse.jface.action.Action; @@ -36,9 +37,9 @@ public class CustomAction extends Action { private ICustomContext context; - private DiagramEditor diagramEditor; + private IDiagramEditorUI diagramEditor; - public CustomAction(ICustomFeature customFeature, ICustomContext context, DiagramEditor diagramEditor) { + public CustomAction(ICustomFeature customFeature, ICustomContext context, IDiagramEditorUI diagramEditor) { super(); this.customFeature = customFeature; this.context = context; diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/action/PasteAction.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/action/PasteAction.java index 689a5750..ce41068f 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/action/PasteAction.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/action/PasteAction.java @@ -11,6 +11,7 @@ * SAP AG - initial API, implementation and documentation * mwenz - Bug 339525 - Enrich paste context with location information * mwenz - Bug 374701 - IPasteContext showing invalid location under certain circumstances + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -25,7 +26,7 @@ import org.eclipse.graphiti.features.context.impl.PasteContext; import org.eclipse.graphiti.internal.command.FeatureCommandWithContext; import org.eclipse.graphiti.internal.command.GenericFeatureCommandWithContext; import org.eclipse.graphiti.mm.pictograms.PictogramElement; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.internal.Messages; import org.eclipse.graphiti.ui.platform.IConfigurationProvider; import org.eclipse.ui.IWorkbenchPart; @@ -93,8 +94,8 @@ public class PasteAction extends AbstractPreDefinedAction { PasteContext context = new PasteContext(pes); Point pasteLocation = new Point(-1, -1); IWorkbenchPart workbenchPart = getWorkbenchPart(); - if (workbenchPart instanceof DiagramEditor) { - DiagramEditor diagramEditor = (DiagramEditor) workbenchPart; + if (workbenchPart instanceof IDiagramEditorUI) { + IDiagramEditorUI diagramEditor = (IDiagramEditorUI) workbenchPart; pasteLocation = diagramEditor.calculateRealMouseLocation(diagramEditor.getMouseLocation()); } context.setLocation(pasteLocation.x, pasteLocation.y); diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/action/SaveImageAction.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/action/SaveImageAction.java index f6c72c98..025af938 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/action/SaveImageAction.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/action/SaveImageAction.java @@ -11,6 +11,7 @@ * SAP AG - initial API, implementation and documentation * jpasch - Bug 323025 ActionBarContributor cleanup * Bug 336488 - DiagramEditor API + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -20,7 +21,7 @@ package org.eclipse.graphiti.ui.internal.action; import org.eclipse.gef.GraphicalViewer; import org.eclipse.graphiti.features.ISaveImageFeature; import org.eclipse.graphiti.features.context.ISaveImageContext; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.internal.Messages; import org.eclipse.graphiti.ui.internal.services.GraphitiUiInternal; import org.eclipse.jface.action.Action; @@ -35,7 +36,7 @@ public class SaveImageAction extends Action { private ISaveImageContext context; - private DiagramEditor graphicsEditor; + private IDiagramEditorUI graphicsEditor; public static final String TOOL_TIP = Messages.SaveImageAction_1_xmsg; @@ -45,7 +46,7 @@ public class SaveImageAction extends Action { public static final String ACTION_DEFINITION_ID = "org.eclipse.graphiti.ui.internal.action.SaveImageAction"; //$NON-NLS-1$ - public SaveImageAction(ISaveImageFeature saveImageFeature, ISaveImageContext context, DiagramEditor graphicsEditor) { + public SaveImageAction(ISaveImageFeature saveImageFeature, ISaveImageContext context, IDiagramEditorUI graphicsEditor) { super(); this.saveImageFeature = saveImageFeature; this.context = context; diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/action/ToggleContextButtonPadAction.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/action/ToggleContextButtonPadAction.java index a816d00e..36338441 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/action/ToggleContextButtonPadAction.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/action/ToggleContextButtonPadAction.java @@ -10,13 +10,14 @@ * Contributors: * Felix Velasco (mwenz) - Bug 323351 - Enable to suppress/reactivate the speed buttons * Bug 336488 - DiagramEditor API + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * *******************************************************************************/ package org.eclipse.graphiti.ui.internal.action; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.internal.Messages; import org.eclipse.graphiti.ui.internal.contextbuttons.IContextButtonManager; import org.eclipse.jface.action.Action; @@ -27,7 +28,7 @@ import org.eclipse.jface.action.Action; */ public class ToggleContextButtonPadAction extends Action { - private DiagramEditor graphicsEditor; + private IDiagramEditorUI graphicsEditor; public static final String TOOL_TIP = Messages.ToggleContextButtonPadAction_0_xmsg; @@ -35,7 +36,7 @@ public class ToggleContextButtonPadAction extends Action { public static final String ACTION_ID = "toggle_context_button_pad"; //$NON-NLS-1$ - public ToggleContextButtonPadAction(DiagramEditor graphicsEditor) { + public ToggleContextButtonPadAction(IDiagramEditorUI graphicsEditor) { super(); this.graphicsEditor = graphicsEditor; setText(TEXT); diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/command/CreateConnectionCommand.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/command/CreateConnectionCommand.java index 16753ab4..f2c718a6 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/command/CreateConnectionCommand.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/command/CreateConnectionCommand.java @@ -16,6 +16,7 @@ * mgorning - Bug 329517 - state call backs during creation of a connection * Bug 336488 - DiagramEditor API * fvelasco - Bug 396247 - ImageDescriptor changes + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -45,7 +46,7 @@ import org.eclipse.graphiti.mm.pictograms.AnchorContainer; import org.eclipse.graphiti.mm.pictograms.Connection; import org.eclipse.graphiti.mm.pictograms.PictogramElement; import org.eclipse.graphiti.services.Graphiti; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.internal.Messages; import org.eclipse.graphiti.ui.internal.util.ui.PopupMenu; import org.eclipse.graphiti.ui.platform.IConfigurationProvider; @@ -162,7 +163,7 @@ public class CreateConnectionCommand extends AbstractCommand { CustomContext customContext = new CustomContext(); customContext.setPictogramElements(new PictogramElement[] { sourceObject, targetObject }); - DiagramEditor diagramEditor = (DiagramEditor) getFeatureProvider().getDiagramTypeProvider().getDiagramEditor(); + IDiagramEditorUI diagramEditor = (IDiagramEditorUI) getFeatureProvider().getDiagramTypeProvider().getDiagramEditor(); Point newLocation = diagramEditor.calculateRealMouseLocation(location); customContext.setLocation(newLocation.x, newLocation.y); @@ -371,7 +372,7 @@ public class CreateConnectionCommand extends AbstractCommand { if (location == null) { return null; } - DiagramEditor diagramEditor = (DiagramEditor) getFeatureProvider().getDiagramTypeProvider() + IDiagramEditorUI diagramEditor = (IDiagramEditorUI) getFeatureProvider().getDiagramTypeProvider() .getDiagramEditor(); Point realLocation = diagramEditor.calculateRealMouseLocation(location); ILocation currentLocation = new LocationImpl(realLocation.x, realLocation.y); diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/command/ReconnectCommand.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/command/ReconnectCommand.java index a4b3acc3..be9adcfc 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/command/ReconnectCommand.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/command/ReconnectCommand.java @@ -12,6 +12,7 @@ * mwenz - Bug 340627 - Features should be able to indicate cancellation * mgorning - Bug 343983 - Notification for Cancelled Reconnection Events * Bug 336488 - DiagramEditor API + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -32,7 +33,7 @@ import org.eclipse.graphiti.internal.datatypes.impl.LocationImpl; import org.eclipse.graphiti.mm.pictograms.Anchor; import org.eclipse.graphiti.mm.pictograms.Connection; import org.eclipse.graphiti.mm.pictograms.PictogramElement; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.platform.IConfigurationProvider; /** @@ -62,7 +63,7 @@ public class ReconnectCommand extends AbstractCommand implements IFeatureAndCont ILocation targetLocation = null; if (location != null) { - DiagramEditor diagramEditor = (DiagramEditor) getFeatureProvider().getDiagramTypeProvider().getDiagramEditor(); + IDiagramEditorUI diagramEditor = (IDiagramEditorUI) getFeatureProvider().getDiagramTypeProvider().getDiagramEditor(); Point realLocation = diagramEditor.calculateRealMouseLocation(location); targetLocation = new LocationImpl(realLocation.x, realLocation.y); } diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/config/ConfigurationProvider.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/config/ConfigurationProvider.java index ca6dcb10..df61fad4 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/config/ConfigurationProvider.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/config/ConfigurationProvider.java @@ -10,6 +10,7 @@ * Contributors: * SAP AG - initial API, implementation and documentation * Bug 336488 - DiagramEditor API + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -19,7 +20,7 @@ package org.eclipse.graphiti.ui.internal.config; import org.eclipse.graphiti.dt.IDiagramTypeProvider; import org.eclipse.graphiti.features.IFeatureProvider; import org.eclipse.graphiti.mm.pictograms.Diagram; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.internal.IResourceRegistry; import org.eclipse.graphiti.ui.internal.ResourceRegistry; import org.eclipse.graphiti.ui.internal.contextbuttons.IContextButtonManager; @@ -43,7 +44,7 @@ public class ConfigurationProvider implements IConfigurationProviderInternal { private IWorkbenchPart _workbenchPart; - private DiagramEditor diagramEditor; + private IDiagramEditorUI diagramEditor; private IDiagramTypeProvider diagramTypeProvider; @@ -60,7 +61,7 @@ public class ConfigurationProvider implements IConfigurationProviderInternal { * @param diagramTypeProvider * the diagram type provider */ - public ConfigurationProvider(DiagramEditor diagramEditor, IDiagramTypeProvider diagramTypeProvider) { + public ConfigurationProvider(IDiagramEditorUI diagramEditor, IDiagramTypeProvider diagramTypeProvider) { this.diagramEditor = diagramEditor; setDiagramTypeProvider(diagramTypeProvider); } @@ -157,7 +158,7 @@ public class ConfigurationProvider implements IConfigurationProviderInternal { * @see org.eclipse.graphiti.ui.internal.config.IConfigurationProviderInternal# * getDiagramEditor() */ - public DiagramEditor getDiagramEditor() { + public IDiagramEditorUI getDiagramEditor() { return diagramEditor; } diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/contextbuttons/ContextButton.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/contextbuttons/ContextButton.java index ddb86a88..8f884cbc 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/contextbuttons/ContextButton.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/contextbuttons/ContextButton.java @@ -13,6 +13,7 @@ * mwenz - Bug 373298 - Possible Resource leaks in Graphiti * mwenz - Bug 389379 - Editor Dirty Handling (gets broken after context button execution) * fvelasco - Bug 396247 - ImageDescriptor changes + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -37,7 +38,7 @@ import org.eclipse.graphiti.features.IFeature; import org.eclipse.graphiti.internal.contextbuttons.PositionedContextButton; import org.eclipse.graphiti.tb.ContextButtonEntry; import org.eclipse.graphiti.tb.IContextButtonEntry; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.internal.editor.GFDragConnectionTool; import org.eclipse.graphiti.ui.internal.figures.GFFigureUtil; import org.eclipse.graphiti.ui.internal.util.DataTypeTransformation; @@ -234,13 +235,13 @@ public class ContextButton extends Clickable implements MouseMotionListener, Act } /** - * Returns the {@link DiagramEditor} for which the context button is + * Returns the {@link IDiagramEditorUI} for which the context button is * displayed. * - * @return The {@link DiagramEditor} for which the context button is + * @return The {@link IDiagramEditorUI} for which the context button is * displayed. */ - public final DiagramEditor getEditor() { + public final IDiagramEditorUI getEditor() { return getContextButtonPad().getEditor(); } diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/contextbuttons/ContextButtonManagerForPad.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/contextbuttons/ContextButtonManagerForPad.java index 3741a744..4f629a49 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/contextbuttons/ContextButtonManagerForPad.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/contextbuttons/ContextButtonManagerForPad.java @@ -13,6 +13,7 @@ * Bug 336488 - DiagramEditor API * mgorning - Bug 369370 - visibility of context button pad for graphical entities * mwenz - Bug 392309 - Scrollbars appear when a tooltip is being displayed on a decorator + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -45,7 +46,7 @@ import org.eclipse.graphiti.mm.pictograms.Diagram; import org.eclipse.graphiti.mm.pictograms.PictogramElement; import org.eclipse.graphiti.tb.IContextButtonPadData; import org.eclipse.graphiti.tb.IToolBehaviorProvider; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.internal.IResourceRegistry; import org.eclipse.graphiti.ui.internal.parts.IPictogramElementEditPart; import org.eclipse.swt.SWT; @@ -69,7 +70,7 @@ public class ContextButtonManagerForPad implements IContextButtonManager { * The editor on which this context button manager works, see * {@link #getEditor()}. It is set in the constructor. */ - private DiagramEditor editor; + private IDiagramEditorUI editor; /** * A backward-map from the edit-part figures to their edit-parts as @@ -121,7 +122,7 @@ public class ContextButtonManagerForPad implements IContextButtonManager { } private void reactOnMouse(MouseEvent me) { - DiagramEditor ed = getEditor(); + IDiagramEditorUI ed = getEditor(); if (ed.isDirectEditingActive()) { return; @@ -159,7 +160,7 @@ public class ContextButtonManagerForPad implements IContextButtonManager { * {@link #getEditor()}. * @param iResourceRegistry */ - public ContextButtonManagerForPad(DiagramEditor editor, IResourceRegistry resourceRegistry) { + public ContextButtonManagerForPad(IDiagramEditorUI editor, IResourceRegistry resourceRegistry) { this.editor = editor; this.resourceRegistry = resourceRegistry; @@ -179,7 +180,7 @@ public class ContextButtonManagerForPad implements IContextButtonManager { * * @return The editor this context button manager works on. */ - public DiagramEditor getEditor() { + public IDiagramEditorUI getEditor() { return editor; } diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/contextbuttons/ContextButtonPad.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/contextbuttons/ContextButtonPad.java index b3aec977..524555df 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/contextbuttons/ContextButtonPad.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/contextbuttons/ContextButtonPad.java @@ -13,6 +13,7 @@ * mwenz - Bug 373298 - Possible Resource leaks in Graphiti * fvelasco - Bug 396247 - ImageDescriptor changes * mwenz - Bug 397303 - Accessibility issue with Graphiti diagram in High Contrast Mode + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -31,7 +32,7 @@ import org.eclipse.gef.EditPart; import org.eclipse.graphiti.internal.contextbuttons.IContextButtonPadDeclaration; import org.eclipse.graphiti.internal.contextbuttons.IContextButtonPadDeclaration.PadStyle; import org.eclipse.graphiti.internal.contextbuttons.PositionedContextButton; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.internal.IResourceRegistry; import org.eclipse.graphiti.ui.internal.figures.GFFigureUtil; import org.eclipse.graphiti.ui.internal.util.DataTypeTransformation; @@ -87,7 +88,7 @@ public class ContextButtonPad extends Shape implements ITransparencyProvider { /** * The editor as described in {@link #getEditor()}. */ - private DiagramEditor editor; + private IDiagramEditorUI editor; /** * The edit-part as described in {@link #getEditPart()}. @@ -173,7 +174,7 @@ public class ContextButtonPad extends Shape implements ITransparencyProvider { * @param resourceRegistry */ public ContextButtonPad(ContextButtonManagerForPad contextButtonManagerForPad, - IContextButtonPadDeclaration declaration, double zoomLevel, DiagramEditor editor, EditPart editPart, + IContextButtonPadDeclaration declaration, double zoomLevel, IDiagramEditorUI editor, EditPart editPart, IResourceRegistry resourceRegistry) { this.declaration = declaration; this.zoomLevel = zoomLevel; @@ -220,7 +221,7 @@ public class ContextButtonPad extends Shape implements ITransparencyProvider { * * @return The editor, which can be used to access the environment. */ - public final DiagramEditor getEditor() { + public final IDiagramEditorUI getEditor() { return editor; } diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/dnd/GFTemplateTransferDropTargetListener.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/dnd/GFTemplateTransferDropTargetListener.java index 6f471adb..6cc38b63 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/dnd/GFTemplateTransferDropTargetListener.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/dnd/GFTemplateTransferDropTargetListener.java @@ -10,6 +10,7 @@ * Contributors: * SAP AG - initial API, implementation and documentation * Bug 336488 - DiagramEditor API + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -20,7 +21,7 @@ import org.eclipse.gef.EditPart; import org.eclipse.gef.EditPartViewer; import org.eclipse.gef.commands.Command; import org.eclipse.gef.dnd.TemplateTransferDropTargetListener; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.swt.dnd.DND; /** @@ -34,9 +35,9 @@ import org.eclipse.swt.dnd.DND; */ public class GFTemplateTransferDropTargetListener extends TemplateTransferDropTargetListener { - private DiagramEditor editor; + private IDiagramEditorUI editor; - public GFTemplateTransferDropTargetListener(EditPartViewer viewer, DiagramEditor editor) { + public GFTemplateTransferDropTargetListener(EditPartViewer viewer, IDiagramEditorUI editor) { super(viewer); // it is important to set this value to true setEnablementDeterminedByCommand(true); diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/DiagramChangeListener.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/DiagramChangeListener.java index 905f4027..0092f819 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/DiagramChangeListener.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/DiagramChangeListener.java @@ -13,6 +13,7 @@ * (for Bug 330035 - Notational metamodel extension) * Bug 336488 - DiagramEditor API * Benjamin Schmeling - mwenz - Bug 367483 - Support composite connections + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -52,7 +53,7 @@ import org.eclipse.graphiti.mm.pictograms.Diagram; import org.eclipse.graphiti.mm.pictograms.PictogramElement; import org.eclipse.graphiti.mm.pictograms.PictogramsPackage; import org.eclipse.graphiti.services.Graphiti; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.internal.Messages; import org.eclipse.graphiti.ui.internal.T; import org.eclipse.graphiti.ui.internal.parts.ConnectionEditPart; @@ -68,9 +69,9 @@ import org.eclipse.swt.widgets.Display; public class DiagramChangeListener implements ResourceSetListener { private DiagramRefreshJob diagramRefreshJob; - private DiagramEditor ed; + private IDiagramEditorUI ed; - public DiagramChangeListener(DiagramEditor ed) { + public DiagramChangeListener(IDiagramEditorUI ed) { this.ed = ed; } diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/DiagramRefreshJob.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/DiagramRefreshJob.java index 286081ed..ce090674 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/DiagramRefreshJob.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/DiagramRefreshJob.java @@ -10,6 +10,7 @@ * Contributors: * SAP AG - initial API, implementation and documentation * Bug 336488 - DiagramEditor API + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -28,7 +29,7 @@ import org.eclipse.gef.EditPart; import org.eclipse.graphiti.features.IDirectEditingInfo; import org.eclipse.graphiti.internal.pref.GFPreferences; import org.eclipse.graphiti.internal.util.T; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.internal.parts.ConnectionDecoratorEditPart; import org.eclipse.graphiti.ui.internal.parts.DiagramEditPart; import org.eclipse.graphiti.ui.internal.parts.ShapeEditPart; @@ -52,9 +53,9 @@ class DiagramRefreshJob extends UIJob { private boolean refreshAll = false; - private DiagramEditor ed; + private IDiagramEditorUI ed; - DiagramRefreshJob(String name, DiagramEditor ed) { + DiagramRefreshJob(String name, IDiagramEditorUI ed) { super(name); this.ed = ed; } diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/DomainModelWorkspaceSynchronizerDelegate.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/DomainModelWorkspaceSynchronizerDelegate.java index 0def2c83..02469d2d 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/DomainModelWorkspaceSynchronizerDelegate.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/DomainModelWorkspaceSynchronizerDelegate.java @@ -11,6 +11,7 @@ * SAP AG - initial API, implementation and documentation * Bug 336488 - DiagramEditor API * pjpaulin - Bug 352120 - Eliminated assumption that diagram is in an IEditorPart + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -21,7 +22,7 @@ import org.eclipse.core.resources.IFile; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.editor.IDiagramEditorInput; /** @@ -30,13 +31,13 @@ import org.eclipse.graphiti.ui.editor.IDiagramEditorInput; */ public class DomainModelWorkspaceSynchronizerDelegate implements WorkspaceSynchronizer.Delegate { - private DiagramEditor diagramEditor; + private IDiagramEditorUI diagramEditor; /** * The DiagramEditorBehavior reacts on a setResourceChanged(true) if he gets * activated. */ - public DomainModelWorkspaceSynchronizerDelegate(DiagramEditor diagramEditor) { + public DomainModelWorkspaceSynchronizerDelegate(IDiagramEditorUI diagramEditor) { this.diagramEditor = diagramEditor; } diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/GFDragConnectionTool.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/GFDragConnectionTool.java index 0f0b5e91..b9a51e25 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/GFDragConnectionTool.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/GFDragConnectionTool.java @@ -10,6 +10,7 @@ * Contributors: * SAP AG - initial API, implementation and documentation * Bug 336488 - DiagramEditor API + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -23,7 +24,7 @@ import org.eclipse.gef.commands.Command; import org.eclipse.gef.requests.CreateConnectionRequest; import org.eclipse.gef.tools.ConnectionDragCreationTool; import org.eclipse.graphiti.tb.ContextButtonEntry; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.internal.command.CreateConnectionCommand; import org.eclipse.graphiti.ui.internal.requests.ContextButtonDragRequest; @@ -80,7 +81,7 @@ public class GFDragConnectionTool extends ConnectionDragCreationTool { return request; } - private DiagramEditor diagramEditor; + private IDiagramEditorUI diagramEditor; private ContextButtonEntry contextButtonEntry; @@ -94,7 +95,7 @@ public class GFDragConnectionTool extends ConnectionDragCreationTool { * @param contextButtonEntry * the context button entry */ - public void startConnection(EditPart targetEditPart, DiagramEditor diagramEditor, ContextButtonEntry contextButtonEntry) { + public void startConnection(EditPart targetEditPart, IDiagramEditorUI diagramEditor, ContextButtonEntry contextButtonEntry) { this.diagramEditor = diagramEditor; this.contextButtonEntry = contextButtonEntry; @@ -126,7 +127,7 @@ public class GFDragConnectionTool extends ConnectionDragCreationTool { * @param targetTargetEditPart * the target target edit part */ - public void continueConnection(EditPart targetEditPart, DiagramEditor diagramEditor, ContextButtonEntry contextButtonEntry, + public void continueConnection(EditPart targetEditPart, IDiagramEditorUI diagramEditor, ContextButtonEntry contextButtonEntry, EditPart targetTargetEditPart) { this.diagramEditor = diagramEditor; diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/GFFigureCanvas.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/GFFigureCanvas.java index 985e0da5..d1ecf836 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/GFFigureCanvas.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/GFFigureCanvas.java @@ -11,6 +11,7 @@ * SAP AG - initial API, implementation and documentation * mwenz - Bug 352440 - Fixed deprecation warnings - contributed by Felix Velasco * Bug 336488 - DiagramEditor API + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -34,7 +35,7 @@ import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.gef.EditPart; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.internal.parts.DiagramEditPart; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; @@ -90,7 +91,7 @@ public class GFFigureCanvas extends Canvas implements IAdaptable { private final GFUpdateListener gfUpdateListener = new GFUpdateListener(); - private DiagramEditor diagramEditor = null; + private IDiagramEditorUI diagramEditor = null; private boolean init = true; @@ -176,7 +177,7 @@ public class GFFigureCanvas extends Canvas implements IAdaptable { * @param diagramEditor * the diagram editor */ - public GFFigureCanvas(Composite parent, DiagramEditor diagramEditor) { + public GFFigureCanvas(Composite parent, IDiagramEditorUI diagramEditor) { this(parent, SWT.DOUBLE_BUFFERED, new LightweightSystem(), diagramEditor); } @@ -191,7 +192,7 @@ public class GFFigureCanvas extends Canvas implements IAdaptable { * the diagram editor * @since 3.1 */ - public GFFigureCanvas(Composite parent, int style, DiagramEditor diagramEditor) { + public GFFigureCanvas(Composite parent, int style, IDiagramEditorUI diagramEditor) { this(parent, style, new LightweightSystem(), diagramEditor); } @@ -206,7 +207,7 @@ public class GFFigureCanvas extends Canvas implements IAdaptable { * @param diagramEditor * the diagram editor */ - public GFFigureCanvas(Composite parent, LightweightSystem lws, DiagramEditor diagramEditor) { + public GFFigureCanvas(Composite parent, LightweightSystem lws, IDiagramEditorUI diagramEditor) { this(parent, SWT.DOUBLE_BUFFERED, lws, diagramEditor); } @@ -223,7 +224,7 @@ public class GFFigureCanvas extends Canvas implements IAdaptable { * the diagram editor * @since 3.1 */ - public GFFigureCanvas(Composite parent, int style, LightweightSystem lws, DiagramEditor diagramEditor) { + public GFFigureCanvas(Composite parent, int style, LightweightSystem lws, IDiagramEditorUI diagramEditor) { super(parent, checkStyle(style | SWT.NO_REDRAW_RESIZE | SWT.NO_BACKGROUND | SWT.V_SCROLL | SWT.H_SCROLL)); getHorizontalBar().setVisible(false); getVerticalBar().setVisible(false); diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/GFScrollingGraphicalViewer.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/GFScrollingGraphicalViewer.java index b40af073..81727628 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/GFScrollingGraphicalViewer.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/GFScrollingGraphicalViewer.java @@ -10,6 +10,7 @@ * Contributors: * SAP AG - initial API, implementation and documentation * Bug 336488 - DiagramEditor API + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -25,7 +26,7 @@ import org.eclipse.gef.AccessibleEditPart; import org.eclipse.gef.EditPart; import org.eclipse.gef.ExposeHelper; import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.internal.fixed.FixedScalableRootEditPart; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; @@ -52,7 +53,7 @@ public class GFScrollingGraphicalViewer extends GraphitiScrollingGraphicalViewer * @param diagramEditor * the diagram editor */ - public GFScrollingGraphicalViewer(DiagramEditor diagramEditor) { + public GFScrollingGraphicalViewer(IDiagramEditorUI diagramEditor) { super(diagramEditor); } diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/GraphitiScrollingGraphicalViewer.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/GraphitiScrollingGraphicalViewer.java index 6ff9a6fc..89237fba 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/GraphitiScrollingGraphicalViewer.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/GraphitiScrollingGraphicalViewer.java @@ -10,6 +10,7 @@ * Contributors: * SAP AG - initial API, implementation and documentation * Bug 336488 - DiagramEditor API + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -23,16 +24,16 @@ import org.eclipse.gef.EditPart; import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; import org.eclipse.graphiti.mm.pictograms.Connection; import org.eclipse.graphiti.tb.IToolBehaviorProvider; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.StructuredSelection; public class GraphitiScrollingGraphicalViewer extends ScrollingGraphicalViewer { - private DiagramEditor diagramEditor; + private IDiagramEditorUI diagramEditor; - public GraphitiScrollingGraphicalViewer(DiagramEditor diagramEditor) { + public GraphitiScrollingGraphicalViewer(IDiagramEditorUI diagramEditor) { this.setDiagramEditor(diagramEditor); } @@ -170,11 +171,11 @@ public class GraphitiScrollingGraphicalViewer extends ScrollingGraphicalViewer { } } - private void setDiagramEditor(DiagramEditor diagramEditor) { + private void setDiagramEditor(IDiagramEditorUI diagramEditor) { this.diagramEditor = diagramEditor; } - protected DiagramEditor getDiagramEditor() { + protected IDiagramEditorUI getDiagramEditor() { return diagramEditor; } } diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/feature/DebugFeature.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/feature/DebugFeature.java index 33c2204c..a2445049 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/feature/DebugFeature.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/feature/DebugFeature.java @@ -11,6 +11,7 @@ * SAP AG - initial API, implementation and documentation * Bug 336488 - DiagramEditor API * cbrand - Bug 377783 - Dump for figures in connection layer needed + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -24,7 +25,7 @@ import org.eclipse.graphiti.features.context.ICustomContext; import org.eclipse.graphiti.features.custom.AbstractCustomFeature; import org.eclipse.graphiti.mm.pictograms.Diagram; import org.eclipse.graphiti.mm.pictograms.PictogramElement; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.internal.services.GraphitiUiInternal; /** @@ -58,7 +59,7 @@ public class DebugFeature extends AbstractCustomFeature { PictogramElement[] pes = context.getPictogramElements(); if (pes != null && pes.length > 0 && pes[0] != null) { PictogramElement pe = pes[0]; - DiagramEditor diagramEditor = (DiagramEditor) getDiagramEditor(); + IDiagramEditorUI diagramEditor = (IDiagramEditorUI) getDiagramEditor(); GraphicalEditPart ep = diagramEditor.getEditPartForPictogramElement(pe); IFigure figure = diagramEditor.getFigureForPictogramElement(pe); diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/parts/ConnectionEditPart.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/parts/ConnectionEditPart.java index b0572cfb..08104e90 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/parts/ConnectionEditPart.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/parts/ConnectionEditPart.java @@ -13,6 +13,7 @@ * Bug 336488 - DiagramEditor API * mwenz - Bug 341898 - Support for AdvancedPropertySheet * Benjamin Schmeling - mwenz - Bug 367483 - Support composite connections + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -39,7 +40,7 @@ import org.eclipse.graphiti.internal.features.context.impl.base.DoubleClickConte import org.eclipse.graphiti.mm.pictograms.Connection; import org.eclipse.graphiti.mm.pictograms.PictogramElement; import org.eclipse.graphiti.tb.IToolBehaviorProvider; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.internal.command.GefCommandWrapper; import org.eclipse.graphiti.ui.internal.config.IConfigurationProviderInternal; import org.eclipse.graphiti.ui.platform.GraphitiConnectionEditPart; @@ -265,7 +266,7 @@ public abstract class ConnectionEditPart extends GraphitiConnectionEditPart impl if (doubleClickFeature != null && doubleClickFeature.canExecute(dcc)) { GenericFeatureCommandWithContext commandWithContext = new GenericFeatureCommandWithContext(doubleClickFeature, dcc); - DiagramEditor diagramEditor = getConfigurationProvider().getDiagramEditor(); + IDiagramEditorUI diagramEditor = getConfigurationProvider().getDiagramEditor(); CommandStack commandStack = diagramEditor.getEditDomain().getCommandStack(); commandStack.execute(new GefCommandWrapper(commandWithContext, diagramEditor.getEditingDomain())); } diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/parts/DiagramEditPart.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/parts/DiagramEditPart.java index f4600cf8..1d216ced 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/parts/DiagramEditPart.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/parts/DiagramEditPart.java @@ -11,6 +11,7 @@ * SAP AG - initial API, implementation and documentation * Bug 336488 - DiagramEditor API * pjpaulin - Bug 352120 - Eliminated assumption that diagram is in an IEditorPart + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -39,7 +40,7 @@ import org.eclipse.graphiti.mm.pictograms.ConnectionDecorator; import org.eclipse.graphiti.mm.pictograms.Diagram; import org.eclipse.graphiti.mm.pictograms.PictogramElement; import org.eclipse.graphiti.services.Graphiti; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.internal.config.IConfigurationProviderInternal; import org.eclipse.graphiti.ui.internal.util.DataTypeTransformation; import org.eclipse.swt.SWT; @@ -181,7 +182,7 @@ public class DiagramEditPart extends ContainerShapeEditPart implements IDiagramE */ @Override public void refresh() { - DiagramEditor editor = getConfigurationProvider().getDiagramEditor(); + IDiagramEditorUI editor = getConfigurationProvider().getDiagramEditor(); editor.getRefreshBehavior().initRefresh(); super.refresh(); } diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/parts/PictogramElementDelegate.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/parts/PictogramElementDelegate.java index dd6e9206..de422aea 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/parts/PictogramElementDelegate.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/parts/PictogramElementDelegate.java @@ -21,6 +21,7 @@ * mwenz - Bug 358255 - Add Border/Background decorators * mgorning - Bug 368124 - ConnectionDecorator with Text causes problems * fvelasco - Bug 396247 - ImageDescriptor changes + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -106,7 +107,7 @@ import org.eclipse.graphiti.tb.IDecorator; import org.eclipse.graphiti.tb.IImageDecorator; import org.eclipse.graphiti.tb.IToolBehaviorProvider; import org.eclipse.graphiti.ui.editor.DefaultRefreshBehavior; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.internal.IResourceRegistry; import org.eclipse.graphiti.ui.internal.config.IConfigurationProviderInternal; import org.eclipse.graphiti.ui.internal.figures.DecoratorImageFigure; @@ -1530,7 +1531,7 @@ public class PictogramElementDelegate implements IPictogramElementDelegate { return forceRefresh; } - private DiagramEditor getEditor() { + private IDiagramEditorUI getEditor() { return getConfigurationProvider().getDiagramEditor(); } diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/parts/ShapeEditPart.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/parts/ShapeEditPart.java index 976f2f3d..bb25518e 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/parts/ShapeEditPart.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/parts/ShapeEditPart.java @@ -15,6 +15,7 @@ * mwenz - Bug 341898 - Support for AdvancedPropertySheet * mgorning - Bug 386913 - Support also Single-Click-Features * pjpaulin - Bug 352120 - Eliminated assumption that diagram is in an IEditorPart + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -72,7 +73,7 @@ import org.eclipse.graphiti.mm.pictograms.PictogramElement; import org.eclipse.graphiti.mm.pictograms.Shape; import org.eclipse.graphiti.services.Graphiti; import org.eclipse.graphiti.tb.IToolBehaviorProvider; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.internal.command.GefCommandWrapper; import org.eclipse.graphiti.ui.internal.config.IConfigurationProviderInternal; import org.eclipse.graphiti.ui.internal.contextbuttons.IContextButtonManager; @@ -537,7 +538,7 @@ public class ShapeEditPart extends GraphitiShapeEditPart implements IShapeEditPa if (singleClickFeature != null && singleClickFeature.canExecute(scc)) { GenericFeatureCommandWithContext commandWithContext = new GenericFeatureCommandWithContext( singleClickFeature, scc); - DiagramEditor diagramEditor = getConfigurationProvider().getDiagramEditor(); + IDiagramEditorUI diagramEditor = getConfigurationProvider().getDiagramEditor(); CommandStack commandStack = diagramEditor.getEditDomain().getCommandStack(); commandStack .execute(new GefCommandWrapper(commandWithContext, diagramEditor.getEditingDomain())); @@ -558,7 +559,7 @@ public class ShapeEditPart extends GraphitiShapeEditPart implements IShapeEditPa if (doubleClickFeature != null && doubleClickFeature.canExecute(dcc)) { GenericFeatureCommandWithContext commandWithContext = new GenericFeatureCommandWithContext( doubleClickFeature, dcc); - DiagramEditor diagramEditor = getConfigurationProvider().getDiagramEditor(); + IDiagramEditorUI diagramEditor = getConfigurationProvider().getDiagramEditor(); CommandStack commandStack = diagramEditor.getEditDomain().getCommandStack(); commandStack.execute(new GefCommandWrapper(commandWithContext, diagramEditor.getEditingDomain())); } @@ -732,7 +733,7 @@ public class ShapeEditPart extends GraphitiShapeEditPart implements IShapeEditPa } private Point getRelativeMouseLocation() { - DiagramEditor editor = getConfigurationProvider().getDiagramEditor(); + IDiagramEditorUI editor = getConfigurationProvider().getDiagramEditor(); // get current mouse location from the viewer Point mouseLocation = new Point(editor.getMouseLocation()); diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/parts/directedit/GFDirectEditManager.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/parts/directedit/GFDirectEditManager.java index 3ffc483e..7790d8b7 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/parts/directedit/GFDirectEditManager.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/parts/directedit/GFDirectEditManager.java @@ -12,6 +12,7 @@ * Bug 336488 - DiagramEditor API * mgorning - Bug 347262 - DirectEditingFeature with TYPE_DIALOG type * mgorning - Bug 377419 - Hide text in underlying GA while DirectEditing is enabled + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -29,7 +30,7 @@ import org.eclipse.graphiti.features.context.IDirectEditingContext; import org.eclipse.graphiti.func.IDirectEditing; import org.eclipse.graphiti.func.IProposal; import org.eclipse.graphiti.func.Proposal; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.internal.figures.GFMultilineText; import org.eclipse.graphiti.ui.internal.figures.GFText; import org.eclipse.graphiti.ui.internal.parts.ShapeEditPart; @@ -64,7 +65,7 @@ public class GFDirectEditManager extends DirectEditManager implements IDirectEdi private IDirectEditingFeature directEditingFeature; - private DiagramEditor diagramEditor; + private IDiagramEditorUI diagramEditor; private Font cellEditorFont = null; diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/platform/ExtensionManager.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/platform/ExtensionManager.java index deab64ec..b4fd103a 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/platform/ExtensionManager.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/platform/ExtensionManager.java @@ -12,6 +12,8 @@ * mwenz - Bug 352709 - invalid image provider id crashes diagram editor * fvelasco - Bug 323349 - Enable external invocation of features * fvelasco - Bug 396247 - ImageDescriptor changes + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface + * * </copyright> * *******************************************************************************/ @@ -41,7 +43,7 @@ import org.eclipse.graphiti.dt.IDiagramTypeProvider; import org.eclipse.graphiti.features.IFeatureProvider; import org.eclipse.graphiti.internal.util.T; import org.eclipse.graphiti.mm.pictograms.Diagram; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.internal.editor.DiagramEditorDummy; import org.eclipse.graphiti.ui.internal.util.ui.print.IDiagramsExporter; import org.eclipse.graphiti.ui.platform.IImageProvider; @@ -242,7 +244,7 @@ public class ExtensionManager implements IExtensionManager { } String context = element.getAttribute(EP_ATTRIBUTE_CONTEXT); if (context == null) { - context = DiagramEditor.DIAGRAM_CONTEXT_ID; + context = IDiagramEditorUI.DIAGRAM_CONTEXT_ID; } if (name != null) { // read direct references to image extensions and try to diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/policy/DefaultDirectEditPolicy.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/policy/DefaultDirectEditPolicy.java index 23d33682..87a9c7a8 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/policy/DefaultDirectEditPolicy.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/policy/DefaultDirectEditPolicy.java @@ -13,6 +13,7 @@ * mgorning - Bug 347262 - DirectEditingFeature with TYPE_DIALOG type * mwenz - Bug 397346 - Digram Editor loses focus on closing of MessageDialog in Graphiti * pjpaulin - Bug 352120 - Eliminated assumption that diagram is in an IEditorPart + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -32,7 +33,7 @@ import org.eclipse.graphiti.func.IProposal; import org.eclipse.graphiti.internal.command.DirectEditingFeatureCommandWithContext; import org.eclipse.graphiti.internal.command.ICommand; import org.eclipse.graphiti.internal.util.LookManager; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.internal.Messages; import org.eclipse.graphiti.ui.internal.command.GefCommandWrapper; import org.eclipse.graphiti.ui.internal.config.IConfigurationProviderInternal; @@ -137,7 +138,7 @@ public class DefaultDirectEditPolicy extends DirectEditPolicy { value, acceptedProposal); final IFeatureProvider fp = directEditingFeature.getFeatureProvider(); - final DiagramEditor diagramEditor = (DiagramEditor) fp.getDiagramTypeProvider().getDiagramEditor(); + final IDiagramEditorUI diagramEditor = (IDiagramEditorUI) fp.getDiagramTypeProvider().getDiagramEditor(); final CommandStack commandStack = diagramEditor.getEditDomain().getCommandStack(); commandStack.execute(new GefCommandWrapper(cmd, diagramEditor.getEditingDomain())); // CommandExec.getSingleton().executeCommand(cmd, fp.getConnection()); diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/policy/ShapeXYLayoutEditPolicy.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/policy/ShapeXYLayoutEditPolicy.java index c6754537..c224fb41 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/policy/ShapeXYLayoutEditPolicy.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/policy/ShapeXYLayoutEditPolicy.java @@ -16,6 +16,7 @@ * Bug 336488 - DiagramEditor API * mgorning - Bug 363186 - Allow modification of selection and hover state also for anchors * mgorning - Bug 383512 - Moving (Resizing) Problem - Polyline/Polygon on first level + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -76,7 +77,7 @@ import org.eclipse.graphiti.mm.pictograms.ContainerShape; import org.eclipse.graphiti.mm.pictograms.PictogramElement; import org.eclipse.graphiti.mm.pictograms.Shape; import org.eclipse.graphiti.services.Graphiti; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.internal.command.AddModelObjectCommand; import org.eclipse.graphiti.ui.internal.command.CreateModelObjectCommand; import org.eclipse.graphiti.ui.internal.command.GefCommandWrapper; @@ -280,7 +281,7 @@ public class ShapeXYLayoutEditPolicy extends XYLayoutEditPolicy { IContextButtonManager contextButtonManager = getConfigurationProvider().getContextButtonManager(); contextButtonManager.hideContextButtonsInstantly(); - DiagramEditor editor = getConfigurationProvider().getDiagramEditor(); + IDiagramEditorUI editor = getConfigurationProvider().getDiagramEditor(); return new GefCommandWrapper(ret, editor.getEditingDomain()); } else { return null; diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/services/IWorkbenchService.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/services/IWorkbenchService.java index 8c8cbd9e..cb7a44ab 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/services/IWorkbenchService.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/services/IWorkbenchService.java @@ -11,6 +11,7 @@ * SAP AG - initial API, implementation and documentation * Ali Akar, mwenz - Bug 348420 - Opening a user contributed editor * Bug 336488 - DiagramEditor API + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -19,7 +20,7 @@ package org.eclipse.graphiti.ui.internal.services; import org.eclipse.graphiti.mm.pictograms.Diagram; import org.eclipse.graphiti.platform.IDiagramEditor; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.jface.action.IStatusLineManager; import org.eclipse.jface.action.StatusLineManager; import org.eclipse.swt.widgets.Shell; @@ -83,7 +84,7 @@ public interface IWorkbenchService { * be used by the editor. * @param editorId * the unique Eclipse editor id of the diagram editor to open. - * This id must belong to a subclass of {@link DiagramEditor} . + * This id must belong to a subclass of {@link IDiagramEditorUI} . * @return the editor instance * @since 0.8.0 */ diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/services/impl/WorkbenchService.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/services/impl/WorkbenchService.java index 8a488274..c2f95155 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/services/impl/WorkbenchService.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/services/impl/WorkbenchService.java @@ -11,6 +11,7 @@ * SAP AG - initial API, implementation and documentation * Ali Akar, mwenz - Bug 348420 - Opening a user contributed editor * Bug 336488 - DiagramEditor API + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -22,6 +23,7 @@ import org.eclipse.graphiti.internal.util.T; import org.eclipse.graphiti.mm.pictograms.Diagram; import org.eclipse.graphiti.platform.IDiagramEditor; import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.editor.DiagramEditorInput; import org.eclipse.graphiti.ui.internal.GraphitiUIPlugin; import org.eclipse.graphiti.ui.internal.services.IWorkbenchService; @@ -118,7 +120,7 @@ public class WorkbenchService implements IWorkbenchService { * be used by the editor. * @param editorId * the unique Eclipse editor id of the diagram editor to open. - * This id must belong to a subclass of {@link DiagramEditor} . + * This id must belong to a subclass of {@link IDiagramEditorUI} . * @return the editor instance * @since 0.8.0 */ diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/platform/GFPropertySection.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/platform/GFPropertySection.java index 60480080..5b6319d5 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/platform/GFPropertySection.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/platform/GFPropertySection.java @@ -11,6 +11,7 @@ * SAP AG - initial API, implementation and documentation * mwenz - Bug 340627 - Features should be able to indicate cancellation * Bug 336488 - DiagramEditor API + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -31,7 +32,7 @@ import org.eclipse.graphiti.internal.command.CommandExec; import org.eclipse.graphiti.mm.pictograms.Diagram; import org.eclipse.graphiti.mm.pictograms.PictogramElement; import org.eclipse.graphiti.platform.IDiagramEditor; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.internal.T; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.ui.IWorkbenchPart; @@ -100,15 +101,15 @@ public abstract class GFPropertySection extends AbstractPropertySection implemen */ protected IDiagramEditor getDiagramEditor() { IWorkbenchPart part = getPart(); - if (part instanceof DiagramEditor) { - return (DiagramEditor) part; + if (part instanceof IDiagramEditorUI) { + return (IDiagramEditorUI) part; } IContributedContentsView contributedView = (IContributedContentsView) part.getAdapter(IContributedContentsView.class); if (contributedView != null) { part = contributedView.getContributingPart(); } - if (part instanceof DiagramEditor) { - return (DiagramEditor) part; + if (part instanceof IDiagramEditorUI) { + return (IDiagramEditorUI) part; } return null; diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/platform/GraphitiConnectionEditPart.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/platform/GraphitiConnectionEditPart.java index efc0c9d4..0decb0c6 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/platform/GraphitiConnectionEditPart.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/platform/GraphitiConnectionEditPart.java @@ -9,6 +9,7 @@ *
* Contributors:
* SAP AG - Bug 341898 - initial API, implementation and documentation
+ * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface
*
* </copyright>
*
@@ -20,7 +21,7 @@ import org.eclipse.gef.EditPart; import org.eclipse.gef.editparts.AbstractConnectionEditPart;
import org.eclipse.graphiti.features.IFeatureProviderHolder;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
-import org.eclipse.graphiti.ui.editor.DiagramEditor;
+import org.eclipse.graphiti.ui.editor.IDiagramEditorUI;
/**
* This is an abstract marker class that indicates that an {@link EditPart} is a
@@ -28,7 +29,7 @@ import org.eclipse.graphiti.ui.editor.DiagramEditor; * {@link IAdapterFactory} against Graphiti edit parts. This is useful e.g. for
* providing standard property sheets (or
* org.eclipse.ui.views.properties.tabbed.AdvancedPropertySections inside tabbed
- * property sheets) for a selection in the Graphiti {@link DiagramEditor};
+ * property sheets) for a selection in the Graphiti {@link IDiagramEditorUI};
* simply use this class as for the adaptableType attribute of the adapter
* factory definition in plugin.xml.
* <p>
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/platform/GraphitiShapeEditPart.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/platform/GraphitiShapeEditPart.java index 77d4c80c..5c1c6ce8 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/platform/GraphitiShapeEditPart.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/platform/GraphitiShapeEditPart.java @@ -9,6 +9,7 @@ *
* Contributors:
* SAP AG - Bug 341898 - initial API, implementation and documentation
+ * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface
*
* </copyright>
*
@@ -20,7 +21,7 @@ import org.eclipse.gef.EditPart; import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
import org.eclipse.graphiti.features.IFeatureProviderHolder;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
-import org.eclipse.graphiti.ui.editor.DiagramEditor;
+import org.eclipse.graphiti.ui.editor.IDiagramEditorUI;
/**
* This is an abstract marker class that indicates that an {@link EditPart} is a
@@ -28,7 +29,7 @@ import org.eclipse.graphiti.ui.editor.DiagramEditor; * {@link IAdapterFactory} against Graphiti edit parts. This is useful e.g. for
* providing standard property sheets (or
* org.eclipse.ui.views.properties.tabbed.AdvancedPropertySections inside tabbed
- * property sheets) for a selection in the Graphiti {@link DiagramEditor};
+ * property sheets) for a selection in the Graphiti {@link IDiagramEditorUI};
* simply use this class as for the adaptableType attribute of the adapter
* factory definition in plugin.xml.
* <p>
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/platform/IConfigurationProvider.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/platform/IConfigurationProvider.java index 2167873f..ed4552e3 100644 --- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/platform/IConfigurationProvider.java +++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/platform/IConfigurationProvider.java @@ -10,6 +10,7 @@ * Contributors:
* SAP AG - initial API, implementation and documentation
* Bug 336488 - DiagramEditor API
+ * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface
*
* </copyright>
*
@@ -19,7 +20,7 @@ package org.eclipse.graphiti.ui.platform; import org.eclipse.graphiti.dt.IDiagramTypeProvider;
import org.eclipse.graphiti.features.IFeatureProviderHolder;
import org.eclipse.graphiti.mm.pictograms.Diagram;
-import org.eclipse.graphiti.ui.editor.DiagramEditor;
+import org.eclipse.graphiti.ui.editor.IDiagramEditorUI;
import org.eclipse.ui.IWorkbenchPart;
/**
@@ -96,5 +97,5 @@ public interface IConfigurationProvider extends IFeatureProviderHolder { *
* @return the editor which is connected with this configuration-provider
*/
- public DiagramEditor getDiagramEditor();
+ public IDiagramEditorUI getDiagramEditor();
}
diff --git a/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/platform/IDiagramEditor.java b/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/platform/IDiagramEditor.java index 5f575d96..6eda9204 100644 --- a/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/platform/IDiagramEditor.java +++ b/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/platform/IDiagramEditor.java @@ -14,6 +14,7 @@ * Bug 336488 - DiagramEditor API * mwenz - Bug 367204 - Correctly return the added PE inAbstractFeatureProvider's addIfPossible method * pjpaulin - Bug 352120 - Added non-GEF methods required for a diagram container. + * pjpaulin - Bug 352120 - Removed @noimplement and @noextend. Created filters for new methods. * * </copyright> * diff --git a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/pageobjects/PoDiagramEditor.java b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/pageobjects/PoDiagramEditor.java index 26c55ada..c508aace 100644 --- a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/pageobjects/PoDiagramEditor.java +++ b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/pageobjects/PoDiagramEditor.java @@ -11,7 +11,7 @@ import org.eclipse.graphiti.bot.tests.AbstractGFTests; import org.eclipse.graphiti.mm.algorithms.RoundedRectangle;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.services.Graphiti;
-import org.eclipse.graphiti.ui.editor.DiagramEditor;
+import org.eclipse.graphiti.ui.editor.IDiagramEditorUI;
import org.eclipse.graphiti.ui.internal.editor.GFFigureCanvas;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Canvas;
@@ -50,7 +50,7 @@ public class PoDiagramEditor extends PageObject{ }
public void dirtify() {
- final DiagramEditor diagramEditor = getActiveDiagramEditor();
+ final IDiagramEditorUI diagramEditor = getActiveDiagramEditor();
AbstractGFTests.executeInRecordingCommandInUIThread(diagramEditor, new Runnable() {
public void run() {
ContainerShape cs1 = Graphiti.getPeService()
@@ -64,8 +64,8 @@ public class PoDiagramEditor extends PageObject{ });
}
- public DiagramEditor getActiveDiagramEditor(){
- return (DiagramEditor) getGefEditor().getReference().getEditor(false);
+ public IDiagramEditorUI getActiveDiagramEditor(){
+ return (IDiagramEditorUI) getGefEditor().getReference().getEditor(false);
}
/**
diff --git a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/pageobjects/PoWorkbenchPage.java b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/pageobjects/PoWorkbenchPage.java index 0dc14e1f..adcec732 100644 --- a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/pageobjects/PoWorkbenchPage.java +++ b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/pageobjects/PoWorkbenchPage.java @@ -11,6 +11,7 @@ * SAP AG - initial API, implementation and documentation
* Bug 336488 - DiagramEditor API
* mwenz - Bug 374918 - Let default paste use LocalSelectionTransfer
+ * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface
*
* </copyright>
*
@@ -33,6 +34,7 @@ import org.eclipse.graphiti.bot.tests.AbstractGFTests; import org.eclipse.graphiti.bot.tests.GFOtherTests;
import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.ui.editor.DiagramEditor;
+import org.eclipse.graphiti.ui.editor.IDiagramEditorUI;
import org.eclipse.graphiti.ui.editor.DiagramEditorInput;
import org.eclipse.graphiti.ui.services.GraphitiUi;
import org.eclipse.swt.SWT;
@@ -70,7 +72,7 @@ public class PoWorkbenchPage extends PageObject{ public Integer run() {
try {
IEditorPart ed = IDE.openEditor(getWorkbenchPage(), diagFile, org.eclipse.graphiti.ui.editor.DiagramEditor.DIAGRAM_EDITOR_ID);
- GFOtherTests.assertTrue("Editor must be a diagram editor: " + ed, ed instanceof DiagramEditor);
+ GFOtherTests.assertTrue("Editor must be a diagram editor: " + ed, ed instanceof IDiagramEditorUI);
} catch (PartInitException e) {
GFOtherTests.fail(e.getMessage());
}
@@ -90,7 +92,7 @@ public class PoWorkbenchPage extends PageObject{ IEditorInput input = DiagramEditorInput.createEditorInput(diagram, GraphitiUi.getExtensionManager()
.getDiagramTypeProviderId(diagram.getDiagramTypeId()));
IEditorPart ed = IDE.openEditor(page, input, DiagramEditor.DIAGRAM_EDITOR_ID);
- assertTrue("Editor must be a diagram editor: " + ed, ed instanceof DiagramEditor);
+ assertTrue("Editor must be a diagram editor: " + ed, ed instanceof IDiagramEditorUI);
} catch (PartInitException e) {
fail(e.getMessage());
}
@@ -122,7 +124,7 @@ public class PoWorkbenchPage extends PageObject{ diagramEditor.saveAndClose();
}
- public void shutdownEditor(final DiagramEditor diagramEditor) {
+ public void shutdownEditor(final IDiagramEditorUI diagramEditor) {
// Close popups.
syncExec(new VoidResult() {
public void run() {
diff --git a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/AbstractGFTests.java b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/AbstractGFTests.java index 5ecba7ea..ccee41eb 100644 --- a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/AbstractGFTests.java +++ b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/AbstractGFTests.java @@ -13,6 +13,7 @@ * Bug 336488 - DiagramEditor API * mwenz - Felix Velasco - Bug 374918 - Let default paste use LocalSelectionTransfer * mwenz - Bug 378342 - Cannot store more than a diagram per file + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -71,7 +72,7 @@ import org.eclipse.graphiti.platform.IDiagramEditor; import org.eclipse.graphiti.services.Graphiti; import org.eclipse.graphiti.services.IPeService; import org.eclipse.graphiti.testtool.sketch.SketchFeatureProvider; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.internal.config.IConfigurationProviderInternal; import org.eclipse.graphiti.ui.internal.services.GraphitiUiInternal; import org.eclipse.graphiti.ui.platform.IConfigurationProvider; @@ -269,17 +270,17 @@ public abstract class AbstractGFTests extends SWTBotGefTestCase { } } - protected DiagramEditor openDiagram(final String type) { + protected IDiagramEditorUI openDiagram(final String type) { return openDiagram(type, "xmi", "diagram"); } - protected DiagramEditor openDiagram(final String type, final String fileExtension, final String diagramName) { - DiagramEditor diagramEditor = syncExec(new Result<DiagramEditor>() { - public DiagramEditor run() { + protected IDiagramEditorUI openDiagram(final String type, final String fileExtension, final String diagramName) { + IDiagramEditorUI diagramEditor = syncExec(new Result<IDiagramEditorUI>() { + public IDiagramEditorUI run() { final Diagram newDiagram = createDiagram(type, fileExtension, diagramName); assertTrue("create diagram does not work", newDiagram != null); - DiagramEditor diagramEditor = (DiagramEditor) GraphitiUiInternal.getWorkbenchService() + IDiagramEditorUI diagramEditor = (IDiagramEditorUI) GraphitiUiInternal.getWorkbenchService() .openDiagramEditor(newDiagram); return diagramEditor; } @@ -450,7 +451,7 @@ public abstract class AbstractGFTests extends SWTBotGefTestCase { return event; } - protected IConfigurationProvider getConfigProviderMock(IDiagramTypeProvider dtp, DiagramEditor ed) { + protected IConfigurationProvider getConfigProviderMock(IDiagramTypeProvider dtp, IDiagramEditorUI ed) { IConfigurationProvider configurationProviderMock = createNiceMock(IConfigurationProviderInternal.class); expect(configurationProviderMock.getDiagramTypeProvider()).andReturn(dtp).anyTimes(); expect(configurationProviderMock.getDiagramEditor()).andReturn(ed).anyTimes(); diff --git a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFDialogTests.java b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFDialogTests.java index 6a9dc96c..782c4fc7 100644 --- a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFDialogTests.java +++ b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFDialogTests.java @@ -10,6 +10,7 @@ * Contributors: * SAP AG - initial API, implementation and documentation * pjpaulin - Bug 352120 - Changed to create action with actual workbench part + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -25,7 +26,7 @@ import org.eclipse.graphiti.bot.tests.util.ITestConstants; import org.eclipse.graphiti.dt.IDiagramTypeProvider; import org.eclipse.graphiti.features.IFeatureProvider; import org.eclipse.graphiti.features.IPrintFeature; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.internal.Messages; import org.eclipse.graphiti.ui.internal.action.PrintGraphicalViewerAction; import org.eclipse.graphiti.ui.internal.services.GraphitiUiInternal; @@ -43,7 +44,7 @@ public class GFDialogTests extends AbstractGFTests { @Test public void testPrintDialog() throws Exception { - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); final boolean[] enabled = new boolean[1]; final CountDownLatch signal = new CountDownLatch(1); asyncExec(new VoidResult() { @@ -80,7 +81,7 @@ public class GFDialogTests extends AbstractGFTests { @Test public void testSaveDialog() throws Exception { - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); asyncExec(new VoidResult() { public void run() { diff --git a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFInteractionComponentTests.java b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFInteractionComponentTests.java index 8b9b1b8e..3375f41f 100644 --- a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFInteractionComponentTests.java +++ b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFInteractionComponentTests.java @@ -16,6 +16,7 @@ * mwenz - Bug 363796 - Make setting of selection width of connections public * mwenz - Bug 358255 - Add Border/Background decorators * Benjamin Schmeling - mwenz - Bug 367483 - Support composite connections + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -74,7 +75,7 @@ import org.eclipse.graphiti.testtool.sketch.features.create.SketchCreateCurvedCo import org.eclipse.graphiti.testtool.sketch.features.create.SketchCreateFreeformConnectionFeature; import org.eclipse.graphiti.testtool.sketch.features.create.SketchCreateGaContainerFeature; import org.eclipse.graphiti.testtool.sketch.features.create.SketchCreateGaShapeFeature; -import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.internal.Messages; import org.eclipse.graphiti.ui.internal.command.CreateModelObjectCommand; import org.eclipse.graphiti.ui.internal.command.GefCommandWrapper; @@ -122,7 +123,7 @@ public class GFInteractionComponentTests extends AbstractGFTests { public void testSelectionTool() throws Exception { final int x = 100; final int y = 100; - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); createClassesAndConnection(x, y, diagramEditor.getDiagramTypeProvider(), null, SHAPE_NAME); Thread.sleep(DELAY); syncExec(new VoidResult() { @@ -139,7 +140,7 @@ public class GFInteractionComponentTests extends AbstractGFTests { public void testHidePalette() throws Exception { boolean oldValue = TestToolBehavior.showFlyoutPalette; TestToolBehavior.setShowFlyoutPalette(true); - DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); + IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); assertNotNull(diagramEditor.getEditDomain().getPaletteViewer()); page.shutdownEditor(diagramEditor); TestToolBehavior.setShowFlyoutPalette(false); @@ -151,7 +152,7 @@ public class GFInteractionComponentTests extends AbstractGFTests { @Test public void testLineSelectionWidth() throws Exception { - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); final ICreateService createService = Graphiti.getCreateService(); executeInRecordingCommand(diagramEditor, new Runnable() { public void run() { @@ -169,7 +170,7 @@ public class GFInteractionComponentTests extends AbstractGFTests { public void testMarqueeTool() throws Exception { final int x = 100; final int y = 100; - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); createClassesAndConnection(x, y, diagramEditor.getDiagramTypeProvider(), "Marquee", SHAPE_NAME); Thread.sleep(DELAY); // Select the newly added shapes with the marquee tool. @@ -215,7 +216,7 @@ public class GFInteractionComponentTests extends AbstractGFTests { public void testGFFigureCanvas() throws Exception { final int x = 100; final int y = 100; - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); syncExec(new VoidResult() { public void run() { // find diagram @@ -311,7 +312,7 @@ public class GFInteractionComponentTests extends AbstractGFTests { */ final int x = 100; final int y = 100; - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); syncExec(new VoidResult() { public void run() { @@ -386,7 +387,7 @@ public class GFInteractionComponentTests extends AbstractGFTests { public void testContextPadHiding() throws Exception { final int x = 100; final int y = 100; - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); syncExec(new VoidResult() { public void run() { @@ -532,7 +533,7 @@ public class GFInteractionComponentTests extends AbstractGFTests { final int x = 100; final int y = 100; - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); syncExec(new VoidResult() { public void run() { @@ -674,7 +675,7 @@ public class GFInteractionComponentTests extends AbstractGFTests { public void testContextButtons() throws Exception { final int x = 100; final int y = 100; - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); syncExec(new VoidResult() { public void run() { @@ -780,7 +781,7 @@ public class GFInteractionComponentTests extends AbstractGFTests { final int height = 60; final int DIL = 30; - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); syncExec(new VoidResult() { public void run() { @@ -855,7 +856,7 @@ public class GFInteractionComponentTests extends AbstractGFTests { public void testDirectEditingMultiText() throws Exception { final int x = 100; final int y = 100; - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); syncExec(new VoidResult() { public void run() { @@ -901,7 +902,7 @@ public class GFInteractionComponentTests extends AbstractGFTests { public void testDirectEditingSingleText() throws Exception { final int x = 100; final int y = 100; - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); syncExec(new VoidResult() { public void run() { @@ -956,7 +957,7 @@ public class GFInteractionComponentTests extends AbstractGFTests { public void testDropIntoContainer() throws Exception { final int x = 100; final int y = 100; - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); syncExec(new VoidResult() { public void run() { @@ -1001,7 +1002,7 @@ public class GFInteractionComponentTests extends AbstractGFTests { final int yContainer3 = 300; final int containerSize = 100; final int rectangleSize = 60; - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); syncExec(new VoidResult() { public void run() { @@ -1093,7 +1094,7 @@ public class GFInteractionComponentTests extends AbstractGFTests { public void testCreateConnection() throws Exception { final int x = 100; final int y = 100; - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); syncExec(new VoidResult() { public void run() { @@ -1163,7 +1164,7 @@ public class GFInteractionComponentTests extends AbstractGFTests { public void testCancelConnection() throws Exception { final int x = 100; final int y = 100; - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); syncExec(new VoidResult() { public void run() { @@ -1219,7 +1220,7 @@ public class GFInteractionComponentTests extends AbstractGFTests { public void testResizeAndPosition() throws Exception { final int x = 100; final int y = 100; - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); syncExec(new VoidResult() { public void run() { @@ -1254,7 +1255,7 @@ public class GFInteractionComponentTests extends AbstractGFTests { @Test public void testSketchAll() throws Exception { - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); PaletteFinder paletteFinder = new PaletteFinder(diagramEditor.getEditDomain()); List<PaletteEntry> objectCreationTools = paletteFinder.findEntries(new AbstractToolEntryMatcher() { @@ -1297,7 +1298,7 @@ public class GFInteractionComponentTests extends AbstractGFTests { // Test for Bug 355027: Move of connection decorators when zoom level != // 100 behaves weird page.closeAllEditors(); - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); final IDiagramTypeProvider dtp = diagramEditor.getDiagramTypeProvider(); final IFeatureProvider fp = ((DefaultFeatureProviderWrapper) dtp.getFeatureProvider()) .getInnerFeatureProvider(); @@ -1410,7 +1411,7 @@ public class GFInteractionComponentTests extends AbstractGFTests { @Test public void testCurvedConnection() throws Exception { page.closeAllEditors(); - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); final IDiagramTypeProvider dtp = diagramEditor.getDiagramTypeProvider(); final IFeatureProvider fp = ((DefaultFeatureProviderWrapper) dtp.getFeatureProvider()) .getInnerFeatureProvider(); @@ -1471,7 +1472,7 @@ public class GFInteractionComponentTests extends AbstractGFTests { @Test public void testRenderingDecorators() throws Exception { page.closeAllEditors(); - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); final IDiagramTypeProvider dtp = diagramEditor.getDiagramTypeProvider(); final IFeatureProvider fp = ((DefaultFeatureProviderWrapper) dtp.getFeatureProvider()) .getInnerFeatureProvider(); @@ -1593,7 +1594,7 @@ public class GFInteractionComponentTests extends AbstractGFTests { public void testCompositeConnection() throws Exception { page.closeAllEditors(); - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); final IDiagramTypeProvider dtp = diagramEditor.getDiagramTypeProvider(); final IFeatureProvider fp = ((DefaultFeatureProviderWrapper) dtp.getFeatureProvider()) .getInnerFeatureProvider(); diff --git a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFOtherTests.java b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFOtherTests.java index 572871c7..0e6745a2 100644 --- a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFOtherTests.java +++ b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFOtherTests.java @@ -19,6 +19,7 @@ * mwenz - Bug 367204 - Correctly return the added PE inAbstractFeatureProvider's addIfPossible method * mwenz - Bug 376008 - Iterating through navigation history causes exceptions * mwenz - Bug 378342 - Cannot store more than a diagram per file + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -119,6 +120,7 @@ import org.eclipse.graphiti.mm.pictograms.Shape; import org.eclipse.graphiti.services.Graphiti; import org.eclipse.graphiti.services.IGaService; import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.editor.DiagramEditorInput; import org.eclipse.graphiti.ui.editor.DiagramEditorInputFactory; import org.eclipse.graphiti.ui.features.AbstractDrillDownFeature; @@ -169,7 +171,7 @@ public class GFOtherTests extends AbstractGFTests { @Test public void testOnEcoreDiagram() throws Exception { - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); syncExec(new VoidResult() { public void run() { @@ -224,7 +226,7 @@ public class GFOtherTests extends AbstractGFTests { * selectionFigure which is in case of the tutorial different from the * figure holding the tooltip. See Bugzilla 348662 for details. */ - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_TUTORIAL); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_TUTORIAL); /* * Open a new diagram containing just one class @@ -314,7 +316,7 @@ public class GFOtherTests extends AbstractGFTests { @Test public void testUndoRedo() throws Exception { - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); final IDiagramTypeProvider diagramTypeProvider = diagramEditor.getDiagramTypeProvider(); final IFeatureProvider fp = diagramTypeProvider.getFeatureProvider(); final Diagram diagram = diagramTypeProvider.getDiagram(); @@ -355,7 +357,7 @@ public class GFOtherTests extends AbstractGFTests { */ @Test public void testRollback() throws Exception { - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); final IFeatureProvider fp = diagramEditor.getDiagramTypeProvider().getFeatureProvider(); final Diagram diagram = fp.getDiagramTypeProvider().getDiagram(); executeInRecordingCommand(diagramEditor, new Runnable() { @@ -373,7 +375,7 @@ public class GFOtherTests extends AbstractGFTests { @Test public void testAbstractDrillDownFeature() throws Exception { - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); Object rootModelObject = diagramEditor.getGraphicalViewer().getContents().getModel(); assertTrue(rootModelObject instanceof Diagram); Diagram diagram = (Diagram) rootModelObject; @@ -468,7 +470,7 @@ public class GFOtherTests extends AbstractGFTests { @Test public void testOnSketchDiagram() throws Exception { - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH); syncExec(new VoidResult() { public void run() { @@ -1106,7 +1108,7 @@ public class GFOtherTests extends AbstractGFTests { public void testAutoUpdateAtStartup() throws Exception { // Test for Bug 356218 - DefaultUpdateDiagramFeature correctly // triggered via editor command stack - DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_WITH_AUTO_UPDATE_AT_STARTUP); + IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_WITH_AUTO_UPDATE_AT_STARTUP); Thread.sleep(1000); assertFalse(diagramEditor.isDirty()); } @@ -1117,7 +1119,7 @@ public class GFOtherTests extends AbstractGFTests { * Test for Bug 367204 - AbstractFeatureProvider's addIfPossible method * should return added {@link PictogramElement} */ - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_TUTORIAL); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_TUTORIAL); syncExec(new VoidResult() { public void run() { @@ -1227,8 +1229,8 @@ public class GFOtherTests extends AbstractGFTests { { DiagramEditorInput input1 = new DiagramEditorInput(diagramUri1, "org.eclipse.graphiti.testtool.sketch.SketchDiagramTypeProvider"); - DiagramEditor editor1; - editor1 = (DiagramEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() + IDiagramEditorUI editor1; + editor1 = (IDiagramEditorUI) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .openEditor(input1, DiagramEditor.DIAGRAM_EDITOR_ID); assertEquals("Diagram1", editor1.getDiagramTypeProvider().getDiagram().getName()); } @@ -1237,19 +1239,19 @@ public class GFOtherTests extends AbstractGFTests { { DiagramEditorInput input2 = new DiagramEditorInput(diagramUri2, "org.eclipse.graphiti.testtool.sketch.SketchDiagramTypeProvider"); - DiagramEditor editor2 = (DiagramEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow() + IDiagramEditorUI editor2 = (IDiagramEditorUI) PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getActivePage().openEditor(input2, DiagramEditor.DIAGRAM_EDITOR_ID); assertEquals("Diagram2", editor2.getDiagramTypeProvider().getDiagram().getName()); } page.closeAllEditors(); - DiagramEditor editor3; + IDiagramEditorUI editor3; { // Open editor for default diagram in file DiagramEditorInput input3 = new DiagramEditorInput(resourceUri, "org.eclipse.graphiti.testtool.sketch.SketchDiagramTypeProvider"); - editor3 = (DiagramEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() + editor3 = (IDiagramEditorUI) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .openEditor(input3, DiagramEditor.DIAGRAM_EDITOR_ID); assertEquals("Diagram1", editor3.getDiagramTypeProvider().getDiagram().getName()); } @@ -1258,7 +1260,7 @@ public class GFOtherTests extends AbstractGFTests { { DiagramEditorInput input4 = new DiagramEditorInput(diagramUri1, "org.eclipse.graphiti.testtool.sketch.SketchDiagramTypeProvider"); - DiagramEditor editor4 = (DiagramEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow() + IDiagramEditorUI editor4 = (IDiagramEditorUI) PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getActivePage().openEditor(input4, DiagramEditor.DIAGRAM_EDITOR_ID); assertEquals("Diagram1", editor4.getDiagramTypeProvider().getDiagram().getName()); assertEquals(editor3, editor4); diff --git a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFPackageTests.java b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFPackageTests.java index b895e119..f8b9d4a8 100644 --- a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFPackageTests.java +++ b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFPackageTests.java @@ -13,6 +13,7 @@ * mgorning - Bug 371671 - addGraphicalRepresentation returns null in dark mode * mwenz - Felix Velasco - Bug 374918 - Let default paste use LocalSelectionTransfer * fvelasco - Bug 396247 - ImageDescriptor changes + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -74,6 +75,7 @@ import org.eclipse.graphiti.services.Graphiti; import org.eclipse.graphiti.testtool.ecore.TestDiagramTypeProvider; import org.eclipse.graphiti.testtool.sketch.SketchDiagramTypeProvider; import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.graphiti.ui.editor.IDiagramEditorUI; import org.eclipse.graphiti.ui.features.AbstractPasteFeature; import org.eclipse.graphiti.ui.features.DefaultFeatureProvider; import org.eclipse.graphiti.ui.internal.GraphitiUIPlugin; @@ -182,7 +184,7 @@ public class GFPackageTests extends AbstractGFTests { assertNotNull(myConfigurableFeatureProviderWrapper.getAddFeature(addContext)); // test canLayout - DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); + IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); PictogramElement pe = getPictogramElement(diagramEditor); LayoutContext layoutContext = new LayoutContext(pe); assertFalse(myConfigurableFeatureProviderWrapper.canLayout(layoutContext).toBoolean()); @@ -195,7 +197,7 @@ public class GFPackageTests extends AbstractGFTests { String s = null; TestDiagramTypeProvider myDiagramTypeProvider = new TestDiagramTypeProvider(); - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); final Diagram diagram = diagramEditor.getDiagramTypeProvider().getDiagram(); myDiagramTypeProvider.init(diagram, diagramEditor); PictogramElement pe = getPictogramElement(diagramEditor); @@ -340,7 +342,7 @@ public class GFPackageTests extends AbstractGFTests { @Test public void testGraphitiPasteTwoDiagrams() throws Exception { TestDiagramTypeProvider myDiagramTypeProvider = new TestDiagramTypeProvider(); - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); final Diagram diagram = diagramEditor.getDiagramTypeProvider().getDiagram(); myDiagramTypeProvider.init(diagram, diagramEditor); PictogramElement pe = getPictogramElement(diagramEditor); @@ -365,7 +367,7 @@ public class GFPackageTests extends AbstractGFTests { // Test paste in a second diagram TestDiagramTypeProvider myDiagramTypeProvider2 = new TestDiagramTypeProvider(); - final DiagramEditor diagramEditor2 = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE, "xmi", "diagram2"); + final IDiagramEditorUI diagramEditor2 = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE, "xmi", "diagram2"); final Diagram diagram2 = diagramEditor2.getDiagramTypeProvider().getDiagram(); myDiagramTypeProvider2.init(diagram2, diagramEditor2); final MyPasteFeature myPasteFeature = new MyPasteFeature(myDiagramTypeProvider2.getFeatureProvider(), diagram2); @@ -391,7 +393,7 @@ public class GFPackageTests extends AbstractGFTests { page.closeAllEditors(); } - private PictogramElement getPictogramElement(DiagramEditor diagramEditor) { + private PictogramElement getPictogramElement(IDiagramEditorUI diagramEditor) { Diagram diagram = diagramEditor.getDiagramTypeProvider().getDiagram(); addClassesAndReferencesToDiagram(diagramEditor); @@ -403,7 +405,7 @@ public class GFPackageTests extends AbstractGFTests { return pe; } - private void addClassesAndReferencesToDiagram(final DiagramEditor diagramEditor) { + private void addClassesAndReferencesToDiagram(final IDiagramEditorUI diagramEditor) { syncExec(new VoidResult() { public void run() { IDiagramTypeProvider diagramTypeProvider = diagramEditor.getDiagramTypeProvider(); @@ -517,7 +519,7 @@ public class GFPackageTests extends AbstractGFTests { expect(diagramMock.getConnections()).andReturn(connections).anyTimes(); replay(diagramMock); - final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); + final IDiagramEditorUI diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); final Diagram diagram = diagramEditor.getDiagramTypeProvider().getDiagram(); IDiagramTypeProvider diagramTypeProvider = diagramEditor.getDiagramTypeProvider(); diff --git a/tests/org.eclipse.graphiti.tests/.settings/.api_filters b/tests/org.eclipse.graphiti.tests/.settings/.api_filters deleted file mode 100644 index d630ca63..00000000 --- a/tests/org.eclipse.graphiti.tests/.settings/.api_filters +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<component id="org.eclipse.graphiti.tests" version="2">
- <resource path="src/org/eclipse/graphiti/tests/cases/FeatureParametersTest.java" type="org.eclipse.graphiti.tests.cases.FeatureParametersTest">
- <filter id="574619656">
- <message_arguments>
- <message_argument value="IDiagramEditor"/>
- <message_argument value="FeatureParametersTest"/>
- </message_arguments>
- </filter>
- </resource>
-</component>
diff --git a/tests/org.eclipse.graphiti.testtool.sketch/src/org/eclipse/graphiti/testtool/sketch/editors/MultiPageEditor.java b/tests/org.eclipse.graphiti.testtool.sketch/src/org/eclipse/graphiti/testtool/sketch/editors/MultiPageEditor.java index 979a861f..d194f8da 100644 --- a/tests/org.eclipse.graphiti.testtool.sketch/src/org/eclipse/graphiti/testtool/sketch/editors/MultiPageEditor.java +++ b/tests/org.eclipse.graphiti.testtool.sketch/src/org/eclipse/graphiti/testtool/sketch/editors/MultiPageEditor.java @@ -11,6 +11,7 @@ * SAP AG - initial API, implementation and documentation * mwenz - Bug 387971 - Features cant't be invoked from contextMenu * pjpaulin - Bug 352120 - Changed to instantiate DiagramEditorImpl + * pjpaulin - Bug 352120 - Now uses IDiagramEditorUI interface * * </copyright> * @@ -23,7 +24,7 @@ import org.eclipse.core.resources.IResourceChangeEvent; import org.eclipse.core.resources.IResourceChangeListener; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.graphiti.ui.editor.DiagramEditorImpl; +import org.eclipse.graphiti.ui.editor.DiagramEditor; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.viewers.ISelection; import org.eclipse.swt.widgets.Display; @@ -59,7 +60,7 @@ public class MultiPageEditor extends FormEditor implements IResourceChangeListen */ void createPage0() { try { - editor = new DiagramEditorImpl(); + editor = new DiagramEditor(); int index = addPage(editor, getEditorInput()); setPageText(index, editor.getTitle()); } catch (PartInitException e) { |