forrest-svn mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgard...@apache.org
Subject svn commit: rev 35597 - in forrest/trunk/scratchpad/eclipsePlugin: . icons src/org/apache/forrest/eclipse/actions
Date Mon, 02 Aug 2004 17:01:49 GMT
Author: rgardler
Date: Mon Aug  2 10:01:49 2004
New Revision: 35597

Added:
   forrest/trunk/scratchpad/eclipsePlugin/icons/build.png   (contents, props changed)
   forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/actions/BuildSite.java
  (contents, props changed)
Modified:
   forrest/trunk/scratchpad/eclipsePlugin/.classpath
   forrest/trunk/scratchpad/eclipsePlugin/plugin.xml
Log:
Added action to build a forrest site

Modified: forrest/trunk/scratchpad/eclipsePlugin/.classpath
==============================================================================
--- forrest/trunk/scratchpad/eclipsePlugin/.classpath	(original)
+++ forrest/trunk/scratchpad/eclipsePlugin/.classpath	Mon Aug  2 10:01:49 2004
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
+	<classpathentry kind="src" path="src"/>
 	<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/icons/build.png
==============================================================================
Binary file. No diff available.

Modified: forrest/trunk/scratchpad/eclipsePlugin/plugin.xml
==============================================================================
--- forrest/trunk/scratchpad/eclipsePlugin/plugin.xml	(original)
+++ forrest/trunk/scratchpad/eclipsePlugin/plugin.xml	Mon Aug  2 10:01:49 2004
@@ -23,7 +23,7 @@
    class="org.apache.forrest.eclipse.ForrestPlugin">
 
    <runtime>
-      <library name="application.jar">
+      <library name="forrestplugin.jar">
          <export name="*"/>
       </library>
    </runtime>
@@ -52,23 +52,34 @@
             </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">
+                toolbarPath="forrestGroup"
+                label="Stop Forrest"
+                accelerator="o"
+                class="org.apache.forrest.eclipse.actions.StopForrest"
+                tooltip="Stop Forrest"
+                icon="icons/stop.png"
+                menubarPath="forrestMenu/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">
+                toolbarPath="forrestGroup"
+                label="Start Forrest"
+                accelerator="s"
+                class="org.apache.forrest.eclipse.actions.StartForrest"
+                tooltip="Start Forrest"
+                icon="icons/start.png"
+                menubarPath="forrestMenu/forrestGroup"
+                id="org.apache.forrest.eclipse.actions.StartForrest">
          </action>
+          <action
+                toolbarPath="forrestGroup"
+                label="Build Site"
+                class="org.apache.forrest.eclipse.actions.BuildSite"
+                tooltip="Build Forrest site"
+                icon="icons/build.png"
+                accelerator="b"
+                menubarPath="forrestMenu/forrestGroup"
+                id="org.apache.forrest.eclipse.Build"/>
       </actionSet>
    </extension>
    <extension
@@ -79,4 +90,4 @@
             id="org.apache.forrest.eclipse.preference.ForrestPreferences"/>
    </extension>
 
-</plugin>
+</plugin>
\ No newline at end of file

Added: forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/actions/BuildSite.java
==============================================================================
--- (empty file)
+++ forrest/trunk/scratchpad/eclipsePlugin/src/org/apache/forrest/eclipse/actions/BuildSite.java
Mon Aug  2 10:01:49 2004
@@ -0,0 +1,147 @@
+/*
+ * 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.apache.forrest.eclipse.ForrestPlugin;
+import org.apache.forrest.eclipse.preference.ForrestPreferences;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+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 BuildSite implements IWorkbenchWindowActionDelegate,
+		IJavaLaunchConfigurationConstants {
+	private IWorkbenchWindow window;
+
+	/**
+	 * The constructor.
+	 */
+	public BuildSite() {
+	}
+
+	/**
+	 * 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);
+
+		// FIXME: move preferences code to utilities class
+		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
+					+ " site";
+			Utilities.RunExtCommand(cmdString);
+		}
+
+		if (System.getProperty("os.name").toLowerCase().startsWith("windows")) {
+			cmdString = "cmd /c forrest -Dbasedir=" + workingDirectory
+					+ " site";
+			Utilities.RunExtCommand(cmdString);
+		}		
+		
+		dialog.close();
+	}
+
+	/**
+	 * 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;
+	}
+}

Mime
View raw message