You are viewing a plain text version of this content. The canonical link for it is here.
Posted to svn@forrest.apache.org by cr...@apache.org on 2004/07/31 03:32:46 UTC
svn commit: rev 31009 - in forrest/trunk/scratchpad/eclipsePlugin: . src/org/apache/forrest/eclipse src/org/apache/forrest/eclipse/actions src/org/apache/forrest/eclipse/preference
Author: crossley
Date: Fri Jul 30 18:32:45 2004
New Revision: 31009
Modified:
forrest/trunk/scratchpad/eclipsePlugin/build.properties (contents, props changed)
forrest/trunk/scratchpad/eclipsePlugin/plugin.xml (contents, props changed)
forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/ForrestPlugin.java (contents, props changed)
forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/actions/StartForrest.java (contents, props changed)
forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/actions/StopForrest.java (contents, props changed)
forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/actions/Utilities.java (contents, props changed)
forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/preference/ForrestPreferences.java (contents, props changed)
Log:
dos2unix to fix line-endings.
Do 'svn propset svn:eol-style native' for all text files.
Modified: forrest/trunk/scratchpad/eclipsePlugin/build.properties
==============================================================================
--- forrest/trunk/scratchpad/eclipsePlugin/build.properties (original)
+++ forrest/trunk/scratchpad/eclipsePlugin/build.properties Fri Jul 30 18:32:45 2004
@@ -1,19 +1,19 @@
-# Copyright [yyyy] [name of copyright owner]
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-source.forrestplugin.jar = src/
-output.forrestplugin.jar = bin/
-bin.includes = plugin.xml,\
- forrestplugin.jar,\
- icons/
+# Copyright [yyyy] [name of copyright owner]
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+source.forrestplugin.jar = src/
+output.forrestplugin.jar = bin/
+bin.includes = plugin.xml,\
+ forrestplugin.jar,\
+ icons/
Modified: forrest/trunk/scratchpad/eclipsePlugin/plugin.xml
==============================================================================
--- forrest/trunk/scratchpad/eclipsePlugin/plugin.xml (original)
+++ forrest/trunk/scratchpad/eclipsePlugin/plugin.xml Fri Jul 30 18:32:45 2004
@@ -1,82 +1,82 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright 1999-2004 The Apache Software Foundation.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<?eclipse version="3.0"?>
-<plugin
- id="org.apache.forrest.eclipse"
- name="Forrest Plug-in"
- version="0.1.0"
- provider-name="The Apache Software Foundation"
- class="org.apache.forrest.eclipse.ForrestPlugin">
-
- <runtime>
- <library name="application.jar">
- <export name="*"/>
- </library>
- </runtime>
- <requires>
- <import plugin="org.eclipse.ui"/>
- <import plugin="org.eclipse.debug.core"/>
- <import plugin="org.eclipse.debug.ui"/>
- <import plugin="org.eclipse.jdt.core"/>
- <import plugin="org.eclipse.jdt.launching"/>
- <import plugin="org.eclipse.core.resources"/>
- <import plugin="org.eclipse.core.runtime"/>
- </requires>
-
-
- <extension
- point="org.eclipse.ui.actionSets">
- <actionSet
- label="Forrest Action Set"
- visible="true"
- id="org.apache.forrest.actionSet.eclipse">
- <menu
- label="Forrest"
- id="forrestMenu">
- <separator
- name="forrestGroup">
- </separator>
- </menu>
- <action
- label="Stop Forrest"
- icon="icons/stop.png"
- tooltip="Stop Forrest"
- class="org.apache.forrest.eclipse.actions.StopForrest"
- menubarPath="forrestMenu/forrestGroup"
- toolbarPath="forrestGroup"
- id="org.apache.forrest.eclipse.actions.StopForrest">
- </action>
- <action
- label="Start Forrest"
- icon="icons/start.png"
- tooltip="Start Forrest"
- class="org.apache.forrest.eclipse.actions.StartForrest"
- menubarPath="forrestMenu/forrestGroup"
- toolbarPath="forrestGroup"
- id="org.apache.forrest.eclipse.actions.StartForrest">
- </action>
- </actionSet>
- </extension>
- <extension
- point="org.eclipse.ui.preferencePages">
- <page
- class="org.apache.forrest.eclipse.preference.ForrestPreferences"
- name="Forrest Preferences"
- id="org.apache.forrest.eclipse.preference.ForrestPreferences"/>
- </extension>
-
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 1999-2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<?eclipse version="3.0"?>
+<plugin
+ id="org.apache.forrest.eclipse"
+ name="Forrest Plug-in"
+ version="0.1.0"
+ provider-name="The Apache Software Foundation"
+ class="org.apache.forrest.eclipse.ForrestPlugin">
+
+ <runtime>
+ <library name="application.jar">
+ <export name="*"/>
+ </library>
+ </runtime>
+ <requires>
+ <import plugin="org.eclipse.ui"/>
+ <import plugin="org.eclipse.debug.core"/>
+ <import plugin="org.eclipse.debug.ui"/>
+ <import plugin="org.eclipse.jdt.core"/>
+ <import plugin="org.eclipse.jdt.launching"/>
+ <import plugin="org.eclipse.core.resources"/>
+ <import plugin="org.eclipse.core.runtime"/>
+ </requires>
+
+
+ <extension
+ point="org.eclipse.ui.actionSets">
+ <actionSet
+ label="Forrest Action Set"
+ visible="true"
+ id="org.apache.forrest.actionSet.eclipse">
+ <menu
+ label="Forrest"
+ id="forrestMenu">
+ <separator
+ name="forrestGroup">
+ </separator>
+ </menu>
+ <action
+ label="Stop Forrest"
+ icon="icons/stop.png"
+ tooltip="Stop Forrest"
+ class="org.apache.forrest.eclipse.actions.StopForrest"
+ menubarPath="forrestMenu/forrestGroup"
+ toolbarPath="forrestGroup"
+ id="org.apache.forrest.eclipse.actions.StopForrest">
+ </action>
+ <action
+ label="Start Forrest"
+ icon="icons/start.png"
+ tooltip="Start Forrest"
+ class="org.apache.forrest.eclipse.actions.StartForrest"
+ menubarPath="forrestMenu/forrestGroup"
+ toolbarPath="forrestGroup"
+ id="org.apache.forrest.eclipse.actions.StartForrest">
+ </action>
+ </actionSet>
+ </extension>
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ class="org.apache.forrest.eclipse.preference.ForrestPreferences"
+ name="Forrest Preferences"
+ id="org.apache.forrest.eclipse.preference.ForrestPreferences"/>
+ </extension>
+
+</plugin>
Modified: forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/ForrestPlugin.java
==============================================================================
--- forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/ForrestPlugin.java (original)
+++ forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/ForrestPlugin.java Fri Jul 30 18:32:45 2004
@@ -1,79 +1,79 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.forrest.eclipse;
-
-import org.eclipse.ui.plugin.*;
-import java.util.*;
-
-/**
- * The main plugin class to be used in the desktop.
- */
-public class ForrestPlugin extends AbstractUIPlugin {
- //The shared instance.
- private static ForrestPlugin plugin;
-
- //Resource bundle.
- private ResourceBundle resourceBundle;
-
- /**
- * The constructor.
- *
- */
- public ForrestPlugin() {
- super();
- plugin = this;
- try {
- resourceBundle = ResourceBundle
- .getBundle("org.apache.forrest.ForrestPluginResources"); //$NON-NLS-1$
- } catch (MissingResourceException x) {
- resourceBundle = null;
- }
- }
-
- /**
- * Returns the shared instance.
- *
- * @return
- */
- public static ForrestPlugin getDefault() {
- return plugin;
- }
-
- /**
- * Returns the string from the plugin's resource bundle, or 'key' if not
- * found.
- *
- * @param key
- * @return
- */
- public static String getResourceString(String key) {
- ResourceBundle bundle = ForrestPlugin.getDefault().getResourceBundle();
- try {
- return (bundle != null) ? bundle.getString(key) : key;
- } catch (MissingResourceException e) {
- return key;
- }
- }
-
- /**
- * Returns the plugin's resource bundle,
- *
- * @return
- */
- public ResourceBundle getResourceBundle() {
- return resourceBundle;
- }
-}
\ No newline at end of file
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.eclipse;
+
+import org.eclipse.ui.plugin.*;
+import java.util.*;
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class ForrestPlugin extends AbstractUIPlugin {
+ //The shared instance.
+ private static ForrestPlugin plugin;
+
+ //Resource bundle.
+ private ResourceBundle resourceBundle;
+
+ /**
+ * The constructor.
+ *
+ */
+ public ForrestPlugin() {
+ super();
+ plugin = this;
+ try {
+ resourceBundle = ResourceBundle
+ .getBundle("org.apache.forrest.ForrestPluginResources"); //$NON-NLS-1$
+ } catch (MissingResourceException x) {
+ resourceBundle = null;
+ }
+ }
+
+ /**
+ * Returns the shared instance.
+ *
+ * @return
+ */
+ public static ForrestPlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns the string from the plugin's resource bundle, or 'key' if not
+ * found.
+ *
+ * @param key
+ * @return
+ */
+ public static String getResourceString(String key) {
+ ResourceBundle bundle = ForrestPlugin.getDefault().getResourceBundle();
+ try {
+ return (bundle != null) ? bundle.getString(key) : key;
+ } catch (MissingResourceException e) {
+ return key;
+ }
+ }
+
+ /**
+ * Returns the plugin's resource bundle,
+ *
+ * @return
+ */
+ public ResourceBundle getResourceBundle() {
+ return resourceBundle;
+ }
+}
Modified: forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/actions/StartForrest.java
==============================================================================
--- forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/actions/StartForrest.java (original)
+++ forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/actions/StartForrest.java Fri Jul 30 18:32:45 2004
@@ -1,253 +1,253 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.forrest.eclipse.actions;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.forrest.eclipse.ForrestPlugin;
-import org.apache.forrest.eclipse.preference.ForrestPreferences;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.ui.DebugUITools;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
-import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
-import org.eclipse.jdt.launching.IVMInstall;
-import org.eclipse.jdt.launching.JavaRuntime;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-
-/**
- * Our sample action implements workbench action delegate. The action proxy will
- * be created by the workbench and shown in the UI. When the user tries to use
- * the action, this delegate will be created and execution will be delegated to
- * it.
- *
- * @see IWorkbenchWindowActionDelegate
- */
-public class StartForrest implements IWorkbenchWindowActionDelegate,
- IJavaLaunchConfigurationConstants {
- private IWorkbenchWindow window;
-
- /**
- * The constructor.
- */
- public StartForrest() {
- }
-
- /**
- * The action has been activated. The argument of the method represents the
- * 'real' action sitting in the workbench UI.
- *
- * @param action
- * @throws NullPointerException
- *
- *
- */
- public void run(IAction action) throws NullPointerException {
- String cmdString = null;
- IPath path = JavaCore.getClasspathVariable("ECLIPSE_HOME");
- Shell shell = window.getShell();
- Shell dialog = new Shell(shell);
-
- String fhome = ForrestPlugin.getDefault().getPluginPreferences()
- .getString(ForrestPreferences.FORREST_HOME);
-
- // TODO: Working diretory should not be a property it should be whatever project directory Eclipse is currently working with
- String wdir = ForrestPlugin.getDefault().getPluginPreferences()
- .getString(ForrestPreferences.WORKING_DIR);
-
- if (fhome.equals("") || wdir.equals("")) {
- dialog.setText("Configure Forrest");
- dialog.setSize(400, 100);
- Label statusMsg = new Label(dialog, SWT.NONE);
- statusMsg
- .setText("Please configure Forrest by providing values for the required preferences");
- statusMsg.setLocation(30, 25);
- statusMsg.pack();
- // TODO: Add an OK button
- dialog.open();
- // TODO: open the properties editor
- return;
- }
-
- dialog.setText("Forrest Server");
- dialog.setSize(500, 250);
- Label statusMsg = new Label(dialog, SWT.NONE);
- StringBuffer sb = new StringBuffer("Forrest server is starting.\n");
- sb.append("\n\nPlease wait...");
- statusMsg.setText(sb.toString());
- statusMsg.setLocation(30, 25);
- statusMsg.pack();
- dialog.open();
-
- IPath workingDirectory = new Path(wdir);
-
- if (System.getProperty("os.name").toLowerCase().startsWith("linux")) {
- cmdString = "forrest -Dbasedir=" + workingDirectory
- + " webapp-local";
- Utilities.RunExtCommand(cmdString);
- }
-
- if (System.getProperty("os.name").toLowerCase().startsWith("windows")) {
- cmdString = "cmd /c forrest -Dbasedir=" + workingDirectory
- + " webapp-local";
- Utilities.RunExtCommand(cmdString);
- }
-
- try {
- ILaunchManager manager = DebugPlugin.getDefault()
- .getLaunchManager();
- ILaunchConfigurationType type = manager
- .getLaunchConfigurationType(ID_JAVA_APPLICATION);
- ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(
- null, "Start Jetty");
-
- // find the JRE used to start
- IVMInstall jre = JavaRuntime.getDefaultVMInstall();
-
- IPath forrestHome = new Path(fhome);
-
- // specify a JRE
- workingCopy.setAttribute(ATTR_VM_INSTALL_NAME, jre.getName());
- workingCopy.setAttribute(ATTR_VM_INSTALL_TYPE, jre
- .getVMInstallType().getId());
-
- // specify main type and program arguments
- workingCopy.setAttribute(ATTR_MAIN_TYPE_NAME,
- "org.mortbay.jetty.Server");
- workingCopy.setAttribute(ATTR_PROGRAM_ARGUMENTS, workingDirectory
- + "/build/webapp/jettyconf.xml");
-
- // specify classpath
- List classpath = new ArrayList();
-
- String parent = ".." + File.separator;
-
- String sPath = fhome + File.separator + parent + parent + "lib";
- File searchDir = new File(sPath);
- File forrestBuildDir = new File(fhome + File.separator + parent + parent + "build");
- File jettyDir = new File(fhome + File.separator + parent + parent + "tools"
- + File.separator + "jetty");
-
- try {
- //FIXME: check that the search directory exists, if it doesn't eclipse throws an unhandled loop exception
- List allfiles = Utilities.getFileListing(searchDir);
- allfiles.addAll(Utilities.getFileListing(forrestBuildDir));
- allfiles.addAll(Utilities.getFileListing(jettyDir));
- Iterator filesListing = allfiles.iterator();
- String thisFile;
-
- while (filesListing.hasNext()) {
- thisFile = filesListing.next().toString();
-
- if (thisFile.toString().toLowerCase().endsWith("jar")) { //$NON-NLS-1$
- IPath forrestCorePath = new Path(thisFile.toString());
- IRuntimeClasspathEntry forrestCoreEntry = JavaRuntime
- .newArchiveRuntimeClasspathEntry(forrestCorePath);
- forrestCoreEntry
- .setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
- classpath.add(forrestCoreEntry.getMemento());
- }
- }
- } catch (FileNotFoundException e1) {
- e1.printStackTrace();
- }
-
- IPath systemLibsPath = new Path(JavaRuntime.JRE_CONTAINER);
- IRuntimeClasspathEntry systemLibsEntry = JavaRuntime
- .newRuntimeContainerClasspathEntry(systemLibsPath,
- IRuntimeClasspathEntry.STANDARD_CLASSES);
- classpath.add(systemLibsEntry.getMemento());
- workingCopy.setAttribute(ATTR_CLASSPATH, classpath);
- workingCopy.setAttribute(ATTR_DEFAULT_CLASSPATH, false);
-
- // specify working diretory
- File workingDir = workingDirectory.append("build").append("webapp")
- .toFile();
- workingCopy.setAttribute(ATTR_WORKING_DIRECTORY, workingDir
- .getAbsolutePath());
-
- workingCopy.setAttribute(ATTR_VM_ARGUMENTS, "-Dproject.home=\"" + wdir + "\""
- + " -Dforrest.home=\"" + fhome + "\"");
-
- ILaunchConfiguration configuration = workingCopy.doSave();
- IProgressMonitor monitor = new NullProgressMonitor();
- ILaunch launch = DebugUITools.buildAndLaunch(configuration,
- ILaunchManager.RUN_MODE, monitor);
- Utilities.jetty = launch;
- dialog.close();
- shell.setFocus();
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- /**
- * Selection in the workbench has been changed. We can change the state of
- * the 'real' action here if we want, but this can only happen after the
- * delegate has been created.
- *
- * @param action
- * @param selection
- *
- *
- */
- public void selectionChanged(IAction action, ISelection selection) {
- }
-
- /**
- * We can use this method to dispose of any system resources we previously
- * allocated.
- *
- * @see IWorkbenchWindowActionDelegate#dispose
- */
- public void dispose() {
- }
-
- /**
- * We will cache window object in order to be able to provide parent shell
- * for the message dialog.
- *
- * @param window
- *
- * @see IWorkbenchWindowActionDelegate#init
- */
- public void init(IWorkbenchWindow window) {
- this.window = window;
- }
-}
\ No newline at end of file
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.eclipse.actions;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.forrest.eclipse.ForrestPlugin;
+import org.apache.forrest.eclipse.preference.ForrestPreferences;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+
+/**
+ * Our sample action implements workbench action delegate. The action proxy will
+ * be created by the workbench and shown in the UI. When the user tries to use
+ * the action, this delegate will be created and execution will be delegated to
+ * it.
+ *
+ * @see IWorkbenchWindowActionDelegate
+ */
+public class StartForrest implements IWorkbenchWindowActionDelegate,
+ IJavaLaunchConfigurationConstants {
+ private IWorkbenchWindow window;
+
+ /**
+ * The constructor.
+ */
+ public StartForrest() {
+ }
+
+ /**
+ * The action has been activated. The argument of the method represents the
+ * 'real' action sitting in the workbench UI.
+ *
+ * @param action
+ * @throws NullPointerException
+ *
+ *
+ */
+ public void run(IAction action) throws NullPointerException {
+ String cmdString = null;
+ IPath path = JavaCore.getClasspathVariable("ECLIPSE_HOME");
+ Shell shell = window.getShell();
+ Shell dialog = new Shell(shell);
+
+ String fhome = ForrestPlugin.getDefault().getPluginPreferences()
+ .getString(ForrestPreferences.FORREST_HOME);
+
+ // TODO: Working diretory should not be a property it should be whatever project directory Eclipse is currently working with
+ String wdir = ForrestPlugin.getDefault().getPluginPreferences()
+ .getString(ForrestPreferences.WORKING_DIR);
+
+ if (fhome.equals("") || wdir.equals("")) {
+ dialog.setText("Configure Forrest");
+ dialog.setSize(400, 100);
+ Label statusMsg = new Label(dialog, SWT.NONE);
+ statusMsg
+ .setText("Please configure Forrest by providing values for the required preferences");
+ statusMsg.setLocation(30, 25);
+ statusMsg.pack();
+ // TODO: Add an OK button
+ dialog.open();
+ // TODO: open the properties editor
+ return;
+ }
+
+ dialog.setText("Forrest Server");
+ dialog.setSize(500, 250);
+ Label statusMsg = new Label(dialog, SWT.NONE);
+ StringBuffer sb = new StringBuffer("Forrest server is starting.\n");
+ sb.append("\n\nPlease wait...");
+ statusMsg.setText(sb.toString());
+ statusMsg.setLocation(30, 25);
+ statusMsg.pack();
+ dialog.open();
+
+ IPath workingDirectory = new Path(wdir);
+
+ if (System.getProperty("os.name").toLowerCase().startsWith("linux")) {
+ cmdString = "forrest -Dbasedir=" + workingDirectory
+ + " webapp-local";
+ Utilities.RunExtCommand(cmdString);
+ }
+
+ if (System.getProperty("os.name").toLowerCase().startsWith("windows")) {
+ cmdString = "cmd /c forrest -Dbasedir=" + workingDirectory
+ + " webapp-local";
+ Utilities.RunExtCommand(cmdString);
+ }
+
+ try {
+ ILaunchManager manager = DebugPlugin.getDefault()
+ .getLaunchManager();
+ ILaunchConfigurationType type = manager
+ .getLaunchConfigurationType(ID_JAVA_APPLICATION);
+ ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(
+ null, "Start Jetty");
+
+ // find the JRE used to start
+ IVMInstall jre = JavaRuntime.getDefaultVMInstall();
+
+ IPath forrestHome = new Path(fhome);
+
+ // specify a JRE
+ workingCopy.setAttribute(ATTR_VM_INSTALL_NAME, jre.getName());
+ workingCopy.setAttribute(ATTR_VM_INSTALL_TYPE, jre
+ .getVMInstallType().getId());
+
+ // specify main type and program arguments
+ workingCopy.setAttribute(ATTR_MAIN_TYPE_NAME,
+ "org.mortbay.jetty.Server");
+ workingCopy.setAttribute(ATTR_PROGRAM_ARGUMENTS, workingDirectory
+ + "/build/webapp/jettyconf.xml");
+
+ // specify classpath
+ List classpath = new ArrayList();
+
+ String parent = ".." + File.separator;
+
+ String sPath = fhome + File.separator + parent + parent + "lib";
+ File searchDir = new File(sPath);
+ File forrestBuildDir = new File(fhome + File.separator + parent + parent + "build");
+ File jettyDir = new File(fhome + File.separator + parent + parent + "tools"
+ + File.separator + "jetty");
+
+ try {
+ //FIXME: check that the search directory exists, if it doesn't eclipse throws an unhandled loop exception
+ List allfiles = Utilities.getFileListing(searchDir);
+ allfiles.addAll(Utilities.getFileListing(forrestBuildDir));
+ allfiles.addAll(Utilities.getFileListing(jettyDir));
+ Iterator filesListing = allfiles.iterator();
+ String thisFile;
+
+ while (filesListing.hasNext()) {
+ thisFile = filesListing.next().toString();
+
+ if (thisFile.toString().toLowerCase().endsWith("jar")) { //$NON-NLS-1$
+ IPath forrestCorePath = new Path(thisFile.toString());
+ IRuntimeClasspathEntry forrestCoreEntry = JavaRuntime
+ .newArchiveRuntimeClasspathEntry(forrestCorePath);
+ forrestCoreEntry
+ .setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
+ classpath.add(forrestCoreEntry.getMemento());
+ }
+ }
+ } catch (FileNotFoundException e1) {
+ e1.printStackTrace();
+ }
+
+ IPath systemLibsPath = new Path(JavaRuntime.JRE_CONTAINER);
+ IRuntimeClasspathEntry systemLibsEntry = JavaRuntime
+ .newRuntimeContainerClasspathEntry(systemLibsPath,
+ IRuntimeClasspathEntry.STANDARD_CLASSES);
+ classpath.add(systemLibsEntry.getMemento());
+ workingCopy.setAttribute(ATTR_CLASSPATH, classpath);
+ workingCopy.setAttribute(ATTR_DEFAULT_CLASSPATH, false);
+
+ // specify working diretory
+ File workingDir = workingDirectory.append("build").append("webapp")
+ .toFile();
+ workingCopy.setAttribute(ATTR_WORKING_DIRECTORY, workingDir
+ .getAbsolutePath());
+
+ workingCopy.setAttribute(ATTR_VM_ARGUMENTS, "-Dproject.home=\"" + wdir + "\""
+ + " -Dforrest.home=\"" + fhome + "\"");
+
+ ILaunchConfiguration configuration = workingCopy.doSave();
+ IProgressMonitor monitor = new NullProgressMonitor();
+ ILaunch launch = DebugUITools.buildAndLaunch(configuration,
+ ILaunchManager.RUN_MODE, monitor);
+ Utilities.jetty = launch;
+ dialog.close();
+ shell.setFocus();
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ /**
+ * Selection in the workbench has been changed. We can change the state of
+ * the 'real' action here if we want, but this can only happen after the
+ * delegate has been created.
+ *
+ * @param action
+ * @param selection
+ *
+ *
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ }
+
+ /**
+ * We can use this method to dispose of any system resources we previously
+ * allocated.
+ *
+ * @see IWorkbenchWindowActionDelegate#dispose
+ */
+ public void dispose() {
+ }
+
+ /**
+ * We will cache window object in order to be able to provide parent shell
+ * for the message dialog.
+ *
+ * @param window
+ *
+ * @see IWorkbenchWindowActionDelegate#init
+ */
+ public void init(IWorkbenchWindow window) {
+ this.window = window;
+ }
+}
Modified: forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/actions/StopForrest.java
==============================================================================
--- forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/actions/StopForrest.java (original)
+++ forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/actions/StopForrest.java Fri Jul 30 18:32:45 2004
@@ -1,96 +1,96 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.forrest.eclipse.actions;
-
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-
-/**
- * Our sample action implements workbench action delegate. The action proxy will
- * be created by the workbench and shown in the UI. When the user tries to use
- * the action, this delegate will be created and execution will be delegated to
- * it.
- *
- * @see IWorkbenchWindowActionDelegate
- */
-public class StopForrest implements IWorkbenchWindowActionDelegate,
- IJavaLaunchConfigurationConstants {
- private IWorkbenchWindow window;
-
- /**
- * The constructor.
- */
- public StopForrest() {
- }
-
- /**
- * The action has been activated. The argument of the method represents the
- * 'real' action sitting in the workbench UI.
- *
- * @param action
- *
- *
- */
- public void run(IAction action) {
- try {
- Utilities.jetty.terminate();
- } catch (DebugException e) {
- e.printStackTrace();
- }
-
- MessageDialog.openInformation(window.getShell(), "Forrest",
- "Forrest server stopped");
- }
-
- /**
- * Selection in the workbench has been changed. We can change the state of
- * the 'real' action here if we want, but this can only happen after the
- * delegate has been created.
- *
- * @param action
- * @param selection
- *
- *
- */
- public void selectionChanged(IAction action, ISelection selection) {
- }
-
- /**
- * We can use this method to dispose of any system resources we previously
- * allocated.
- *
- * @see IWorkbenchWindowActionDelegate#dispose
- */
- public void dispose() {
- }
-
- /**
- * We will cache window object in order to be able to provide parent shell
- * for the message dialog.
- *
- * @param window
- *
- * @see IWorkbenchWindowActionDelegate#init
- */
- public void init(IWorkbenchWindow window) {
- this.window = window;
- }
-}
\ No newline at end of file
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.eclipse.actions;
+
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+
+/**
+ * Our sample action implements workbench action delegate. The action proxy will
+ * be created by the workbench and shown in the UI. When the user tries to use
+ * the action, this delegate will be created and execution will be delegated to
+ * it.
+ *
+ * @see IWorkbenchWindowActionDelegate
+ */
+public class StopForrest implements IWorkbenchWindowActionDelegate,
+ IJavaLaunchConfigurationConstants {
+ private IWorkbenchWindow window;
+
+ /**
+ * The constructor.
+ */
+ public StopForrest() {
+ }
+
+ /**
+ * The action has been activated. The argument of the method represents the
+ * 'real' action sitting in the workbench UI.
+ *
+ * @param action
+ *
+ *
+ */
+ public void run(IAction action) {
+ try {
+ Utilities.jetty.terminate();
+ } catch (DebugException e) {
+ e.printStackTrace();
+ }
+
+ MessageDialog.openInformation(window.getShell(), "Forrest",
+ "Forrest server stopped");
+ }
+
+ /**
+ * Selection in the workbench has been changed. We can change the state of
+ * the 'real' action here if we want, but this can only happen after the
+ * delegate has been created.
+ *
+ * @param action
+ * @param selection
+ *
+ *
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ }
+
+ /**
+ * We can use this method to dispose of any system resources we previously
+ * allocated.
+ *
+ * @see IWorkbenchWindowActionDelegate#dispose
+ */
+ public void dispose() {
+ }
+
+ /**
+ * We will cache window object in order to be able to provide parent shell
+ * for the message dialog.
+ *
+ * @param window
+ *
+ * @see IWorkbenchWindowActionDelegate#init
+ */
+ public void init(IWorkbenchWindow window) {
+ this.window = window;
+ }
+}
Modified: forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/actions/Utilities.java
==============================================================================
--- forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/actions/Utilities.java (original)
+++ forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/actions/Utilities.java Fri Jul 30 18:32:45 2004
@@ -1,98 +1,98 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.forrest.eclipse.actions;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FilenameFilter;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.debug.core.ILaunch;
-
-/**
- *
- * Some handy utilities for working with plugins.
- */
-public class Utilities {
- /**
- * Comment for <code>jetty</code>
- */
- public static ILaunch jetty;
-
- /**
- * @param directory
- * @return @throws
- * FileNotFoundException
- */
- static public List getFileListing(File directory)
- throws FileNotFoundException {
- class JARFilter implements FilenameFilter {
- public boolean accept(File dir, String name) {
- return (name.endsWith(".jar"));
- }
- }
-
- List result = new ArrayList();
- File[] filesAndDirs = directory.listFiles();
- List filesDirs = Arrays.asList(filesAndDirs);
- Iterator filesIter = filesDirs.iterator();
- File file = null;
-
- while (filesIter.hasNext()) {
- file = (File) filesIter.next();
-
- if (!file.isFile()) {
- List deeperList = getFileListing(file);
- result.addAll(deeperList);
- } else {
- result.add(file);
- }
- }
-
- return result;
- }
-
- /**
- * @param cmdString
- */
- static public void RunExtCommand(final String cmdString) {
- Runnable r = new Runnable() {
- public void run() {
- Process p;
- try {
- System.out.println(cmdString);
- p = Runtime.getRuntime().exec(cmdString);
-
- BufferedReader br = new BufferedReader(
- new InputStreamReader(p.getInputStream()));
- String str;
- while ((str = br.readLine()) != null)
- System.out.println(str);
-
- p.waitFor();
- } catch (Exception e) {
- System.out.println(e);
- }
- }
- };
- r.run();
- }
-}
\ No newline at end of file
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.eclipse.actions;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FilenameFilter;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.debug.core.ILaunch;
+
+/**
+ *
+ * Some handy utilities for working with plugins.
+ */
+public class Utilities {
+ /**
+ * Comment for <code>jetty</code>
+ */
+ public static ILaunch jetty;
+
+ /**
+ * @param directory
+ * @return @throws
+ * FileNotFoundException
+ */
+ static public List getFileListing(File directory)
+ throws FileNotFoundException {
+ class JARFilter implements FilenameFilter {
+ public boolean accept(File dir, String name) {
+ return (name.endsWith(".jar"));
+ }
+ }
+
+ List result = new ArrayList();
+ File[] filesAndDirs = directory.listFiles();
+ List filesDirs = Arrays.asList(filesAndDirs);
+ Iterator filesIter = filesDirs.iterator();
+ File file = null;
+
+ while (filesIter.hasNext()) {
+ file = (File) filesIter.next();
+
+ if (!file.isFile()) {
+ List deeperList = getFileListing(file);
+ result.addAll(deeperList);
+ } else {
+ result.add(file);
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * @param cmdString
+ */
+ static public void RunExtCommand(final String cmdString) {
+ Runnable r = new Runnable() {
+ public void run() {
+ Process p;
+ try {
+ System.out.println(cmdString);
+ p = Runtime.getRuntime().exec(cmdString);
+
+ BufferedReader br = new BufferedReader(
+ new InputStreamReader(p.getInputStream()));
+ String str;
+ while ((str = br.readLine()) != null)
+ System.out.println(str);
+
+ p.waitFor();
+ } catch (Exception e) {
+ System.out.println(e);
+ }
+ }
+ };
+ r.run();
+ }
+}
Modified: forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/preference/ForrestPreferences.java
==============================================================================
--- forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/preference/ForrestPreferences.java (original)
+++ forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/preference/ForrestPreferences.java Fri Jul 30 18:32:45 2004
@@ -1,72 +1,72 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.forrest.eclipse.preference;
-
-import org.eclipse.jface.preference.*;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.IWorkbench;
-import org.apache.forrest.eclipse.ForrestPlugin;
-import org.eclipse.jface.preference.IPreferenceStore;
-
-/**
- * This class represents a preference page that is contributed to the
- * Preferences dialog. By subclassing <samp>FieldEditorPreferencePage </samp>,
- * we can use the field support built into JFace that allows us to create a page
- * that is small and knows how to save, restore and apply itself.
- * <p>
- * This page is used to modify preferences only. They are stored in the
- * preference store that belongs to the main plug-in class. That way,
- * preferences can be accessed directly via the preference store.
- */
-
-public class ForrestPreferences extends FieldEditorPreferencePage implements
- IWorkbenchPreferencePage {
- public static final String WORKING_DIR = "WORKING_DIR";
-
- public static final String FORREST_HOME = "FORREST_HOME";
-
- public ForrestPreferences() {
- super(GRID);
- setPreferenceStore(ForrestPlugin.getDefault().getPreferenceStore());
- setDescription("Configuration for Forrest");
- initializeDefaults();
- }
-
- /**
- * Sets the default values of the preferences.
- * TODO Initialise FORREST_HOME from environment variable if available
- */
- private void initializeDefaults() {
- IPreferenceStore store = getPreferenceStore();
-
- }
-
- /**
- * Creates the field editors. Field editors are abstractions of the common
- * GUI blocks needed to manipulate various types of preferences. Each field
- * editor knows how to save and restore itself.
- */
- public void createFieldEditors() {
- addField(new DirectoryFieldEditor(WORKING_DIR, "&Working Directory:",
- getFieldEditorParent()));
- addField(new DirectoryFieldEditor(FORREST_HOME, "&Forrest Home:",
- getFieldEditorParent()));
-
- }
-
- public void init(IWorkbench workbench) {
- }
-}
\ No newline at end of file
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.eclipse.preference;
+
+import org.eclipse.jface.preference.*;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.IWorkbench;
+import org.apache.forrest.eclipse.ForrestPlugin;
+import org.eclipse.jface.preference.IPreferenceStore;
+
+/**
+ * This class represents a preference page that is contributed to the
+ * Preferences dialog. By subclassing <samp>FieldEditorPreferencePage </samp>,
+ * we can use the field support built into JFace that allows us to create a page
+ * that is small and knows how to save, restore and apply itself.
+ * <p>
+ * This page is used to modify preferences only. They are stored in the
+ * preference store that belongs to the main plug-in class. That way,
+ * preferences can be accessed directly via the preference store.
+ */
+
+public class ForrestPreferences extends FieldEditorPreferencePage implements
+ IWorkbenchPreferencePage {
+ public static final String WORKING_DIR = "WORKING_DIR";
+
+ public static final String FORREST_HOME = "FORREST_HOME";
+
+ public ForrestPreferences() {
+ super(GRID);
+ setPreferenceStore(ForrestPlugin.getDefault().getPreferenceStore());
+ setDescription("Configuration for Forrest");
+ initializeDefaults();
+ }
+
+ /**
+ * Sets the default values of the preferences.
+ * TODO Initialise FORREST_HOME from environment variable if available
+ */
+ private void initializeDefaults() {
+ IPreferenceStore store = getPreferenceStore();
+
+ }
+
+ /**
+ * Creates the field editors. Field editors are abstractions of the common
+ * GUI blocks needed to manipulate various types of preferences. Each field
+ * editor knows how to save and restore itself.
+ */
+ public void createFieldEditors() {
+ addField(new DirectoryFieldEditor(WORKING_DIR, "&Working Directory:",
+ getFieldEditorParent()));
+ addField(new DirectoryFieldEditor(FORREST_HOME, "&Forrest Home:",
+ getFieldEditorParent()));
+
+ }
+
+ public void init(IWorkbench workbench) {
+ }
+}