~ubuntu-branches/ubuntu/trusty/eclipse-linuxtools/trusty

« back to all changes in this revision

Viewing changes to systemtap/org.eclipse.linuxtools.threadprofiler/src/org/eclipse/linuxtools/internal/threadprofiler/ThreadProfilerPlugin.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2012-06-29 12:07:30 UTC
  • Revision ID: package-import@ubuntu.com-20120629120730-bfri1xys1i71dpn6
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.eclipse.linuxtools.internal.threadprofiler;
 
2
 
 
3
import java.io.IOException;
 
4
import java.net.URL;
 
5
 
 
6
import org.eclipse.core.runtime.FileLocator;
 
7
import org.eclipse.core.runtime.Path;
 
8
import org.eclipse.jface.resource.ImageDescriptor;
 
9
import org.eclipse.ui.plugin.AbstractUIPlugin;
 
10
import org.osgi.framework.Bundle;
 
11
import org.osgi.framework.BundleContext;
 
12
 
 
13
/**
 
14
 * The activator class controls the plug-in life cycle
 
15
 */
 
16
public class ThreadProfilerPlugin extends AbstractUIPlugin {
 
17
 
 
18
        // The plug-in ID
 
19
        public static final String PLUGIN_ID = "org.eclipse.linuxtools.threadprofiler";
 
20
 
 
21
        // The shared instance
 
22
        private static ThreadProfilerPlugin plugin;
 
23
        
 
24
        /**
 
25
         * The constructor
 
26
         */
 
27
        public ThreadProfilerPlugin() {
 
28
        }
 
29
 
 
30
        /*
 
31
         * (non-Javadoc)
 
32
         * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
 
33
         */
 
34
        public void start(BundleContext context) throws Exception {
 
35
                super.start(context);
 
36
                plugin = this;
 
37
        }
 
38
 
 
39
        /*
 
40
         * (non-Javadoc) 
 
41
         * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
 
42
         */
 
43
        public void stop(BundleContext context) throws Exception {
 
44
                plugin = null;
 
45
                super.stop(context);
 
46
        }
 
47
 
 
48
        /**
 
49
         * Returns the shared instance
 
50
         *
 
51
         * @return the shared instance
 
52
         */
 
53
        public static ThreadProfilerPlugin getDefault() {
 
54
                return plugin;
 
55
        }
 
56
 
 
57
        /**
 
58
         * Returns the location of the plugin by checking the path of the bundle's 
 
59
         * locationURL.
 
60
         * 
 
61
         * @return
 
62
         */
 
63
        public String getPluginLocation() {
 
64
                Bundle bundle = getBundle();
 
65
 
 
66
                URL locationUrl = FileLocator.find(bundle,new Path("/"), null); //$NON-NLS-1$
 
67
                URL fileUrl = null;
 
68
                try {
 
69
                        fileUrl = FileLocator.toFileURL(locationUrl);
 
70
                } catch (IOException e) {
 
71
                        e.printStackTrace();
 
72
                }
 
73
                return fileUrl.getFile();
 
74
        }
 
75
        
 
76
        /**
 
77
         * Returns an image descriptor for the image file at the given
 
78
         * plug-in relative path
 
79
         *
 
80
         * @param path the path
 
81
         * @return the image descriptor
 
82
         */
 
83
        public static ImageDescriptor getImageDescriptor(String path) {
 
84
                return imageDescriptorFromPlugin(PLUGIN_ID, path);
 
85
        }
 
86
}