1 /*******************************************************************************
2 * Copyright (c) 2009, 2010 Ericsson
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
10 * Francois Chouinard - Initial API and implementation
11 * Bernd Hufmann - Updated for LTTng trace control
13 *******************************************************************************/
15 package org
.eclipse
.linuxtools
.internal
.lttng
.ui
;
17 import java
.util
.concurrent
.ExecutionException
;
18 import java
.util
.concurrent
.TimeoutException
;
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
.tracecontrol
.Messages
;
26 import org
.eclipse
.linuxtools
.internal
.lttng
.ui
.tracecontrol
.model
.TraceAdapterFactory
;
27 import org
.eclipse
.rse
.services
.clientserver
.messages
.SimpleSystemMessage
;
28 import org
.eclipse
.rse
.services
.clientserver
.messages
.SystemMessage
;
29 import org
.eclipse
.rse
.ui
.SystemBasePlugin
;
30 import org
.osgi
.framework
.BundleContext
;
33 * The activator class controls the plug-in life cycle
35 public class Activator
extends SystemBasePlugin
{
38 public static final String PLUGIN_ID
= "org.eclipse.linuxtools.lttng.ui"; //$NON-NLS-1$
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$
52 // The shared instance
53 private static Activator plugin
;
63 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
66 public void start(BundleContext context
) throws Exception
{
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);
77 // Assign shared instance
83 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
86 public void stop(BundleContext context
) throws Exception
{
93 * Returns the shared instance
95 * @return the shared instance
97 public static Activator
getDefault() {
102 * Create a System Message for given throwable
104 * @param x - The throwable the message is for
107 public SystemMessage
getMessage(Throwable x
) {
108 String msg
= x
.getMessage();
110 msg
= ""; //$NON-NLS-1$
112 if ((x
instanceof ExecutionException
) && (((ExecutionException
)x
).getCause() != null)) {
113 msg
+= " (" + ((ExecutionException
)x
).getCause().getMessage() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
115 if (x
instanceof TimeoutException
) {
116 msg
+= " (" + Messages
.Ltt_TimeoutMsg
+ ")"; //$NON-NLS-1$ //$NON-NLS-2$
118 return new SimpleSystemMessage(PLUGIN_ID
, SystemMessage
.ERROR
, msg
, x
);
123 * @see org.eclipse.rse.ui.SystemBasePlugin#initializeImageRegistry()
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$