Bug 329523 - Add notification of DiagramTypeProvider after saving a diagram
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/DiagramEditorBehavior.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/DiagramEditorBehavior.java
index a345436..0fe4c55 100644
--- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/DiagramEditorBehavior.java
+++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/DiagramEditorBehavior.java
@@ -9,6 +9,7 @@
  *
  * Contributors:
  *    SAP AG - initial API, implementation and documentation
+ *    mwenz - Bug 329523 - Add notification of DiagramTypeProvider after saving a diagram
  *
  * </copyright>
  *
@@ -17,6 +18,7 @@
 
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Set;
@@ -425,8 +427,7 @@
 	 */
 	private boolean handleDirtyConflict() {
 		return MessageDialog.openQuestion(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
-				Messages.DiscardChangesDialog_0_xmsg,
-				Messages.DiscardChangesDialog_1_xmsg);
+				Messages.DiscardChangesDialog_0_xmsg, Messages.DiscardChangesDialog_1_xmsg);
 	}
 
 	/**
@@ -482,10 +483,11 @@
 	 * @param progressMonitor
 	 *            The {@link IProgressMonitor} progress monitor
 	 */
-	public void doSave(IProgressMonitor progressMonitor) {
+	public Resource[] doSave(IProgressMonitor progressMonitor) {
 		// Save only resources that have actually changed.
 		final Map<Object, Object> saveOptions = new HashMap<Object, Object>();
 		saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
+		final Set<Resource> savedResources = new HashSet<Resource>();
 
 		// Do the work within an operation because this is a long running activity that modifies the workbench.
 		final WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
@@ -494,7 +496,7 @@
 			public void execute(IProgressMonitor monitor) {
 				// Save the resources to the file system.
 				try {
-					GraphitiUiInternal.getEmfService().save(editingDomain);
+					savedResources.addAll(GraphitiUiInternal.getEmfService().save(editingDomain));
 				} catch (final WrappedException e) {
 					final MultiStatus errorStatus = new MultiStatus(GraphitiUIPlugin.PLUGIN_ID, 0, e.getMessage(), e.exception());
 					GraphitiUIPlugin.getDefault().getLog().log(errorStatus);
@@ -519,6 +521,8 @@
 		}
 		this.updateProblemIndication = true;
 		updateProblemIndication();
+
+		return savedResources.toArray(new Resource[savedResources.size()]);
 	}
 
 	private IOperationHistory getOperationHistory() {
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/DiagramEditorInternal.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/DiagramEditorInternal.java
index eb21f57..f968535 100644
--- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/DiagramEditorInternal.java
+++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/DiagramEditorInternal.java
@@ -13,6 +13,7 @@
  *    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
  *
  * </copyright>
  *
@@ -35,6 +36,7 @@
 import org.eclipse.draw2d.geometry.Point;
 import org.eclipse.emf.common.command.CommandStackListener;
 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;
@@ -564,8 +566,12 @@
 
 	@Override
 	public void doSave(IProgressMonitor monitor) {
-		getBehavior().doSave(monitor);
+		Resource[] savedResources = getBehavior().doSave(monitor);
 		commandStackChanged(null);
+
+		IDiagramTypeProvider provider = getConfigurationProvider().getDiagramTypeProvider();
+		provider.resourcesSaved(getDiagramTypeProvider().getDiagram(), savedResources);
+
 	}
 
 	@Override
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/services/IEmfService.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/services/IEmfService.java
index e9a80ac..3cba0a9 100644
--- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/services/IEmfService.java
+++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/services/IEmfService.java
@@ -9,6 +9,7 @@
  *
  * Contributors:
  *    SAP AG - initial API, implementation and documentation
+ *    mwenz - Bug 329523 - Add notification of DiagramTypeProvider after saving a diagram
  *
  * </copyright>
  *
@@ -16,6 +17,7 @@
 package org.eclipse.graphiti.ui.internal.services;
 
 import java.util.Map;
+import java.util.Set;
 
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
@@ -68,7 +70,6 @@
 	 */
 	public abstract EObject getEObject(Object object);
 
-
 	/**
 	 * Returns the Eclipse file for the given {@link EObject}'s {@link Resource}
 	 * .
@@ -135,17 +136,16 @@
 	 */
 	public abstract IFile getFile(URI uri, ResourceSet resourceSet);
 
-
 	/**
 	 * Saves the given {@link TransactionalEditingDomain} by saving all its
 	 * dirty {@link Resource}s.
 	 * 
 	 * @param editingDomain
 	 *            The {@link TransactionalEditingDomain} to be saved.
+	 * @return
 	 */
-	public abstract void save(TransactionalEditingDomain editingDomain) throws WrappedException;
-	
-	
+	public abstract Set<Resource> save(TransactionalEditingDomain editingDomain) throws WrappedException;
+
 	/**
 	 * Saves the given {@link TransactionalEditingDomain} by saving all its
 	 * dirty {@link Resource}s.
@@ -154,8 +154,9 @@
 	 *            The {@link TransactionalEditingDomain} to be saved.
 	 * @param options
 	 *            Save options for each of the {@link Resource}s to save.
+	 * @return
 	 */
-	public abstract void save(final TransactionalEditingDomain editingDomain, final Map<Resource, Map<?, ?>> options);
+	public abstract Set<Resource> save(final TransactionalEditingDomain editingDomain, final Map<Resource, Map<?, ?>> options);
 
 	/**
 	 * Creates an extended string presentation of the given {@link EObject},
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/services/impl/EmfService.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/services/impl/EmfService.java
index 811adc4..8ec7164 100644
--- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/services/impl/EmfService.java
+++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/services/impl/EmfService.java
@@ -9,6 +9,7 @@
  *
  * Contributors:
  *    SAP AG - initial API, implementation and documentation
+ *    mwenz - Bug 329523 - Add notification of DiagramTypeProvider after saving a diagram
  *
  * </copyright>
  *
@@ -202,17 +203,17 @@
 		return null;
 	}
 
-
 	@Override
 	@SuppressWarnings("unchecked")
-	public void save(TransactionalEditingDomain editingDomain) throws WrappedException {
-		save(editingDomain, Collections.EMPTY_MAP);
+	public Set<Resource> save(TransactionalEditingDomain editingDomain) throws WrappedException {
+		return save(editingDomain, Collections.EMPTY_MAP);
 	}
 
 	@Override
-	public void save(final TransactionalEditingDomain editingDomain, final Map<Resource, Map<?, ?>> options) {
+	public Set<Resource> save(final TransactionalEditingDomain editingDomain, final Map<Resource, Map<?, ?>> options) {
 
 		final Map<URI, Throwable> failedSaves = new HashMap<URI, Throwable>();
+		final Set<Resource> savedResources = new HashSet<Resource>();
 		final IWorkspaceRunnable wsRunnable = new IWorkspaceRunnable() {
 			@Override
 			public void run(final IProgressMonitor monitor) throws CoreException {
@@ -237,7 +238,6 @@
 						// during the saving of the dirty resources
 						Resource[] resourcesArray = new Resource[resources.size()];
 						resourcesArray = resources.toArray(resourcesArray);
-						final Set<Resource> savedResources = new HashSet<Resource>();
 						for (int i = 0; i < resourcesArray.length; i++) {
 							// In case resource modification tracking is switched on, 
 							// we can check if a resource has been modified, so that we only need to save
@@ -279,6 +279,8 @@
 			}
 			throw new RuntimeException(e);
 		}
+
+		return savedResources;
 	}
 
 	private String createMessage(Map<URI, Throwable> failedSaves) {