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