summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-07-06 02:26:24 (EDT)
committerEike Stepper2007-07-06 02:26:24 (EDT)
commita1441354f38bc8c0cae61da8667dd739debdcb74 (patch)
tree1c135b1d7836d161682fb94209d0399a4a3a5a9f
parent6ed11420a11b55ace78fa52b75dd0e75e78f7adc (diff)
downloadcdo-a1441354f38bc8c0cae61da8667dd739debdcb74.zip
cdo-a1441354f38bc8c0cae61da8667dd739debdcb74.tar.gz
cdo-a1441354f38bc8c0cae61da8667dd739debdcb74.tar.bz2
task 1: Develop 0.8.0
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/LabelUtil.java77
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditorInput.java33
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java60
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOViewHistory.java8
-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/internal/cdo/CDOSessionImpl.java6
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java13
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Connector.java1
8 files changed, 94 insertions, 108 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/LabelUtil.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/LabelUtil.java
deleted file mode 100644
index 32e5306..0000000
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/LabelUtil.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/***************************************************************************
- * 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.internal.ui;
-
-import org.eclipse.emf.cdo.CDOSession;
-import org.eclipse.emf.cdo.CDOView;
-import org.eclipse.emf.cdo.internal.ui.bundle.SharedIcons;
-
-import org.eclipse.net4j.IConnector;
-
-import org.eclipse.swt.graphics.Image;
-
-import java.util.Date;
-
-/**
- * @author Eike Stepper
- */
-public final class LabelUtil
-{
- private LabelUtil()
- {
- }
-
- public static String getText(Object obj)
- {
- if (obj instanceof CDOSession)
- {
- CDOSession session = (CDOSession)obj;
- IConnector connector = session.getChannel().getConnector();
- String repositoryName = session.getRepositoryName();
- return connector.getURL() + "/" + repositoryName;
- }
-
- if (obj instanceof CDOView)
- {
- CDOView view = (CDOView)obj;
- return view.isHistorical() ? new Date(view.getTimeStamp()).toString() : view.isReadOnly() ? "View"
- : "Transaction";
- }
-
- return null;
- }
-
- public static Image getImage(Object obj)
- {
- if (obj instanceof CDOSession)
- {
- return SharedIcons.getImage(SharedIcons.OBJ_SESSION);
- }
-
- if (obj instanceof CDOView)
- {
- CDOView view = (CDOView)obj;
- if (view.isHistorical())
- {
- return SharedIcons.getImage(SharedIcons.OBJ_EDITOR_HISTORICAL);
- }
-
- if (view.isReadOnly())
- {
- return SharedIcons.getImage(SharedIcons.OBJ_EDITOR_READONLY);
- }
-
- return SharedIcons.getImage(SharedIcons.OBJ_EDITOR);
- }
-
- return null;
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditorInput.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditorInput.java
index 0d35594..e175ed5 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditorInput.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditorInput.java
@@ -10,10 +10,13 @@
**************************************************************************/
package org.eclipse.emf.cdo.internal.ui.editor;
+import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.CDOView;
-import org.eclipse.emf.cdo.internal.ui.LabelUtil;
import org.eclipse.emf.cdo.internal.ui.bundle.SharedIcons;
+import org.eclipse.net4j.IConnector;
+
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IEditorInput;
@@ -68,14 +71,12 @@ public class CDOEditorInput extends PlatformObject implements IEditorInput
public String getName()
{
- StringBuilder builder = new StringBuilder();
- builder.append(view.getSession().getRepositoryName());
if (resourcePath != null)
{
- builder.append(resourcePath);
+ return new Path(resourcePath).lastSegment();
}
- return builder.toString();
+ return view.getSession().getRepositoryName();
}
public IPersistableElement getPersistable()
@@ -85,23 +86,33 @@ public class CDOEditorInput extends PlatformObject implements IEditorInput
public String getToolTipText()
{
+ CDOSession session = view.getSession();
+ IConnector connector = session.getChannel().getConnector();
+ String repositoryName = session.getRepositoryName();
+
StringBuilder builder = new StringBuilder();
- builder.append(LabelUtil.getText(view.getSession()));
+ builder.append(connector.getURL());
+ builder.append("/");
+ builder.append(repositoryName);
if (resourcePath != null)
{
builder.append(resourcePath);
}
+ builder.append(" [");
+ builder.append(session.getSessionID());
+ builder.append(":");
+ builder.append(view.getID());
+ builder.append("]");
+
if (view.isHistorical())
{
- builder.append(" (");
+ builder.append(" ");
builder.append(new Date(view.getTimeStamp()));
- builder.append(")");
}
-
- if (view.isReadOnly())
+ else if (view.isReadOnly())
{
- builder.append(" (readonly)");
+ builder.append(" readonly");
}
return builder.toString();
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 3a24854..08d2678 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
@@ -15,11 +15,11 @@ import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.CDOViewCommittedEvent;
import org.eclipse.emf.cdo.CDOViewDirtyEvent;
import org.eclipse.emf.cdo.CDOViewEvent;
-import org.eclipse.emf.cdo.internal.ui.LabelUtil;
import org.eclipse.emf.cdo.internal.ui.bundle.SharedIcons;
import org.eclipse.emf.cdo.internal.ui.editor.CDOEditor;
import org.eclipse.emf.cdo.internal.ui.views.CDOViewHistory.Entry;
+import org.eclipse.net4j.IConnector;
import org.eclipse.net4j.ui.actions.LongRunningAction;
import org.eclipse.net4j.ui.views.ContainerItemProvider;
import org.eclipse.net4j.ui.views.IElementFilter;
@@ -37,6 +37,7 @@ import org.eclipse.jface.viewers.ITreeSelection;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IWorkbenchPage;
+import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@@ -65,6 +66,15 @@ public class CDOItemProvider extends ContainerItemProvider
try
{
fireLabelProviderChanged(view);
+ CDOViewHistory history = viewHistories.get(view);
+ if (history != null)
+ {
+ Entry[] entries = history.getEntries();
+ if (entries != null && entries.length != 0)
+ {
+ fireLabelProviderChanged(entries);
+ }
+ }
}
catch (Exception ignore)
{
@@ -161,34 +171,56 @@ public class CDOItemProvider extends ContainerItemProvider
@Override
public String getText(Object obj)
{
- String text = LabelUtil.getText(obj);
- if (text == null)
+ if (obj instanceof CDOSession)
{
- text = super.getText(obj);
+ CDOSession session = (CDOSession)obj;
+ IConnector connector = session.getChannel().getConnector();
+ String repositoryName = session.getRepositoryName();
+ return connector.getURL() + "/" + repositoryName + " [" + session.getSessionID() + "]";
}
- if (obj instanceof CDOView && text != null)
+ if (obj instanceof CDOView)
{
CDOView view = (CDOView)obj;
- if (view.isDirty())
- {
- text = "*" + text;
- }
+ return (view.isDirty() ? "*" : "")
+ + (view.isHistorical() ? new Date(view.getTimeStamp()).toString() : view.isReadOnly() ? "View"
+ : "Transaction") + "[" + view.getID() + "]";
+ }
+
+ if (obj instanceof CDOViewHistory.Entry)
+ {
+ CDOViewHistory.Entry entry = (CDOViewHistory.Entry)obj;
+ return (entry.getView().isDirty() ? "*" : "") + entry.getResourcePath();
}
- return text;
+ return super.getText(obj);
}
@Override
public Image getImage(Object obj)
{
- Image image = LabelUtil.getImage(obj);
- if (image == null)
+ if (obj instanceof CDOSession)
+ {
+ return SharedIcons.getImage(SharedIcons.OBJ_SESSION);
+ }
+
+ if (obj instanceof CDOView)
{
- image = super.getImage(obj);
+ CDOView view = (CDOView)obj;
+ if (view.isHistorical())
+ {
+ return SharedIcons.getImage(SharedIcons.OBJ_EDITOR_HISTORICAL);
+ }
+
+ if (view.isReadOnly())
+ {
+ return SharedIcons.getImage(SharedIcons.OBJ_EDITOR_READONLY);
+ }
+
+ return SharedIcons.getImage(SharedIcons.OBJ_EDITOR);
}
- return image;
+ return super.getImage(obj);
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOViewHistory.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOViewHistory.java
index d6d6af6..12c711e 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOViewHistory.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOViewHistory.java
@@ -180,7 +180,13 @@ public final class CDOViewHistory extends Notifier
@Override
public boolean equals(Object obj)
{
- return resourcePath.equals(obj);
+ if (obj instanceof Entry)
+ {
+ Entry that = (Entry)obj;
+ return view == that.getView() && resourcePath.equals(that.resourcePath);
+ }
+
+ return false;
}
@Override
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 c92c5e4..83245d4 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
@@ -26,10 +26,12 @@ public interface CDOView extends INotifier
{
public static final long UNSPECIFIED_DATE = CDORevision.UNSPECIFIED_DATE;
- public ResourceSet getResourceSet();
+ public int getID();
public CDOSession getSession();
+ public ResourceSet getResourceSet();
+
public long getTimeStamp();
public boolean isHistorical();
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 0af3cfa..5a9a6ab 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
@@ -64,6 +64,8 @@ public class CDOSessionImpl extends Lifecycle implements CDOSession
private Map<ResourceSet, CDOViewImpl> views = new HashMap();
+ private int lastViewID = 0;
+
private IListener channelListener = new LifecycleEventAdapter()
{
@Override
@@ -149,13 +151,13 @@ public class CDOSessionImpl extends Lifecycle implements CDOSession
public CDOViewImpl openView(ResourceSet resourceSet, boolean readOnly)
{
prepare(resourceSet);
- return attach(resourceSet, new CDOViewImpl(this, readOnly));
+ return attach(resourceSet, new CDOViewImpl(++lastViewID, this, readOnly));
}
public CDOViewImpl openView(ResourceSet resourceSet, long timeStamp)
{
prepare(resourceSet);
- return attach(resourceSet, new CDOViewImpl(this, timeStamp));
+ return attach(resourceSet, new CDOViewImpl(++lastViewID, this, timeStamp));
}
public CDOViewImpl[] getViews()
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 ea46b10..de96ee9 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
@@ -54,6 +54,8 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
{
private static final ContextTracer TRACER = new ContextTracer(CDO.DEBUG_VIEW, CDOViewImpl.class);
+ private int id;
+
private CDOSessionImpl session;
private ResourceSet resourceSet;
@@ -68,8 +70,9 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
private CDOObjectImpl lastLookupObject;
- public CDOViewImpl(CDOSessionImpl session, boolean readOnly)
+ public CDOViewImpl(int id, CDOSessionImpl session, boolean readOnly)
{
+ this.id = id;
this.session = session;
timeStamp = UNSPECIFIED_DATE;
if (!readOnly)
@@ -78,12 +81,18 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
}
}
- public CDOViewImpl(CDOSessionImpl session, long timeStamp)
+ public CDOViewImpl(int id, CDOSessionImpl session, long timeStamp)
{
+ this.id = id;
this.session = session;
this.timeStamp = timeStamp;
}
+ public int getID()
+ {
+ return id;
+ }
+
public ResourceSet getResourceSet()
{
return resourceSet;
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Connector.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Connector.java
index f5c03b2..8a3e8e5 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Connector.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Connector.java
@@ -458,6 +458,7 @@ public abstract class Connector extends Lifecycle implements IConnector
protected boolean removeChannel(Channel channel, boolean actively)
{
+ // TODO Can cause deadlock on shutdown
synchronized (channels)
{
int channelIndex = channel.getChannelIndex();