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

« back to all changes in this revision

Viewing changes to rpmstubby/org.eclipse.linuxtools.rpmstubby/src/org/eclipse/linuxtools/internal/rpmstubby/StubbyPlugin.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
/*******************************************************************************
 
2
 * Copyright (c) 2006 Red Hat, Inc.
 
3
 * All rights reserved. This program and the accompanying materials
 
4
 * are made available under the terms of the Eclipse Public License v1.0
 
5
 * which accompanies this distribution, and is available at
 
6
 * http://www.eclipse.org/legal/epl-v10.html
 
7
 *
 
8
 * Contributors:
 
9
 *     Red Hat Incorporated - initial API and implementation
 
10
 *******************************************************************************/
 
11
package org.eclipse.linuxtools.internal.rpmstubby;
 
12
 
 
13
import org.eclipse.jface.resource.ImageDescriptor;
 
14
import org.eclipse.swt.widgets.Shell;
 
15
import org.eclipse.ui.IWorkbenchWindow;
 
16
import org.eclipse.ui.plugin.AbstractUIPlugin;
 
17
import org.osgi.framework.BundleContext;
 
18
 
 
19
/**
 
20
 * The activator class controls the plug-in life cycle
 
21
 */
 
22
public class StubbyPlugin extends AbstractUIPlugin {
 
23
 
 
24
        /** The plug-in ID. */
 
25
        public static final String PLUGIN_ID = "org.eclipse.linuxtools.internal.rpmstubby";
 
26
 
 
27
        // The shared instance
 
28
        private static StubbyPlugin plugin;
 
29
        
 
30
        /**
 
31
         * The constructor
 
32
         */
 
33
        public StubbyPlugin() {
 
34
                plugin = this;
 
35
        }
 
36
 
 
37
        /*
 
38
         * (non-Javadoc)
 
39
         * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
 
40
         */
 
41
        @Override
 
42
        public void start(BundleContext context) throws Exception {
 
43
                super.start(context);
 
44
        }
 
45
 
 
46
        /*
 
47
         * (non-Javadoc)
 
48
         * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
 
49
         */
 
50
        @Override
 
51
        public void stop(BundleContext context) throws Exception {
 
52
                plugin = null;
 
53
                super.stop(context);
 
54
        }
 
55
 
 
56
        /**
 
57
         * Returns the shared instance
 
58
         *
 
59
         * @return the shared instance
 
60
         */
 
61
        public static StubbyPlugin getDefault() {
 
62
                return plugin;
 
63
        }
 
64
 
 
65
        /**
 
66
         * Returns an image descriptor for the image file at the given
 
67
         * plug-in relative path
 
68
         *
 
69
         * @param path the path
 
70
         * @return the image descriptor
 
71
         */
 
72
        public static ImageDescriptor getImageDescriptor(String path) {
 
73
                return imageDescriptorFromPlugin(PLUGIN_ID, path);
 
74
        }
 
75
        
 
76
        /**
 
77
         * Returns active shell.
 
78
         * @return The active workbench shell.
 
79
         */
 
80
        public static Shell getActiveWorkbenchShell() {
 
81
                IWorkbenchWindow window = getDefault().getWorkbench().getActiveWorkbenchWindow();
 
82
                if (window != null) {
 
83
                        return window.getShell();
 
84
                }
 
85
                return null;
 
86
        }
 
87
}