Commit | Line | Data |
---|---|---|
faf37fd0 | 1 | /******************************************************************************* |
60ae41e1 | 2 | * Copyright (c) 2013, 2014 École Polytechnique de Montréal |
faf37fd0 GB |
3 | * |
4 | * All rights reserved. This program and the accompanying materials are | |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * Geneviève Bastien - Initial implementation and API | |
11 | *******************************************************************************/ | |
12 | ||
2bdf0193 | 13 | package org.eclipse.tracecompass.tmf.analysis.xml.core.tests; |
faf37fd0 | 14 | |
9a0aa59e GB |
15 | import java.io.IOException; |
16 | import java.net.URL; | |
17 | ||
18 | import org.eclipse.core.runtime.FileLocator; | |
19 | import org.eclipse.core.runtime.IPath; | |
20 | import org.eclipse.core.runtime.Path; | |
e11e382c | 21 | import org.eclipse.core.runtime.Plugin; |
faf37fd0 GB |
22 | import org.osgi.framework.BundleContext; |
23 | ||
24 | /** | |
25 | * The activator class controls the plug-in life cycle | |
26 | */ | |
e11e382c | 27 | public class Activator extends Plugin { |
faf37fd0 GB |
28 | |
29 | /** | |
30 | * The plug-in ID | |
31 | */ | |
c77a695a | 32 | public static final String PLUGIN_ID = "org.eclipse.tracecompass.tmf.analysis.xml.core.tests"; //$NON-NLS-1$ |
faf37fd0 GB |
33 | |
34 | // The shared instance | |
35 | private static Activator plugin; | |
36 | ||
37 | /** | |
38 | * The constructor | |
39 | */ | |
40 | public Activator() { | |
41 | } | |
42 | ||
43 | @Override | |
44 | public void start(BundleContext context) throws Exception { | |
45 | super.start(context); | |
46 | plugin = this; | |
47 | } | |
48 | ||
49 | @Override | |
50 | public void stop(BundleContext context) throws Exception { | |
51 | plugin = null; | |
52 | super.stop(context); | |
53 | } | |
54 | ||
55 | /** | |
56 | * Returns the shared instance | |
57 | * | |
58 | * @return the shared instance | |
59 | */ | |
60 | public static Activator getDefault() { | |
61 | return plugin; | |
62 | } | |
63 | ||
9a0aa59e GB |
64 | /** |
65 | * Gets the absolute path from a path relative to this plugin's root | |
66 | * | |
67 | * @param relativePath | |
68 | * The path relative to this plugin | |
69 | * @return The absolute path corresponding to this relative path | |
70 | */ | |
71 | public static IPath getAbsolutePath(Path relativePath) { | |
72 | Activator plugin2 = getDefault(); | |
73 | if (plugin2 == null) { | |
74 | /* | |
75 | * Shouldn't happen but at least throw something to get the test to | |
76 | * fail early | |
77 | */ | |
78 | return null; | |
79 | } | |
80 | URL location = FileLocator.find(plugin2.getBundle(), relativePath, null); | |
81 | try { | |
82 | IPath path = new Path(FileLocator.toFileURL(location).getPath()); | |
83 | return path; | |
84 | } catch (IOException e) { | |
85 | return null; | |
86 | } | |
87 | } | |
88 | ||
faf37fd0 | 89 | } |