01: /*******************************************************************************
02: * Copyright (c) 2005 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.ui.examples.components;
11:
12: import org.eclipse.ui.plugin.*;
13: import org.osgi.framework.BundleContext;
14: import java.util.*;
15:
16: /**
17: * The main plugin class to be used in the desktop.
18: */
19: public class ComponentExamplesPlugin extends AbstractUIPlugin {
20: //The shared instance.
21: private static ComponentExamplesPlugin plugin;
22: //Resource bundle.
23: private ResourceBundle resourceBundle;
24:
25: /**
26: * The constructor.
27: */
28: public ComponentExamplesPlugin() {
29: super ();
30: plugin = this ;
31: }
32:
33: /**
34: * This method is called upon plug-in activation
35: */
36: public void start(BundleContext context) throws Exception {
37: super .start(context);
38: }
39:
40: /**
41: * This method is called when the plug-in is stopped
42: */
43: public void stop(BundleContext context) throws Exception {
44: super .stop(context);
45: plugin = null;
46: resourceBundle = null;
47: }
48:
49: /**
50: * Returns the shared instance.
51: */
52: public static ComponentExamplesPlugin getDefault() {
53: return plugin;
54: }
55:
56: /**
57: * Returns the string from the plugin's resource bundle,
58: * or 'key' if not found.
59: */
60: public static String getResourceString(String key) {
61: ResourceBundle bundle = ComponentExamplesPlugin.getDefault()
62: .getResourceBundle();
63: try {
64: return (bundle != null) ? bundle.getString(key) : key;
65: } catch (MissingResourceException e) {
66: return key;
67: }
68: }
69:
70: /**
71: * Returns the plugin's resource bundle,
72: */
73: public ResourceBundle getResourceBundle() {
74: try {
75: if (resourceBundle == null)
76: resourceBundle = ResourceBundle
77: .getBundle("org.eclipse.ui.examples.components.ComponentsPluginResources");
78: } catch (MissingResourceException x) {
79: resourceBundle = null;
80: }
81: return resourceBundle;
82: }
83: }
|