Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon McDuff2008-11-03 10:03:33 -0500
committerSimon McDuff2008-11-03 10:03:33 -0500
commit4c1355f45efd7874d27e66f97cab8164cc578bf6 (patch)
treeb9f7266a951b49e6bb7186bc420855c6ea4ea5c4
parent6492822b5c84e813309f0b9e07f513d7969c084c (diff)
downloadcdo-4c1355f45efd7874d27e66f97cab8164cc578bf6.tar.gz
cdo-4c1355f45efd7874d27e66f97cab8164cc578bf6.tar.xz
cdo-4c1355f45efd7874d27e66f97cab8164cc578bf6.zip
[252883] Objects not updated when CDOSessionInvalidationEvent is received
https://bugs.eclipse.org/bugs/show_bug.cgi?id=252883
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/ItemsProcessor.java16
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOEventHandler.java36
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOViewInvalidationEvent.java46
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java95
4 files changed, 147 insertions, 46 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/ItemsProcessor.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/ItemsProcessor.java
index b7f81f0cf8..88a98cb429 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/ItemsProcessor.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/ItemsProcessor.java
@@ -7,11 +7,12 @@
*
* Contributors:
* Eike Stepper - initial API and implementation
+ * Simon McDuff - maintenance
**************************************************************************/
package org.eclipse.emf.cdo.internal.ui;
+import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.CDOView;
-import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.internal.cdo.InternalCDOObject;
import org.eclipse.emf.internal.cdo.util.FSMUtil;
@@ -43,7 +44,7 @@ public abstract class ItemsProcessor
processCDOObjects(viewer, null);
}
- public void processCDOObjects(final TreeViewer viewer, final Set<CDOID> ids)
+ public void processCDOObjects(final TreeViewer viewer, final Set<? extends CDOObject> ids)
{
try
{
@@ -84,7 +85,7 @@ public abstract class ItemsProcessor
protected abstract void processCDOObject(TreeViewer viewer, InternalCDOObject cdoObject);
- private void processItems(TreeViewer viewer, Set<CDOID> ids, TreeItem[] items)
+ private void processItems(TreeViewer viewer, Set<? extends CDOObject> ids, TreeItem[] items)
{
for (TreeItem item : items)
{
@@ -97,15 +98,12 @@ public abstract class ItemsProcessor
}
}
- private void processObject(TreeViewer viewer, Set<CDOID> ids, Object object)
+ private void processObject(TreeViewer viewer, Set<? extends CDOObject> ids, Object object)
{
InternalCDOObject cdoObject = getCDOObject(object);
- if (cdoObject != null)
+ if (ids.contains(cdoObject))
{
- if (ids == null || ids.contains(cdoObject.cdoID()))
- {
- processCDOObject(viewer, cdoObject);
- }
+ processCDOObject(viewer, cdoObject);
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOEventHandler.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOEventHandler.java
index d6be86dd2a..c54dfd16ed 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOEventHandler.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOEventHandler.java
@@ -7,18 +7,17 @@
*
* Contributors:
* Eike Stepper - initial API and implementation
+ * Simon McDuff - maintenance
**************************************************************************/
package org.eclipse.emf.cdo.ui;
import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.CDOSession;
-import org.eclipse.emf.cdo.CDOSessionInvalidationEvent;
import org.eclipse.emf.cdo.CDOTransactionConflictEvent;
import org.eclipse.emf.cdo.CDOTransactionFinishedEvent;
import org.eclipse.emf.cdo.CDOTransactionStartedEvent;
import org.eclipse.emf.cdo.CDOView;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDAndVersion;
+import org.eclipse.emf.cdo.CDOViewInvalidationEvent;
import org.eclipse.emf.cdo.internal.ui.ItemsProcessor;
import org.eclipse.emf.internal.cdo.InternalCDOObject;
@@ -31,7 +30,6 @@ import org.eclipse.net4j.util.lifecycle.ILifecycleEvent;
import org.eclipse.jface.viewers.TreeViewer;
-import java.util.HashSet;
import java.util.Set;
/**
@@ -47,15 +45,7 @@ public class CDOEventHandler
{
public void notifyEvent(IEvent event)
{
- if (event instanceof CDOSessionInvalidationEvent)
- {
- CDOSessionInvalidationEvent e = (CDOSessionInvalidationEvent)event;
- if (e.getView() != view)
- {
- sessionInvalidated(e.getDirtyOIDs());
- }
- }
- else if (event instanceof IContainerEvent)
+ if (event instanceof IContainerEvent)
{
IContainerEvent<?> e = (IContainerEvent<?>)event;
if (e.getDeltaElement() == view && e.getDeltaKind() == IContainerDelta.Kind.REMOVED)
@@ -78,7 +68,12 @@ public class CDOEventHandler
{
public void notifyEvent(IEvent event)
{
- if (event instanceof CDOTransactionFinishedEvent)
+ if (event instanceof CDOViewInvalidationEvent)
+ {
+ CDOViewInvalidationEvent e = (CDOViewInvalidationEvent)event;
+ viewInvalidated(e.getDirtyObjects());
+ }
+ else if (event instanceof CDOTransactionFinishedEvent)
{
// CDOTransactionFinishedEvent e = (CDOTransactionFinishedEvent)event;
// if (e.getType() == CDOTransactionFinishedEvent.Type.COMMITTED)
@@ -170,14 +165,11 @@ public class CDOEventHandler
treeViewer = viewer;
}
- protected void sessionInvalidated(Set<CDOIDAndVersion> dirtyOIDs)
+ /**
+ * @since 2.0
+ */
+ protected void viewInvalidated(Set<? extends CDOObject> dirtyObjects)
{
- Set<CDOID> idsWithoutVersion = new HashSet<CDOID>();
- for (CDOIDAndVersion idAandVersion : dirtyOIDs)
- {
- idsWithoutVersion.add(idAandVersion.getID());
- }
-
new ItemsProcessor(view)
{
@Override
@@ -186,7 +178,7 @@ public class CDOEventHandler
objectInvalidated(cdoObject);
viewer.refresh(cdoObject.cdoInternalInstance(), true);
}
- }.processCDOObjects(treeViewer, idsWithoutVersion);
+ }.processCDOObjects(treeViewer, dirtyObjects);
}
protected void objectInvalidated(InternalCDOObject cdoObject)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOViewInvalidationEvent.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOViewInvalidationEvent.java
new file mode 100644
index 0000000000..befc5b06e9
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOViewInvalidationEvent.java
@@ -0,0 +1,46 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * 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:
+ * Simon McDuff - initial API and implementation
+ **************************************************************************/
+package org.eclipse.emf.cdo;
+
+import org.eclipse.net4j.util.event.IListener;
+
+import java.util.Set;
+
+/**
+ * An event that is emitted to registered {@link IListener listeners} of a {@link CDOView} if
+ * {@link CDOSession#setPassiveUpdateEnabled(boolean) passive update} is enabled for the session.
+ *
+ * @author Simon McDuff
+ * @see CDOInvalidationNotification
+ * @see CDOChangeSubscriptionPolicy
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @since 2.0
+ */
+public interface CDOViewInvalidationEvent extends CDOViewEvent
+{
+ /**
+ * Returns the time stamp of the server transaction if this event was sent as a result of a successfully committed
+ * transaction or <code>LOCAL_ROLLBACK</code> if this event was sent due to a local rollback.
+ */
+ public long getTimeStamp();
+
+ /**
+ * Returns a set of the {@link CDOObject CDOObjects} of the modified objects.
+ */
+ public Set<? extends CDOObject> getDirtyObjects();
+
+ /**
+ * Returns a set of the {@link CDOObject CDOObjects} of the removed objects.
+ *
+ * @since 2.0
+ */
+ public Set<? extends CDOObject> getDetachedObjects();
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
index 4fc545f3ec..d8797a457c 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
@@ -21,6 +21,7 @@ import org.eclipse.emf.cdo.CDORevisionPrefetchingPolicy;
import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.CDOViewEvent;
+import org.eclipse.emf.cdo.CDOViewInvalidationEvent;
import org.eclipse.emf.cdo.CDOViewSet;
import org.eclipse.emf.cdo.common.CDOProtocolConstants;
import org.eclipse.emf.cdo.common.id.CDOID;
@@ -78,6 +79,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -1032,9 +1034,10 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
* dirtyOIDs set to be unmodifiable. It does not wrap the set (again).
* @since 2.0
*/
- public void handleInvalidation(long timeStamp, Set<CDOIDAndVersion> dirtyOIDs, Collection<CDOID> detachedObjects)
+ public void handleInvalidation(long timeStamp, Set<CDOIDAndVersion> dirtyOIDs, Collection<CDOID> detachedOIDs)
{
- List<InternalCDOObject> dirtyObjects = invalidationNotificationEnabled ? new ArrayList<InternalCDOObject>() : null;
+ Set<InternalCDOObject> dirtyObjects = new HashSet<InternalCDOObject>();
+ Set<InternalCDOObject> detachedObjects = new HashSet<InternalCDOObject>();
lock.lock();
try
@@ -1048,34 +1051,39 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
if (dirtyObject != null)
{
CDOStateMachine.INSTANCE.invalidate(dirtyObject, dirtyOID.getVersion());
+ dirtyObjects.add(dirtyObject);
}
}
-
- if (dirtyObject != null && dirtyObjects != null && dirtyObject.eNotificationRequired())
- {
- dirtyObjects.add(dirtyObject);
- }
}
- for (CDOID id : detachedObjects)
+ for (CDOID id : detachedOIDs)
{
InternalCDOObject cdoObject = removeObject(id);
if (cdoObject != null)
{
CDOStateMachine.INSTANCE.detachRemote(cdoObject);
- if (dirtyObjects != null && cdoObject.eNotificationRequired())
- {
- dirtyObjects.add(cdoObject);
- }
+ detachedObjects.add(cdoObject);
}
}
- if (dirtyObjects != null)
+ if (invalidationNotificationEnabled)
{
for (InternalCDOObject dirtyObject : dirtyObjects)
{
- CDOInvalidationNotificationImpl notification = new CDOInvalidationNotificationImpl(dirtyObject);
- dirtyObject.eNotify(notification);
+ if (dirtyObject.eNotificationRequired())
+ {
+ CDOInvalidationNotificationImpl notification = new CDOInvalidationNotificationImpl(dirtyObject);
+ dirtyObject.eNotify(notification);
+ }
+ }
+
+ for (InternalCDOObject detachedObject : detachedObjects)
+ {
+ if (detachedObject.eNotificationRequired())
+ {
+ CDOInvalidationNotificationImpl notification = new CDOInvalidationNotificationImpl(detachedObject);
+ detachedObject.eNotify(notification);
+ }
}
}
}
@@ -1083,6 +1091,21 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
{
lock.unlock();
}
+
+ fireInvalidationEvent(timeStamp, Collections.unmodifiableSet(dirtyObjects), Collections
+ .unmodifiableSet(detachedObjects));
+ }
+
+ /**
+ * @since 2.0
+ */
+ public void fireInvalidationEvent(long timeStamp, Set<? extends CDOObject> dirtyObjects,
+ Set<? extends CDOObject> detachedObjects)
+ {
+ if (!dirtyObjects.isEmpty() || !detachedObjects.isEmpty())
+ {
+ fireEvent(new InvalidationEvent(timeStamp, dirtyObjects, detachedObjects));
+ }
}
/**
@@ -1548,4 +1571,46 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
}
+ /**
+ * @author Simon McDuff
+ */
+ private final class InvalidationEvent extends Event implements CDOViewInvalidationEvent
+ {
+ private static final long serialVersionUID = 1L;
+
+ private long timeStamp;
+
+ private Set<? extends CDOObject> dirtyObjects;
+
+ private Set<? extends CDOObject> detachedObjects;
+
+ public InvalidationEvent(long timeStamp, Set<? extends CDOObject> dirtyOIDs,
+ Set<? extends CDOObject> detachedObjects)
+ {
+ this.timeStamp = timeStamp;
+ dirtyObjects = dirtyOIDs;
+ this.detachedObjects = detachedObjects;
+ }
+
+ public long getTimeStamp()
+ {
+ return timeStamp;
+ }
+
+ public Set<? extends CDOObject> getDirtyObjects()
+ {
+ return dirtyObjects;
+ }
+
+ public Set<? extends CDOObject> getDetachedObjects()
+ {
+ return detachedObjects;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "CDOViewInvalidationEvent: " + dirtyObjects;
+ }
+ }
}

Back to the top