[483913] Improve behavior with target platform

fix dialogs

Change-Id: I0a3ae6c12e106e5eaf178f8fe21bc042f0994545
Signed-off-by: Thomas Guiu <thomas.guiu@soyatec.com>
diff --git a/plugins/org.eclipse.egf.core.platform/src/org/eclipse/egf/core/platform/internal/pde/BasePlatformManager.java b/plugins/org.eclipse.egf.core.platform/src/org/eclipse/egf/core/platform/internal/pde/BasePlatformManager.java
index 6f9bd8a..438347b 100644
--- a/plugins/org.eclipse.egf.core.platform/src/org/eclipse/egf/core/platform/internal/pde/BasePlatformManager.java
+++ b/plugins/org.eclipse.egf.core.platform/src/org/eclipse/egf/core/platform/internal/pde/BasePlatformManager.java
@@ -1,13 +1,20 @@
 package org.eclipse.egf.core.platform.internal.pde;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import org.eclipse.core.internal.registry.Handle;
+import org.eclipse.core.runtime.Assert;
 import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IRegistryEventListener;
 import org.eclipse.core.runtime.RegistryFactory;
 import org.eclipse.egf.common.helper.BundleHelper;
 import org.eclipse.egf.core.platform.EGFPlatformPlugin;
@@ -44,11 +51,16 @@
 		initializeRegistry();
 		PDECore.getDefault().getModelManager().addPluginModelListener(listener);
 		PDECore.getDefault().getModelManager().addExtensionDeltaListener(listener);
+		for (Map.Entry<String, Class<? extends IPlatformExtensionPoint>> entry : EGFPlatformPlugin.getPlatformExtensionPoints().entrySet()) {
+			String point = entry.getKey().trim();
+			RuntimeRegistryListener l = new RuntimeRegistryListener(point, entry.getValue());
+			RegistryFactory.getRegistry().addListener(l, point);
+		}
 
 	}
 
 	private void initializeRegistry() {
-		//runtime registry
+		// runtime registry
 		for (Map.Entry<String, Class<? extends IPlatformExtensionPoint>> entry : EGFPlatformPlugin.getPlatformExtensionPoints().entrySet()) {
 			IConfigurationElement[] elements = RegistryFactory.getRegistry().getConfigurationElementsFor(entry.getKey());
 			if (elements == null) {
@@ -59,7 +71,7 @@
 			}
 		}
 
-		//workspace registry
+		// workspace registry
 		for (IPluginModelBase base : PluginRegistry.getWorkspaceModels()) {
 			addWorkspaceElement(base);
 		}
@@ -100,7 +112,6 @@
 		return platformBundle;
 	}
 
-	//TODO WIU voir le rôle du param init 
 	private void addRuntimeElement(IConfigurationElement element, Class<? extends IPlatformExtensionPoint> clazz, boolean init) {
 		Bundle bundle = BundleHelper.getBundle(element.getDeclaringExtension().getContributor());
 		if (bundle == null || element.isValid() == false) {
@@ -144,7 +155,7 @@
 			listener.platformExtensionPointChanged(delta);
 	}
 
-	protected static void collectPlatformExtensionPoints(Map<Class<?>, Set<Object>> registry, Class<?> clazz, List<Object> collector) {
+	protected static void collectPlatformExtensionPoints(Map<Class<?>, Set<Object>> registry, Class<?> clazz, Collection<Object> collector) {
 		if (clazz != null) {
 			if (registry.get(clazz) != null) {
 				collector.addAll(registry.get(clazz));
@@ -171,4 +182,109 @@
 		}
 
 	}
+
+	private class RuntimeRegistryListener implements IRegistryEventListener {
+
+		private Class<? extends IPlatformExtensionPoint> _clazz;
+
+		public RuntimeRegistryListener(String point, Class<? extends IPlatformExtensionPoint> clazz) {
+			Assert.isNotNull(point);
+			Assert.isLegal(point.trim().length() != 0);
+			Assert.isNotNull(clazz);
+			_clazz = clazz;
+		}
+
+		public void removed(IExtension[] extensions) {
+			// Initialize a delta
+			PlatformExtensionPointDelta delta = new PlatformExtensionPointDelta();
+			// Lock PlatformManager
+			{
+				if (extensions == null) {
+					return;
+				}
+				// Process
+				for (IExtension extension : extensions) {
+					for (Iterator<IPlatformBundle> it = runtimeRegistry.values().iterator(); it.hasNext();) {
+						PlatformBundle bundle = (PlatformBundle) it.next();
+						// Analyse Removed Extension Points
+						for (IPlatformExtensionPoint extensionPoint : bundle.getPlatformExtensionPoints(_clazz)) {
+							if (originatesFrom(extension, extensionPoint.getUniqueIdentifier(), extensionPoint.getHandleId())) {
+								// Remove this ExtensionPoint from our existing
+								// model
+								if (bundle.removePlatformExtensionPoint(_clazz, extensionPoint) == false) {
+									EGFPlatformPlugin.getDefault().logError(NLS.bind("RuntimePlatformManager$RuntimeRegistryListener.removed(..) _ ''{0}'' unable to remove Extension Point from IPlatformBundle.", //$NON-NLS-1$
+											extensionPoint));
+								}
+								removeExtensionPoint(extensionPoint, _clazz, runtimeExtensionPointRegistry, delta);
+							}
+						}
+						if (bundle.isEmpty()) {
+							it.remove();
+						}
+					}
+				}
+			}
+			// Broadcast
+			if (delta.isEmpty() == false) {
+				// Notify all interested listeners
+				firePlatformExtensionPoint(delta);
+			}
+		}
+
+		protected void removeExtensionPoint(IPlatformExtensionPoint extensionPoint, Class<? extends IPlatformExtensionPoint> clazz, Map<Class<?>, Set<Object>> extensions, PlatformExtensionPointDelta delta) {
+			// remove extension point from Extension registry
+			if (extensions.get(clazz).remove(extensionPoint)) {
+				// Clean Extension registry if necessary
+				if (extensions.get(clazz).isEmpty()) {
+					extensions.remove(clazz);
+				}
+				// Update delta
+				if (delta != null) {
+					delta.storeRemovedPlatformExtensionPoint(clazz, extensionPoint);
+				}
+			}
+		}
+
+		public void added(IExtension[] extensions) {
+			// Initialize a delta
+			PlatformExtensionPointDelta delta = new PlatformExtensionPointDelta();
+			// Lock PlatformManager
+			{
+				// Process
+				for (IExtension extension : extensions) {
+					for (IConfigurationElement element : extension.getConfigurationElements()) {
+						addRuntimeElement(element, _clazz, false);
+					}
+				}
+			}
+			// Broadcast
+			if (delta.isEmpty() == false) {
+				// Notify all interested listeners
+				firePlatformExtensionPoint(delta);
+			}
+		}
+
+		public void added(IExtensionPoint[] extensionPoints) {
+			// Nothing to do
+			System.out.println();
+		}
+
+		public void removed(IExtensionPoint[] extensionPoints) {
+			// Nothing to do
+			System.out.println();
+		}
+
+		public boolean originatesFrom(IExtension extension, String uniqueIdentifier, int handleId) {
+			String id = extension.getUniqueIdentifier();
+			if (id != null) {
+				return id.equals(uniqueIdentifier);
+			}
+			if (extension instanceof Handle == false) {
+				return false;
+			}
+			return (handleId == ((Handle) extension).getId());
+		}
+
+	}
+
 }
diff --git a/plugins/org.eclipse.egf.core.platform/src/org/eclipse/egf/core/platform/internal/pde/EgfPlatformManager.java b/plugins/org.eclipse.egf.core.platform/src/org/eclipse/egf/core/platform/internal/pde/EgfPlatformManager.java
index 869ad4c..e4cc4bf 100644
--- a/plugins/org.eclipse.egf.core.platform/src/org/eclipse/egf/core/platform/internal/pde/EgfPlatformManager.java
+++ b/plugins/org.eclipse.egf.core.platform/src/org/eclipse/egf/core/platform/internal/pde/EgfPlatformManager.java
@@ -1,7 +1,9 @@
 package org.eclipse.egf.core.platform.internal.pde;
 
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 import org.eclipse.egf.common.helper.BundleHelper;
 import org.eclipse.egf.common.helper.CollectionHelper;
@@ -20,7 +22,7 @@
 	}
 
 	public <T extends IPlatformExtensionPoint> T[] getPlatformExtensionPoints(Class<T> clazz) {
-		List<Object> extensionPoints = new ArrayList<Object>();
+		Set<Object> extensionPoints = new HashSet<Object>();
 		collectPlatformExtensionPoints(workspaceExtensionPointRegistry, clazz, extensionPoints);
 		collectPlatformExtensionPoints(runtimeExtensionPointRegistry, clazz, extensionPoints);
 		return CollectionHelper.toArray(extensionPoints, clazz);
diff --git a/plugins/org.eclipse.egf.core.platform/src/org/eclipse/egf/core/platform/pde/PlatformExtensionPoint.java b/plugins/org.eclipse.egf.core.platform/src/org/eclipse/egf/core/platform/pde/PlatformExtensionPoint.java
index b0a8d11..02ee470 100644
--- a/plugins/org.eclipse.egf.core.platform/src/org/eclipse/egf/core/platform/pde/PlatformExtensionPoint.java
+++ b/plugins/org.eclipse.egf.core.platform/src/org/eclipse/egf/core/platform/pde/PlatformExtensionPoint.java
@@ -1,98 +1,92 @@
-/**

- * Copyright (c) 2009-2010 Thales Corporate Services S.A.S.

- * 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:

- * Thales Corporate Services S.A.S - initial API and implementation

- */

-package org.eclipse.egf.core.platform.pde;

-

-import org.eclipse.core.runtime.Assert;

-import org.eclipse.egf.core.platform.internal.pde.AbstractPlatformExtensionPoint;

-

-public abstract class PlatformExtensionPoint extends AbstractPlatformExtensionPoint implements IPlatformExtensionPoint, Comparable<IPlatformExtensionPoint> {

-

-    private String _id;

-

-    public PlatformExtensionPoint(IPlatformBundle bundle, String id) {

-        super(bundle);

-        Assert.isNotNull(id);

-        Assert.isLegal(id.trim().length() > 0);

-        _id = id.trim();

-    }

-

-    public PlatformExtensionPoint(IPlatformBundle bundle, String id, String uniqueIdentifier, int handleId) {

-        super(bundle, uniqueIdentifier, handleId);

-        Assert.isNotNull(id);

-        Assert.isLegal(id.trim().length() > 0);

-        _id = id.trim();

-    }

-

-    public String getId() {

-        return _id;

-    }

-

-    public String getUniqueIdentifier() {

-        return _uniqueIdentifier;

-    }

-

-    public int getHandleId() {

-        return _handleId;

-    }

-

-    public IPlatformBundle getPlatformBundle() {

-        return _platformBundle;

-    }

-

-    public int compareTo(IPlatformExtensionPoint platformExtensionPoint) {

-        return getId().compareTo(platformExtensionPoint.getId());

-    }

-

-    @Override

-    public int hashCode() {

-        final int prime = 31;

-        int result = 1;

-        result = prime * result + getPlatformBundle().hashCode();

-        result = prime * result + _id.hashCode();

-        if (_uniqueIdentifier != null) {

-            result = prime * result + _uniqueIdentifier.hashCode();

-        }

-        return result;

-    }

-

-    @Override

-    public boolean equals(Object object) {

-        if (object == null) {

-            return false;

-        }

-        if (this == object) {

-            return true;

-        }

-        if (object instanceof IPlatformExtensionPoint == false) {

-            return false;

-        }

-        IPlatformExtensionPoint platformExtensionPoint = (IPlatformExtensionPoint) object;

-        if (platformExtensionPoint.getPlatformBundle().equals(getPlatformBundle()) == false) {

-            return false;

-        }

-        if (getId().compareTo(platformExtensionPoint.getId()) != 0) {

-            return false;

-        }

-        if (getUniqueIdentifier() != null && platformExtensionPoint.getUniqueIdentifier() != null) {

-            if (getUniqueIdentifier().compareTo(platformExtensionPoint.getUniqueIdentifier()) != 0) {

-                return false;

-            }

-            return getHandleId() == platformExtensionPoint.getHandleId();

-        }

-        return true;

-    }

-

-    @Override

-    public String toString() {

-        return getId();

-    }

-

-}

+/**
+ * Copyright (c) 2009-2010 Thales Corporate Services S.A.S.
+ * 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:
+ * Thales Corporate Services S.A.S - initial API and implementation
+ */
+package org.eclipse.egf.core.platform.pde;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.egf.core.platform.internal.pde.AbstractPlatformExtensionPoint;
+import org.eclipse.emf.common.util.URI;
+
+public abstract class PlatformExtensionPoint extends AbstractPlatformExtensionPoint implements IPlatformExtensionPoint, Comparable<IPlatformExtensionPoint> {
+
+	private String _id;
+
+	public PlatformExtensionPoint(IPlatformBundle bundle, String id) {
+		super(bundle);
+		Assert.isNotNull(id);
+		Assert.isLegal(id.trim().length() > 0);
+		_id = id.trim();
+	}
+
+	public PlatformExtensionPoint(IPlatformBundle bundle, String id, String uniqueIdentifier, int handleId) {
+		super(bundle, uniqueIdentifier, handleId);
+		Assert.isNotNull(id);
+		Assert.isLegal(id.trim().length() > 0);
+		_id = id.trim();
+	}
+
+	public String getId() {
+		return _id;
+	}
+
+	public String getUniqueIdentifier() {
+		return _uniqueIdentifier;
+	}
+
+	public int getHandleId() {
+		return _handleId;
+	}
+
+	public IPlatformBundle getPlatformBundle() {
+		return _platformBundle;
+	}
+
+	public int compareTo(IPlatformExtensionPoint platformExtensionPoint) {
+		return getId().compareTo(platformExtensionPoint.getId());
+	}
+
+	@Override
+	public int hashCode() {
+		return (_platformBundle.getBundleId() + URI.decode(getId())).hashCode();
+	}
+
+	@Override
+	public boolean equals(Object object) {
+		if (object == null) {
+			return false;
+		}
+		if (this == object) {
+			return true;
+		}
+		if (!(object instanceof IPlatformExtensionPoint)) {
+			return false;
+		}
+		IPlatformExtensionPoint platformExtensionPoint = (IPlatformExtensionPoint) object;
+		if (!platformExtensionPoint.getPlatformBundle().equals(getPlatformBundle())) {
+			return false;
+		}
+		if (getId().compareTo(platformExtensionPoint.getId()) != 0) {
+			return false;
+		}
+		if (getUniqueIdentifier() != null && platformExtensionPoint.getUniqueIdentifier() != null) {
+			if (getUniqueIdentifier().compareTo(platformExtensionPoint.getUniqueIdentifier()) != 0) {
+				return false;
+			}
+			return getHandleId() == platformExtensionPoint.getHandleId();
+		}
+		return true;
+	}
+
+	@Override
+	public String toString() {
+		return getId();
+	}
+
+}
diff --git a/plugins/org.eclipse.egf.core/src/org/eclipse/egf/core/domain/EgfEditingDomainFactory.java b/plugins/org.eclipse.egf.core/src/org/eclipse/egf/core/domain/EgfEditingDomainFactory.java
index bb1d6d0..2636729 100644
--- a/plugins/org.eclipse.egf.core/src/org/eclipse/egf/core/domain/EgfEditingDomainFactory.java
+++ b/plugins/org.eclipse.egf.core/src/org/eclipse/egf/core/domain/EgfEditingDomainFactory.java
@@ -89,7 +89,7 @@
      */
     protected void configure(final TransactionalEditingDomain domain) {
         // the listener depends on UI to ask the user to solve conflict
-        new EGFWorkspaceSynchronizer(domain, TargetPlatformResourceLoadedListener.getResourceLoadedListener());
+        new EGFWorkspaceSynchronizer(domain, PlatformResourceLoadedListener.getResourceLoadedListener());
         // configure domain management
         configureResourceModificationManagement(domain);
     }
diff --git a/plugins/org.eclipse.egf.core/src/org/eclipse/egf/core/domain/PlatformResourceLoadedListener.java b/plugins/org.eclipse.egf.core/src/org/eclipse/egf/core/domain/PlatformResourceLoadedListener.java
new file mode 100644
index 0000000..796d7f0
--- /dev/null
+++ b/plugins/org.eclipse.egf.core/src/org/eclipse/egf/core/domain/PlatformResourceLoadedListener.java
@@ -0,0 +1,530 @@
+/**
+ * Copyright (c) 2009-2010 Thales Corporate Services S.A.S.
+ * 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:
+ * Thales Corporate Services S.A.S - initial API and implementation
+ */
+package org.eclipse.egf.core.domain;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.commands.operations.IOperationHistory;
+import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.core.commands.operations.ObjectUndoContext;
+import org.eclipse.egf.common.helper.URIHelper;
+import org.eclipse.egf.core.EGFCorePlugin;
+import org.eclipse.egf.core.fcore.IPlatformFcore;
+import org.eclipse.egf.core.fcore.IPlatformFcoreConstants;
+import org.eclipse.egf.core.platform.EGFPlatformPlugin;
+import org.eclipse.egf.core.platform.pde.IPlatformExtensionPointDelta;
+import org.eclipse.egf.core.platform.pde.IPlatformExtensionPointListener;
+import org.eclipse.egf.core.workspace.EGFWorkspaceSynchronizer;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.common.util.UniqueEList;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.pde.core.plugin.ModelEntry;
+import org.eclipse.pde.internal.core.IExtensionDeltaListener;
+import org.eclipse.pde.internal.core.IPluginModelListener;
+import org.eclipse.pde.internal.core.PDECore;
+import org.eclipse.pde.internal.core.PluginModelDelta;
+
+/**
+ * @author Thomas Guiu
+ * 
+ */
+public final class PlatformResourceLoadedListener implements EGFWorkspaceSynchronizer.Delegate {
+
+	private static volatile PlatformResourceLoadedListener resourceLoadedListener = new PlatformResourceLoadedListener();
+
+	private static volatile ResourceManager resourceManager = new ResourceManager();
+
+	private final WorkspaceListener listener = new WorkspaceListener();
+
+	public static ResourceManager getResourceManager() {
+		return resourceManager;
+	}
+
+	public static PlatformResourceLoadedListener getResourceLoadedListener() {
+		return resourceLoadedListener;
+	}
+
+	public static interface ResourceUser {
+
+		public Resource getResource();
+
+		public ResourceListener getListener();
+
+		public boolean isDirty();
+
+		public boolean userHasSavedResource();
+
+		public boolean resourceHasBeenExternallyChanged();
+
+		public IOperationHistory getOperationHistory();
+
+		public ObjectUndoContext getUndoContext();
+
+	}
+
+	public static interface ResourceListener {
+
+		public void resourceDeleted(final Resource resource);
+
+		public void resourceMoved(final Resource resource, URI oldURI);
+
+		public void resourceReloaded(final Resource resource);
+
+		public void externalUpdate(final Resource resource);
+
+		public void internalUpdate(final Resource resource);
+
+	}
+
+	public static class ResourceManager {
+
+		final private List<ResourceListener> listeners = new ArrayList<ResourceListener>();
+
+		final private Map<Resource, List<ResourceUser>> observers = new HashMap<Resource, List<ResourceUser>>();
+
+		protected void dispose() {
+			listeners.clear();
+			observers.clear();
+		}
+
+		public void addObserver(ResourceUser resourceUser) {
+			synchronized (PlatformResourceLoadedListener.class) {
+				Resource resource = resourceUser.getResource();
+				List<ResourceUser> list = observers.get(resource);
+				if (list == null) {
+					list = new ArrayList<ResourceUser>();
+					observers.put(resource, list);
+				}
+				list.add(resourceUser);
+				listeners.add(resourceUser.getListener());
+			}
+		}
+
+		public void removeObserver(ResourceUser resourceUser) {
+			synchronized (resourceLoadedListener) {
+				Resource resource = resourceUser.getResource();
+				List<ResourceUser> list = observers.get(resource);
+				if (list == null) {
+					return;
+				}
+				list.remove(resourceUser);
+				if (list.isEmpty()) {
+					try {
+						resource.unload();
+						observers.remove(resource);
+						if (noMoreObserver() == false) {
+							resource.load(Collections.EMPTY_MAP);
+						}
+					} catch (IOException ioe) {
+						resource.getErrors().add(new DiagnosticResourceException(resource, ioe));
+					}
+				}
+				listeners.remove(resourceUser.getListener());
+				if (noMoreObserver()) {
+					clear();
+				}
+			}
+		}
+
+		private void clear() {
+			// no editor is actually open, so let's unload all the resources
+			final TransactionalEditingDomain editingDomain = TransactionalEditingDomain.Registry.INSTANCE.getEditingDomain(EGFCorePlugin.EDITING_DOMAIN_ID);
+			try {
+				editingDomain.runExclusive(new Runnable() {
+
+					public void run() {
+						ResourceSet resourceSet = editingDomain.getResourceSet();
+						for (Iterator<Resource> it = resourceSet.getResources().iterator(); it.hasNext();) {
+							Resource resource = it.next();
+							resource.unload();
+							it.remove();
+						}
+					}
+				});
+				if (EGFCorePlugin.getDefault().isDebugging()) {
+					EGFPlatformPlugin.getDefault().logInfo(NLS.bind("''{0}'' _ clear", EGFCorePlugin.EDITING_DOMAIN_ID)); //$NON-NLS-1$
+				}
+			} catch (InterruptedException e) {
+				EGFCorePlugin.getDefault().logError(e);
+			}
+		}
+
+		private boolean noMoreObserver() {
+			for (List<ResourceUser> users : observers.values()) {
+				if (users.isEmpty() == false) {
+					return false;
+				}
+			}
+			return true;
+		}
+
+		public void removeResource(Resource resource) {
+			if (resource == null) {
+				throw new IllegalArgumentException();
+			}
+			synchronized (resourceLoadedListener) {
+				boolean isDirty = false;
+				// Check whether or not we are editing the current resource
+				List<ResourceUser> users = observers.get(resource);
+				if (users != null) {
+					for (ResourceUser user : users) {
+						// This state is propagated, the first user is enough to
+						// check this state
+						isDirty = user.isDirty();
+						break;
+					}
+				}
+				// Notify, use an iterator as a closing editor always remove its
+				// listener
+				// This we avoid any concurrent modification exception
+				for (Iterator<ResourceListener> iterator = listeners.iterator(); iterator.hasNext();) {
+					ResourceListener resourceListener = iterator.next();
+					resourceListener.resourceDeleted(resource);
+				}
+				// Non dirty editors should close themselves while editing a
+				// deleted resource if any
+				if (isDirty == false) {
+					resource.unload();
+				}
+			}
+		}
+
+		public void reloadResource(Resource resource) {
+			if (resource == null) {
+				throw new IllegalArgumentException();
+			}
+			synchronized (resourceLoadedListener) {
+				try {
+					resource.unload();
+					resource.load(Collections.EMPTY_MAP);
+				} catch (IOException ioe) {
+					resource.getErrors().add(new DiagnosticResourceException(resource, ioe));
+				}
+				for (Iterator<ResourceListener> iterator = listeners.iterator(); iterator.hasNext();) {
+					ResourceListener resourceListener = iterator.next();
+					resourceListener.resourceReloaded(resource);
+				}
+			}
+		}
+
+		public void movedResource(Resource movedResource, URI newURI) {
+			if (newURI == null) {
+				throw new IllegalArgumentException();
+			}
+			final TransactionalEditingDomain editingDomain = TransactionalEditingDomain.Registry.INSTANCE.getEditingDomain(EGFCorePlugin.EDITING_DOMAIN_ID);
+			synchronized (resourceLoadedListener) {
+				ResourceSet resourceSet = editingDomain.getResourceSet();
+				Resource resource = resourceSet.getResource(newURI, false);
+				// Resource who can't open a physical resource raise exception
+				// but are loaded
+				// in the resource set, its flag is also set to isLoaded
+				// we need to unload it otherwise our resource set will be messy
+				// (two resources with the same URI)
+				if (resource != null && resource.getContents().size() == 0 && resource.getErrors().isEmpty() == false) {
+					resource.unload();
+					resourceSet.getResources().remove(resource);
+					if (EGFCorePlugin.getDefault().isDebugging()) {
+						EGFPlatformPlugin.getDefault().logInfo(NLS.bind("TargetPlatformResourceLoadedListener$ResourceManager.movedResource(...) - discard loaded empty resource with errors ''{0}''", //$NON-NLS-1$
+								URIHelper.toString(newURI)));
+					}
+					// Load it in our resource set
+					movedResource = editingDomain.getResourceSet().getResource(newURI, true);
+				} else {
+					if (movedResource != null) {
+						movedResource.setURI(newURI);
+					}
+				}
+				if (movedResource != null) {
+					URI oldURI = movedResource.getURI();
+					for (Iterator<ResourceListener> iterator = listeners.iterator(); iterator.hasNext();) {
+						ResourceListener resourceListener = iterator.next();
+						resourceListener.resourceMoved(movedResource, oldURI);
+					}
+				}
+			}
+		}
+
+		public boolean resourceHasBeenExternallyChanged(Resource resource) {
+			if (resource == null) {
+				throw new IllegalArgumentException();
+			}
+			synchronized (resourceLoadedListener) {
+				List<ResourceUser> users = observers.get(resource);
+				if (users == null) {
+					return false;
+				}
+				boolean resourceHasBeenExternallyChanged = false;
+				// This state is propagated, the first user is enough to check
+				// this state
+				for (ResourceUser user : users) {
+					resourceHasBeenExternallyChanged = user.resourceHasBeenExternallyChanged();
+					break;
+				}
+				return resourceHasBeenExternallyChanged;
+			}
+		}
+
+		public void populateUndoContext(IOperationHistory operationHistory, ObjectUndoContext undoContext, Resource resource) {
+			if (resource == null || undoContext == null) {
+				throw new IllegalArgumentException();
+			}
+			synchronized (resourceLoadedListener) {
+				List<ResourceUser> users = observers.get(resource);
+				if (users == null) {
+					return;
+				}
+				// Operation History is propagated, the first user is enough to
+				// retrieve it
+				ObjectUndoContext innerUndoContext = null;
+				for (ResourceUser user : users) {
+					if (user.getUndoContext() != undoContext) {
+						innerUndoContext = user.getUndoContext();
+						break;
+					}
+				}
+				// Populate
+				if (innerUndoContext != null) {
+					for (IUndoableOperation operation : operationHistory.getUndoHistory(innerUndoContext)) {
+						operation.addContext(undoContext);
+					}
+					for (IUndoableOperation operation : operationHistory.getRedoHistory(innerUndoContext)) {
+						operation.addContext(undoContext);
+					}
+				}
+			}
+		}
+
+	}
+
+	/**
+	 * This listens for platform changes.
+	 */
+	protected IPlatformExtensionPointListener platformListener = new IPlatformExtensionPointListener() {
+
+		public void platformExtensionPointChanged(IPlatformExtensionPointDelta delta) {
+
+			synchronized (PlatformResourceLoadedListener.this) {
+
+				TransactionalEditingDomain editingDomain = getEditingDomain();
+
+				List<Resource> deltaChangedFcores = new UniqueEList<Resource>();
+
+				Map<Resource, IPlatformFcore> deltaRemovedFcores = new HashMap<Resource, IPlatformFcore>();
+
+				// Check if removed platform fcores are applicable
+				for (IPlatformFcore fcore : delta.getRemovedPlatformExtensionPoints(IPlatformFcore.class)) {
+					Resource resource = editingDomain.getResourceSet().getResource(fcore.getURI(), false);
+					if (resource == null) {
+						continue;
+					}
+					deltaRemovedFcores.put(resource, fcore);
+				}
+
+				// Check if added platform fcores are applicable
+				// if a removed platform fcore is also detected it means a
+				// changed resource
+				// eg: changed means target versus workspace fcore
+				for (IPlatformFcore fcore : delta.getAddedPlatformExtensionPoints(IPlatformFcore.class)) {
+					Resource resource = editingDomain.getResourceSet().getResource(fcore.getURI(), false);
+					if (resource == null) {
+						continue;
+					}
+					// Resource who can't open a physical resource raise
+					// exception but are loaded in the resource set
+					// we need to unload it to get a chance to load it again
+					if (resource.getContents().size() == 0 && resource.getErrors().isEmpty() == false) {
+						// start substitution removed resource if applicable
+						IPlatformFcore deletedFcore = deltaRemovedFcores.get(resource);
+						if (deletedFcore != null) {
+							deltaRemovedFcores.remove(resource);
+						}
+						// Remove previous on error resource
+						resource.unload();
+						resource.getResourceSet().getResources().remove(resource);
+						if (EGFCorePlugin.getDefault().isDebugging()) {
+							EGFPlatformPlugin.getDefault().logInfo(NLS.bind("TargetPlatformResourceLoadedListener.platformExtensionPointChanged(...) - discard loaded empty resource with errors ''{0}''", //$NON-NLS-1$
+									fcore.toString()));
+						}
+						// Load it in our resource set, beware the URIConverter
+						// should be updated accordingly
+						resource = editingDomain.getResourceSet().getResource(fcore.getURI(), true);
+						if (resource == null) {
+							continue;
+						}
+						// end substitution removed resource if applicable
+						if (deletedFcore != null) {
+							deltaRemovedFcores.put(resource, deletedFcore);
+						}
+					}
+					if (deltaRemovedFcores.remove(resource) != null) {
+						deltaChangedFcores.add(resource);
+					}
+				}
+
+				// Process Removed Fcores
+				if (deltaRemovedFcores.isEmpty() == false) {
+					for (Resource resource : deltaRemovedFcores.keySet()) {
+						getResourceManager().removeResource(resource);
+					}
+				}
+
+				// Target and workspace update, this is not detected by other
+				// listeners
+				// This is safe to do it here
+				if (deltaChangedFcores.isEmpty() == false) {
+					for (Resource resource : deltaChangedFcores) {
+						getResourceManager().reloadResource(resource);
+					}
+				}
+
+			}
+
+		}
+
+	};
+
+	private PlatformResourceLoadedListener() {
+		// TODO WIU est ce bien utile ?
+		// EGFPlatformPlugin.getPlatformManager().addPlatformExtensionPointListener(_platformListener);
+		PDECore.getDefault().getModelManager().addPluginModelListener(listener);
+	}
+
+	private TransactionalEditingDomain getEditingDomain() {
+		return TransactionalEditingDomain.Registry.INSTANCE.getEditingDomain(EGFCorePlugin.EDITING_DOMAIN_ID);
+	}
+
+	public synchronized boolean handleResourcePersisted(Resource resource) {
+		for (Iterator<ResourceListener> iterator = getResourceManager().listeners.iterator(); iterator.hasNext();) {
+			ResourceListener resourceListener = iterator.next();
+			resourceListener.internalUpdate(resource);
+		}
+		return true;
+	}
+
+	public synchronized boolean handleResourceMoved(Resource movedResource, URI newURI) {
+		// check whether or not we face a moved fcore to non fcore
+		boolean isFcore = IPlatformFcoreConstants.FCORE_FILE_EXTENSION.equals(movedResource.getURI().fileExtension());
+		boolean isMovedToFcore = IPlatformFcoreConstants.FCORE_FILE_EXTENSION.equals(newURI.fileExtension());
+		// Not sure here is we need to let process non fcore file
+		if ((isFcore && isMovedToFcore) || isFcore == false) {
+			// Moved resource are always in non dirty editors
+			// when moving a dirty resource the platform request to save the
+			// resource
+			// if not saved the resource is not moved
+			Resource resource = getEditingDomain().getResourceSet().getResource(movedResource.getURI(), false);
+			if (resource != null || getEditingDomain().getResourceSet().getResource(newURI, false) != null) {
+				// Notify moved resource
+				getResourceManager().movedResource(resource, newURI);
+			}
+		} else {
+			// an fcore has moved to a non fcore resource, process a remove
+			return handleResourceDeleted(movedResource);
+		}
+		return true;
+	}
+
+	public synchronized boolean handleResourceDeleted(Resource deletedResource) {
+		IPlatformFcore fcore = EGFCorePlugin.getPlatformFcore(deletedResource);
+		// Either a non Fcore resource or an already processed deleted fcore
+		// from _platformListener
+		if (fcore == null) {
+			// _platformListener has been called first, Process workspace
+			// removed fcores detected in _platformListener
+			getResourceManager().removeResource(deletedResource);
+		}
+		return true;
+	}
+
+	public synchronized boolean handleResourceChanged(final Resource changedResource) {
+		List<ResourceUser> users = getResourceManager().observers.get(changedResource);
+		// No one edit this resource, process a standard reload
+		if (users == null) {
+			getResourceManager().reloadResource(changedResource);
+			return true;
+		}
+		// Check the state of this edited resource
+		boolean hasSavedResource = false;
+		boolean isDirty = false;
+		for (ResourceUser user : users) {
+			// We need to deeply analyze users as anyone could have saved this
+			// resource if any
+			hasSavedResource |= user.userHasSavedResource();
+			// This state is propagated, the first user is enough to check this
+			// state
+			isDirty |= user.isDirty();
+		}
+		// Nothing to do, we just reload the resource
+		if (hasSavedResource == false && isDirty == false) {
+			getResourceManager().reloadResource(changedResource);
+			return true;
+		}
+		// Dirty resource
+		if (hasSavedResource == false && isDirty) { // Give a chance to cancel
+													// dirty editors while
+													// reloading external
+													// changed resource
+			for (Iterator<ResourceListener> iterator = getResourceManager().listeners.iterator(); iterator.hasNext();) {
+				ResourceListener resourceListener = iterator.next();
+				resourceListener.externalUpdate(changedResource);
+			}
+			return true;
+		}
+		// Non dirty resource
+		for (Iterator<ResourceListener> iterator = getResourceManager().listeners.iterator(); iterator.hasNext();) {
+			ResourceListener resourceListener = iterator.next();
+			resourceListener.internalUpdate(changedResource);
+		}
+		return true;
+	}
+
+	public synchronized void dispose() {
+		PDECore.getDefault().getModelManager().removePluginModelListener(listener);
+		EGFPlatformPlugin.getPlatformManager().removePlatformExtensionPointListener(platformListener);
+		getResourceManager().dispose();
+		resourceManager = null;
+	}
+
+	public class WorkspaceListener implements IPluginModelListener {
+
+		public void modelsChanged(PluginModelDelta delta) {
+			TransactionalEditingDomain editingDomain = TransactionalEditingDomain.Registry.INSTANCE.getEditingDomain(EGFCorePlugin.EDITING_DOMAIN_ID);
+			for (ModelEntry entry : delta.getChangedEntries()) {
+				String id = entry.getId();
+				for (Resource r : editingDomain.getResourceSet().getResources()) {
+					if (id.equals(r.getURI().segment(1)))
+						reloadResource(r);
+				}
+			}
+		}
+
+		private void reloadResource(Resource r) {
+			System.out.println("reload " + r.getURI());
+			r.unload();
+			try {
+				r.load(Collections.EMPTY_MAP);
+			} catch (IOException e) {
+				EGFPlatformPlugin.getDefault().logError(e);
+			}
+
+		}
+
+	}
+
+}
diff --git a/plugins/org.eclipse.egf.core/src/org/eclipse/egf/core/domain/TargetPlatformResourceLoadedListener.java b/plugins/org.eclipse.egf.core/src/org/eclipse/egf/core/domain/TargetPlatformResourceLoadedListener.java
deleted file mode 100644
index 90fcdc0..0000000
--- a/plugins/org.eclipse.egf.core/src/org/eclipse/egf/core/domain/TargetPlatformResourceLoadedListener.java
+++ /dev/null
@@ -1,519 +0,0 @@
-/**
- * Copyright (c) 2009-2010 Thales Corporate Services S.A.S.
- * 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:
- * Thales Corporate Services S.A.S - initial API and implementation
- */
-package org.eclipse.egf.core.domain;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.commands.operations.IOperationHistory;
-import org.eclipse.core.commands.operations.IUndoableOperation;
-import org.eclipse.core.commands.operations.ObjectUndoContext;
-import org.eclipse.egf.common.helper.URIHelper;
-import org.eclipse.egf.core.EGFCorePlugin;
-import org.eclipse.egf.core.fcore.IPlatformFcore;
-import org.eclipse.egf.core.fcore.IPlatformFcoreConstants;
-import org.eclipse.egf.core.platform.EGFPlatformPlugin;
-import org.eclipse.egf.core.platform.pde.IPlatformExtensionPointDelta;
-import org.eclipse.egf.core.platform.pde.IPlatformExtensionPointListener;
-import org.eclipse.egf.core.workspace.EGFWorkspaceSynchronizer;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.common.util.UniqueEList;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.osgi.util.NLS;
-
-/**
- * @author Thomas Guiu
- * 
- */
-public final class TargetPlatformResourceLoadedListener implements EGFWorkspaceSynchronizer.Delegate {
-
-	private static volatile TargetPlatformResourceLoadedListener __resourceLoadedListener;
-
-	private static volatile ResourceManager __resourceManager;
-
-	// Use a lock object, this will prevent us against
-	// a lock against the ResourceEventManager instance
-	private static Object __lockResourceManager = new Object();
-
-	public static ResourceManager getResourceManager() {
-		if (__resourceManager == null) {
-			synchronized (__lockResourceManager) {
-				if (__resourceManager == null) {
-					__resourceManager = new ResourceManager();
-				}
-			}
-		}
-		return __resourceManager;
-	}
-
-	// Use a lock object, this will prevent us against
-	// a lock against the EGFResourceLoadedListener instance
-	private static Object __lockResourceLoadedListener = new Object();
-
-	public static TargetPlatformResourceLoadedListener getResourceLoadedListener() {
-		if (__resourceLoadedListener == null) {
-			synchronized (__lockResourceLoadedListener) {
-				if (__resourceLoadedListener == null) {
-					__resourceLoadedListener = new TargetPlatformResourceLoadedListener();
-				}
-			}
-		}
-		return __resourceLoadedListener;
-	}
-
-	public static interface ResourceUser {
-
-		public Resource getResource();
-
-		public ResourceListener getListener();
-
-		public boolean isDirty();
-
-		public boolean userHasSavedResource();
-
-		public boolean resourceHasBeenExternallyChanged();
-
-		public IOperationHistory getOperationHistory();
-
-		public ObjectUndoContext getUndoContext();
-
-	}
-
-	public static interface ResourceListener {
-
-		public void resourceDeleted(final Resource resource);
-
-		public void resourceMoved(final Resource resource, URI oldURI);
-
-		public void resourceReloaded(final Resource resource);
-
-		public void externalUpdate(final Resource resource);
-
-		public void internalUpdate(final Resource resource);
-
-	}
-
-	public static class ResourceManager {
-
-		final private List<ResourceListener> _listeners = new ArrayList<ResourceListener>();
-
-		final private Map<Resource, List<ResourceUser>> _observers = new HashMap<Resource, List<ResourceUser>>();
-
-		protected void dispose() {
-			_listeners.clear();
-			_observers.clear();
-		}
-
-		public void addObserver(ResourceUser resourceUser) {
-			// Lock __resourceEventManager
-			synchronized (__lockResourceManager) {
-				Resource resource = resourceUser.getResource();
-				List<ResourceUser> list = _observers.get(resource);
-				if (list == null) {
-					list = new ArrayList<ResourceUser>();
-					_observers.put(resource, list);
-				}
-				list.add(resourceUser);
-				_listeners.add(resourceUser.getListener());
-			}
-		}
-
-		public void removeObserver(ResourceUser resourceUser) {
-			// Lock __resourceEventManager
-			synchronized (__lockResourceManager) {
-				Resource resource = resourceUser.getResource();
-				List<ResourceUser> list = _observers.get(resource);
-				if (list == null) {
-					return;
-				}
-				list.remove(resourceUser);
-				if (list.isEmpty()) {
-					try {
-						resource.unload();
-						_observers.remove(resource);
-						if (noMoreObserver() == false) {
-							resource.load(Collections.EMPTY_MAP);
-						}
-					} catch (IOException ioe) {
-						resource.getErrors().add(new DiagnosticResourceException(resource, ioe));
-					}
-				}
-				_listeners.remove(resourceUser.getListener());
-				if (noMoreObserver()) {
-					clear();
-				}
-			}
-		}
-
-		private void clear() {
-			// no editor is actually open, so let's unload all the resources
-			final TransactionalEditingDomain editingDomain = TransactionalEditingDomain.Registry.INSTANCE.getEditingDomain(EGFCorePlugin.EDITING_DOMAIN_ID);
-			try {
-				editingDomain.runExclusive(new Runnable() {
-
-					public void run() {
-						ResourceSet resourceSet = editingDomain.getResourceSet();
-						for (Iterator<Resource> it = resourceSet.getResources().iterator(); it.hasNext();) {
-							Resource resource = it.next();
-							resource.unload();
-							it.remove();
-						}
-					}
-				});
-				if (EGFCorePlugin.getDefault().isDebugging()) {
-					EGFPlatformPlugin.getDefault().logInfo(NLS.bind("''{0}'' _ clear", EGFCorePlugin.EDITING_DOMAIN_ID)); //$NON-NLS-1$           
-				}
-			} catch (InterruptedException e) {
-				EGFCorePlugin.getDefault().logError(e);
-			}
-		}
-
-		private boolean noMoreObserver() {
-			for (List<ResourceUser> users : _observers.values()) {
-				if (users.isEmpty() == false) {
-					return false;
-				}
-			}
-			return true;
-		}
-
-		public void removeResource(Resource resource) {
-			if (resource == null) {
-				throw new IllegalArgumentException();
-			}
-			// Lock __resourceEventManager
-			synchronized (__lockResourceManager) {
-				boolean isDirty = false;
-				// Check whether or not we are editing the current resource
-				List<ResourceUser> users = _observers.get(resource);
-				if (users != null) {
-					for (ResourceUser user : users) {
-						// This state is propagated, the first user is enough to check this state
-						isDirty = user.isDirty();
-						break;
-					}
-				}
-				// Notify, use an iterator as a closing editor always remove its listener
-				// This we avoid any concurrent modification exception
-				for (Iterator<ResourceListener> iterator = _listeners.iterator(); iterator.hasNext();) {
-					ResourceListener resourceListener = iterator.next();
-					resourceListener.resourceDeleted(resource);
-				}
-				// Non dirty editors should close themselves while editing a deleted resource if any
-				if (isDirty == false) {
-					resource.unload();
-				}
-			}
-		}
-
-		public void reloadResource(Resource resource) {
-			if (resource == null) {
-				throw new IllegalArgumentException();
-			}
-			// Lock __resourceEventManager
-			synchronized (__lockResourceManager) {
-				try {
-					resource.unload();
-					resource.load(Collections.EMPTY_MAP);
-				} catch (IOException ioe) {
-					resource.getErrors().add(new DiagnosticResourceException(resource, ioe));
-				}
-				for (Iterator<ResourceListener> iterator = _listeners.iterator(); iterator.hasNext();) {
-					ResourceListener resourceListener = iterator.next();
-					resourceListener.resourceReloaded(resource);
-				}
-			}
-		}
-
-		public void movedResource(Resource movedResource, URI newURI) {
-			if (newURI == null) {
-				throw new IllegalArgumentException();
-			}
-			final TransactionalEditingDomain editingDomain = TransactionalEditingDomain.Registry.INSTANCE.getEditingDomain(EGFCorePlugin.EDITING_DOMAIN_ID);
-			// Lock __resourceEventManager
-			synchronized (__lockResourceManager) {
-				ResourceSet resourceSet = editingDomain.getResourceSet();
-				Resource resource = resourceSet.getResource(newURI, false);
-				// Resource who can't open a physical resource raise exception but are loaded
-				// in the resource set, its flag is also set to isLoaded
-				// we need to unload it otherwise our resource set will be messy (two resources with the same URI)
-				if (resource != null && resource.getContents().size() == 0 && resource.getErrors().isEmpty() == false) {
-					resource.unload();
-					resourceSet.getResources().remove(resource);
-					if (EGFCorePlugin.getDefault().isDebugging()) {
-						EGFPlatformPlugin.getDefault().logInfo(NLS.bind("TargetPlatformResourceLoadedListener$ResourceManager.movedResource(...) - discard loaded empty resource with errors ''{0}''", URIHelper.toString(newURI))); //$NON-NLS-1$           
-					}
-					// Load it in our resource set
-					movedResource = editingDomain.getResourceSet().getResource(newURI, true);
-				} else {
-					if (movedResource != null) {
-						movedResource.setURI(newURI);
-					}
-				}
-				if (movedResource != null) {
-					URI oldURI = movedResource.getURI();
-					for (Iterator<ResourceListener> iterator = _listeners.iterator(); iterator.hasNext();) {
-						ResourceListener resourceListener = iterator.next();
-						resourceListener.resourceMoved(movedResource, oldURI);
-					}
-				}
-			}
-		}
-
-		public boolean resourceHasBeenExternallyChanged(Resource resource) {
-			if (resource == null) {
-				throw new IllegalArgumentException();
-			}
-			// Lock __resourceEventManager
-			synchronized (__lockResourceManager) {
-				List<ResourceUser> users = _observers.get(resource);
-				if (users == null) {
-					return false;
-				}
-				boolean resourceHasBeenExternallyChanged = false;
-				// This state is propagated, the first user is enough to check this state
-				for (ResourceUser user : users) {
-					resourceHasBeenExternallyChanged = user.resourceHasBeenExternallyChanged();
-					break;
-				}
-				return resourceHasBeenExternallyChanged;
-			}
-		}
-
-		public void populateUndoContext(IOperationHistory operationHistory, ObjectUndoContext undoContext, Resource resource) {
-			if (resource == null || undoContext == null) {
-				throw new IllegalArgumentException();
-			}
-			// Lock __resourceEventManager
-			synchronized (__lockResourceManager) {
-				List<ResourceUser> users = _observers.get(resource);
-				if (users == null) {
-					return;
-				}
-				// Operation History is propagated, the first user is enough to retrieve it
-				ObjectUndoContext innerUndoContext = null;
-				for (ResourceUser user : users) {
-					if (user.getUndoContext() != undoContext) {
-						innerUndoContext = user.getUndoContext();
-						break;
-					}
-				}
-				// Populate
-				if (innerUndoContext != null) {
-					for (IUndoableOperation operation : operationHistory.getUndoHistory(innerUndoContext)) {
-						operation.addContext(undoContext);
-					}
-					for (IUndoableOperation operation : operationHistory.getRedoHistory(innerUndoContext)) {
-						operation.addContext(undoContext);
-					}
-				}
-			}
-		}
-
-	}
-
-	/**
-	 * This listens for platform changes.
-	 */
-	protected IPlatformExtensionPointListener _platformListener = new IPlatformExtensionPointListener() {
-
-		public void platformExtensionPointChanged(IPlatformExtensionPointDelta delta) {
-
-			synchronized (__lockResourceLoadedListener) {
-
-				TransactionalEditingDomain editingDomain = TransactionalEditingDomain.Registry.INSTANCE.getEditingDomain(EGFCorePlugin.EDITING_DOMAIN_ID);
-
-				List<Resource> deltaChangedFcores = new UniqueEList<Resource>();
-
-				Map<Resource, IPlatformFcore> deltaRemovedFcores = new HashMap<Resource, IPlatformFcore>();
-
-				// Check if removed platform fcores are applicable
-				for (IPlatformFcore fcore : delta.getRemovedPlatformExtensionPoints(IPlatformFcore.class)) {
-					Resource resource = editingDomain.getResourceSet().getResource(fcore.getURI(), false);
-					if (resource == null) {
-						continue;
-					}
-					deltaRemovedFcores.put(resource, fcore);
-				}
-
-				// Check if added platform fcores are applicable
-				// if a removed platform fcore is also detected it means a changed resource
-				// eg: changed means target versus workspace fcore
-				for (IPlatformFcore fcore : delta.getAddedPlatformExtensionPoints(IPlatformFcore.class)) {
-					Resource resource = editingDomain.getResourceSet().getResource(fcore.getURI(), false);
-					if (resource == null) {
-						continue;
-					}
-					// Resource who can't open a physical resource raise exception but are loaded in the resource set
-					// we need to unload it to get a chance to load it again
-					if (resource.getContents().size() == 0 && resource.getErrors().isEmpty() == false) {
-						// start substitution removed resource if applicable
-						IPlatformFcore deletedFcore = deltaRemovedFcores.get(resource);
-						if (deletedFcore != null) {
-							deltaRemovedFcores.remove(resource);
-						}
-						// Remove previous on error resource
-						resource.unload();
-						resource.getResourceSet().getResources().remove(resource);
-						if (EGFCorePlugin.getDefault().isDebugging()) {
-							EGFPlatformPlugin.getDefault().logInfo(NLS.bind("TargetPlatformResourceLoadedListener.platformExtensionPointChanged(...) - discard loaded empty resource with errors ''{0}''", fcore.toString())); //$NON-NLS-1$           
-						}
-						// Load it in our resource set, beware the URIConverter should be updated accordingly
-						resource = editingDomain.getResourceSet().getResource(fcore.getURI(), true);
-						if (resource == null) {
-							continue;
-						}
-						// end substitution removed resource if applicable
-						if (deletedFcore != null) {
-							deltaRemovedFcores.put(resource, deletedFcore);
-						}
-					}
-					if (deltaRemovedFcores.remove(resource) != null) {
-						deltaChangedFcores.add(resource);
-					}
-				}
-
-				// Process Removed Fcores
-				if (deltaRemovedFcores.isEmpty() == false) {
-					for (Resource resource : deltaRemovedFcores.keySet()) {
-						getResourceManager().removeResource(resource);
-					}
-				}
-
-				// Target and workspace update, this is not detected by other listeners
-				// This is safe to do it here
-				if (deltaChangedFcores.isEmpty() == false) {
-					for (Resource resource : deltaChangedFcores) {
-						getResourceManager().reloadResource(resource);
-					}
-				}
-
-			}
-
-		}
-
-	};
-
-	private TransactionalEditingDomain _editingDomain;
-
-	private TargetPlatformResourceLoadedListener() {
-		EGFPlatformPlugin.getPlatformManager().addPlatformExtensionPointListener(_platformListener);
-	}
-
-	public TransactionalEditingDomain getEditingDomain() {
-		synchronized (__lockResourceLoadedListener) {
-			if (_editingDomain == null) {
-				_editingDomain = TransactionalEditingDomain.Registry.INSTANCE.getEditingDomain(EGFCorePlugin.EDITING_DOMAIN_ID);
-			}
-			return _editingDomain;
-		}
-	}
-
-	public boolean handleResourcePersisted(Resource resource) {
-		synchronized (__lockResourceLoadedListener) {
-			for (Iterator<ResourceListener> iterator = getResourceManager()._listeners.iterator(); iterator.hasNext();) {
-				ResourceListener resourceListener = iterator.next();
-				resourceListener.internalUpdate(resource);
-			}
-			return true;
-		}
-	}
-
-	public boolean handleResourceMoved(Resource movedResource, URI newURI) {
-		synchronized (__lockResourceLoadedListener) {
-			// check whether or not we face a moved fcore to non fcore
-			boolean isFcore = IPlatformFcoreConstants.FCORE_FILE_EXTENSION.equals(movedResource.getURI().fileExtension());
-			boolean isMovedToFcore = IPlatformFcoreConstants.FCORE_FILE_EXTENSION.equals(newURI.fileExtension());
-			// Not sure here is we need to let process non fcore file
-			if ((isFcore && isMovedToFcore) || isFcore == false) {
-				// Moved resource are always in non dirty editors
-				// when moving a dirty resource the platform request to save the resource
-				// if not saved the resource is not moved
-				Resource resource = getEditingDomain().getResourceSet().getResource(movedResource.getURI(), false);
-				if (resource != null || getEditingDomain().getResourceSet().getResource(newURI, false) != null) {
-					// Notify moved resource
-					getResourceManager().movedResource(resource, newURI);
-				}
-			} else {
-				// an fcore has moved to a non fcore resource, process a remove
-				return handleResourceDeleted(movedResource);
-			}
-			return true;
-		}
-	}
-
-	public boolean handleResourceDeleted(Resource deletedResource) {
-		synchronized (__lockResourceLoadedListener) {
-			IPlatformFcore fcore = EGFCorePlugin.getPlatformFcore(deletedResource);
-			// Either a non Fcore resource or an already processed deleted fcore from _platformListener
-			if (fcore == null) {
-				// _platformListener has been called first, Process workspace removed fcores detected in _platformListener
-				getResourceManager().removeResource(deletedResource);
-			}
-			return true;
-		}
-	}
-
-	public boolean handleResourceChanged(final Resource changedResource) {
-		synchronized (__lockResourceLoadedListener) {
-			List<ResourceUser> users = getResourceManager()._observers.get(changedResource);
-			// No one edit this resource, process a standard reload
-			if (users == null) {
-				getResourceManager().reloadResource(changedResource);
-				return true;
-			}
-			// Check the state of this edited resource
-			boolean hasSavedResource = false;
-			boolean isDirty = false;
-			for (ResourceUser user : users) {
-				// We need to deeply analyze users as anyone could have saved this resource if any
-				hasSavedResource |= user.userHasSavedResource();
-				// This state is propagated, the first user is enough to check this state
-				isDirty |= user.isDirty();
-			}
-			// Nothing to do, we just reload the resource
-			if (hasSavedResource == false && isDirty == false) {
-				getResourceManager().reloadResource(changedResource);
-				return true;
-			}
-			// Dirty resource
-			if (hasSavedResource == false && isDirty) { // Give a chance to cancel dirty editors while reloading external changed resource
-				for (Iterator<ResourceListener> iterator = getResourceManager()._listeners.iterator(); iterator.hasNext();) {
-					ResourceListener resourceListener = iterator.next();
-					resourceListener.externalUpdate(changedResource);
-				}
-				return true;
-			}
-			// Non dirty resource
-			for (Iterator<ResourceListener> iterator = getResourceManager()._listeners.iterator(); iterator.hasNext();) {
-				ResourceListener resourceListener = iterator.next();
-				resourceListener.internalUpdate(changedResource);
-			}
-			return true;
-		}
-	}
-
-	public void dispose() {
-		synchronized (__lockResourceLoadedListener) {
-			EGFPlatformPlugin.getPlatformManager().removePlatformExtensionPointListener(_platformListener);
-			getResourceManager().dispose();
-			__resourceManager = null;
-		}
-	}
-
-}
diff --git a/plugins/org.eclipse.egf.core/src/org/eclipse/egf/core/epackage/ProxyTargetPlatformFactory.java b/plugins/org.eclipse.egf.core/src/org/eclipse/egf/core/epackage/ProxyTargetPlatformFactory.java
index a16eda2..b8416f7 100644
--- a/plugins/org.eclipse.egf.core/src/org/eclipse/egf/core/epackage/ProxyTargetPlatformFactory.java
+++ b/plugins/org.eclipse.egf.core/src/org/eclipse/egf/core/epackage/ProxyTargetPlatformFactory.java
@@ -1,79 +1,79 @@
-/**

- *  Copyright (c) 2009-2010 Thales Corporate Services S.A.S.

- *  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:

- *      Thales Corporate Services S.A.S - initial API and implementation

- */

-package org.eclipse.egf.core.epackage;

-

-import org.eclipse.egf.core.EGFCorePlugin;

-import org.eclipse.egf.core.genmodel.IPlatformGenModel;

-import org.eclipse.emf.common.util.URI;

-

-/**

- * @author Xavier Maysonnave

- * 

- */

-public class ProxyTargetPlatformFactory {

-

-    public ProxyTargetPlatformFactory() {

-        // Nothing to do

-    }

-

-    protected static URI getEPackageNsURI(URI uri) {

-        if (uri == null) {

-            return null;

-        }

-        String innerUri = uri.toString();

-        if (innerUri.contains("#//") == false) { //$NON-NLS-1$

-            return uri;

-        }

-        return URI.createURI(innerUri.substring(0, innerUri.indexOf("#//"))); //$NON-NLS-1$

-    }

-

-    public IProxyEObject getIProxyEObject(URI uri) {

-        IProxyERoot proxy = getIProxyERoot(uri);

-        if (proxy != null) {

-            return proxy.getIProxyEObject(uri);

-        }

-        return null;

-    }

-

-    public IProxyEPackage getIProxyEPackage(URI uri) {

-        IProxyERoot proxy = getIProxyERoot(uri);

-        if (proxy != null && proxy.getChildren().length == 1) {

-            return proxy.getChildren()[0];

-        }

-        return null;

-    }

-

-    public IProxyERoot getIProxyERoot(URI uri) {

-        // Ignore

-        if (uri == null) {

-            return null;

-        }

-        // Locate an IPlatformGenModel

-        URI nsURI = getEPackageNsURI(uri);

-        IPlatformGenModel packageGenModel = EGFCorePlugin.getWorspacePlatformGenModel(nsURI);

-        // Not found

-        if (packageGenModel == null) {

-            return null;

-        }

-        // Inner ePackage processing if applicable

-        URI innerNsURI = packageGenModel.getEPackageNsURI(uri);

-        if (innerNsURI != null) {

-            packageGenModel = EGFCorePlugin.getWorspacePlatformGenModel(innerNsURI);

-        }

-        // Not found

-        if (packageGenModel == null) {

-            return null;

-        }

-        // Build an ERootWrapper

-        return packageGenModel.getIProxyERoot();

-    }

-

-}

+/**
+ *  Copyright (c) 2009-2010 Thales Corporate Services S.A.S.
+ *  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:
+ *      Thales Corporate Services S.A.S - initial API and implementation
+ */
+package org.eclipse.egf.core.epackage;
+
+import org.eclipse.egf.core.EGFCorePlugin;
+import org.eclipse.egf.core.genmodel.IPlatformGenModel;
+import org.eclipse.emf.common.util.URI;
+
+/**
+ * @author Xavier Maysonnave
+ * 
+ */
+public class ProxyTargetPlatformFactory {
+
+	public ProxyTargetPlatformFactory() {
+		// Nothing to do
+	}
+
+	protected static URI getEPackageNsURI(URI uri) {
+		if (uri == null) {
+			return null;
+		}
+		String innerUri = uri.toString();
+		if (innerUri.contains("#//") == false) { //$NON-NLS-1$
+			return uri;
+		}
+		return URI.createURI(innerUri.substring(0, innerUri.indexOf("#//"))); //$NON-NLS-1$
+	}
+
+	public IProxyEObject getIProxyEObject(URI uri) {
+		IProxyERoot proxy = getIProxyERoot(uri);
+		if (proxy != null) {
+			return proxy.getIProxyEObject(uri);
+		}
+		return null;
+	}
+
+	public IProxyEPackage getIProxyEPackage(URI uri) {
+		IProxyERoot proxy = getIProxyERoot(uri);
+		if (proxy != null && proxy.getChildren().length == 1) {
+			return proxy.getChildren()[0];
+		}
+		return null;
+	}
+
+	public IProxyERoot getIProxyERoot(URI uri) {
+		// Ignore
+		if (uri == null) {
+			return null;
+		}
+		// Locate an IPlatformGenModel
+		URI nsURI = getEPackageNsURI(uri);
+		IPlatformGenModel packageGenModel = EGFCorePlugin.getRuntimePlatformGenModel(nsURI);
+		// Not found
+		if (packageGenModel == null) {
+			return null;
+		}
+		// Inner ePackage processing if applicable
+		URI innerNsURI = packageGenModel.getEPackageNsURI(uri);
+		if (innerNsURI != null) {
+			packageGenModel = EGFCorePlugin.getRuntimePlatformGenModel(innerNsURI);
+		}
+		// Not found
+		if (packageGenModel == null) {
+			return null;
+		}
+		// Build an ERootWrapper
+		return packageGenModel.getIProxyERoot();
+	}
+
+}
diff --git a/plugins/org.eclipse.egf.core/src/org/eclipse/egf/core/internal/fcore/PlatformFcore.java b/plugins/org.eclipse.egf.core/src/org/eclipse/egf/core/internal/fcore/PlatformFcore.java
index 169cd40..10975da 100644
--- a/plugins/org.eclipse.egf.core/src/org/eclipse/egf/core/internal/fcore/PlatformFcore.java
+++ b/plugins/org.eclipse.egf.core/src/org/eclipse/egf/core/internal/fcore/PlatformFcore.java
@@ -1,52 +1,41 @@
-/**

- * <copyright>

- * 

- * Copyright (c) 2009-2010 Thales Corporate Services S.A.S.

- * 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:

- * Thales Corporate Services S.A.S - initial API and implementation

- * 

- * </copyright>

- * 

- */

-package org.eclipse.egf.core.internal.fcore;

-

-import org.eclipse.core.runtime.Path;

-import org.eclipse.egf.core.fcore.IPlatformFcore;

-import org.eclipse.egf.core.platform.pde.IPlatformBundle;

-import org.eclipse.egf.core.platform.pde.PlatformExtensionPointURI;

-

-public final class PlatformFcore extends PlatformExtensionPointURI implements IPlatformFcore {

-

-    private String _name;

-

-    public PlatformFcore(IPlatformBundle bundle, String id) {

-        super(bundle, id);

-        _name = new Path(getURI().lastSegment()).removeFileExtension().toString();

-    }

-

-    public PlatformFcore(IPlatformBundle bundle, String id, String uniqueIdentifier, int handleId) {

-        super(bundle, id, uniqueIdentifier, handleId);

-        _name = new Path(getURI().lastSegment()).removeFileExtension().toString();

-    }

-

-    public String getName() {

-        return _name;

-    }

-

-    @Override

-    public boolean equals(Object object) {

-        if (super.equals(object) == false) {

-            return false;

-        }

-        if (object instanceof IPlatformFcore == false) {

-            return false;

-        }

-        return true;

-    }

-

-}

+/**
+ * <copyright>
+ * 
+ * Copyright (c) 2009-2010 Thales Corporate Services S.A.S.
+ * 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:
+ * Thales Corporate Services S.A.S - initial API and implementation
+ * 
+ * </copyright>
+ * 
+ */
+package org.eclipse.egf.core.internal.fcore;
+
+import org.eclipse.core.runtime.Path;
+import org.eclipse.egf.core.fcore.IPlatformFcore;
+import org.eclipse.egf.core.platform.pde.IPlatformBundle;
+import org.eclipse.egf.core.platform.pde.PlatformExtensionPointURI;
+
+public final class PlatformFcore extends PlatformExtensionPointURI implements IPlatformFcore {
+
+	private String _name;
+
+	public PlatformFcore(IPlatformBundle bundle, String id) {
+		super(bundle, id);
+		_name = new Path(getURI().lastSegment()).removeFileExtension().toString();
+	}
+
+	public PlatformFcore(IPlatformBundle bundle, String id, String uniqueIdentifier, int handleId) {
+		super(bundle, id, uniqueIdentifier, handleId);
+		_name = new Path(getURI().lastSegment()).removeFileExtension().toString();
+	}
+
+	public String getName() {
+		return _name;
+	}
+
+}
diff --git a/plugins/org.eclipse.egf.model.editor/generated/org/eclipse/egf/model/fcore/presentation/FcoreEditor.java b/plugins/org.eclipse.egf.model.editor/generated/org/eclipse/egf/model/fcore/presentation/FcoreEditor.java
index 012eee9..3ba1161 100644
--- a/plugins/org.eclipse.egf.model.editor/generated/org/eclipse/egf/model/fcore/presentation/FcoreEditor.java
+++ b/plugins/org.eclipse.egf.model.editor/generated/org/eclipse/egf/model/fcore/presentation/FcoreEditor.java
@@ -38,9 +38,9 @@
 import org.eclipse.egf.common.ui.helper.EditorHelper;

 import org.eclipse.egf.common.ui.helper.ThrowableHandler;

 import org.eclipse.egf.core.EGFCorePlugin;

-import org.eclipse.egf.core.domain.TargetPlatformResourceLoadedListener;

-import org.eclipse.egf.core.domain.TargetPlatformResourceLoadedListener.ResourceListener;

-import org.eclipse.egf.core.domain.TargetPlatformResourceLoadedListener.ResourceUser;

+import org.eclipse.egf.core.domain.PlatformResourceLoadedListener;

+import org.eclipse.egf.core.domain.PlatformResourceLoadedListener.ResourceListener;

+import org.eclipse.egf.core.domain.PlatformResourceLoadedListener.ResourceUser;

 import org.eclipse.egf.core.helper.ResourceHelper;

 import org.eclipse.egf.core.platform.EGFPlatformPlugin;

 import org.eclipse.egf.core.ui.EGFCoreUIPlugin;

@@ -745,7 +745,7 @@
      */

     protected void handleChangedResource() {

         if (isDirty() == false || handleDirtyConflict()) {

-            TargetPlatformResourceLoadedListener.getResourceManager().reloadResource(getResource());

+            PlatformResourceLoadedListener.getResourceManager().reloadResource(getResource());

         }

     }

 

@@ -1122,7 +1122,7 @@
             exception = e;

             resource = editingDomain.getResourceSet().getResource(uri, false);

         }

-        resourceHasBeenExternallyChanged = TargetPlatformResourceLoadedListener.getResourceManager().resourceHasBeenExternallyChanged(resource);

+        resourceHasBeenExternallyChanged = PlatformResourceLoadedListener.getResourceManager().resourceHasBeenExternallyChanged(resource);

         Diagnostic diagnostic = ResourceHelper.analyzeResourceProblems(resource, exception, ID);

         if (diagnostic.getSeverity() != Diagnostic.OK) {

             resourceToDiagnosticMap.put(resource.getURI(), diagnostic);

@@ -1666,9 +1666,9 @@
         site.setSelectionProvider(this);

         site.getPage().addPartListener(partListener);

         createModel();

-        TargetPlatformResourceLoadedListener.getResourceManager().addObserver(this);

+        PlatformResourceLoadedListener.getResourceManager().addObserver(this);

         // populate operation history if applicable

-        TargetPlatformResourceLoadedListener.getResourceManager().populateUndoContext(getOperationHistory(), undoContext, getResource());

+        PlatformResourceLoadedListener.getResourceManager().populateUndoContext(getOperationHistory(), undoContext, getResource());

     }

 

     /**

@@ -1870,7 +1870,7 @@
         getOperationHistory().dispose(getUndoContext(), true, true, true);

 

         // Remove observer

-        TargetPlatformResourceLoadedListener.getResourceManager().removeObserver(this);

+        PlatformResourceLoadedListener.getResourceManager().removeObserver(this);

 

         // Remove our adapters

         editingDomain.getResourceSet().eAdapters().remove(editorResourceAdapter);

diff --git a/plugins/org.eclipse.egf.pattern.ui/src/org/eclipse/egf/pattern/ui/editors/PatternEditor.java b/plugins/org.eclipse.egf.pattern.ui/src/org/eclipse/egf/pattern/ui/editors/PatternEditor.java
index ceca11b..6e31029 100644
--- a/plugins/org.eclipse.egf.pattern.ui/src/org/eclipse/egf/pattern/ui/editors/PatternEditor.java
+++ b/plugins/org.eclipse.egf.pattern.ui/src/org/eclipse/egf/pattern/ui/editors/PatternEditor.java
@@ -26,9 +26,9 @@
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.egf.common.ui.helper.ThrowableHandler;
 import org.eclipse.egf.core.EGFCorePlugin;
-import org.eclipse.egf.core.domain.TargetPlatformResourceLoadedListener;
-import org.eclipse.egf.core.domain.TargetPlatformResourceLoadedListener.ResourceListener;
-import org.eclipse.egf.core.domain.TargetPlatformResourceLoadedListener.ResourceUser;
+import org.eclipse.egf.core.domain.PlatformResourceLoadedListener;
+import org.eclipse.egf.core.domain.PlatformResourceLoadedListener.ResourceListener;
+import org.eclipse.egf.core.domain.PlatformResourceLoadedListener.ResourceUser;
 import org.eclipse.egf.core.platform.EGFPlatformPlugin;
 import org.eclipse.egf.core.ui.l10n.CoreUIMessages;
 import org.eclipse.egf.model.fcore.FcorePackage;
@@ -361,7 +361,7 @@
      */
     protected void handleChangedResource() {
         if (isDirty() == false || handleDirtyConflict()) {
-            TargetPlatformResourceLoadedListener.getResourceManager().reloadResource(getResource());
+            PlatformResourceLoadedListener.getResourceManager().reloadResource(getResource());
         }
     }
 
@@ -520,10 +520,10 @@
         site.getPage().addPartListener(partListener);
         pattern = ((PatternEditorInput) getEditorInput()).getPattern();
         partName = pattern.getName();
-        resourceHasBeenExternallyChanged = TargetPlatformResourceLoadedListener.getResourceManager().resourceHasBeenExternallyChanged(getResource());
-        TargetPlatformResourceLoadedListener.getResourceManager().addObserver(this);
+        resourceHasBeenExternallyChanged = PlatformResourceLoadedListener.getResourceManager().resourceHasBeenExternallyChanged(getResource());
+        PlatformResourceLoadedListener.getResourceManager().addObserver(this);
         // populate operation history if applicable
-        TargetPlatformResourceLoadedListener.getResourceManager().populateUndoContext(getOperationHistory(), undoContext, getResource());
+        PlatformResourceLoadedListener.getResourceManager().populateUndoContext(getOperationHistory(), undoContext, getResource());
         addPatternChangeAdapter();
         setPartName(pattern.getName());
     }
@@ -543,7 +543,7 @@
             removePatternChangeAdapter();
         }
         // Initialized in initializeEditingDomain, if init failed, this must be disposed
-        TargetPlatformResourceLoadedListener.getResourceManager().removeObserver(this);
+        PlatformResourceLoadedListener.getResourceManager().removeObserver(this);
         getOperationHistory().removeOperationHistoryListener(historyListener);
         getOperationHistory().dispose(undoContext, true, true, true);
         editingDomain.getResourceSet().eAdapters().remove(editorResourceAdapter);
diff --git a/plugins/org.eclipse.egf.pattern.ui/src/org/eclipse/egf/pattern/ui/editors/PatternTemplateEditor.java b/plugins/org.eclipse.egf.pattern.ui/src/org/eclipse/egf/pattern/ui/editors/PatternTemplateEditor.java
index dc6d8f0..39988f5 100644
--- a/plugins/org.eclipse.egf.pattern.ui/src/org/eclipse/egf/pattern/ui/editors/PatternTemplateEditor.java
+++ b/plugins/org.eclipse.egf.pattern.ui/src/org/eclipse/egf/pattern/ui/editors/PatternTemplateEditor.java
@@ -18,9 +18,9 @@
 import org.eclipse.core.commands.operations.IOperationHistory;
 import org.eclipse.core.commands.operations.ObjectUndoContext;
 import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.egf.core.domain.TargetPlatformResourceLoadedListener;
-import org.eclipse.egf.core.domain.TargetPlatformResourceLoadedListener.ResourceListener;
-import org.eclipse.egf.core.domain.TargetPlatformResourceLoadedListener.ResourceUser;
+import org.eclipse.egf.core.domain.PlatformResourceLoadedListener;
+import org.eclipse.egf.core.domain.PlatformResourceLoadedListener.ResourceListener;
+import org.eclipse.egf.core.domain.PlatformResourceLoadedListener.ResourceUser;
 import org.eclipse.egf.model.fcore.FcorePackage;
 import org.eclipse.egf.model.pattern.Pattern;
 import org.eclipse.egf.model.pattern.PatternMethod;
@@ -395,7 +395,7 @@
         super.init(site, editorInput);
         patternInWorkspace = ((PatternEditorInput) getEditorInput()).getFile() != null;
         pattern = ((PatternEditorInput) getEditorInput()).getPattern();
-        TargetPlatformResourceLoadedListener.getResourceManager().addObserver(this);
+        PlatformResourceLoadedListener.getResourceManager().addObserver(this);
         addPatternChangeAdapter();
         setPartName(pattern.getName());
     }
@@ -406,7 +406,7 @@
         if (getEditorInput() != null && getEditorInput() instanceof PatternEditorInput) {
             removePatternChangeAdapter();
         }
-        TargetPlatformResourceLoadedListener.getResourceManager().removeObserver(this);
+        PlatformResourceLoadedListener.getResourceManager().removeObserver(this);
         super.dispose();
     }
 
diff --git a/plugins/org.eclipse.egf.producer.ui/src/org/eclipse/egf/producer/ui/internal/actions/RunActivityAction.java b/plugins/org.eclipse.egf.producer.ui/src/org/eclipse/egf/producer/ui/internal/actions/RunActivityAction.java
index b17cb60..98a5c92 100644
--- a/plugins/org.eclipse.egf.producer.ui/src/org/eclipse/egf/producer/ui/internal/actions/RunActivityAction.java
+++ b/plugins/org.eclipse.egf.producer.ui/src/org/eclipse/egf/producer/ui/internal/actions/RunActivityAction.java
@@ -29,7 +29,6 @@
 import org.eclipse.egf.common.ui.helper.ThrowableHandler;
 import org.eclipse.egf.core.EGFCorePlugin;
 import org.eclipse.egf.core.domain.EgfResourceSet;
-import org.eclipse.egf.core.domain.RuntimePlatformResourceSet;
 import org.eclipse.egf.core.fcore.IPlatformFcore;
 import org.eclipse.egf.core.fcore.IPlatformFcoreProvider;
 import org.eclipse.egf.core.l10n.EGFCoreMessages;
@@ -178,7 +177,7 @@
 					}
 
 					// 5 - Switch to runtime mode
-					ResourceSet resourceSet = new RuntimePlatformResourceSet();
+					ResourceSet resourceSet = new EgfResourceSet(true);
 					Activity activity = (Activity) resourceSet.getEObject(EcoreUtil.getURI(_activity), true);
 
 					// 6 - Locate an ActivityManagerProducer and create an
diff --git a/tests/org.eclipse.egf.core.test/test/org/eclipse/egf/core/test/AllTests.java b/tests/org.eclipse.egf.core.test/test/org/eclipse/egf/core/test/AllTests.java
index 40c0080..3c464d9 100644
--- a/tests/org.eclipse.egf.core.test/test/org/eclipse/egf/core/test/AllTests.java
+++ b/tests/org.eclipse.egf.core.test/test/org/eclipse/egf/core/test/AllTests.java
@@ -10,7 +10,11 @@
  */
 package org.eclipse.egf.core.test;
 
+import org.eclipse.egf.core.test.factorycomponent.ContextFactoryComponent;
+import org.eclipse.egf.core.test.loader.ContextLoader;
+import org.eclipse.egf.core.test.model.validation.ModelValidation;
 import org.eclipse.egf.core.test.resourceset.ResourceSetTests;
+import org.eclipse.egf.core.test.task.ContextTask;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
@@ -29,12 +33,12 @@
 		init.addTest(WorkspaceInitializationTest.suite());
 		suite.addTest(init);
 
-		//        new ModelTestHelper().addModelTest(suite);
-		//
-		//        suite.addTest(ModelValidation.suite());
-		//        suite.addTest(ContextFactoryComponent.suite());
-		//        suite.addTest(ContextTask.suite());
-		//        suite.addTest(ContextLoader.suite());
+		new ModelTestHelper().addModelTest(suite);
+
+		suite.addTest(ModelValidation.suite());
+		suite.addTest(ContextFactoryComponent.suite());
+		suite.addTest(ContextTask.suite());
+		suite.addTest(ContextLoader.suite());
 
 		suite.addTest(ResourceSetTests.suite());
 		return suite;