tmf: Use tabs in statistics view for each traces
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / internal / lttng / ui / Activator.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
0977b009 15package org.eclipse.linuxtools.internal.lttng.ui;
6e512b93 16
eb1bab5b 17import java.net.URL;
e8d771d5
BH
18import java.util.concurrent.ExecutionException;
19import java.util.concurrent.TimeoutException;
20
21import org.eclipse.core.runtime.IAdapterManager;
22import org.eclipse.core.runtime.Platform;
eb1bab5b 23import org.eclipse.jface.resource.ImageDescriptor;
5945cec9
FC
24import org.eclipse.linuxtools.internal.lttng.core.tracecontrol.model.ProviderResource;
25import org.eclipse.linuxtools.internal.lttng.core.tracecontrol.model.TargetResource;
26import org.eclipse.linuxtools.internal.lttng.core.tracecontrol.model.TraceResource;
638eac44
FC
27import org.eclipse.linuxtools.internal.lttng.ui.tracecontrol.Messages;
28import org.eclipse.linuxtools.internal.lttng.ui.tracecontrol.model.TraceAdapterFactory;
e8d771d5
BH
29import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage;
30import org.eclipse.rse.services.clientserver.messages.SystemMessage;
31import org.eclipse.rse.ui.SystemBasePlugin;
eb1bab5b 32import org.eclipse.swt.graphics.Image;
6e512b93
ASL
33import org.osgi.framework.BundleContext;
34
35/**
36 * The activator class controls the plug-in life cycle
37 */
638eac44 38public class Activator extends SystemBasePlugin {
6e512b93
ASL
39
40 // The plug-in ID
3b38ea61 41 public static final String PLUGIN_ID = "org.eclipse.linuxtools.lttng.ui"; //$NON-NLS-1$
6e512b93 42
e8d771d5
BH
43 // Icon names
44 public static final String ICON_ID_PROVIDER = "ICON_ID_PROVIDER"; //$NON-NLS-1$
45 public static final String ICON_ID_TARGET = "ICON_ID_TARGET"; //$NON-NLS-1$
46 public static final String ICON_ID_TRACE = "ICON_ID_TRACE"; //$NON-NLS-1$
47 public static final String ICON_ID_NEW_TRACE = "ICON_ID_NEW_TRACE"; //$NON-NLS-1$
48 public static final String ICON_ID_CONFIG_MARKERS = "ICON_ID_CONFIG_MARKERS"; //$NON-NLS-1$
49 public static final String ICON_ID_CONFIG_TRACE = "ICON_ID_CONFIG_TRACE"; //$NON-NLS-1$
50 public static final String ICON_ID_CHECKED = "ICON_ID_CHECKED"; //$NON-NLS-1$
51 public static final String ICON_ID_UNCHECKED = "ICON_ID_UNCHECKED"; //$NON-NLS-1$
52 public static final String ICON_ID_IMPORT_TRACE = "ICON_ID_IMPORT_TRACE"; //$NON-NLS-1$
53 public static final String ICON_ID_EDIT = "ICON_ID_EDIT"; //$NON-NLS-1$
54
6e512b93 55 // The shared instance
638eac44 56 private static Activator plugin;
6e512b93
ASL
57
58 /**
59 * The constructor
60 */
638eac44 61 public Activator() {
6e512b93
ASL
62 }
63
64 /*
65 * (non-Javadoc)
66 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
67 */
68 @Override
69 public void start(BundleContext context) throws Exception {
70 super.start(context);
dfaf8391 71 TraceDebug.init();
e8d771d5
BH
72
73 // Trace control initialization
74 IAdapterManager manager = Platform.getAdapterManager();
75 TraceAdapterFactory factory = new TraceAdapterFactory();
76 manager.registerAdapters(factory, ProviderResource.class);
77 manager.registerAdapters(factory, TargetResource.class);
78 manager.registerAdapters(factory, TraceResource.class);
79
80 // Assign shared instance
6e512b93
ASL
81 plugin = this;
82 }
83
84 /*
85 * (non-Javadoc)
86 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
87 */
88 @Override
89 public void stop(BundleContext context) throws Exception {
0c2a2e08 90 TraceDebug.stop();
6e512b93
ASL
91 plugin = null;
92 super.stop(context);
93 }
94
95 /**
96 * Returns the shared instance
97 *
98 * @return the shared instance
99 */
638eac44 100 public static Activator getDefault() {
6e512b93
ASL
101 return plugin;
102 }
e8d771d5
BH
103
104 /**
105 * Create a System Message for given throwable
106 *
107 * @param x - The throwable the message is for
108 * @return
109 */
110 public SystemMessage getMessage(Throwable x) {
111 String msg = x.getMessage();
112 if (msg == null) {
113 msg = ""; //$NON-NLS-1$
114 }
115 if ((x instanceof ExecutionException) && (((ExecutionException)x).getCause() != null)) {
116 msg += " (" + ((ExecutionException)x).getCause().getMessage() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
117 }
118 if (x instanceof TimeoutException) {
119 msg += " (" + Messages.Ltt_TimeoutMsg + ")"; //$NON-NLS-1$ //$NON-NLS-2$
120 }
121 return new SimpleSystemMessage(PLUGIN_ID, SystemMessage.ERROR, msg, x);
122 }
6e512b93 123
e8d771d5
BH
124 /*
125 * (non-Javadoc)
126 * @see org.eclipse.rse.ui.SystemBasePlugin#initializeImageRegistry()
127 */
128 @Override
129 protected void initializeImageRegistry() {
130 String path = getIconPath();
131 putImageInRegistry(ICON_ID_PROVIDER, path + "obj16/providers.gif"); //$NON-NLS-1$
132 putImageInRegistry(ICON_ID_TARGET, path + "obj16/targets.gif"); //$NON-NLS-1$
133 putImageInRegistry(ICON_ID_TRACE, path + "obj16/trace.gif"); //$NON-NLS-1$
134 putImageInRegistry(ICON_ID_NEW_TRACE, path + "elcl16/new_trace.gif"); //$NON-NLS-1$
135 putImageInRegistry(ICON_ID_CONFIG_MARKERS, path + "elcl16/configure_markers.gif"); //$NON-NLS-1$
136 putImageInRegistry(ICON_ID_CONFIG_TRACE, path + "elcl16/configure_trace.gif"); //$NON-NLS-1$
137 putImageInRegistry(ICON_ID_CHECKED, path + "elcl16/checked.gif"); //$NON-NLS-1$
138 putImageInRegistry(ICON_ID_UNCHECKED, path + "elcl16/unchecked.gif"); //$NON-NLS-1$
139 putImageInRegistry(ICON_ID_IMPORT_TRACE, path + "elcl16/import_trace.gif"); //$NON-NLS-1$
140 putImageInRegistry(ICON_ID_EDIT, path + "elcl16/edit.gif"); //$NON-NLS-1$
141 }
eb1bab5b
BH
142
143 /**
31a6a4e4
BH
144 * Loads the image in the plug-ins image registry (if necessary) and returns the image
145 * @param url - URL relative to the Bundle
146 * @return the image
eb1bab5b
BH
147 */
148 public Image loadIcon(String url) {
31a6a4e4
BH
149 String key = plugin.getBundle().getSymbolicName() + "/" + url; //$NON-NLS-1$
150 Image icon = plugin.getImageRegistry().get(key);
eb1bab5b 151 if (icon == null) {
31a6a4e4 152 URL imageURL = plugin.getBundle().getResource(url);
eb1bab5b
BH
153 ImageDescriptor descriptor = ImageDescriptor.createFromURL(imageURL);
154 icon = descriptor.createImage();
31a6a4e4 155 plugin.getImageRegistry().put(key, icon);
eb1bab5b
BH
156 }
157 return icon;
158 }
6e512b93 159}
This page took 0.098262 seconds and 5 git commands to generate.