You are viewing a plain text version of this content. The canonical link for it is here.
Posted to svn@forrest.apache.org by rg...@apache.org on 2004/07/30 01:32:27 UTC
svn commit: rev 30950 - in forrest/trunk/scratchpad/eclipsePlugin: . build build/org build/org/apache build/org/apache/forrest build/org/apache/forrest/eclipse build/org/apache/forrest/eclipse/actions build/org/apache/forrest/eclipse/preference icons src src/org src/org/apache src/org/apache/forrest src/org/apache/forrest/eclipse src/org/apache/forrest/eclipse/actions src/org/apache/forrest/eclipse/preference
Author: rgardler
Date: Thu Jul 29 16:32:26 2004
New Revision: 30950
Added:
forrest/trunk/scratchpad/eclipsePlugin/
forrest/trunk/scratchpad/eclipsePlugin/.classpath
forrest/trunk/scratchpad/eclipsePlugin/.cvsignore
forrest/trunk/scratchpad/eclipsePlugin/.project
forrest/trunk/scratchpad/eclipsePlugin/build/
forrest/trunk/scratchpad/eclipsePlugin/build.properties
forrest/trunk/scratchpad/eclipsePlugin/build/org/
forrest/trunk/scratchpad/eclipsePlugin/build/org/apache/
forrest/trunk/scratchpad/eclipsePlugin/build/org/apache/forrest/
forrest/trunk/scratchpad/eclipsePlugin/build/org/apache/forrest/eclipse/
forrest/trunk/scratchpad/eclipsePlugin/build/org/apache/forrest/eclipse/ForrestPlugin.class (contents, props changed)
forrest/trunk/scratchpad/eclipsePlugin/build/org/apache/forrest/eclipse/actions/
forrest/trunk/scratchpad/eclipsePlugin/build/org/apache/forrest/eclipse/actions/StartForrest.class (contents, props changed)
forrest/trunk/scratchpad/eclipsePlugin/build/org/apache/forrest/eclipse/actions/StopForrest.class (contents, props changed)
forrest/trunk/scratchpad/eclipsePlugin/build/org/apache/forrest/eclipse/actions/Utilities$1$JARFilter.class (contents, props changed)
forrest/trunk/scratchpad/eclipsePlugin/build/org/apache/forrest/eclipse/actions/Utilities$1.class (contents, props changed)
forrest/trunk/scratchpad/eclipsePlugin/build/org/apache/forrest/eclipse/actions/Utilities.class (contents, props changed)
forrest/trunk/scratchpad/eclipsePlugin/build/org/apache/forrest/eclipse/preference/
forrest/trunk/scratchpad/eclipsePlugin/build/org/apache/forrest/eclipse/preference/ForrestPreferences.class (contents, props changed)
forrest/trunk/scratchpad/eclipsePlugin/icons/
forrest/trunk/scratchpad/eclipsePlugin/icons/build.png (contents, props changed)
forrest/trunk/scratchpad/eclipsePlugin/icons/reload.png (contents, props changed)
forrest/trunk/scratchpad/eclipsePlugin/icons/sample.gif (contents, props changed)
forrest/trunk/scratchpad/eclipsePlugin/icons/start.png (contents, props changed)
forrest/trunk/scratchpad/eclipsePlugin/icons/stop.png (contents, props changed)
forrest/trunk/scratchpad/eclipsePlugin/plugin.xml
forrest/trunk/scratchpad/eclipsePlugin/src/
forrest/trunk/scratchpad/eclipsePlugin/src/org/
forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/
forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/
forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/
forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/ForrestPlugin.java
forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/actions/
forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/actions/StartForrest.java
forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/actions/StopForrest.java
forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/actions/Utilities.java
forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/preference/
forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/preference/ForrestPreferences.java
Log:
Initial donation from Burrokeet project - original author Anil Ramnanan <an...@users.sourceforge.net>
Added: forrest/trunk/scratchpad/eclipsePlugin/.classpath
==============================================================================
--- (empty file)
+++ forrest/trunk/scratchpad/eclipsePlugin/.classpath Thu Jul 29 16:32:26 2004
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="build"/>
+</classpath>
Added: forrest/trunk/scratchpad/eclipsePlugin/.cvsignore
==============================================================================
--- (empty file)
+++ forrest/trunk/scratchpad/eclipsePlugin/.cvsignore Thu Jul 29 16:32:26 2004
@@ -0,0 +1 @@
+.externalToolBuilders
Added: forrest/trunk/scratchpad/eclipsePlugin/.project
==============================================================================
--- (empty file)
+++ forrest/trunk/scratchpad/eclipsePlugin/.project Thu Jul 29 16:32:26 2004
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>eclipseplugin</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
+ <arguments>
+ <dictionary>
+ <key>LaunchConfigHandle</key>
+ <value><project>/.externalToolBuilders/com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder.launch</value>
+ </dictionary>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ </natures>
+</projectDescription>
Added: forrest/trunk/scratchpad/eclipsePlugin/build.properties
==============================================================================
--- (empty file)
+++ forrest/trunk/scratchpad/eclipsePlugin/build.properties Thu Jul 29 16:32:26 2004
@@ -0,0 +1,5 @@
+source.forrestplugin.jar = src/
+output.forrestplugin.jar = bin/
+bin.includes = plugin.xml,\
+ forrestplugin.jar,\
+ icons/
Added: forrest/trunk/scratchpad/eclipsePlugin/build/org/apache/forrest/eclipse/ForrestPlugin.class
==============================================================================
Binary file. No diff available.
Added: forrest/trunk/scratchpad/eclipsePlugin/build/org/apache/forrest/eclipse/actions/StartForrest.class
==============================================================================
Binary file. No diff available.
Added: forrest/trunk/scratchpad/eclipsePlugin/build/org/apache/forrest/eclipse/actions/StopForrest.class
==============================================================================
Binary file. No diff available.
Added: forrest/trunk/scratchpad/eclipsePlugin/build/org/apache/forrest/eclipse/actions/Utilities$1$JARFilter.class
==============================================================================
Binary file. No diff available.
Added: forrest/trunk/scratchpad/eclipsePlugin/build/org/apache/forrest/eclipse/actions/Utilities$1.class
==============================================================================
Binary file. No diff available.
Added: forrest/trunk/scratchpad/eclipsePlugin/build/org/apache/forrest/eclipse/actions/Utilities.class
==============================================================================
Binary file. No diff available.
Added: forrest/trunk/scratchpad/eclipsePlugin/build/org/apache/forrest/eclipse/preference/ForrestPreferences.class
==============================================================================
Binary file. No diff available.
Added: forrest/trunk/scratchpad/eclipsePlugin/icons/build.png
==============================================================================
Binary file. No diff available.
Added: forrest/trunk/scratchpad/eclipsePlugin/icons/reload.png
==============================================================================
Binary file. No diff available.
Added: forrest/trunk/scratchpad/eclipsePlugin/icons/sample.gif
==============================================================================
Binary file. No diff available.
Added: forrest/trunk/scratchpad/eclipsePlugin/icons/start.png
==============================================================================
Binary file. No diff available.
Added: forrest/trunk/scratchpad/eclipsePlugin/icons/stop.png
==============================================================================
Binary file. No diff available.
Added: forrest/trunk/scratchpad/eclipsePlugin/plugin.xml
==============================================================================
--- (empty file)
+++ forrest/trunk/scratchpad/eclipsePlugin/plugin.xml Thu Jul 29 16:32:26 2004
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?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>
Added: forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/ForrestPlugin.java
==============================================================================
--- (empty file)
+++ forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/ForrestPlugin.java Thu Jul 29 16:32:26 2004
@@ -0,0 +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
Added: forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/actions/StartForrest.java
==============================================================================
--- (empty file)
+++ forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/actions/StartForrest.java Thu Jul 29 16:32:26 2004
@@ -0,0 +1,244 @@
+/*
+ * 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 directory project Forrest 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("Burrokeet Application");
+ dialog.setSize(500, 250);
+ Label statusMsg = new Label(dialog, SWT.NONE);
+ StringBuffer sb = new StringBuffer("Forrest application 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, forrestHome
+ + "/context/jettyconf.xml");
+
+ // specify classpath
+ List classpath = new ArrayList();
+
+ String sPath = fhome + File.separator + "lib";
+ File searchDir = new File(sPath);
+ File jettyDir = new File(fhome + File.separator + "tools"
+ + File.separator + "jetty");
+
+ try {
+ List allfiles = Utilities.getFileListing(searchDir);
+ 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());
+
+ 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
Added: forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/actions/StopForrest.java
==============================================================================
--- (empty file)
+++ forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/actions/StopForrest.java Thu Jul 29 16:32:26 2004
@@ -0,0 +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(), "Burrokeet",
+ "Burrokeet Application 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
Added: forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/actions/Utilities.java
==============================================================================
--- (empty file)
+++ forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/actions/Utilities.java Thu Jul 29 16:32:26 2004
@@ -0,0 +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
Added: forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/preference/ForrestPreferences.java
==============================================================================
--- (empty file)
+++ forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/preference/ForrestPreferences.java Thu Jul 29 16:32:26 2004
@@ -0,0 +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