intial source from ttp://www.sf.net/projects/wdte
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.js.core / src / net / sourceforge / phpeclipse / js / core / JSCorePlugin.java
1 /*
2  * $RCSfile: JSCorePlugin.java,v $
3  *
4  * Copyright 2002
5  * CH-1700 Fribourg, Switzerland
6  * All rights reserved.
7  *
8  *========================================================================
9  * Modifications history
10  *========================================================================
11  * $Log: not supported by cvs2svn $
12  * Revision 1.2  2004/05/22 16:14:37  l950637
13  * Adapt for Eclipse 3.0M9
14  *
15  * Revision 1.1  2004/02/05 03:10:08  agfitzp
16  * Initial Submission
17  *
18  * Revision 1.3  2003/12/10 20:19:16  agfitzp
19  * 3.0 port
20  *
21  * Revision 1.2  2003/06/21 03:48:51  agfitzp
22  * fixed global variables as functions bug
23  * fixed length calculation of instance variables
24  * Automatic outlining is now a preference
25  *
26  * Revision 1.1  2003/05/28 15:17:12  agfitzp
27  * net.sourceforge.phpeclipse.js.core 0.0.1 code base
28  *
29  *========================================================================
30 */
31
32 package net.sourceforge.phpeclipse.js.core;
33
34 import java.util.LinkedList;
35 import java.util.List;
36 import java.util.MissingResourceException;
37 import java.util.ResourceBundle;
38
39 import org.eclipse.core.resources.IWorkspace;
40 import org.eclipse.core.resources.ResourcesPlugin;
41 import org.eclipse.core.runtime.Plugin;
42
43
44 /**
45  * The main plugin class to be used in the desktop.
46  */
47 public class JSCorePlugin extends Plugin
48 {
49    //The shared instance.
50    private static JSCorePlugin plugin;
51
52    //Resource bundle.
53    private ResourceBundle resourceBundle;
54    
55    private boolean defaultsInitialized = false;
56    
57    /**
58     * current func list
59     */
60    private List currentFunctions = new LinkedList();
61      
62    /**
63     * The constructor.
64     * @param descriptor
65     */
66    public JSCorePlugin() {
67       plugin = this;
68
69       try {
70          resourceBundle = ResourceBundle.getBundle("net.sourceforge.phpeclipse.js.core.JSCorePluginResources");
71       } catch(MissingResourceException x) {
72          resourceBundle = null;
73       }
74    }
75
76    /**
77     * Returns the shared instance.
78     * @return
79     */
80    public static JSCorePlugin getDefault() {
81       return plugin;
82    }
83
84    /**
85     * Returns the workspace instance.
86     * @return
87     */
88    public static IWorkspace getWorkspace() {
89       return ResourcesPlugin.getWorkspace();
90    }
91
92    /**
93     * Returns the string from the plugin's resource bundle, or 'key' if not found.
94     * @param key
95     * 
96     * @return
97     */
98    public static String getResourceString(String key) {
99       ResourceBundle bundle = JSCorePlugin.getDefault().getResourceBundle();
100
101       try {
102          return bundle.getString(key);
103       } catch(MissingResourceException e) {
104          return key;
105       }
106    }
107
108    /**
109     * Returns the plugin's resource bundle,
110     * @return
111     */
112    public ResourceBundle getResourceBundle() {
113       return resourceBundle;
114    }
115    
116         /**
117          * Returns the currentFunctions.
118          * @return List
119          */
120         public List getCurrentFunctions() {
121                 return currentFunctions;
122         }
123
124         /**
125          * Sets the currentFunctions.
126          * @param currentFunctions The currentFunctions to set
127          */
128         public void setCurrentFunctions(List currentFunctions) {
129                 this.currentFunctions = currentFunctions;
130         }
131 }