summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-07-02 03:41:39 (EDT)
committerEike Stepper2007-07-02 03:41:39 (EDT)
commit8c0ce1f30e6fd4e85f76ddd873bebdcdce92519e (patch)
treef08600db06845149c26a88a7f5684a460fa2a509
parent1db3bcb946993358321a881865b74383f153c467 (diff)
downloadcdo-8c0ce1f30e6fd4e85f76ddd873bebdcdce92519e.zip
cdo-8c0ce1f30e6fd4e85f76ddd873bebdcdce92519e.tar.gz
cdo-8c0ce1f30e6fd4e85f76ddd873bebdcdce92519e.tar.bz2
task 1: Develop 0.8.0
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java54
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOViewResourcesEvent.java33
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java48
5 files changed, 111 insertions, 30 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java
index 96d833a..5205e18 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java
@@ -155,6 +155,33 @@ public class CDOItemProvider extends ContainerItemProvider
return SharedIcons.getDescriptor(SharedIcons.ETOOL_OPEN_EDITOR);
}
+ @Override
+ protected Display getDisplay()
+ {
+ Display display = getViewer().getControl().getDisplay();
+ if (display == null)
+ {
+ display = Display.getCurrent();
+ }
+
+ if (display == null)
+ {
+ display = Display.getDefault();
+ }
+
+ if (display == null)
+ {
+ throw new IllegalStateException("display == null");
+ }
+
+ return display;
+ }
+
+ protected Object[] getResources(CDOView view)
+ {
+ return ResourceHistory.INSTANCE.getEntries(view);
+ }
+
/**
* @author Eike Stepper
*/
@@ -209,31 +236,4 @@ public class CDOItemProvider extends ContainerItemProvider
protected abstract CDOView createView();
}
-
- @Override
- protected Display getDisplay()
- {
- Display display = getViewer().getControl().getDisplay();
- if (display == null)
- {
- display = Display.getCurrent();
- }
-
- if (display == null)
- {
- display = Display.getDefault();
- }
-
- if (display == null)
- {
- throw new IllegalStateException("display == null");
- }
-
- return display;
- }
-
- protected Object[] getResources(CDOView view)
- {
- return ResourceHistory.INSTANCE.getEntries(view);
- }
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java
index 4b279ce..c03a84c 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java
@@ -14,13 +14,15 @@ import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
+import org.eclipse.net4j.util.event.INotifier;
+
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.ResourceSet;
/**
* @author Eike Stepper
*/
-public interface CDOView
+public interface CDOView extends INotifier
{
public static final long UNSPECIFIED_DATE = CDORevision.UNSPECIFIED_DATE;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOViewResourcesEvent.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOViewResourcesEvent.java
new file mode 100644
index 0000000..dbf95fb
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOViewResourcesEvent.java
@@ -0,0 +1,33 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 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:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.emf.cdo;
+
+import org.eclipse.net4j.util.event.IEvent;
+
+/**
+ * @author Eike Stepper
+ */
+public interface CDOViewResourcesEvent extends IEvent
+{
+ public CDOView getView();
+
+ public String getResourcePath();
+
+ public Kind getKind();
+
+ /**
+ * @author Eike Stepper
+ */
+ public enum Kind
+ {
+ ADDED, REMOVED;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
index 314feef..794768c 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
@@ -284,7 +284,7 @@ public class CDOSessionImpl extends Lifecycle implements CDOSession
public CDOSession getSession()
{
- return (CDOSession)getContainer();
+ return CDOSessionImpl.this;
}
public CDOView getView()
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 776714e..6d4c82b 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
@@ -13,6 +13,7 @@ package org.eclipse.emf.internal.cdo;
import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.CDOView;
+import org.eclipse.emf.cdo.CDOViewResourcesEvent;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.eresource.EresourceFactory;
import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl;
@@ -24,6 +25,7 @@ import org.eclipse.emf.cdo.protocol.util.ImplementationError;
import org.eclipse.emf.cdo.protocol.util.TransportException;
import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.net4j.internal.util.event.Event;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.emf.common.notify.Adapter;
@@ -44,7 +46,7 @@ import java.util.Set;
/**
* @author Eike Stepper
*/
-public class CDOViewImpl implements CDOView, Adapter.Internal
+public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier implements CDOView, Adapter.Internal
{
private static final ContextTracer TRACER = new ContextTracer(CDO.DEBUG_VIEW, CDOViewImpl.class);
@@ -377,6 +379,7 @@ public class CDOViewImpl implements CDOView, Adapter.Internal
{
if (!oldResources.contains(newResource))
{
+ // TODO Optimize event notification with IContainerEvent
notifyAdd((CDOResourceImpl)newResource);
}
}
@@ -386,6 +389,7 @@ public class CDOViewImpl implements CDOView, Adapter.Internal
private void notifyAdd(CDOResourceImpl cdoResource)
{
CDOStateMachine.INSTANCE.attach(cdoResource, cdoResource, this);
+ fireEvent(new ResourcesEvent(cdoResource.getPath(), ResourcesEvent.Kind.ADDED));
}
private void notifyRemove(Notification msg)
@@ -406,6 +410,7 @@ public class CDOViewImpl implements CDOView, Adapter.Internal
{
if (!newResources.contains(oldResource))
{
+ // TODO Optimize event notification with IContainerEvent
notifyRemove((CDOResourceImpl)oldResource);
}
}
@@ -415,6 +420,7 @@ public class CDOViewImpl implements CDOView, Adapter.Internal
private void notifyRemove(CDOResourceImpl cdoResource)
{
CDOStateMachine.INSTANCE.detach(cdoResource, cdoResource, this);
+ fireEvent(new ResourcesEvent(cdoResource.getPath(), ResourcesEvent.Kind.REMOVED));
}
private CDOObjectImpl createObject(CDOID id)
@@ -484,4 +490,44 @@ public class CDOViewImpl implements CDOView, Adapter.Internal
// return resourcePath;
// }
// }
+
+ /**
+ * @author Eike Stepper
+ */
+ private final class ResourcesEvent extends Event implements CDOViewResourcesEvent
+ {
+ private static final long serialVersionUID = 1L;
+
+ private String resourcePath;
+
+ private Kind kind;
+
+ public ResourcesEvent(String resourcePath, Kind kind)
+ {
+ super(CDOViewImpl.this);
+ this.resourcePath = resourcePath;
+ this.kind = kind;
+ }
+
+ public CDOViewImpl getView()
+ {
+ return CDOViewImpl.this;
+ }
+
+ public String getResourcePath()
+ {
+ return resourcePath;
+ }
+
+ public Kind getKind()
+ {
+ return kind;
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("CDOViewResourcesEvent[{0}, {1}, {2}]", getView(), resourcePath, kind);
+ }
+ }
}