Commit | Line | Data |
---|---|---|
866e5b51 FC |
1 | /******************************************************************************* |
2 | * Copyright (c) 2011-2012 Ericsson, Ecole Polytechnique de Montreal and others | |
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 | * Francois Chouinard - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
a9d52b8f | 13 | package org.eclipse.linuxtools.internal.ctf.core; |
866e5b51 FC |
14 | |
15 | import org.eclipse.core.runtime.IStatus; | |
16 | import org.eclipse.core.runtime.Plugin; | |
17 | import org.eclipse.core.runtime.Status; | |
18 | import org.osgi.framework.BundleContext; | |
19 | ||
20 | /** | |
a9d52b8f | 21 | * <b><u>Activator</u></b> |
866e5b51 | 22 | * <p> |
a9d52b8f | 23 | * The activator class controls the plug-in life cycle. |
866e5b51 | 24 | */ |
a9d52b8f | 25 | public class Activator extends Plugin { |
866e5b51 FC |
26 | |
27 | // ------------------------------------------------------------------------ | |
28 | // Attributes | |
29 | // ------------------------------------------------------------------------ | |
30 | ||
9ac2eb62 MK |
31 | /** |
32 | * The plug-in ID | |
33 | */ | |
866e5b51 FC |
34 | public static final String PLUGIN_ID = "org.eclipse.linuxtools.ctf"; //$NON-NLS-1$ |
35 | ||
9ac2eb62 MK |
36 | /** |
37 | * The shared instance | |
38 | */ | |
a9d52b8f | 39 | private static Activator fPlugin; |
866e5b51 FC |
40 | |
41 | // ------------------------------------------------------------------------ | |
42 | // Constructors | |
43 | // ------------------------------------------------------------------------ | |
44 | ||
9ac2eb62 MK |
45 | /** |
46 | * Constructor | |
47 | */ | |
a9d52b8f | 48 | public Activator() { |
866e5b51 FC |
49 | setDefault(this); |
50 | } | |
51 | ||
52 | // ------------------------------------------------------------------------ | |
53 | // Accessors | |
54 | // ------------------------------------------------------------------------ | |
55 | ||
9ac2eb62 MK |
56 | /** |
57 | * Get the default activator | |
58 | * @return the default activator | |
59 | */ | |
a9d52b8f | 60 | public static Activator getDefault() { |
866e5b51 FC |
61 | return fPlugin; |
62 | } | |
63 | ||
9ac2eb62 MK |
64 | /** |
65 | * Sets the default activator | |
66 | * | |
67 | * @param plugin the default activator | |
68 | */ | |
a9d52b8f | 69 | private static void setDefault(Activator plugin) { |
866e5b51 FC |
70 | fPlugin = plugin; |
71 | } | |
72 | ||
73 | // ------------------------------------------------------------------------ | |
74 | // Plugin | |
75 | // ------------------------------------------------------------------------ | |
76 | ||
77 | @Override | |
78 | public void start(BundleContext context) throws Exception { | |
79 | super.start(context); | |
80 | setDefault(this); | |
81 | } | |
82 | ||
83 | @Override | |
84 | public void stop(BundleContext context) throws Exception { | |
85 | setDefault(null); | |
86 | super.stop(context); | |
87 | } | |
88 | ||
89 | // ------------------------------------------------------------------------ | |
90 | // Logging | |
91 | // ------------------------------------------------------------------------ | |
92 | ||
9ac2eb62 MK |
93 | /** |
94 | * Log a message | |
95 | * @param msg the message to log | |
96 | */ | |
866e5b51 FC |
97 | public void log(String msg) { |
98 | log(msg, null); | |
99 | } | |
100 | ||
9ac2eb62 MK |
101 | /** |
102 | * Log a message with an exception | |
103 | * @param msg the message | |
104 | * @param e the exception | |
105 | */ | |
866e5b51 FC |
106 | public void log(String msg, Exception e) { |
107 | getLog().log(new Status(IStatus.INFO, PLUGIN_ID, IStatus.OK, msg, e)); | |
108 | } | |
109 | ||
110 | } |