Fix importing an archive containing colons (:) in the names on Windows
[deliverable/tracecompass.git] / ctf / org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests / src / org / eclipse / tracecompass / tmf / ctf / ui / swtbot / tests / Activator.java
1 /*******************************************************************************
2 * Copyright (c) 2016 Ericsson
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
10 package org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests;
11
12 import java.io.IOException;
13 import java.net.URL;
14
15 import org.eclipse.core.runtime.FileLocator;
16 import org.eclipse.core.runtime.IPath;
17 import org.eclipse.core.runtime.Path;
18 import org.eclipse.core.runtime.Plugin;
19 import org.osgi.framework.BundleContext;
20
21 /**
22 * The activator class controls the plug-in life cycle
23 */
24 public class Activator extends Plugin {
25
26 /**
27 * The plug-in ID
28 */
29 public static final String PLUGIN_ID = "org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests"; //$NON-NLS-1$
30
31 // The shared instance
32 private static Activator plugin;
33
34 /**
35 * The constructor
36 */
37 public Activator() {
38 }
39
40 @Override
41 public void start(BundleContext context) throws Exception {
42 super.start(context);
43 plugin = this;
44 }
45
46 @Override
47 public void stop(BundleContext context) throws Exception {
48 plugin = null;
49 super.stop(context);
50 }
51
52 /**
53 * Returns the shared instance
54 *
55 * @return the shared instance
56 */
57 public static Activator getDefault() {
58 return plugin;
59 }
60
61 /**
62 * Gets the absolute path from a path relative to this plugin's root
63 *
64 * @param relativePath
65 * The path relative to this plugin
66 * @return The absolute path corresponding to this relative path
67 */
68 public static IPath getAbsolutePath(Path relativePath) {
69 Activator plugin2 = getDefault();
70 if (plugin2 == null) {
71 /*
72 * Shouldn't happen but at least throw something to get the test to
73 * fail early
74 */
75 return null;
76 }
77 URL location = FileLocator.find(plugin2.getBundle(), relativePath, null);
78 try {
79 IPath path = new Path(FileLocator.toFileURL(location).getPath());
80 return path;
81 } catch (IOException e) {
82 return null;
83 }
84 }
85
86 }
This page took 0.031666 seconds and 5 git commands to generate.