1
2
3
4
5
6 package org.dbe.studio.tools.ontologyviewer;
7
8 import org.dbe.studio.tools.ontologyviewer.utils.Constants;
9 import org.eclipse.jface.preference.IPreferenceStore;
10 import org.eclipse.jface.resource.ImageDescriptor;
11 import org.eclipse.ui.plugin.*;
12 import org.osgi.framework.BundleContext;
13
14 import java.util.*;
15
16 /***
17 * The main plugin class to be used in the desktop.
18 */
19 public class OntologyViewerPlugin extends AbstractUIPlugin {
20
21 private static OntologyViewerPlugin plugin;
22
23 private ResourceBundle resourceBundle;
24
25 /***
26 * The constructor.
27 */
28 public OntologyViewerPlugin() {
29 super();
30 plugin = this;
31 try {
32 resourceBundle = ResourceBundle.getBundle("Test.MyTreeView.MyTreeViewPluginResources");
33 } catch (MissingResourceException x) {
34 resourceBundle = null;
35 }
36 }
37
38 /***
39 * This method is called upon plug-in activation
40 */
41 public void start(BundleContext context) throws Exception {
42 super.start(context);
43 }
44
45 /***
46 * This method is called when the plug-in is stopped
47 */
48 public void stop(BundleContext context) throws Exception {
49 super.stop(context);
50 }
51
52 /***
53 * Returns the shared instance.
54 */
55 public static OntologyViewerPlugin getDefault() {
56 return plugin;
57 }
58
59 /***
60 * Returns the string from the plugin's resource bundle,
61 * or 'key' if not found.
62 */
63 public static String getResourceString(String key) {
64 ResourceBundle bundle = OntologyViewerPlugin.getDefault().getResourceBundle();
65 try {
66 return (bundle != null) ? bundle.getString(key) : key;
67 } catch (MissingResourceException e) {
68 return key;
69 }
70 }
71
72 /***
73 * Returns the plugin's resource bundle,
74 */
75 public ResourceBundle getResourceBundle() {
76 return resourceBundle;
77 }
78
79 /***
80 * Returns the image descriptor with the given relative path.
81 */
82 public static ImageDescriptor getImageDescriptor(String name) {
83
84 return imageDescriptorFromPlugin( plugin.getBundle().getSymbolicName(),
85 Constants.ICONS_PATH + name
86 );
87 }
88
89 /***
90 * Initializes a preference store with default preference values
91 * for this plug-in.
92 *
93 * @param store the preference store to fill
94 */
95 protected void initializeDefaultPreferences(IPreferenceStore store) {
96 store.setDefault( Constants.FADA_NODE_ADDRESS, Constants.FADA_NODE_ADDRESS);
97 }
98 }