Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-10-18 03:39:21 -0400
committerEike Stepper2008-10-18 03:39:21 -0400
commit11968dd945be9ae7292a991cb2a13b24a23e1d36 (patch)
tree799e5159fd0d6dec481b73b59fe4ac7097d02f2e
parent7a414508c8619cf60781cd5a2cf302f3f73b2244 (diff)
downloadcdo-11968dd945be9ae7292a991cb2a13b24a23e1d36.tar.gz
cdo-11968dd945be9ae7292a991cb2a13b24a23e1d36.tar.xz
cdo-11968dd945be9ae7292a991cb2a13b24a23e1d36.zip
[249847] Store resources in a hierarchical structure
https://bugs.eclipse.org/bugs/show_bug.cgi?id=249847
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassServerInfo.java16
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java26
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java68
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ObjectIDIterator.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ObjectTypeCache.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceTest.java34
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenResourceEditorAction.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ResourceNodeAction.java (renamed from plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/EntryAction.java)16
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsView.java21
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOItemProvider.java131
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/viewhistory/CDOViewHistory.java156
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/viewhistory/CDOViewHistoryEntry.java74
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/viewhistory/CDOViewHistoryEvent.java31
14 files changed, 131 insertions, 469 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassServerInfo.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassServerInfo.java
index cdf76c7770..9efa80867d 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassServerInfo.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassServerInfo.java
@@ -25,6 +25,10 @@ public final class ClassServerInfo extends ServerInfo
public static final int CDO_RESOURCE_CLASS_DBID = -2;
+ public static final int CDO_RESOURCE_NODE_CLASS_DBID = -3;
+
+ public static final int CDO_RESOURCE_FOLDERCLASS_DBID = -4;
+
private IClassMapping classMapping;
private ClassServerInfo(int id)
@@ -39,8 +43,8 @@ public final class ClassServerInfo extends ServerInfo
return serverInfo;
}
- /**
- * Should only be called from {@link MappingStrategy#getClassMapping(CDOClass)}.
+ /*
+ * Should only be called from MappingStrategy#getClassMapping(CDOClass).
*/
public static IClassMapping getClassMapping(CDOClass cdoClass)
{
@@ -68,6 +72,14 @@ public final class ClassServerInfo extends ServerInfo
{
serverInfo = setDBID(cdoClass, CDO_OBJECT_CLASS_DBID);
}
+ else if (cdoClass.isResourceNode())
+ {
+ serverInfo = setDBID(cdoClass, CDO_RESOURCE_NODE_CLASS_DBID);
+ }
+ else if (cdoClass.isResourceFolder())
+ {
+ serverInfo = setDBID(cdoClass, CDO_RESOURCE_FOLDERCLASS_DBID);
+ }
else if (cdoClass.isResource())
{
serverInfo = setDBID(cdoClass, CDO_RESOURCE_CLASS_DBID);
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
index 727ebe6f90..f9712ce7be 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
@@ -16,7 +16,6 @@ import org.eclipse.emf.cdo.internal.server.StoreAccessorPool;
import org.eclipse.emf.cdo.server.ISession;
import org.eclipse.emf.cdo.server.IView;
import org.eclipse.emf.cdo.server.StoreThreadLocal;
-import org.eclipse.emf.cdo.server.db.IClassMapping;
import org.eclipse.emf.cdo.server.db.IDBStore;
import org.eclipse.emf.cdo.server.db.IMappingStrategy;
import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
@@ -37,6 +36,7 @@ import javax.sql.DataSource;
import java.sql.Connection;
import java.text.MessageFormat;
+import java.util.HashSet;
import java.util.Set;
/**
@@ -230,14 +230,7 @@ public class DBStore extends LongIDStore implements IDBStore
DBUtil.insertRow(connection, dbAdapter, CDODBSchema.REPOSITORY, creationTime, 1, startupTime, 0, CRASHED,
CRASHED);
- MappingStrategy mappingStrategy = (MappingStrategy)getMappingStrategy();
-
- IClassMapping resourceClassMapping = mappingStrategy.getResourceNodeClassMapping();
- Set<IDBTable> tables = resourceClassMapping.getAffectedTables();
- if (dbAdapter.createTables(tables, connection).size() != tables.size())
- {
- throw new DBException("CDOResource tables not completely created");
- }
+ initResourceTables(connection);
}
else
{
@@ -343,6 +336,21 @@ public class DBStore extends LongIDStore implements IDBStore
return new DBSchema(name);
}
+ protected void initResourceTables(Connection connection)
+ {
+ IMappingStrategy mappingStrategy = getMappingStrategy();
+ Set<IDBTable> tables = new HashSet<IDBTable>();
+
+ tables.addAll(mappingStrategy.getResourceNodeClassMapping().getAffectedTables());
+ tables.addAll(mappingStrategy.getResourceFolderClassMapping().getAffectedTables());
+ tables.addAll(mappingStrategy.getResourceClassMapping().getAffectedTables());
+
+ if (dbAdapter.createTables(tables, connection).size() != tables.size())
+ {
+ throw new DBException("Resource tables not completely created");
+ }
+ }
+
protected long getStartupTime()
{
return System.currentTimeMillis();
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java
index 88e7d37d82..2dd1174577 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java
@@ -19,9 +19,10 @@ import org.eclipse.emf.cdo.common.model.CDOPackage;
import org.eclipse.emf.cdo.common.model.resource.CDOFolderFeature;
import org.eclipse.emf.cdo.common.model.resource.CDONameFeature;
import org.eclipse.emf.cdo.common.model.resource.CDOResourceClass;
+import org.eclipse.emf.cdo.common.model.resource.CDOResourceFolderClass;
import org.eclipse.emf.cdo.common.model.resource.CDOResourceNodeClass;
+import org.eclipse.emf.cdo.common.model.resource.CDOResourcePackage;
import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.server.IPackageManager;
import org.eclipse.emf.cdo.server.StoreUtil;
import org.eclipse.emf.cdo.server.IStoreReader.QueryResourcesContext;
import org.eclipse.emf.cdo.server.IStoreReader.QueryResourcesContext.ExactMatch;
@@ -66,6 +67,10 @@ public abstract class MappingStrategy extends Lifecycle implements IMappingStrat
private IClassMapping resourceNodeClassMapping;
+ private IClassMapping resourceFolderClassMapping;
+
+ private IClassMapping resourceClassMapping;
+
private IAttributeMapping resourceFolderFeatureMapping;
private IAttributeMapping resourceNameFeatureMapping;
@@ -135,14 +140,30 @@ public abstract class MappingStrategy extends Lifecycle implements IMappingStrat
CDOClassRef classRef = classRefs.get(classID);
if (classRef == null)
{
- if (classID == ClassServerInfo.CDO_RESOURCE_CLASS_DBID)
+ switch (classID)
{
- IPackageManager packageManager = getStore().getRepository().getPackageManager();
- CDOResourceClass resourceClass = packageManager.getCDOResourcePackage().getCDOResourceClass();
- classRef = resourceClass.createClassRef();
+ case ClassServerInfo.CDO_RESOURCE_NODE_CLASS_DBID:
+ {
+ CDOResourcePackage resourcePackage = getStore().getRepository().getPackageManager().getCDOResourcePackage();
+ classRef = resourcePackage.getCDOResourceNodeClass().createClassRef();
+ break;
}
- else
+
+ case ClassServerInfo.CDO_RESOURCE_FOLDERCLASS_DBID:
+ {
+ CDOResourcePackage resourcePackage = getStore().getRepository().getPackageManager().getCDOResourcePackage();
+ classRef = resourcePackage.getCDOResourceFolderClass().createClassRef();
+ break;
+ }
+
+ case ClassServerInfo.CDO_RESOURCE_CLASS_DBID:
{
+ CDOResourcePackage resourcePackage = getStore().getRepository().getPackageManager().getCDOResourcePackage();
+ classRef = resourcePackage.getCDOResourceClass().createClassRef();
+ break;
+ }
+
+ default:
classRef = storeReader.readClassRef(classID);
}
@@ -179,6 +200,26 @@ public abstract class MappingStrategy extends Lifecycle implements IMappingStrat
return resourceNodeClassMapping;
}
+ public IClassMapping getResourceFolderClassMapping()
+ {
+ if (resourceFolderClassMapping == null)
+ {
+ initResourceInfos();
+ }
+
+ return resourceFolderClassMapping;
+ }
+
+ public IClassMapping getResourceClassMapping()
+ {
+ if (resourceClassMapping == null)
+ {
+ initResourceInfos();
+ }
+
+ return resourceClassMapping;
+ }
+
public IFeatureMapping getResourceFolderFeatureMapping()
{
if (resourceFolderFeatureMapping == null)
@@ -241,15 +282,26 @@ public abstract class MappingStrategy extends Lifecycle implements IMappingStrat
protected void initResourceInfos()
{
- IPackageManager packageManager = getStore().getRepository().getPackageManager();
- CDOResourceNodeClass resourceNodeClass = packageManager.getCDOResourcePackage().getCDOResourceNodeClass();
+ // Package
+ CDOResourcePackage resourcePackage = getStore().getRepository().getPackageManager().getCDOResourcePackage();
+
+ // Classes
+ CDOResourceNodeClass resourceNodeClass = resourcePackage.getCDOResourceNodeClass();
+ CDOResourceFolderClass resourceFolderClass = resourcePackage.getCDOResourceFolderClass();
+ CDOResourceClass resourceClass = resourcePackage.getCDOResourceClass();
+
+ // Features
CDOFolderFeature folderFeature = resourceNodeClass.getCDOFolderFeature();
CDONameFeature nameFeature = resourceNodeClass.getCDONameFeature();
+ // Mappings
resourceNodeClassMapping = getClassMapping(resourceNodeClass);
+ resourceFolderClassMapping = getClassMapping(resourceFolderClass);
+ resourceClassMapping = getClassMapping(resourceClass);
resourceFolderFeatureMapping = resourceNodeClassMapping.getAttributeMapping(folderFeature);
resourceNameFeatureMapping = resourceNodeClassMapping.getAttributeMapping(nameFeature);
+ // Schema
resourceNodeTable = resourceNodeClassMapping.getTable();
resourceIDField = resourceNodeTable.getField(CDODBSchema.ATTRIBUTES_ID);
resourceFolderField = resourceFolderFeatureMapping.getField();
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ObjectIDIterator.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ObjectIDIterator.java
index c92259e858..94d4ea9105 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ObjectIDIterator.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ObjectIDIterator.java
@@ -14,6 +14,7 @@ package org.eclipse.emf.cdo.server.internal.db;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.server.db.IDBStoreReader;
+import org.eclipse.emf.cdo.server.db.IMappingStrategy;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
@@ -28,7 +29,7 @@ import java.util.NoSuchElementException;
*/
public abstract class ObjectIDIterator implements CloseableIterator<CDOID>
{
- private MappingStrategy mappingStrategy;
+ private IMappingStrategy mappingStrategy;
private IDBStoreReader storeReader;
@@ -42,7 +43,7 @@ public abstract class ObjectIDIterator implements CloseableIterator<CDOID>
* Creates an iterator over all objects in a store. It is important to {@link #dispose()} of this iterator after usage
* to properly close internal result sets.
*/
- public ObjectIDIterator(MappingStrategy mappingStrategy, IDBStoreReader storeReader)
+ public ObjectIDIterator(IMappingStrategy mappingStrategy, IDBStoreReader storeReader)
{
this.mappingStrategy = mappingStrategy;
this.storeReader = storeReader;
@@ -60,7 +61,7 @@ public abstract class ObjectIDIterator implements CloseableIterator<CDOID>
return closed;
}
- public MappingStrategy getMappingStrategy()
+ public IMappingStrategy getMappingStrategy()
{
return mappingStrategy;
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ObjectTypeCache.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ObjectTypeCache.java
index 71cfe61e8a..60a5ecd909 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ObjectTypeCache.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ObjectTypeCache.java
@@ -16,6 +16,7 @@ import org.eclipse.emf.cdo.common.model.CDOClass;
import org.eclipse.emf.cdo.common.model.CDOClassRef;
import org.eclipse.emf.cdo.server.db.IDBStoreReader;
import org.eclipse.emf.cdo.server.db.IDBStoreWriter;
+import org.eclipse.emf.cdo.server.db.IMappingStrategy;
import org.eclipse.emf.cdo.server.db.IObjectTypeCache;
import org.eclipse.net4j.db.DBException;
@@ -37,7 +38,7 @@ import java.sql.Statement;
*/
public class ObjectTypeCache extends Lifecycle implements IObjectTypeCache
{
- private MappingStrategy mappingStrategy;
+ private IMappingStrategy mappingStrategy;
private IDBTable table;
@@ -51,12 +52,12 @@ public class ObjectTypeCache extends Lifecycle implements IObjectTypeCache
{
}
- public MappingStrategy getMappingStrategy()
+ public IMappingStrategy getMappingStrategy()
{
return mappingStrategy;
}
- public void setMappingStrategy(MappingStrategy mappingStrategy)
+ public void setMappingStrategy(IMappingStrategy mappingStrategy)
{
this.mappingStrategy = mappingStrategy;
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceTest.java
index dfbe08b745..0a7f5339af 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceTest.java
@@ -104,6 +104,7 @@ public class ResourceTest extends AbstractCDOTest
names.add(name);
path += "/" + name;
}
+
final URI uri = URI.createURI("cdo:" + path);
CDOResource resource = (CDOResource)resourceSet.createResource(uri);
assertEquals(names.get(names.size() - 1), resource.getName());
@@ -122,8 +123,10 @@ public class ResourceTest extends AbstractCDOTest
{
next = ((CDOResourceFolder)next).getNodes().get(0);
}
+
nodesList.add(next);
}
+
resourceByLookup = (CDOResource)next;
assertSame(resource, resourceByLookup);
assertClean(resourceByLookup, transaction);
@@ -146,6 +149,7 @@ public class ResourceTest extends AbstractCDOTest
assertEquals(CDOID.NULL, cdoResourceNode.cdoRevision().getData().getResourceID());
assertEquals(cdoParent.cdoID(), cdoResourceNode.cdoRevision().getData().getContainerID());
}
+
cdoParent = cdoResourceNode;
}
@@ -176,6 +180,7 @@ public class ResourceTest extends AbstractCDOTest
{
assertEquals(false, resourceSet.getResources().contains(transientNode));
}
+
assertEquals(null, transientNode.eResource());
if (i == depthtoRemove)
{
@@ -185,6 +190,7 @@ public class ResourceTest extends AbstractCDOTest
{
assertEquals(cdoParent, transientNode.eContainer());
}
+
cdoParent = transientNode;
}
@@ -205,23 +211,21 @@ public class ResourceTest extends AbstractCDOTest
assertEquals(CDOURIUtil.createResourceURI(session, "test1"), resource.getURI());
assertEquals("test1", resource.getName());
assertEquals(null, resource.getFolder());
+
transaction.getRootResource().getContents().contains(resource);
transaction.commit();
CDOObject cdoResource = CDOUtil.getCDOObject(resource);
CDOObject cdoRootResource = CDOUtil.getCDOObject(transaction.getRootResource());
-
assertClean(cdoResource, transaction);
assertClean(cdoRootResource, transaction);
assertEquals(CDOID.NULL, cdoResource.cdoRevision().getData().getContainerID());
assertEquals(cdoRootResource.cdoID(), cdoResource.cdoRevision().getData().getResourceID());
assertEquals(CDOID.NULL, cdoRootResource.cdoRevision().getData().getResourceID());
-
assertEquals(true, transaction.getResourceSet().getResources().contains(resource));
assertEquals(true, transaction.getResourceSet().getResources().contains(transaction.getRootResource()));
transaction.getRootResource().getContents().remove(resource);
-
assertEquals(false, transaction.getResourceSet().getResources().contains(resource));
assertEquals(true, transaction.getResourceSet().getResources().contains(transaction.getRootResource()));
@@ -249,23 +253,18 @@ public class ResourceTest extends AbstractCDOTest
public void testCreateResource_FromTransaction() throws Exception
{
- msg("Opening session");
CDOSession session = openModel1Session();
-
- msg("Opening transaction");
CDOTransaction transaction = session.openTransaction();
// Test if Resource is well-formed after CDOResourceFactoryImpl.
// Adapter will be called right after and could be used!
transaction.getResourceSet().eAdapters().add(new TestAdapter());
- msg("Creating resource");
CDOResource resource = transaction.createResource("/test1");
assertActive(resource);
+
CDOResource resourceCopy = transaction.getOrCreateResource("/test1");
assertEquals(resource, resourceCopy);
-
- msg("Verifying resource");
assertNew(resource, transaction);
assertEquals(CDOURIUtil.createResourceURI(session, "test1"), resource.getURI());
assertEquals(transaction.getResourceSet(), resource.getResourceSet());
@@ -274,22 +273,17 @@ public class ResourceTest extends AbstractCDOTest
public void testRemoveResourceWithCloseView() throws Exception
{
{
- msg("Opening session");
CDOSession session = openModel1Session();
-
- msg("Opening transaction");
CDOTransaction transaction = session.openTransaction();
ResourceSet rset = transaction.getResourceSet();
- msg("Creating resource");
CDOResource resource = transaction.createResource("/test1");
assertActive(resource);
- transaction.commit();
+ transaction.commit();
Assert.assertEquals(2, rset.getResources().size());
Assert.assertEquals(1, CDOUtil.getViewSet(rset).getViews().length);
transaction.close();
-
Assert.assertEquals(0, CDOUtil.getViewSet(rset).getViews().length);
Assert.assertEquals(0, rset.getResources().size());
session.close();
@@ -297,10 +291,7 @@ public class ResourceTest extends AbstractCDOTest
{
CDOSession session = openModel1Session();
- msg("Opening transaction");
CDOTransaction transaction = session.openTransaction();
-
- msg("Getting resource");
CDOResource resource = (CDOResource)transaction.getResourceSet().getResource(
CDOURIUtil.createResourceURI(transaction, "/test1"), true);
assertNotNull(resource);
@@ -324,25 +315,21 @@ public class ResourceTest extends AbstractCDOTest
List<Resource> tobeRemoved = new ArrayList<Resource>();
tobeRemoved.add(resource1);
tobeRemoved.add(resource3);
-
assertEquals(4, transaction.getResourceSet().getResources().size());
transaction.getResourceSet().getResources().removeAll(tobeRemoved);
-
assertEquals(2, transaction.getResourceSet().getResources().size());
assertEquals(null, transaction.getResourceSet().getResource(resource1.getURI(), false));
assertEquals(resource2, transaction.getResourceSet().getResource(resource2.getURI(), false));
assertEquals(null, transaction.getResourceSet().getResource(resource3.getURI(), false));
transaction.getResourceSet().getResources().addAll(tobeRemoved);
-
assertEquals(4, transaction.getResourceSet().getResources().size());
assertEquals(resource1, transaction.getResourceSet().getResource(resource1.getURI(), false));
assertEquals(resource2, transaction.getResourceSet().getResource(resource2.getURI(), false));
assertEquals(resource3, transaction.getResourceSet().getResource(resource3.getURI(), false));
transaction.commit();
-
session.close();
}
@@ -358,11 +345,9 @@ public class ResourceTest extends AbstractCDOTest
List<Resource> tobeRemoved = new ArrayList<Resource>();
tobeRemoved.add(resource1);
tobeRemoved.add(resource3);
-
assertEquals(4, transaction.getResourceSet().getResources().size());
transaction.getResourceSet().getResources().removeAll(tobeRemoved);
-
assertEquals(2, transaction.getResourceSet().getResources().size());
assertEquals(null, transaction.getResourceSet().getResource(resource1.getURI(), false));
assertEquals(resource2, transaction.getResourceSet().getResource(resource2.getURI(), false));
@@ -508,6 +493,7 @@ public class ResourceTest extends AbstractCDOTest
assertClean(order, transaction);
session.close();
}
+
CDOSession session = openModel1Session();
CDOTransaction transaction = session.openTransaction();
diff --git a/plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF
index 15b465e0e5..0b69287036 100644
--- a/plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF
@@ -26,6 +26,5 @@ Export-Package: org.eclipse.emf.cdo.internal.ui;version="2.0.0";x-internal:=true
org.eclipse.emf.cdo.internal.ui.preferences;version="2.0.0";x-internal:=true,
org.eclipse.emf.cdo.internal.ui.views;version="2.0.0";x-internal:=true,
org.eclipse.emf.cdo.ui;version="2.0.0",
- org.eclipse.emf.cdo.ui.viewhistory;version="2.0.0",
org.eclipse.emf.cdo.ui.widgets;version="2.0.0"
Bundle-ActivationPolicy: lazy
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenResourceEditorAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenResourceEditorAction.java
index a9bd2929a7..d457a0b0e9 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenResourceEditorAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenResourceEditorAction.java
@@ -11,8 +11,8 @@
package org.eclipse.emf.cdo.internal.ui.actions;
import org.eclipse.emf.cdo.CDOView;
+import org.eclipse.emf.cdo.eresource.CDOResourceNode;
import org.eclipse.emf.cdo.internal.ui.editor.CDOEditor;
-import org.eclipse.emf.cdo.ui.viewhistory.CDOViewHistoryEntry;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IWorkbenchPage;
@@ -20,23 +20,23 @@ import org.eclipse.ui.IWorkbenchPage;
/**
* @author Eike Stepper
*/
-public final class OpenResourceEditorAction extends EntryAction
+public final class OpenResourceEditorAction extends ResourceNodeAction
{
private static final String TITLE = "Open Editor";
private static final String TOOL_TIP = "Open a CDO editor for this resource";
public OpenResourceEditorAction(IWorkbenchPage page, String text, String toolTipText, ImageDescriptor image,
- CDOViewHistoryEntry entry)
+ CDOResourceNode resourceNode)
{
- super(page, TITLE, TOOL_TIP, null, entry);
+ super(page, TITLE, TOOL_TIP, null, resourceNode);
}
@Override
protected void doRun() throws Exception
{
- CDOView view = getEntry().getView();
- String resourcePath = getEntry().getResourcePath();
+ CDOView view = getResourceNode().cdoView();
+ String resourcePath = getResourceNode().getPath();
CDOEditor.open(getPage(), view, resourcePath);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/EntryAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ResourceNodeAction.java
index 27e81e4c81..1eae1606ff 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/EntryAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ResourceNodeAction.java
@@ -10,7 +10,7 @@
**************************************************************************/
package org.eclipse.emf.cdo.internal.ui.actions;
-import org.eclipse.emf.cdo.ui.viewhistory.CDOViewHistoryEntry;
+import org.eclipse.emf.cdo.eresource.CDOResourceNode;
import org.eclipse.net4j.util.ui.actions.LongRunningAction;
@@ -20,19 +20,19 @@ import org.eclipse.ui.IWorkbenchPage;
/**
* @author Eike Stepper
*/
-public abstract class EntryAction extends LongRunningAction
+public abstract class ResourceNodeAction extends LongRunningAction
{
- private CDOViewHistoryEntry entry;
+ private CDOResourceNode resourceNode;
- public EntryAction(IWorkbenchPage page, String text, String toolTipText, ImageDescriptor image,
- CDOViewHistoryEntry entry)
+ public ResourceNodeAction(IWorkbenchPage page, String text, String toolTipText, ImageDescriptor image,
+ CDOResourceNode resourceNode)
{
super(page, text, toolTipText, image);
- this.entry = entry;
+ this.resourceNode = resourceNode;
}
- public CDOViewHistoryEntry getEntry()
+ public CDOResourceNode getResourceNode()
{
- return entry;
+ return resourceNode;
}
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsView.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsView.java
index e6e46ab40e..e9308481f9 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsView.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsView.java
@@ -11,11 +11,8 @@
package org.eclipse.emf.cdo.internal.ui.views;
import org.eclipse.emf.cdo.CDOSession;
-import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.internal.ui.actions.OpenSessionAction;
-import org.eclipse.emf.cdo.internal.ui.editor.CDOEditor;
import org.eclipse.emf.cdo.ui.CDOItemProvider;
-import org.eclipse.emf.cdo.ui.viewhistory.CDOViewHistoryEntry;
import org.eclipse.net4j.util.container.IContainer;
import org.eclipse.net4j.util.container.IManagedContainer;
@@ -27,7 +24,6 @@ import org.eclipse.net4j.util.ui.views.IElementFilter;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IWorkbenchPage;
public class CDOSessionsView extends ContainerView
{
@@ -68,21 +64,4 @@ public class CDOSessionsView extends ContainerView
manager.add(openSessionAction);
super.fillLocalToolBar(manager);
}
-
- @Override
- protected void doubleClicked(Object object)
- {
- if (object instanceof CDOViewHistoryEntry)
- {
- CDOViewHistoryEntry entry = (CDOViewHistoryEntry)object;
- IWorkbenchPage page = getViewSite().getPage();
- CDOView view = entry.getView();
- String resourcePath = entry.getResourcePath();
- CDOEditor.open(page, view, resourcePath);
- }
- else
- {
- super.doubleClicked(object);
- }
- }
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOItemProvider.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOItemProvider.java
index 2668ba13c3..1f13777bd3 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOItemProvider.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOItemProvider.java
@@ -14,10 +14,7 @@ package org.eclipse.emf.cdo.ui;
import org.eclipse.emf.cdo.CDOAudit;
import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.CDOTransaction;
-import org.eclipse.emf.cdo.CDOTransactionFinishedEvent;
-import org.eclipse.emf.cdo.CDOTransactionStartedEvent;
import org.eclipse.emf.cdo.CDOView;
-import org.eclipse.emf.cdo.CDOViewEvent;
import org.eclipse.emf.cdo.internal.ui.SharedIcons;
import org.eclipse.emf.cdo.internal.ui.actions.CloseSessionAction;
import org.eclipse.emf.cdo.internal.ui.actions.CloseViewAction;
@@ -36,15 +33,10 @@ import org.eclipse.emf.cdo.internal.ui.actions.RegisterSinglePackageAction;
import org.eclipse.emf.cdo.internal.ui.actions.RegisterWorkspacePackagesAction;
import org.eclipse.emf.cdo.internal.ui.actions.ReloadViewAction;
import org.eclipse.emf.cdo.internal.ui.actions.RollbackTransactionAction;
-import org.eclipse.emf.cdo.ui.viewhistory.CDOViewHistory;
-import org.eclipse.emf.cdo.ui.viewhistory.CDOViewHistoryEntry;
-import org.eclipse.emf.cdo.ui.viewhistory.CDOViewHistoryEvent;
import org.eclipse.emf.cdo.util.CDOPackageType;
import org.eclipse.emf.cdo.util.CDOPackageTypeRegistry;
import org.eclipse.net4j.util.container.IContainer;
-import org.eclipse.net4j.util.event.IEvent;
-import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.ui.actions.SafeAction;
import org.eclipse.net4j.util.ui.views.ContainerItemProvider;
import org.eclipse.net4j.util.ui.views.IElementFilter;
@@ -61,7 +53,6 @@ import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -74,66 +65,6 @@ public class CDOItemProvider extends ContainerItemProvider<IContainer<Object>>
{
private IWorkbenchPage page;
- private Map<CDOView, CDOViewHistory> viewHistories = new HashMap<CDOView, CDOViewHistory>();
-
- private IListener viewListener = new IListener()
- {
- public void notifyEvent(IEvent event)
- {
- if (event instanceof CDOTransactionStartedEvent || event instanceof CDOTransactionFinishedEvent)
- {
- try
- {
- final CDOView view = ((CDOViewEvent)event).getView();
- getViewer().getControl().getDisplay().syncExec(new Runnable()
- {
- public void run()
- {
- try
- {
- fireLabelProviderChanged(view);
- CDOViewHistory history = viewHistories.get(view);
- if (history != null)
- {
- CDOViewHistoryEntry[] entries = history.getEntries();
- if (entries != null && entries.length != 0)
- {
- fireLabelProviderChanged(entries);
- }
- }
- }
- catch (Exception ignore)
- {
- }
- }
- });
- }
- catch (Exception ignore)
- {
- }
- }
- }
- };
-
- private IListener historyListener = new IListener()
- {
- public void notifyEvent(IEvent event)
- {
- if (event instanceof CDOViewHistoryEvent)
- {
- CDOViewHistoryEvent e = (CDOViewHistoryEvent)event;
- CDOView view = e.getViewHistory().getView();
- refreshElement(view, false);
-
- CDOViewHistoryEntry addedEntry = e.getAddedEntry();
- if (addedEntry != null)
- {
- revealElement(addedEntry);
- }
- }
- }
- };
-
public CDOItemProvider(IWorkbenchPage page, IElementFilter rootElementFilter)
{
super(rootElementFilter);
@@ -150,13 +81,7 @@ public class CDOItemProvider extends ContainerItemProvider<IContainer<Object>>
{
if (element instanceof CDOView)
{
- CDOView view = (CDOView)element;
- CDOViewHistory history = viewHistories.get(view);
- if (history != null)
- {
- return history.getEntries();
- }
-
+ // CDOView view = (CDOView)element;
return NO_ELEMENTS;
}
@@ -168,13 +93,7 @@ public class CDOItemProvider extends ContainerItemProvider<IContainer<Object>>
{
if (element instanceof CDOView)
{
- CDOView view = (CDOView)element;
- CDOViewHistory history = viewHistories.get(view);
- if (history != null)
- {
- return history.hasEntries();
- }
-
+ // CDOView view = (CDOView)element;
return false;
}
@@ -184,10 +103,10 @@ public class CDOItemProvider extends ContainerItemProvider<IContainer<Object>>
@Override
public Object getParent(Object element)
{
- if (element instanceof CDOViewHistoryEntry)
- {
- return ((CDOViewHistoryEntry)element).getView();
- }
+ // if (element instanceof CDOViewHistoryEntry)
+ // {
+ // return ((CDOViewHistoryEntry)element).getView();
+ // }
return super.getParent(element);
}
@@ -205,11 +124,6 @@ public class CDOItemProvider extends ContainerItemProvider<IContainer<Object>>
return getViewLabel((CDOView)obj);
}
- if (obj instanceof CDOViewHistoryEntry)
- {
- return getHistroyEntryLabel((CDOViewHistoryEntry)obj);
- }
-
return super.getText(obj);
}
@@ -260,14 +174,6 @@ public class CDOItemProvider extends ContainerItemProvider<IContainer<Object>>
return MessageFormat.format("View [{0}]", view.getViewID());
}
- /**
- * @since 2.0
- */
- public static String getHistroyEntryLabel(CDOViewHistoryEntry entry)
- {
- return (entry.getView().isDirty() ? "*" : "") + entry.getResourcePath();
- }
-
@Override
protected void fillContextMenu(IMenuManager manager, ITreeSelection selection)
{
@@ -283,10 +189,6 @@ public class CDOItemProvider extends ContainerItemProvider<IContainer<Object>>
{
fillView(manager, (CDOView)object);
}
- else if (object instanceof CDOViewHistoryEntry)
- {
- fillHistoryEntry(manager, (CDOViewHistoryEntry)object);
- }
}
}
@@ -363,25 +265,13 @@ public class CDOItemProvider extends ContainerItemProvider<IContainer<Object>>
manager.add(new CloseViewAction(page, view));
}
- /**
- * @since 2.0
- */
- protected void fillHistoryEntry(IMenuManager manager, CDOViewHistoryEntry entry)
- {
- }
-
@Override
protected void elementAdded(Object element, Object parent)
{
super.elementAdded(element, parent);
if (element instanceof CDOView)
{
- CDOView view = (CDOView)element;
- view.addListener(viewListener);
-
- CDOViewHistory history = new CDOViewHistory(view);
- history.addListener(historyListener);
- viewHistories.put(view, history);
+ // CDOView view = (CDOView)element;
}
}
@@ -391,12 +281,7 @@ public class CDOItemProvider extends ContainerItemProvider<IContainer<Object>>
super.elementRemoved(element, parent);
if (element instanceof CDOView)
{
- CDOView view = (CDOView)element;
- view.removeListener(viewListener);
-
- CDOViewHistory history = viewHistories.remove(view);
- history.removeListener(historyListener);
- history.dispose();
+ // CDOView view = (CDOView)element;
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/viewhistory/CDOViewHistory.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/viewhistory/CDOViewHistory.java
deleted file mode 100644
index ad050c1e36..0000000000
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/viewhistory/CDOViewHistory.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/***************************************************************************
- * 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:
- * Eike Stepper - initial API and implementation
- **************************************************************************/
-package org.eclipse.emf.cdo.ui.viewhistory;
-
-import org.eclipse.emf.cdo.CDOView;
-import org.eclipse.emf.cdo.CDOViewResourcesEvent;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-
-import org.eclipse.net4j.util.event.Event;
-import org.eclipse.net4j.util.event.IEvent;
-import org.eclipse.net4j.util.event.IListener;
-import org.eclipse.net4j.util.event.Notifier;
-
-import org.eclipse.emf.ecore.resource.Resource;
-
-import java.text.MessageFormat;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- * @since 2.0
- */
-public final class CDOViewHistory extends Notifier
-{
- private CDOView view;
-
- private Set<CDOViewHistoryEntry> entries = new HashSet<CDOViewHistoryEntry>();
-
- private IListener viewListener = new IListener()
- {
- public void notifyEvent(IEvent event)
- {
- if (event instanceof CDOViewResourcesEvent)
- {
- CDOViewResourcesEvent e = (CDOViewResourcesEvent)event;
- if (e.getView() == view && e.getKind() == CDOViewResourcesEvent.Kind.ADDED)
- {
- addResource(e.getResourcePath());
- }
- }
- }
- };
-
- public CDOViewHistory(CDOView view)
- {
- this.view = view;
- view.addListener(viewListener);
- }
-
- public void dispose()
- {
- view.removeListener(viewListener);
- entries.clear();
- }
-
- public CDOView getView()
- {
- return view;
- }
-
- public CDOViewHistoryEntry[] getEntries()
- {
- synchronized (entries)
- {
- return entries.toArray(new CDOViewHistoryEntry[entries.size()]);
- }
- }
-
- public boolean hasEntries()
- {
- synchronized (entries)
- {
- return !entries.isEmpty();
- }
- }
-
- public void reset()
- {
- Set<CDOViewHistoryEntry> openResources = new HashSet<CDOViewHistoryEntry>();
- for (Resource resource : view.getResourceSet().getResources())
- {
- if (resource instanceof CDOResource)
- {
- CDOResource cdoResource = (CDOResource)resource;
- openResources.add(new CDOViewHistoryEntry(view, cdoResource.getPath()));
- }
- }
-
- boolean changed;
- synchronized (entries)
- {
- changed = entries.retainAll(openResources);
- }
-
- if (changed)
- {
- fireEvent(new ViewHistoryEvent(null));
- }
- }
-
- protected void addResource(String resourcePath)
- {
- CDOViewHistoryEntry entry = new CDOViewHistoryEntry(view, resourcePath);
- boolean changed;
- synchronized (entries)
- {
- changed = entries.add(entry);
- }
-
- if (changed)
- {
- fireEvent(new ViewHistoryEvent(entry));
- }
- }
-
- /**
- * @author Eike Stepper
- */
- private final class ViewHistoryEvent extends Event implements CDOViewHistoryEvent
- {
- private static final long serialVersionUID = 1L;
-
- CDOViewHistoryEntry addedEntry;
-
- public ViewHistoryEvent(CDOViewHistoryEntry addedEntry)
- {
- super(CDOViewHistory.this);
- this.addedEntry = addedEntry;
- }
-
- public CDOViewHistory getViewHistory()
- {
- return CDOViewHistory.this;
- }
-
- public CDOViewHistoryEntry getAddedEntry()
- {
- return addedEntry;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("CDOViewHistoryEvent[source={0}, addedEntry={1}]", getSource(), getAddedEntry());
- }
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/viewhistory/CDOViewHistoryEntry.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/viewhistory/CDOViewHistoryEntry.java
deleted file mode 100644
index 2e27842687..0000000000
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/viewhistory/CDOViewHistoryEntry.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.eclipse.emf.cdo.ui.viewhistory;
-
-import org.eclipse.emf.cdo.CDOView;
-
-/**
- * @author Eike Stepper
- * @since 2.0
- */
-public final class CDOViewHistoryEntry implements Comparable<CDOViewHistoryEntry>
-{
- private CDOView view;
-
- private String resourcePath;
-
- public CDOViewHistoryEntry(CDOView view, String resourcePath)
- {
- if (view == null)
- {
- throw new IllegalArgumentException("view == null");
- }
-
- if (resourcePath == null)
- {
- throw new IllegalArgumentException("resourcePath == null");
- }
-
- this.view = view;
- this.resourcePath = resourcePath;
- }
-
- public CDOView getView()
- {
- return view;
- }
-
- public String getResourcePath()
- {
- return resourcePath;
- }
-
- public int compareTo(CDOViewHistoryEntry entry)
- {
- return resourcePath.compareTo(entry.resourcePath);
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj instanceof CDOViewHistoryEntry)
- {
- CDOViewHistoryEntry that = (CDOViewHistoryEntry)obj;
- return view == that.getView() && resourcePath.equals(that.resourcePath);
- }
-
- return false;
- }
-
- @Override
- public int hashCode()
- {
- return resourcePath.hashCode();
- }
-
- @Override
- public String toString()
- {
- return resourcePath;
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/viewhistory/CDOViewHistoryEvent.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/viewhistory/CDOViewHistoryEvent.java
deleted file mode 100644
index 200f9250ff..0000000000
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/viewhistory/CDOViewHistoryEvent.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/***************************************************************************
- * 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:
- * Eike Stepper - initial API and implementation
- **************************************************************************/
-package org.eclipse.emf.cdo.ui.viewhistory;
-
-import org.eclipse.net4j.util.event.IEvent;
-
-/**
- * @author Eike Stepper
- * @noimplement This interface is not intended to be implemented by clients.
- * @since 2.0
- */
-public interface CDOViewHistoryEvent extends IEvent
-{
- /**
- * @since 2.0
- */
- public CDOViewHistory getViewHistory();
-
- /**
- * @since 2.0
- */
- public CDOViewHistoryEntry getAddedEntry();
-}

Back to the top