Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/PluginContainerViewProvider.java')
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/PluginContainerViewProvider.java79
1 files changed, 79 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/PluginContainerViewProvider.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/PluginContainerViewProvider.java
new file mode 100644
index 0000000000..19762a77bc
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/PluginContainerViewProvider.java
@@ -0,0 +1,79 @@
+/***************************************************************************
+ * 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:
+ * Victor Roldan Betancort - initial API and implementation
+ **************************************************************************/
+package org.eclipse.emf.internal.cdo.util;
+
+import org.eclipse.emf.cdo.CDOSession;
+import org.eclipse.emf.cdo.CDOView;
+import org.eclipse.emf.cdo.CDOViewSet;
+import org.eclipse.emf.cdo.util.CDOURIUtil;
+import org.eclipse.emf.cdo.util.CDOViewProvider;
+import org.eclipse.emf.cdo.util.ManagedContainerViewProvider;
+
+import org.eclipse.emf.internal.cdo.CDOSessionFactory;
+
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.container.IPluginContainer;
+
+import org.eclipse.emf.common.util.URI;
+
+/**
+ * Provides <code>CDOView</code> from <code>CDOSession</code> registered in IPluginContainer
+ *
+ * @author Victor Roldan Betancort
+ */
+public class PluginContainerViewProvider extends ManagedContainerViewProvider implements CDOViewProvider
+{
+ private final static String REGEX = "cdo:.*";
+
+ private final static int PRIORITY = 400;
+
+ public PluginContainerViewProvider()
+ {
+ super(IPluginContainer.INSTANCE, REGEX, PRIORITY);
+ }
+
+ public CDOView getView(URI uri, CDOViewSet viewSet)
+ {
+ IManagedContainer container = getContainer();
+ if (container == null)
+ {
+ return null;
+ }
+
+ String repoUUID = CDOURIUtil.extractRepositoryUUID(uri);
+ for (Object element : container.getElements(CDOSessionFactory.PRODUCT_GROUP, CDOSessionFactory.TYPE))
+ {
+ CDOSession session = (CDOSession)element;
+ String uuid = session.repository().getUUID();
+ if (repoUUID.equals(uuid))
+ {
+ CDOView view = openView(session, uri);
+ if (view != null)
+ {
+ return view;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ protected IManagedContainer getContainer()
+ {
+ return IPluginContainer.INSTANCE;
+ }
+
+ protected CDOView openView(CDOSession session, URI uri)
+ {
+ return session.openTransaction();
+ }
+}

Back to the top