blob: 832a9ee7d81d5742eae15813c43a46f3dee620d4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
/**
* Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others.
* 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
* Eike Stepper - maintenance
*/
package org.eclipse.emf.internal.cdo.view;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.util.CDOURIUtil;
import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.cdo.view.CDOViewProvider;
import org.eclipse.emf.cdo.view.ManagedContainerViewProvider;
import org.eclipse.emf.internal.cdo.session.CDOSessionFactory;
import org.eclipse.net4j.util.container.IManagedContainer;
import org.eclipse.net4j.util.container.IPluginContainer;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.ResourceSet;
/**
* 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:.*"; //$NON-NLS-1$
private final static int PRIORITY = 400;
public PluginContainerViewProvider()
{
super(IPluginContainer.INSTANCE, REGEX, PRIORITY);
}
public CDOView getView(URI uri, ResourceSet resourceSet)
{
IManagedContainer container = getContainer();
if (container == null)
{
return null;
}
String repoUUID = CDOURIUtil.extractRepositoryUUID(uri);
for (Object element : container.getElements(CDOSessionFactory.PRODUCT_GROUP))
{
CDOSession session = (CDOSession)element;
String uuid = session.repository().getUUID();
if (repoUUID.equals(uuid))
{
CDOView view = openView(session, resourceSet);
if (view != null)
{
return view;
}
}
}
return null;
}
@Override
protected IManagedContainer getContainer()
{
return IPluginContainer.INSTANCE;
}
protected CDOView openView(CDOSession session, ResourceSet resourceSet)
{
return session.openTransaction(resourceSet);
}
}
|