Internalize lttng.ui APIs
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / Activator.java
1 /*******************************************************************************
2 * Copyright (c) 2009, 2010 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 * Contributors:
10 * Francois Chouinard - Initial API and implementation
11 * Bernd Hufmann - Updated for LTTng trace control
12 *
13 *******************************************************************************/
14
15 package org.eclipse.linuxtools.lttng.ui;
16
17 import java.util.concurrent.ExecutionException;
18 import java.util.concurrent.TimeoutException;
19
20 import org.eclipse.core.runtime.IAdapterManager;
21 import org.eclipse.core.runtime.Platform;
22 import org.eclipse.linuxtools.internal.lttng.core.tracecontrol.model.ProviderResource;
23 import org.eclipse.linuxtools.internal.lttng.core.tracecontrol.model.TargetResource;
24 import org.eclipse.linuxtools.internal.lttng.core.tracecontrol.model.TraceResource;
25 import org.eclipse.linuxtools.internal.lttng.ui.TraceDebug;
26 import org.eclipse.linuxtools.internal.lttng.ui.tracecontrol.Messages;
27 import org.eclipse.linuxtools.internal.lttng.ui.tracecontrol.model.TraceAdapterFactory;
28 import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage;
29 import org.eclipse.rse.services.clientserver.messages.SystemMessage;
30 import org.eclipse.rse.ui.SystemBasePlugin;
31 import org.osgi.framework.BundleContext;
32
33 /**
34 * The activator class controls the plug-in life cycle
35 */
36 public class Activator extends SystemBasePlugin {
37
38 // The plug-in ID
39 public static final String PLUGIN_ID = "org.eclipse.linuxtools.lttng.ui"; //$NON-NLS-1$
40
41 // Icon names
42 public static final String ICON_ID_PROVIDER = "ICON_ID_PROVIDER"; //$NON-NLS-1$
43 public static final String ICON_ID_TARGET = "ICON_ID_TARGET"; //$NON-NLS-1$
44 public static final String ICON_ID_TRACE = "ICON_ID_TRACE"; //$NON-NLS-1$
45 public static final String ICON_ID_NEW_TRACE = "ICON_ID_NEW_TRACE"; //$NON-NLS-1$
46 public static final String ICON_ID_CONFIG_MARKERS = "ICON_ID_CONFIG_MARKERS"; //$NON-NLS-1$
47 public static final String ICON_ID_CONFIG_TRACE = "ICON_ID_CONFIG_TRACE"; //$NON-NLS-1$
48 public static final String ICON_ID_CHECKED = "ICON_ID_CHECKED"; //$NON-NLS-1$
49 public static final String ICON_ID_UNCHECKED = "ICON_ID_UNCHECKED"; //$NON-NLS-1$
50 public static final String ICON_ID_IMPORT_TRACE = "ICON_ID_IMPORT_TRACE"; //$NON-NLS-1$
51 public static final String ICON_ID_EDIT = "ICON_ID_EDIT"; //$NON-NLS-1$
52
53 // The shared instance
54 private static Activator plugin;
55
56 /**
57 * The constructor
58 */
59 public Activator() {
60 }
61
62 /*
63 * (non-Javadoc)
64 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
65 */
66 @Override
67 public void start(BundleContext context) throws Exception {
68 super.start(context);
69 TraceDebug.init();
70
71 // Trace control initialization
72 IAdapterManager manager = Platform.getAdapterManager();
73 TraceAdapterFactory factory = new TraceAdapterFactory();
74 manager.registerAdapters(factory, ProviderResource.class);
75 manager.registerAdapters(factory, TargetResource.class);
76 manager.registerAdapters(factory, TraceResource.class);
77
78 // Assign shared instance
79 plugin = this;
80 }
81
82 /*
83 * (non-Javadoc)
84 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
85 */
86 @Override
87 public void stop(BundleContext context) throws Exception {
88 TraceDebug.stop();
89 plugin = null;
90 super.stop(context);
91 }
92
93 /**
94 * Returns the shared instance
95 *
96 * @return the shared instance
97 */
98 public static Activator getDefault() {
99 return plugin;
100 }
101
102 /**
103 * Create a System Message for given throwable
104 *
105 * @param x - The throwable the message is for
106 * @return
107 */
108 public SystemMessage getMessage(Throwable x) {
109 String msg = x.getMessage();
110 if (msg == null) {
111 msg = ""; //$NON-NLS-1$
112 }
113 if ((x instanceof ExecutionException) && (((ExecutionException)x).getCause() != null)) {
114 msg += " (" + ((ExecutionException)x).getCause().getMessage() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
115 }
116 if (x instanceof TimeoutException) {
117 msg += " (" + Messages.Ltt_TimeoutMsg + ")"; //$NON-NLS-1$ //$NON-NLS-2$
118 }
119 return new SimpleSystemMessage(PLUGIN_ID, SystemMessage.ERROR, msg, x);
120 }
121
122 /*
123 * (non-Javadoc)
124 * @see org.eclipse.rse.ui.SystemBasePlugin#initializeImageRegistry()
125 */
126 @Override
127 protected void initializeImageRegistry() {
128 String path = getIconPath();
129 putImageInRegistry(ICON_ID_PROVIDER, path + "obj16/providers.gif"); //$NON-NLS-1$
130 putImageInRegistry(ICON_ID_TARGET, path + "obj16/targets.gif"); //$NON-NLS-1$
131 putImageInRegistry(ICON_ID_TRACE, path + "obj16/trace.gif"); //$NON-NLS-1$
132 putImageInRegistry(ICON_ID_NEW_TRACE, path + "elcl16/new_trace.gif"); //$NON-NLS-1$
133 putImageInRegistry(ICON_ID_CONFIG_MARKERS, path + "elcl16/configure_markers.gif"); //$NON-NLS-1$
134 putImageInRegistry(ICON_ID_CONFIG_TRACE, path + "elcl16/configure_trace.gif"); //$NON-NLS-1$
135 putImageInRegistry(ICON_ID_CHECKED, path + "elcl16/checked.gif"); //$NON-NLS-1$
136 putImageInRegistry(ICON_ID_UNCHECKED, path + "elcl16/unchecked.gif"); //$NON-NLS-1$
137 putImageInRegistry(ICON_ID_IMPORT_TRACE, path + "elcl16/import_trace.gif"); //$NON-NLS-1$
138 putImageInRegistry(ICON_ID_EDIT, path + "elcl16/edit.gif"); //$NON-NLS-1$
139 }
140 }
This page took 0.032811 seconds and 5 git commands to generate.