6061d107c7281e361bafe81bfade86270d391b8d
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.analysis.xml.core.tests / src / org / eclipse / tracecompass / tmf / analysis / xml / core / tests / Activator.java
1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 É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 implementation and API
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.tmf.analysis.xml.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 * The activator class controls the plug-in life cycle
26 */
27 public class Activator extends Plugin {
28
29 /**
30 * The plug-in ID
31 */
32 public static final String PLUGIN_ID = "org.eclipse.tracecompass.tmf.analysis.xml.core.tests"; //$NON-NLS-1$
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
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
89 }
This page took 0.052326 seconds and 4 git commands to generate.