Copyright header update, 2015 edition
[deliverable/tracecompass.git] / org.eclipse.tracecompass.ctf.core.tests / src / org / eclipse / tracecompass / ctf / core / tests / CtfCoreTestPlugin.java
CommitLineData
32bf80d2 1/*******************************************************************************
ed902a2b 2 * Copyright (c) 2013, 2014 Ericsson
32bf80d2
AM
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 * Alexandre Montplaisir - Initial API and implementation
11 *******************************************************************************/
12
f357bcd4 13package org.eclipse.tracecompass.ctf.core.tests;
32bf80d2 14
3ec38c4c 15import java.io.File;
3ec38c4c
MAL
16import java.net.URISyntaxException;
17
32bf80d2 18import org.eclipse.core.runtime.Plugin;
1ac53e54 19import org.eclipse.core.runtime.URIUtil;
f357bcd4 20import org.eclipse.tracecompass.internal.ctf.core.Activator;
32bf80d2
AM
21import org.osgi.framework.BundleContext;
22
23/**
24 * The activator class controls the plug-in life cycle
25 */
26public class CtfCoreTestPlugin extends Plugin {
27
3ec38c4c
MAL
28 private static final String TEMP_DIR_NAME = ".temp"; //$NON-NLS-1$
29
32bf80d2
AM
30 // ------------------------------------------------------------------------
31 // Attributes
32 // ------------------------------------------------------------------------
33
34 /** The plug-in ID */
4a9c1f07 35 public static final String PLUGIN_ID = "org.eclipse.linuxtools.ctf.core.tests";
32bf80d2
AM
36
37 // The shared instance
38 private static CtfCoreTestPlugin fPlugin;
39
40 // ------------------------------------------------------------------------
41 // Constructors
42 // ------------------------------------------------------------------------
43
44 /**
45 * The constructor
46 */
47 public CtfCoreTestPlugin() {
48 setDefault(this);
49 }
50
51 // ------------------------------------------------------------------------
52 // Accessors
53 // ------------------------------------------------------------------------
54
55 /**
56 * @return the shared instance
57 */
58 public static CtfCoreTestPlugin getDefault() {
59 return fPlugin;
60 }
61
62 /**
63 * @param plugin
64 * the shared instance
65 */
66 private static void setDefault(CtfCoreTestPlugin plugin) {
67 fPlugin = plugin;
68 }
69
70 // ------------------------------------------------------------------------
71 // Operations
72 // ------------------------------------------------------------------------
73
74 @Override
75 public void start(BundleContext context) throws Exception {
76 super.start(context);
77 setDefault(this);
78 }
79
80 @Override
81 public void stop(BundleContext context) throws Exception {
82 setDefault(null);
83 super.stop(context);
84 }
85
3ec38c4c
MAL
86 /**
87 * Get the temporary directory path. If there is an instance of Eclipse
88 * running, the temporary directory will reside under the workspace.
89 *
90 * @return the temporary directory path suitable to be passed to the
91 * java.io.File constructor without a trailing separator
92 */
93 public static String getTemporaryDirPath() {
94 String property = System.getProperty("osgi.instance.area"); //$NON-NLS-1$
95 if (property != null) {
96 try {
1ac53e54 97 File dir = URIUtil.toFile(URIUtil.fromString(property));
3ec38c4c
MAL
98 dir = new File(dir.getAbsolutePath() + File.separator + TEMP_DIR_NAME);
99 if (!dir.exists()) {
100 dir.mkdirs();
101 }
102 return dir.getAbsolutePath();
103 } catch (URISyntaxException e) {
104 Activator.logError(e.getLocalizedMessage(), e);
105 }
106 }
107 return System.getProperty("java.io.tmpdir"); //$NON-NLS-1$
108 }
32bf80d2 109}
This page took 0.049557 seconds and 5 git commands to generate.