KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > runtime > PDERuntimePlugin


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
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  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.runtime;
12
13 import org.eclipse.swt.widgets.Shell;
14 import org.eclipse.ui.IWorkbenchPage;
15 import org.eclipse.ui.IWorkbenchWindow;
16 import org.eclipse.ui.plugin.AbstractUIPlugin;
17 import org.osgi.framework.BundleContext;
18
19
20 public class PDERuntimePlugin extends AbstractUIPlugin {
21     
22     private static PDERuntimePlugin inst;
23
24     private BundleContext fContext;
25
26     public static IWorkbenchPage getActivePage() {
27         return getDefault().internalGetActivePage();
28     }
29     
30     public static Shell getActiveWorkbenchShell() {
31         return getActiveWorkbenchWindow().getShell();
32     }
33     
34     public static IWorkbenchWindow getActiveWorkbenchWindow() {
35         return getDefault().getWorkbench().getActiveWorkbenchWindow();
36     }
37     
38     public static PDERuntimePlugin getDefault() {
39         return inst;
40     }
41     
42     public static String JavaDoc getPluginId() {
43         return getDefault().getBundle().getSymbolicName();
44     }
45     
46     public PDERuntimePlugin() {
47         inst = this;
48     }
49     
50     private IWorkbenchPage internalGetActivePage() {
51         return getWorkbench().getActiveWorkbenchWindow().getActivePage();
52     }
53     /* (non-Javadoc)
54      * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
55      */

56     public void start(BundleContext context) throws Exception JavaDoc {
57         super.start(context);
58         this.fContext = context;
59     }
60     
61     public BundleContext getBundleContext() {
62         return this.fContext;
63     }
64     
65     /**
66      * This method is called when the plug-in is stopped
67      */

68     public void stop(BundleContext context) throws Exception JavaDoc {
69         super.stop(context);
70         inst = null;
71     }
72
73 }
74
Popular Tags