001: /* Soot - a J*va Optimization Framework
002: * Copyright (C) 2005 Jennifer Lhotak
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the
016: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
017: * Boston, MA 02111-1307, USA.
018: */
019:
020: package ca.mcgill.sable.graph;
021:
022: import org.eclipse.ui.plugin.*;
023: import org.eclipse.core.runtime.*;
024: import org.eclipse.core.resources.*;
025: import java.util.*;
026: import ca.mcgill.sable.graph.testing.*;
027:
028: /**
029: * The main plugin class to be used in the desktop.
030: */
031: public class GraphPlugin extends AbstractUIPlugin {
032: //The shared instance.
033: private static GraphPlugin plugin;
034: //Resource bundle.
035: private ResourceBundle resourceBundle;
036:
037: private GraphGenerator generator;
038:
039: /**
040: * The constructor.
041: */
042: public GraphPlugin(IPluginDescriptor descriptor) {
043: super (descriptor);
044: plugin = this ;
045: try {
046: resourceBundle = ResourceBundle
047: .getBundle("ca.mcgill.sable.graph.GraphPluginResources");
048: } catch (MissingResourceException x) {
049: resourceBundle = null;
050: }
051: }
052:
053: /**
054: * Returns the shared instance.
055: */
056: public static GraphPlugin getDefault() {
057: return plugin;
058: }
059:
060: /**
061: * Returns the workspace instance.
062: */
063: public static IWorkspace getWorkspace() {
064: return ResourcesPlugin.getWorkspace();
065: }
066:
067: /**
068: * Returns the string from the plugin's resource bundle,
069: * or 'key' if not found.
070: */
071: public static String getResourceString(String key) {
072: ResourceBundle bundle = GraphPlugin.getDefault()
073: .getResourceBundle();
074: try {
075: return bundle.getString(key);
076: } catch (MissingResourceException e) {
077: return key;
078: }
079: }
080:
081: /**
082: * Returns the plugin's resource bundle,
083: */
084: public ResourceBundle getResourceBundle() {
085: return resourceBundle;
086: }
087:
088: /**
089: * @return
090: */
091: public GraphGenerator getGenerator() {
092: return generator;
093: }
094:
095: /**
096: * @param generator
097: */
098: public void setGenerator(GraphGenerator generator) {
099: this.generator = generator;
100: }
101:
102: }
|