analysis: Move plugins to their own sub-directory
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.os.linux.core.tests / src / org / eclipse / tracecompass / analysis / os / linux / core / tests / Activator.java
1 /*******************************************************************************
2 * Copyright (c) 2014, 2015 École Polytechnique de Montréal
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 API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.analysis.os.linux.core.tests;
14
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;
21 import org.eclipse.core.runtime.Plugin;
22 import org.osgi.framework.BundleContext;
23
24 /**
25 * Activator for this plugin
26 *
27 * @author Geneviève Bastien
28 */
29 public class Activator extends Plugin {
30 // ------------------------------------------------------------------------
31 // Attributes
32 // ------------------------------------------------------------------------
33
34 /**
35 * The plug-in ID
36 */
37 public static final String PLUGIN_ID = "org.eclipse.tracecompass.analysis.linux.core.tests"; //$NON-NLS-1$
38
39 /**
40 * The shared instance
41 */
42 private static Activator PLUGIN;
43
44 // ------------------------------------------------------------------------
45 // Constructors
46 // ------------------------------------------------------------------------
47
48 /**
49 * The constructor
50 */
51 public Activator() {
52 }
53
54 // ------------------------------------------------------------------------
55 // Accessors
56 // ------------------------------------------------------------------------
57
58 /**
59 * Returns the shared instance
60 *
61 * @return the shared instance
62 */
63 public static Activator getDefault() {
64 return PLUGIN;
65 }
66
67 // ------------------------------------------------------------------------
68 // Operators
69 // ------------------------------------------------------------------------
70
71 @Override
72 public void start(BundleContext context) throws Exception {
73 super.start(context);
74 PLUGIN = this;
75 }
76
77 @Override
78 public void stop(BundleContext context) throws Exception {
79 PLUGIN = null;
80 super.stop(context);
81 }
82
83 /**
84 * Return a path to a file relative to this plugin's base directory
85 *
86 * @param relativePath
87 * The path relative to the plugin's root directory
88 * @return The path corresponding to the relative path in parameter
89 */
90 public static IPath getAbsoluteFilePath(String relativePath) {
91 Activator plugin = Activator.getDefault();
92 if (plugin == null) {
93 /*
94 * Shouldn't happen but at least throw something to get the test to
95 * fail early
96 */
97 throw new IllegalStateException();
98 }
99 URL location = FileLocator.find(plugin.getBundle(), new Path(relativePath), null);
100 try {
101 return new Path(FileLocator.toFileURL(location).getPath());
102 } catch (IOException e) {
103 throw new IllegalStateException();
104 }
105 }
106 }
This page took 0.032186 seconds and 5 git commands to generate.