KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ca > mcgill > sable > graph > GraphPlugin


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2005 Jennifer Lhotak
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */

19
20 package ca.mcgill.sable.graph;
21
22 import org.eclipse.ui.plugin.*;
23 import org.eclipse.core.runtime.*;
24 import org.eclipse.core.resources.*;
25 import java.util.*;
26 import ca.mcgill.sable.graph.testing.*;
27
28 /**
29  * The main plugin class to be used in the desktop.
30  */

31 public class GraphPlugin extends AbstractUIPlugin {
32     //The shared instance.
33
private static GraphPlugin plugin;
34     //Resource bundle.
35
private ResourceBundle resourceBundle;
36     
37     private GraphGenerator generator;
38     
39     /**
40      * The constructor.
41      */

42     public GraphPlugin(IPluginDescriptor descriptor) {
43         super(descriptor);
44         plugin = this;
45         try {
46             resourceBundle= ResourceBundle.getBundle("ca.mcgill.sable.graph.GraphPluginResources");
47         } catch (MissingResourceException x) {
48             resourceBundle = null;
49         }
50     }
51
52     /**
53      * Returns the shared instance.
54      */

55     public static GraphPlugin getDefault() {
56         return plugin;
57     }
58
59     /**
60      * Returns the workspace instance.
61      */

62     public static IWorkspace getWorkspace() {
63         return ResourcesPlugin.getWorkspace();
64     }
65
66     /**
67      * Returns the string from the plugin's resource bundle,
68      * or 'key' if not found.
69      */

70     public static String JavaDoc getResourceString(String JavaDoc key) {
71         ResourceBundle bundle= GraphPlugin.getDefault().getResourceBundle();
72         try {
73             return bundle.getString(key);
74         } catch (MissingResourceException e) {
75             return key;
76         }
77     }
78
79     /**
80      * Returns the plugin's resource bundle,
81      */

82     public ResourceBundle getResourceBundle() {
83         return resourceBundle;
84     }
85     /**
86      * @return
87      */

88     public GraphGenerator getGenerator() {
89         return generator;
90     }
91
92     /**
93      * @param generator
94      */

95     public void setGenerator(GraphGenerator generator) {
96         this.generator = generator;
97     }
98
99 }
100
Popular Tags