Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 1dff73ebd2b3d26553e81926851f8d55708979a2 (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
/*****************************************************************************
 * Copyright (c) 2013, 2017 CEA LIST.
 *
 * 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:
 *   CEA LIST - Initial API and implementation
 *****************************************************************************/
package org.eclipse.papyrus.cdo.internal.core;

import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.papyrus.cdo.internal.core.controlmode.CDOProxyManager;


/**
 * A specialized {@link ResourceSet} that resolves CDO-style cross-resource proxies in the context of the attached {@linkplain CDOView view}.
 */
public class CDOProxyResolvingResourceSet extends ResourceSetImpl {

	public CDOProxyResolvingResourceSet() {
		super();
	}

	/**
	 * Extends the inherited implementation to handle CDO-style cross-resource proxies.
	 */
	@Override
	public EObject getEObject(URI uri, boolean loadOnDemand) {
		EObject result;

		if (CDOProxyManager.isCDOProxyURI(uri)) {
			// force loading (ignore 'loadOnDemand') because export requires a complete model
			Resource res = getResource(uri.trimFragment(), true);
			result = (res == null) ? null : res.getEObject(CDOProxyManager.extractOIDFragment(uri));
		} else {
			result = super.getEObject(uri, loadOnDemand);
		}

		return result;
	}


}

Back to the top