01: /*******************************************************************************
02: * Copyright (c) 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: ******************************************************************************/package org.eclipse.jface.internal;
11:
12: import org.osgi.framework.*;
13:
14: /**
15: * JFaceActivator is the activator class for the JFace plug-in when it is being used
16: * within a full Eclipse install.
17: * @since 3.3
18: *
19: */
20: public class JFaceActivator implements BundleActivator {
21:
22: private static BundleContext bundleContext;
23:
24: /* (non-Javadoc)
25: * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
26: */
27: public void start(BundleContext context) throws Exception {
28: bundleContext = context;
29: }
30:
31: /* (non-Javadoc)
32: * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
33: */
34: public void stop(BundleContext context) throws Exception {
35: bundleContext = null;
36: }
37:
38: /**
39: * Return the bundle context for this bundle, or <code>null</code> if
40: * there is not one. (for instance if the bundle is not activated or we aren't
41: * running OSGi.
42: *
43: * @return the bundle context or <code>null</code>
44: */
45: public static BundleContext getBundleContext() {
46: return bundleContext;
47: }
48:
49: /**
50: * Return the Bundle object for JFace. Returns <code>null</code> if it is not
51: * available.
52: *
53: * @return the bundle or <code>null</code>
54: */
55: public static Bundle getBundle() {
56: return bundleContext == null ? null : bundleContext.getBundle();
57: }
58:
59: }
|