### Eclipse Workspace Patch 1.0
#P org.eclipse.gmf.runtime.emf.core.compatibility
Index: src/org/eclipse/gmf/runtime/emf/core/edit/MEditingDomain.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.emf.core.compatibility/src/org/eclipse/gmf/runtime/emf/core/edit/MEditingDomain.java,v
retrieving revision 1.1
diff -u -r1.1 MEditingDomain.java
--- src/org/eclipse/gmf/runtime/emf/core/edit/MEditingDomain.java 8 Feb 2006 14:52:04 -0000 1.1
+++ src/org/eclipse/gmf/runtime/emf/core/edit/MEditingDomain.java 23 Feb 2006 20:02:19 -0000
@@ -259,61 +259,6 @@
EClass rootEClass, int options);
/**
- * Loads a resource from a given file.
- *
- * @param fileNameURI
- * The resource's file path.
- * @return The loaded resource.
- *
- * @deprecated Use the
- * {@link org.eclipse.emf.ecore.resource.ResourceSet#getResource(URI, boolean)}
- * API or, if it does not already existin in the resource set,
- * {@link org.eclipse.emf.ecore.resource.ResourceSet#createResource(URI) create}
- * it and then {@link org.eclipse.emf.ecore.resource.Resource#load(Map)} it.
- */
- public abstract Resource loadResource(String fileNameURI);
-
- /**
- * Loads a resource from a given file.
- *
- * @param fileNameURI
- * The resource's file path.
- * @param options
- * The load options. This is a bit mask of values from
- * MResourceOption
.
- * @return The loaded resource.
- *
- * @deprecated Use the
- * {@link org.eclipse.emf.ecore.resource.ResourceSet#getResource(URI, boolean)}
- * API or, if it does not already existin in the resource set,
- * {@link org.eclipse.emf.ecore.resource.ResourceSet#createResource(URI) create}
- * it and then {@link org.eclipse.emf.ecore.resource.Resource#load(Map)} it.
- */
- public abstract Resource loadResource(String fileNameURI, int options);
-
- /**
- * Loads a resource with a given file path from the given input stream using
- * the given load options.
- *
- * @param fileNameURI
- * The resource's file path.
- * @param options
- * The load options. This is a bit mask of values from
- * MResourceOption
.
- * @param inputStream
- * The input stream from which to load the resource's contents.
- * @return The loaded resource.
- *
- * @deprecated Use the
- * {@link org.eclipse.emf.ecore.resource.ResourceSet#getResource(URI, boolean)}
- * API or, if it does not already existin in the resource set,
- * {@link org.eclipse.emf.ecore.resource.ResourceSet#createResource(URI) create}
- * it and then {@link org.eclipse.emf.ecore.resource.Resource#load(InputStream, Map)} it.
- */
- public abstract Resource loadResource(String fileNameURI, int options,
- InputStream inputStream);
-
- /**
* Loads an unloaded resource. It is the responsibility of callers to catch
* any exceptions that will be thrown as a result of the resource being loaded
* with errors. Note that the state of the resource could be loaded (ie. it could
Index: src/org/eclipse/gmf/runtime/emf/core/internal/notifications/MSLEventBroker.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.emf.core.compatibility/src/org/eclipse/gmf/runtime/emf/core/internal/notifications/MSLEventBroker.java,v
retrieving revision 1.2
diff -u -r1.2 MSLEventBroker.java
--- src/org/eclipse/gmf/runtime/emf/core/internal/notifications/MSLEventBroker.java 22 Feb 2006 01:02:28 -0000 1.2
+++ src/org/eclipse/gmf/runtime/emf/core/internal/notifications/MSLEventBroker.java 23 Feb 2006 20:02:20 -0000
@@ -126,6 +126,7 @@
* Runs the runnable instance without sending events.
*/
public Object runSilent(MRunnable runnable) {
+
return runWithOptions(runnable, MRunOption.SILENT);
}
@@ -133,6 +134,7 @@
* Runs the runnable instance without semantic procedures.
*/
public Object runWithNoSemProcs(MRunnable runnable) {
+
return runWithOptions(runnable, MRunOption.NO_SEM_PROCS);
}
@@ -140,6 +142,7 @@
* Runs the runnable instance without validation.
*/
public Object runUnvalidated(MRunnable runnable) {
+
return runWithOptions(runnable, MRunOption.UNVALIDATED);
}
@@ -151,6 +154,7 @@
* @see MRunOption
*/
public Object runWithOptions(MRunnable runnable, int options) {
+
Object result = null;
Object previousNoNotifications = null;
@@ -245,6 +249,7 @@
* Adds a new event to the pending list of events.
*/
public void addEvent(Notification event) {
+
notifyMetaModel(event);
if (domain.isUndoInProgress())
@@ -258,7 +263,9 @@
* Checks if event is undo event.
*/
public boolean isUndoEvent(Notification event) {
+
Boolean isUndo = (Boolean) undoRedoEvents.get(event);
+
return (isUndo != null) && (isUndo.booleanValue());
}
@@ -266,7 +273,9 @@
* Checks if event is redo event.
*/
public boolean isRedoEvent(Notification event) {
+
Boolean isUndo = (Boolean) undoRedoEvents.get(event);
+
return (isUndo != null) && (!isUndo.booleanValue());
}
@@ -274,7 +283,9 @@
* Notify the meta-model about the modification.
*/
public void notifyMetaModel(Notification event) {
+
if (sendEventsToMetaModel) {
+
Object notifier = event.getNotifier();
if (((domain.isWriteInProgress()) || (domain
@@ -303,6 +314,7 @@
* Fires events.
*/
private void fireEvents(List events) {
+
if (events.isEmpty())
return;
@@ -323,7 +335,7 @@
// consuming and save the time of extracting the single Notification from the list.
Notification singleEvent = (Notification)events.get(0);
- for (Iterator iter = allListeners.iterator(); iter.hasNext();) {
+ for (Iterator iter = allListeners.iterator(); iter.hasNext();) {
MListener listener = (MListener)iter.next();
fireSingleEvent(listener, singleEvent, events);
}
@@ -333,13 +345,13 @@
// only have two lists occupying memory that are the same size rather
// than allocating lists of different sizes for each listener.
List listenerEventCache = new ArrayList(events.size());
-
+
for (Iterator iter = allListeners.iterator(); iter.hasNext();) {
MListener listener = (MListener)iter.next();
fireEvents(listener, events, listenerEventCache);
- }
}
}
+ }
private boolean shouldSuppressUnbatchedResourceEvent(List events) {
boolean result = false;
@@ -349,11 +361,7 @@
if (notification.getNotifier() instanceof Resource) {
if (notification.getFeatureID(null) == Resource.RESOURCE__IS_LOADED) {
- Resource res = (Resource) notification.getNotifier();
-
- result = notification.getNewBooleanValue()?
- domain.getResouceListener().loadedWithErrors(res) :
- !(notification instanceof MSLResourceListener.UnloadNotification);
+ result = !notification.getNewBooleanValue() && !(notification instanceof MSLResourceListener.UnloadNotification);
}
}
}
@@ -367,6 +375,7 @@
* the returned list is garbage collected.
*/
private List getAllListeners() {
+
List allListeners = new ArrayList(listeners.size()
+ universalListeners.size() + semProcProviders.size());
@@ -397,6 +406,7 @@
Iterator j = events.iterator();
while (j.hasNext()) {
+
Notification event = (Notification) j.next();
if (filter.matches(event))
@@ -408,8 +418,11 @@
return;
try {
+
listener.onEvent(eventsToSend);
+
} catch (Exception e) {
+
// this is a bad listener so remove it so the next
// listeners can get their events.
// bugzilla110334: Do not remove listener as it will cause
@@ -437,7 +450,7 @@
if (!filter.matches(event)) {
return;
}
-
+
try {
listener.onEvent(eventsToSend);
} catch (Exception e) {
Index: src/org/eclipse/gmf/runtime/emf/core/internal/notifications/MSLResourceListener.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.emf.core.compatibility/src/org/eclipse/gmf/runtime/emf/core/internal/notifications/MSLResourceListener.java,v
retrieving revision 1.1
diff -u -r1.1 MSLResourceListener.java
--- src/org/eclipse/gmf/runtime/emf/core/internal/notifications/MSLResourceListener.java 8 Feb 2006 14:52:03 -0000 1.1
+++ src/org/eclipse/gmf/runtime/emf/core/internal/notifications/MSLResourceListener.java 23 Feb 2006 20:02:20 -0000
@@ -69,22 +69,6 @@
private Map unloadedResourcesRoot = new HashMap();
- // TODO Remove this tracking of resources with errors in the next iteration.
- /*
- * This map is here to keep track of which resources were
- * loaded with errors. For now we are not going to be propagating
- * any events associated with loading/unloaded these resources.
- * In the next iteration we will propagate all of these events
- * and listeners will be required to verify whether the resource
- * loaded with errors or not.
- *
- * Look at MEditingDomain.loadResource, MEditingDomain.unloadResource
- * and IDemuxedMListener.handleResourceLoadedEvent for more details.
- *
- * cmcgee
- */
- private Map resourcesWithErrors = new WeakHashMap();
-
/**
* Constructor.
*/
@@ -154,36 +138,9 @@
boolean oldBooleanValue = notification.getOldBooleanValue();
if (newBooleanValue && !oldBooleanValue) {
-
loadedResources.put(notifier, Boolean.TRUE);
MSLUtil.postProcessResource(notifier);
-
- // TODO Remove this check for errors in the next iteration.
- // If the resource loaded with errors, place it into a special
- // map indicating that it was loaded with errors so that we
- // do not propagate any automated unload events. This is going
- // to change in the next iteration where we will propagate all
- // resource-level events.
- //
- // cmcgee
- //
- if (notifier.getErrors().size() > 0) {
- // remove the notification that we got from the
- // current transaction
- InternalTransaction tx = domain.getActiveTransaction();
- if (tx != null) {
- tx.getNotifications().remove(notification);
- }
-
- resourcesWithErrors.put(notifier, Boolean.TRUE);
- } else {
- resourcesWithErrors.remove(notifier);
-
- // forward event to broker.
- domain.getEventBroker().addEvent(notification);
- }
- return;
} else if (!newBooleanValue && oldBooleanValue
&& !(notification instanceof UnloadNotification)) {
@@ -199,28 +156,16 @@
UnloadNotification unloadNotification = new UnloadNotification(root, notification);
unloadedResourcesRoot.remove(notifier);
- // TODO Remove this check for resources with errors in the next iteration.
- // We will be checking whether this resource was one that
- // loaded with errors in it. If this is the case then we
- // do not propagate the event. This is going to change in the
- // next iteration.
- //
- // cmcgee
- //
- if (!resourcesWithErrors.containsKey(notifier)) {
- // remove the notification that we got from the
- // current transaction
- InternalTransaction tx = domain.getActiveTransaction();
- if (tx != null) {
- tx.getNotifications().remove(notification);
- }
-
- // and send this one in its place
- domain.sendNotification(unloadNotification);
- } else {
- resourcesWithErrors.remove(notifier);
+ // remove the notification that we got from the
+ // current transaction
+ InternalTransaction tx = domain.getActiveTransaction();
+ if (tx != null) {
+ tx.getNotifications().remove(notification);
}
+ // and send this one in its place
+ domain.sendNotification(unloadNotification);
+
return;
}
}
@@ -255,17 +200,4 @@
else
loadedResources.remove(resource);
}
-
- /**
- * Was the resource loaded with errors (and, therefore, the load event
- * should not be propagated to listeners)?
- *
- * @param resource a resource
- * @return true
if it was loaded with errors;
- * false
, otherwise
- */
- public boolean loadedWithErrors(Resource resource) {
- return resourcesWithErrors.containsKey(resource)
- || !resource.getErrors().isEmpty();
- }
}
\ No newline at end of file
Index: src/org/eclipse/gmf/runtime/emf/core/internal/domain/MSLEditingDomain.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.emf.core.compatibility/src/org/eclipse/gmf/runtime/emf/core/internal/domain/MSLEditingDomain.java,v
retrieving revision 1.1
diff -u -r1.1 MSLEditingDomain.java
--- src/org/eclipse/gmf/runtime/emf/core/internal/domain/MSLEditingDomain.java 8 Feb 2006 14:52:03 -0000 1.1
+++ src/org/eclipse/gmf/runtime/emf/core/internal/domain/MSLEditingDomain.java 23 Feb 2006 20:02:20 -0000
@@ -692,9 +692,6 @@
resource.load(inputStream, loadOptions);
} catch (Exception e) {
- // TODO In the next iteration, we will no longer be automatically unloading a resource if there are errors.
- resource.unload();
-
RuntimeException newE = null;
if (e instanceof MSLRuntimeException)
Index: src/org/eclipse/gmf/runtime/emf/core/util/ResourceUtil.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.emf.core.compatibility/src/org/eclipse/gmf/runtime/emf/core/util/ResourceUtil.java,v
retrieving revision 1.1
diff -u -r1.1 ResourceUtil.java
--- src/org/eclipse/gmf/runtime/emf/core/util/ResourceUtil.java 8 Feb 2006 14:52:04 -0000 1.1
+++ src/org/eclipse/gmf/runtime/emf/core/util/ResourceUtil.java 23 Feb 2006 20:02:20 -0000
@@ -211,23 +211,6 @@
return MEditingDomain.INSTANCE
.createResource(path, rootEClass, options);
}
-
- /**
- * Loads a resource from a given file.
- *
- * @param path
- * The resource's file path.
- * @param options
- * The load options. This is a bit mask of values from
- * MResourceOption
.
- * @return The loaded resource.
- *
- * @deprecated Create or get an existing resource in the resource set
- * and {@link org.eclipse.emf.ecore.resource.Resource#load(Map) load} it.
- */
- public static Resource load(String path, int options) {
- return MEditingDomain.INSTANCE.loadResource(path, options);
- }
/**
* Produces a resource for a given file path and with the provided
@@ -254,28 +237,6 @@
}
/**
- * Loads a resource with a given file path from the given input stream using
- * the given load options.
- *
- * @param path
- * The resource's file path.
- * @param options
- * The load options. This is a bit mask of values from
- * MResourceOption
.
- * @param inputStream
- * The input stream from which to load the resource's contents.
- * @return The loaded resource.
- *
- * @deprecated Create or get an existing resource in the resource set
- * and {@link org.eclipse.emf.ecore.resource.Resource#load(InputStream, Map) load}
- * it.
- */
- public static Resource load(String path, int options,
- InputStream inputStream) {
- return MEditingDomain.INSTANCE.loadResource(path, options, inputStream);
- }
-
- /**
* Loads an unloaded resource. It is the client's responsibility
* to catch any exceptions that are thrown because of the loading
* of the resource. Also, once a resource is loaded, it could have
@@ -411,21 +372,6 @@
}
/**
- * Loads a resource from a given file.
- *
- * @param path
- * The resource's file path.
- * @return The loaded resource.
- *
- * @deprecated Create or get an existing resource from the resource set,
- * by the required file URI, and
- * {@link org.eclipse.emf.ecore.resource.Resource#load(Map) load} it.
- */
- public static Resource load(String path) {
- return MEditingDomain.INSTANCE.loadResource(path);
- }
-
- /**
* Loads an unloaded resource. It is the client's responsibility
* to catch any exceptions that are thrown because of the loading
* of the resource. Also, once a resource is loaded, it could have
#P org.eclipse.gmf.tests.runtime.emf.core
Index: src/org/eclipse/gmf/tests/runtime/emf/core/internal/listener/MListenerTest.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.gmf/tests/org.eclipse.gmf.tests.runtime.emf.core/src/org/eclipse/gmf/tests/runtime/emf/core/internal/listener/MListenerTest.java,v
retrieving revision 1.1
diff -u -r1.1 MListenerTest.java
--- src/org/eclipse/gmf/tests/runtime/emf/core/internal/listener/MListenerTest.java 25 Nov 2005 21:58:28 -0000 1.1
+++ src/org/eclipse/gmf/tests/runtime/emf/core/internal/listener/MListenerTest.java 23 Feb 2006 20:02:21 -0000
@@ -43,7 +43,6 @@
}
public void testResourceLoadEventsWhenError() {
- // TODO Change this test case come the next iteration when we change the behaviour of resource load
MEditingDomain domain = MEditingDomain.createNewDomain();
final boolean[] results = new boolean[2];
@@ -71,7 +70,7 @@
// Ignore this exception.
}
- assertTrue(results[0]);
+ assertFalse(results[0]);
assertTrue(results[1]);
}
}
Index: src/org/eclipse/gmf/tests/runtime/emf/core/internal/domain/MSLEditingDomainTestCase.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.gmf/tests/org.eclipse.gmf.tests.runtime.emf.core/src/org/eclipse/gmf/tests/runtime/emf/core/internal/domain/MSLEditingDomainTestCase.java,v
retrieving revision 1.3
diff -u -r1.3 MSLEditingDomainTestCase.java
--- src/org/eclipse/gmf/tests/runtime/emf/core/internal/domain/MSLEditingDomainTestCase.java 8 Feb 2006 14:52:17 -0000 1.3
+++ src/org/eclipse/gmf/tests/runtime/emf/core/internal/domain/MSLEditingDomainTestCase.java 23 Feb 2006 20:02:21 -0000
@@ -88,7 +88,6 @@
assertTrue(true);
}
- // TODO Change this line when we turn off automatic unloading of resources during load.
- assertFalse(r.isLoaded());
+ assertTrue(r.isLoaded());
}
}