blob: f186f6b98514f7fd94a982855ce7af6aa7bbc851 (
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
81
82
83
84
85
86
87
88
89
90
91
|
/*******************************************************************************
* Copyright (c) 2012, 2014 Obeo.
* 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:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.emf.compare.diagram.ecoretools.tests.edgechanges.data;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Collections;
import org.eclipse.emf.common.EMFPlugin;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.compare.diagram.ecoretools.tests.DiagramInputData;
import org.eclipse.emf.ecore.EcorePackage;
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.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl;
import org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactory;
import org.eclipse.gmf.runtime.notation.NotationPackage;
public class EdgeChangesInputData extends DiagramInputData {
public Resource getA1Left() throws IOException {
return loadFromClassLoader("a1/TC01.ecorediag"); //$NON-NLS-1$
}
public Resource getA1Right() throws IOException {
return loadFromClassLoader("a1/TC02.ecorediag"); //$NON-NLS-1$
}
public Resource getA2Left() throws IOException {
return loadFromClassLoader("a2/TC01.ecorediag"); //$NON-NLS-1$
}
public Resource getA2Right() throws IOException {
return loadFromClassLoader("a2/TC02.ecorediag"); //$NON-NLS-1$
}
public Resource getA3Left() throws IOException {
return loadFromClassLoader("a3/TC01.ecorediag"); //$NON-NLS-1$
}
public Resource getA3Right() throws IOException {
return loadFromClassLoader("a3/TC02.ecorediag"); //$NON-NLS-1$
}
public Resource getA4Left() throws IOException {
return loadFromClassLoader("a4/TC01.ecorediag"); //$NON-NLS-1$
}
public Resource getA4Right() throws IOException {
return loadFromClassLoader("a4/TC02.ecorediag"); //$NON-NLS-1$
}
@Override
protected Resource loadFromClassLoader(String string) throws IOException {
final URL fileURL = getClass().getResource(string);
final InputStream str = fileURL.openStream();
final URI uri = URI.createURI(fileURL.toString());
ResourceSet resourceSet = new ResourceSetImpl();
getSets().add(resourceSet);
if (!EMFPlugin.IS_RESOURCES_BUNDLE_AVAILABLE) {
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore",
new EcoreResourceFactoryImpl());
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecorediag",
new GMFResourceFactory());
resourceSet.getPackageRegistry().put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
resourceSet.getPackageRegistry().put(NotationPackage.eNS_URI, NotationPackage.eINSTANCE);
}
Resource resource = resourceSet.createResource(uri);
resource.load(str, Collections.emptyMap());
str.close();
EcoreUtil.resolveAll(resourceSet);
return resource;
}
}
|