Clean up separation of methods in diagram container interfaces

*Add all methods from deprecated IDiagramEditor to new successor
IDiagramContainer
*Move methods close, doSave, isAlive, updateDirtyState and getTitle
from IDiagramContainerUI to IDiagramContainer
*Add getTitleToolTip method to DiagramComposite
*Add methods refreshContent and getTitleToolTip implemented in
DiagramEditor to IDiagramContainer
*Fixed compile errors in implementing dummy and test editor classes
*Filtered out usage warnings
*Removed some unused methods from IDiagramContainerUI
*Updated JavaDoc

Change-Id: I8857eafc3415b7aaa5063a3d95b5c13fc2c492c3
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 181c360..c116ebb 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
@@ -175,7 +175,7 @@
 
 		// register listeners
 		_selectionSynchronizer.addViewer(getViewer());
-		_diagramEditor.addPropertyListener(this);
+		_diagramEditor.getWorkbenchPart().addPropertyListener(this);
 
 		initContents();
 	}
@@ -187,7 +187,7 @@
 	public void dispose() {
 		// deregister listeners
 		_selectionSynchronizer.removeViewer(getViewer());
-		_diagramEditor.removePropertyListener(this);
+		_diagramEditor.getWorkbenchPart().removePropertyListener(this);
 
 		if (_thumbnail != null)
 			_thumbnail.deactivate();
diff --git a/plugins/org.eclipse.graphiti.ui/.settings/.api_filters b/plugins/org.eclipse.graphiti.ui/.settings/.api_filters
index 995ea4e..008aa7b 100644
--- a/plugins/org.eclipse.graphiti.ui/.settings/.api_filters
+++ b/plugins/org.eclipse.graphiti.ui/.settings/.api_filters
@@ -99,8 +99,8 @@
     <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="IDiagramContainerUI"/>

+                <message_argument value="IDiagramContainer"/>

                 <message_argument value="DiagramComposite"/>

             </message_arguments>

         </filter>

@@ -285,6 +285,14 @@
             </message_arguments>

         </filter>

     </resource>

+    <resource path="src/org/eclipse/graphiti/ui/editor/IDiagramContainerUI.java" type="org.eclipse.graphiti.ui.editor.IDiagramContainerUI">

+        <filter id="571473929">

+            <message_arguments>

+                <message_argument value="IDiagramContainer"/>

+                <message_argument value="IDiagramContainerUI"/>

+            </message_arguments>

+        </filter>

+    </resource>

     <resource path="src/org/eclipse/graphiti/ui/features/AbstractCopyFeature.java" type="org.eclipse.graphiti.ui.features.AbstractCopyFeature">

         <filter id="574619656">

             <message_arguments>

@@ -335,10 +343,9 @@
         </filter>

     </resource>

     <resource path="src/org/eclipse/graphiti/ui/internal/editor/DiagramEditorDummy.java" type="org.eclipse.graphiti.ui.internal.editor.DiagramEditorDummy">

-        <filter id="574660632">

+        <filter id="574619656">

             <message_arguments>

                 <message_argument value="IDiagramContainer"/>

-                <message_argument value="IDiagramEditor"/>

                 <message_argument value="DiagramEditorDummy"/>

             </message_arguments>

         </filter>

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 3e1933d..52b896e 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
@@ -326,10 +326,6 @@
 		super.setEditDomain(editDomain);
 	}
 
-	public void initializeGEFGraphicalViewer() {
-		this.initializeGraphicalViewer();
-	}
-
 	public ActionRegistry getActionRegistry() {
 		return super.getActionRegistry();
 	}
@@ -363,6 +359,10 @@
 		return this.getWorkbenchPart().getTitle();
 	}
 
+	public String getTitleToolTip() {
+		return getWorkbenchPart().getTitleToolTip();
+	}
+
 	public void addPropertyListener(IPropertyListener listener) {
 		this.getWorkbenchPart().addPropertyListener(listener);
 	}
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/IDiagramContainerUI.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/IDiagramContainerUI.java
index daf1ec5..2200647 100644
--- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/IDiagramContainerUI.java
+++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/IDiagramContainerUI.java
@@ -43,26 +43,22 @@
 import java.util.List;
 
 import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.draw2d.IFigure;
 import org.eclipse.gef.DefaultEditDomain;
-import org.eclipse.gef.EditPart;
 import org.eclipse.gef.GraphicalViewer;
 import org.eclipse.gef.ui.actions.ActionRegistry;
 import org.eclipse.gef.ui.parts.GraphicalEditor;
 import org.eclipse.graphiti.mm.pictograms.PictogramElement;
 import org.eclipse.graphiti.platform.IDiagramContainer;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IPropertyListener;
+import org.eclipse.ui.IEditorInput;
 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
+ * This is the main UI interface for the Graphiti diagram containers. 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
+ * A DiagramContainer 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.
  * 
@@ -85,12 +81,18 @@
 	 * 
 	 * @return the {@link DefaultEditDomain} used in this editor
 	 * @see GraphicalEditor#getEditDomain()
-	 * 
-	 * @since 0.9
 	 */
-	DefaultEditDomain getEditDomain();
+	public DefaultEditDomain getEditDomain();
 
-	void setEditDomain(DefaultEditDomain editDomain);
+	/**
+	 * Sets the GEF edit domain to the container. Needed for initializing the
+	 * container from the {@link DiagramSupport} instance.
+	 * 
+	 * @param editDomain
+	 *            The {@link DefaultEditDomain} to set
+	 * @see GraphicalEditor#setEditDomain()
+	 */
+	public void setEditDomain(DefaultEditDomain editDomain);
 
 	/**
 	 * Returns the GEF {@link GraphicalViewer} as it is needed in some Graphiti
@@ -100,119 +102,101 @@
 	 * @return the {@link GraphicalViewer} used within this editor instance
 	 * @see GraphicalEditor#getGraphicalViewer()
 	 */
-	GraphicalViewer getGraphicalViewer();
+	public 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.
+	 * Returns the instance of the Eclipse {@link IWorkbenchPart} that displays
+	 * this container. E.g. for an editor this will be the editor itself.
 	 * 
-	 * @since 0.9
+	 * @return The {@link IWorkbenchPart} that is displaying the diagram.
 	 */
-	void updateDirtyState();
-
+	public IWorkbenchPart getWorkbenchPart();
 
 	/**
-	 * Request that the diagram model be persisted.
+	 * Returns the {@link IWorkbenchPartSite} of the Eclipse
+	 * {@link IWorkbenchPart} that displays this container. E.g. for an editor
+	 * this will be the editor site.
 	 * 
-	 */
-	void doSave(IProgressMonitor monitor);
-
-	/**
-	 * 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();
-
-	/**
-	 * @return the {@link IWorkbenchPart} that is displaying the diagram.
-	 */
-	IWorkbenchPart getWorkbenchPart();
-
-	/**
-	 * @return the site for the {@link IWorkbenchPart} that is displaying the
+	 * @return The site for the {@link IWorkbenchPart} that is displaying the
 	 *         diagram.
-	 * @since 0.10
 	 */
-	IWorkbenchPartSite getSite();
+	public 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>
+	 * Returns the {@link IDiagramEditorInput} instance used for this container.
+	 * Basically it is used as an Eclipse {@link IEditorInput} object only in
+	 * case the container is an editor; for other types of containers the input
+	 * is simply used as a holder for a URI pointing to a diagram.
 	 * 
-	 * @param listener
-	 *            a property listener
-	 * @since 0.10
+	 * @return The input containing the URI for the diagram
 	 */
-	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);
-
-	/**
-	 * @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 close();
+	public IDiagramEditorInput getDiagramEditorInput();
 
 	/**
 	 * Method to retrieve the Draw2D {@link IFigure} for a given
 	 * {@link PictogramElement}.
 	 * 
 	 * @param pe
-	 *            the {@link PictogramElement} to retrieve the Draw2D
+	 *            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);
-
-	ActionRegistry getActionRegistry();
-
-	@SuppressWarnings("rawtypes")
-	List getSelectionActions();
-
-	void commandStackChanged(EventObject event);
-
-	void setGraphicalViewer(GraphicalViewer viewer);
-
-	void hookGraphicalViewer();
-
-	DiagramSupport getDiagramSupport();
-
-	void initializeGraphicalViewer();
+	public IFigure getFigureForPictogramElement(PictogramElement pe);
 
 	/**
-	 * Checks if this editor is alive.
+	 * Returns the GEF action registry for the container.
 	 * 
-	 * @return <code>true</code>, if editor contains a model connector and a
-	 *         valid Diagram, <code>false</code> otherwise.
+	 * @return The {@link ActionRegistry}
 	 */
-	boolean isAlive();
+	public ActionRegistry getActionRegistry();
+
+	/**
+	 * Returns the actions used for selection of the parent GEF editor, for an
+	 * editor based upon the GEF editor this simply returns the standard GEF
+	 * selection actions by delegating to the super editor class.
+	 * 
+	 * @return A {@link List} containing the selection actions
+	 * @see GraphicalEditor#getSelectionActions()
+	 */
+	@SuppressWarnings("rawtypes")
+	public List getSelectionActions();
+
+	/**
+	 * Notification that the command stack changed. This might e.g. trigger an
+	 * update of the dirty state of the container.
+	 * 
+	 * @param event
+	 *            An event instance describing what happened
+	 * @see GraphicalEditor#commandStackChanged(EventObject event)
+	 */
+	public void commandStackChanged(EventObject event);
+
+	/**
+	 * Sets the {@link GraphicalViewer} to be used inside the container. The
+	 * viewer is created by the {@link DiagramSupport} instance and needs to be
+	 * set in the GEF container.
+	 * 
+	 * @param viewer
+	 *            The viewer to use.
+	 * @see GraphicalEditor#setGraphicalViewer(GraphicalViewer viewer)
+	 */
+	public void setGraphicalViewer(GraphicalViewer viewer);
+
+	/**
+	 * Hooks the {@link GraphicalViewer} to be used inside the container.
+	 * 
+	 * @param viewer
+	 *            The viewer to use.
+	 * @see GraphicalEditor#hookGraphicalViewer(GraphicalViewer viewer)
+	 */
+	public void hookGraphicalViewer();
+
+	/**
+	 * Returns the {@link DiagramSupport} instance associated with this
+	 * container.
+	 * 
+	 * @return The associated {@link DiagramSupport} instance
+	 */
+	public DiagramSupport getDiagramSupport();
 }
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/DiagramEditorDummy.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/DiagramEditorDummy.java
index 7a400f9..f6b556a 100644
--- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/DiagramEditorDummy.java
+++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/DiagramEditorDummy.java
@@ -175,7 +175,19 @@
 	}
 
 	public void doSave(IProgressMonitor monitor) {
-		// TODO Auto-generated method stub
+	}
 
+	public String getTitle() {
+		return "Dummy Editor"; //$NON-NLS-1$
+	}
+
+	public String getTitleToolTip() {
+		return "Dummy Editor"; //$NON-NLS-1$
+	}
+
+	public void updateDirtyState() {
+	}
+
+	public void close() {
 	}
 }
diff --git a/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/platform/IDiagramContainer.java b/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/platform/IDiagramContainer.java
index 9fc545f..e3d2292 100644
--- a/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/platform/IDiagramContainer.java
+++ b/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/platform/IDiagramContainer.java
@@ -15,28 +15,206 @@
  *******************************************************************************/

 package org.eclipse.graphiti.platform;

 

+import org.eclipse.core.runtime.IProgressMonitor;

 import org.eclipse.emf.ecore.resource.ResourceSet;

 import org.eclipse.emf.transaction.TransactionalEditingDomain;

+import org.eclipse.graphiti.dt.IDiagramTypeProvider;

+import org.eclipse.graphiti.features.IFeature;

+import org.eclipse.graphiti.features.context.IContext;

 import org.eclipse.graphiti.mm.pictograms.PictogramElement;

 

 /**

+ * The Interface IDiagramContainer. This is the base interface for all

+ * containers that can display diagrams. Such a container may be an editor or a

+ * view, possibly also a plain composite used within e.g. a popup or inside an

+ * editor or view.

+ * 

+ * @noimplement This interface is not intended to be implemented by clients.

+ * @noextend This interface is not intended to be extended by clients. Extend

+ *           DiagramEditor or DiagramComposite instead.

+ * 

  * @since 0.10

  */

 public interface IDiagramContainer extends IDiagramEditor {

 

-	public ResourceSet getResourceSet();

+	/*

+	 * Selection handling

+	 */

 

-	public TransactionalEditingDomain getEditingDomain();

+	/**

+	 * Selects all the given pictogram elements in the container.

+	 * 

+	 * @param pictogramElements

+	 *            The pictogram elements to select

+	 */

+	public void selectPictogramElements(PictogramElement[] pictogramElements);

 

-	public void refresh();

+	/**

+	 * Gets all pictogram elements that are currently selected.

+	 * 

+	 * @return all selected pictogram elements

+	 */

+	public PictogramElement[] getSelectedPictogramElements();

 

-	public void refreshTitle();

-

-	public void refreshPalette();

-

+	/**

+	 * Sets the pictogram element which should be selected after the container

+	 * refresh.

+	 * 

+	 * @param pictogramElement

+	 *            The pictogram element to select

+	 */

 	public void setPictogramElementForSelection(PictogramElement pictogramElement);

 

+	/**

+	 * Sets the pictogram elements which should be selected after the container

+	 * refresh.

+	 * 

+	 * @param pictogramElements

+	 *            The pictogram elements to select

+	 */

 	public void setPictogramElementsForSelection(PictogramElement[] pictogramElements);

 

-	public PictogramElement[] getSelectedPictogramElements();

+	/*

+	 * EMF

+	 */

+

+	/**

+	 * Gets the transactional editing domain.

+	 * 

+	 * @return The transactional editing domain which is used in the container

+	 */

+	public TransactionalEditingDomain getEditingDomain();

+

+	/**

+	 * Gets the resource set.

+	 * 

+	 * @return The resource set which is used in the container

+	 */

+	public ResourceSet getResourceSet();

+

+	/*

+	 * Refreshing and UI

+	 */

+

+	/**

+	 * Gets the title for the container that is displaying the diagram.

+	 * 

+	 * @return The title as a {@link String}

+	 */

+	public String getTitle();

+

+	/**

+	 * Returns the tooltip for the container. For an editor that would e.g. be

+	 * the string that is displayed when hovering over the editor title tab.

+	 * 

+	 * @return The tooltip as a {@link String}

+	 */

+	public String getTitleToolTip();

+

+	/**

+	 * Refreshes the container.

+	 */

+	public void refresh();

+

+	/**

+	 * Refreshes the title text of this container. It depends on the container

+	 * type what and if anything is refreshed, for an editor e.g. the part tab

+	 * will be refreshed.

+	 */

+	public void refreshTitle();

+

+	/**

+	 * Refreshes the title tool tip text of this part. It depends on the

+	 * container type what and if anything is refreshed, for an editor e.g. the

+	 * part tab tooltip will be refreshed.

+	 */

+	public void refreshTitleToolTip();

+

+	/**

+	 * Refreshes all rendering decorators for the given pictogram element. That

+	 * means: 1. delete current decorators 2. ask the tool behaviour provider

+	 * for decorator data 3. create new decorators with this data and render

+	 * this new decorators

+	 * 

+	 * @param pe

+	 *            The pictogram element to refresh the decorators for

+	 */

+	public void refreshRenderingDecorators(PictogramElement pe);

+

+	/**

+	 * Refreshes the containers's palette.

+	 */

+	public void refreshPalette();

+

+	/**

+	 * Refreshes the content of the container (what's shown inside the diagram

+	 * itself).

+	 */

+	public void refreshContent();

+

+	/*

+	 * Lifecycle

+	 */

+

+	/**

+	 * Checks if the container is dirty.

+	 * 

+	 * @return <code>true</code>, if container is dirty, <code>false</code>

+	 *         otherwise

+	 */

+	public boolean isDirty();

+

+	/**

+	 * Triggers that the diagram model is persisted.

+	 * 

+	 */

+	public void doSave(IProgressMonitor monitor);

+

+	/**

+	 * Updates the UI of the container to correctly reflect the dirty state.

+	 * What (and if anything) happens depends on the container type. The default

+	 * implementation in the editor e.g. does this by firing a

+	 * {@link IEditorPart#PROP_DIRTY} property change.

+	 */

+	void updateDirtyState();

+

+	/**

+	 * Checks if this container is alive.

+	 * 

+	 * @return <code>true</code>, if the container contains a model connector

+	 *         and a valid Diagram, <code>false</code> otherwise.

+	 */

+	public boolean isAlive();

+

+	/**

+	 * Notify the container that it should shut down or clear it's state.

+	 */

+	public void close();

+

+	/*

+	 * Other

+	 */

+

+	/**

+	 * Gets the diagram type provider.

+	 * 

+	 * @return The diagram type provider

+	 */

+	public IDiagramTypeProvider getDiagramTypeProvider();

+

+	/**

+	 * Executes the given feature in the given context using the command stack

+	 * and editing domain of the container. In case of an IAddFeature being

+	 * passed this method will also trigger the selection of the newly added

+	 * shape.

+	 * 

+	 * @param feature

+	 *            The feature to execute

+	 * @param context

+	 *            The context object to use with the feature

+	 * @return an object representing the result of the feature call (depends on

+	 *         the concrete implementation)

+	 * 

+	 */

+	public Object executeFeature(IFeature feature, IContext context);

 }

diff --git a/tests/org.eclipse.graphiti.tests/src/org/eclipse/graphiti/tests/cases/FeatureParametersTest.java b/tests/org.eclipse.graphiti.tests/src/org/eclipse/graphiti/tests/cases/FeatureParametersTest.java
index 6cabfcc..a0dd9ba 100644
--- a/tests/org.eclipse.graphiti.tests/src/org/eclipse/graphiti/tests/cases/FeatureParametersTest.java
+++ b/tests/org.eclipse.graphiti.tests/src/org/eclipse/graphiti/tests/cases/FeatureParametersTest.java
@@ -176,8 +176,20 @@
 			}
 
 			public void doSave(IProgressMonitor monitor) {
-				// TODO Auto-generated method stub
+			}
 
+			public String getTitle() {
+				return "Title";
+			}
+
+			public String getTitleToolTip() {
+				return "ToolTip";
+			}
+
+			public void updateDirtyState() {
+			}
+
+			public void close() {
 			}
 		};