2 * Copyright (c) 2002-2004 Adrian Dinu and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * Adrian Dinu - initial implementation
11 * $Id: JSUIPlugin.java,v 1.1 2004-09-02 18:23:57 jsurfer Exp $
14 package net.sourceforge.phpeclipse.js.ui;
16 import java.util.LinkedList;
17 import java.util.List;
18 import java.util.MissingResourceException;
19 import java.util.ResourceBundle;
21 import net.sourceforge.phpeclipse.js.ui.editors.JSImages;
22 import net.sourceforge.phpeclipse.js.ui.model.JSModelAdapterFactory;
23 import net.sourceforge.phpeclipse.js.ui.preferences.PreferenceNames;
25 import org.eclipse.core.resources.IWorkspace;
26 import org.eclipse.core.resources.ResourcesPlugin;
27 import org.eclipse.core.runtime.Platform;
28 import org.eclipse.jface.preference.IPreferenceStore;
29 import org.eclipse.jface.resource.ImageRegistry;
30 import org.eclipse.ui.plugin.AbstractUIPlugin;
31 import org.osgi.framework.BundleContext;
34 * The main plugin class to be used in the desktop.
36 public class JSUIPlugin extends AbstractUIPlugin {
38 /** The shared instance. */
39 private static JSUIPlugin plugin;
41 /** Resource bundle. */
42 private ResourceBundle resourceBundle;
44 /** The current func list. */
45 private List currentFunctions = new LinkedList();
50 * @param descriptor the plugin descriptors
56 resourceBundle = ResourceBundle.getBundle(
57 "net.sourceforge.phpeclipse.js.ui.jseditorPluginResources"); //$NON-NLS-1$
58 } catch (MissingResourceException e) {
59 resourceBundle = null;
64 * Returns the shared instance.
67 public static JSUIPlugin getDefault() {
72 * Returns the workspace instance.
75 public static IWorkspace getWorkspace() {
76 return ResourcesPlugin.getWorkspace();
80 * Returns the string from the plugin's resource bundle, or 'key' if not
87 public static String getResourceString(String key) {
88 ResourceBundle bundle = JSUIPlugin.getDefault().getResourceBundle();
90 return bundle.getString(key);
91 } catch(MissingResourceException e) {
97 * Returns the plugin's resource bundle,
100 public ResourceBundle getResourceBundle() {
101 return resourceBundle;
105 * Returns the list of current functions.
107 * @return the current functions
109 public List getCurrentFunctions() {
110 return currentFunctions;
114 * Sets the current list of functions.
116 * @param currentFunctions The functions to set
118 public void setCurrentFunctions(List currentFunctions) {
119 this.currentFunctions = currentFunctions;
123 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
125 public void start(BundleContext context) throws Exception {
126 super.start(context);
127 JSModelAdapterFactory.register(Platform.getAdapterManager());
131 * @see AbstractUIPlugin#initializeDefaultPreferences(IPreferenceStore)
133 protected void initializeDefaultPreferences(IPreferenceStore store) {
134 store.setDefault(PreferenceNames.P_AUTO_OUTLINE, true);
135 // TODO Use PreferenceConverter for color/string conversion
136 store.setDefault(PreferenceNames.P_COMMENT_COLOR, "63,127,95");
137 store.setDefault(PreferenceNames.P_STRING_COLOR, "42,0,255");
138 store.setDefault(PreferenceNames.P_KEYWORD_COLOR, "127,0,85");
139 store.setDefault(PreferenceNames.P_DEFAULT_COLOR, "0,0,0");
143 * @see AbstractUIPlugin#initializeImageRegistry(ImageRegistry)
145 protected void initializeImageRegistry(ImageRegistry reg) {
146 JSImages.initializeRegistry(reg);