1 /**********************************************************************
2 Copyright (c) 2000, 2002 IBM Corp. 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 IBM Corporation - Initial implementation
10 Klaus Hartlage - www.eclipseproject.de
11 **********************************************************************/
12 package net.sourceforge.phpeclipse;
14 import java.util.MissingResourceException;
15 import java.util.ResourceBundle;
17 import org.eclipse.core.resources.IWorkspace;
18 import org.eclipse.core.resources.ResourcesPlugin;
19 import org.eclipse.core.runtime.IPluginDescriptor;
20 import org.eclipse.jface.preference.IPreferenceStore;
21 import org.eclipse.ui.plugin.AbstractUIPlugin;
24 * The main plugin class to be used in the desktop.
26 public class PHPeclipsePlugin extends AbstractUIPlugin {
27 public static final String LOCALHOST_PREF = "_localhost";
28 public static final String DOCUMENTROOT_PREF = "_documentroot";
29 public static final String USE_EXTERNAL_BROWSER_PREF = "_use_external_browser";
30 public static final String EXTERNAL_BROWSER_PREF = "_external_browser";
31 public static final String MYSQL_PREF = "_my_sql";
32 public static final String APACHE_START_PREF = "_apache_start";
33 public static final String APACHE_STOP_PREF = "_apache_stop";
34 public static final String APACHE_RESTART_PREF = "_apache_restart";
35 //The shared instance.
36 private static PHPeclipsePlugin plugin;
38 private ResourceBundle resourceBundle;
40 * The Java virtual machine that we are running on.
42 private static int jvm;
45 private static final int MRJ_2_0 = 0;
47 /** MRJ 2.1 or later */
48 private static final int MRJ_2_1 = 1;
50 /** Java on Mac OS X 10.0 (MRJ 3.0) */
51 private static final int MRJ_3_0 = 3;
54 private static final int MRJ_3_1 = 4;
57 private static final int WINDOWS_NT = 5;
60 private static final int WINDOWS_9x = 6;
62 /** JVM constant for any other platform */
63 private static final int OTHER = -1;
67 public PHPeclipsePlugin(IPluginDescriptor descriptor) {
72 resourceBundle = ResourceBundle.getBundle("net.sourceforge.PHPeclipsePluginResources");
73 } catch (MissingResourceException x) {
74 resourceBundle = null;
78 public static void setJVM() {
79 String osName = System.getProperty("os.name");
81 if (osName.startsWith("Mac OS")) {
82 String mrjVersion = System.getProperty("mrj.version");
83 String majorMRJVersion = mrjVersion.substring(0, 3);
87 double version = Double.valueOf(majorMRJVersion).doubleValue();
91 } else if (version >= 2.1 && version < 3) {
93 } else if (version == 3.0) {
95 } else if (version >= 3.1) {
99 } catch (NumberFormatException nfe) {
103 } else if (osName.startsWith("Windows")) {
104 if (osName.indexOf("9") != -1) {
111 public static int getJVM() {
115 * Returns the shared instance.
117 public static PHPeclipsePlugin getDefault() {
122 * Returns the workspace instance.
124 public static IWorkspace getWorkspace() {
125 return ResourcesPlugin.getWorkspace();
129 * Returns the string from the plugin's resource bundle,
130 * or 'key' if not found.
132 public static String getResourceString(String key) {
133 ResourceBundle bundle = PHPeclipsePlugin.getDefault().getResourceBundle();
135 return bundle.getString(key);
136 } catch (MissingResourceException e) {
142 * Returns the plugin's resource bundle,
144 public ResourceBundle getResourceBundle() {
145 return resourceBundle;
148 protected void initializeDefaultPreferences(IPreferenceStore store) {
149 // windows preferences:
150 store.setDefault(LOCALHOST_PREF, "http://localhost");
152 store.setDefault(USE_EXTERNAL_BROWSER_PREF, "false");
153 if (jvm == WINDOWS_9x) {
154 store.setDefault(EXTERNAL_BROWSER_PREF, "command.com /c start iexplore {0}");
155 } else if (jvm == WINDOWS_NT) {
156 store.setDefault(EXTERNAL_BROWSER_PREF, "rundll32 url.dll,FileProtocolHandler {0}");
158 store.setDefault(EXTERNAL_BROWSER_PREF, "netscape {0}");
160 if ((jvm == WINDOWS_9x) || (jvm == WINDOWS_NT)) {
161 store.setDefault(DOCUMENTROOT_PREF, "c:\\eclipse\\workspace");
162 store.setDefault(MYSQL_PREF, "c:\\apache\\mysql\\bin\\mysqld.exe --standalone");
163 store.setDefault(APACHE_START_PREF, "c:\\apache\\apache.exe -c \"DocumentRoot \"{0}\"\"");
164 store.setDefault(APACHE_STOP_PREF, "c:\\apache\\apache.exe -k shutdown");
165 store.setDefault(APACHE_RESTART_PREF, "c:\\apache\\apache.exe -k restart");
167 store.setDefault(DOCUMENTROOT_PREF, "/eclipse/workspace");
168 store.setDefault(MYSQL_PREF, "/apache/mysql/bin/mysqld --standalone");
169 store.setDefault(APACHE_START_PREF, "/apache/apache -c \"DocumentRoot \"{0}\"\"");
170 store.setDefault(APACHE_STOP_PREF, "/apache/apache.exe -k shutdown");
171 store.setDefault(APACHE_RESTART_PREF, "/apache/apache -k restart");