forrest-svn mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cross...@apache.org
Subject svn commit: r208884 - in /forrest/trunk/tools/eclipse/plugins/org.apache.forrest: ./ src/org/apache/forrest/eclipse/job/ src/org/apache/forrest/eclipse/popup/actions/ src/org/apache/forrest/eclipse/views/
Date Sun, 03 Jul 2005 04:35:52 GMT
Author: crossley
Date: Sat Jul  2 21:35:50 2005
New Revision: 208884

URL: http://svn.apache.org/viewcvs?rev=208884&view=rev
Log:
Submitted by: Anil Ramnanan
Issue: FOR-566 "Option to Create a WAR file."

Added:
    forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/job/ForrestWARBuilder.java
  (with props)
    forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/popup/actions/BuildWARSite.java
  (with props)
    forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/
    forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/SiteXMLView.java
  (with props)
Modified:
    forrest/trunk/tools/eclipse/plugins/org.apache.forrest/plugin.xml
    forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/job/ForrestManager.java

Modified: forrest/trunk/tools/eclipse/plugins/org.apache.forrest/plugin.xml
URL: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/plugins/org.apache.forrest/plugin.xml?rev=208884&r1=208883&r2=208884&view=diff
==============================================================================
--- forrest/trunk/tools/eclipse/plugins/org.apache.forrest/plugin.xml (original)
+++ forrest/trunk/tools/eclipse/plugins/org.apache.forrest/plugin.xml Sat Jul  2 21:35:50
2005
@@ -105,6 +105,13 @@
                class="org.apache.forrest.eclipse.popup.actions.BuildSite"
                menubarPath="org.apache.forrest.eclipse.siteMenu/Static"
                id="org.apache.forrest.eclipse.BuildServer"/>
+         <action
+               enablesFor="1"
+               label="Build WAR File"
+               icon="icons/build.png"
+               class="org.apache.forrest.eclipse.popup.actions.BuildWARSite"
+               menubarPath="org.apache.forrest.eclipse.siteMenu/Static"
+               id="org.apache.forrest.eclipse.BuildWARServer"/>
       </objectContribution>
    </extension>
   
@@ -115,5 +122,17 @@
       class="org.eclipse.webbrowser.internal.WebBrowserEditor"
       extensions="html,htm,gif,jpg,jpeg,xhtml"
       contributorClass="org.eclipse.webbrowser.internal.WebBrowserEditorActionBarContributor"/>
+  </extension>
+  <extension
+        point="org.eclipse.ui.views">
+     <category
+           id="StructureViewer"
+           name="StructureViewer"/>
+     <view
+           category="StructureView"
+           class="org.apache.forrest.eclipse.views.SiteXMLView"
+           icon="icons/start.png"
+           id="SiteXML"
+           name="SiteXML"/>
   </extension>
 </plugin>

Modified: forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/job/ForrestManager.java
URL: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/job/ForrestManager.java?rev=208884&r1=208883&r2=208884&view=diff
==============================================================================
--- forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/job/ForrestManager.java
(original)
+++ forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/job/ForrestManager.java
Sat Jul  2 21:35:50 2005
@@ -49,7 +49,10 @@
 
     /** The command for building the static site */
     public static final String COMMAND_BUILD = "site";
-
+    
+    /** The command for building the static site */
+    public static final String COMMAND_BUILD_WAR = "war";
+   
     /** The command for running the site server */
     public static final String COMMAND_START = "run";
 
@@ -187,6 +190,8 @@
             theJob = new ForrestRunner(workingDir);
         } else if (cmd.equals(COMMAND_BUILD)) {
             theJob = new ForrestBuilder(workingDir);
+        } else if (cmd.equals(COMMAND_BUILD_WAR)) {
+            theJob = new ForrestWARBuilder(workingDir);
         } else if (cmd.equals(COMMAND_BUILD_PLAIN)) {
             theJob = new ForrestBuilder(workingDir, SKIN_PLAIN);
         } else {

Added: forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/job/ForrestWARBuilder.java
URL: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/job/ForrestWARBuilder.java?rev=208884&view=auto
==============================================================================
--- forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/job/ForrestWARBuilder.java
(added)
+++ forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/job/ForrestWARBuilder.java
Sat Jul  2 21:35:50 2005
@@ -0,0 +1,86 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation or its licensors,
+ * as applicable.
+ * 
+ * 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.job;
+
+import java.io.File;
+
+import org.apache.forrest.eclipse.ForrestPlugin;
+import org.apache.forrest.eclipse.preference.ForrestPreferences;
+import org.apache.log4j.Logger;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+
+
+/**
+ * Run a version of Forrest
+ */
+public class ForrestWARBuilder extends ForrestJob  {
+	/**
+	 * Logger for this class
+	 */
+	protected static final Logger logger = Logger.getLogger(ForrestWARBuilder.class);
+	/** The name of the skin to use. If null, the value in forrest.properties will be used.
*/
+    private String skinName;
+	
+	/**
+	 * Create a Forrest builder that will build the default
+	 * site configuration.
+	 * @param workingDir - the working directory for the command
+	 */
+	protected ForrestWARBuilder(String workingDir) {
+		super("Forrest Runner");
+		this.workingDir = workingDir;
+	}
+
+	/**
+	 * Create a Forrest builder that will build the 
+	 * site using the indicated skin.
+	 * @param workingDir - the working directory for the command
+	 */
+	protected ForrestWARBuilder(String workingDir, String skinName) {
+		super("Forrest Runner");
+		this.workingDir = workingDir;
+		this.skinName = skinName;
+	}
+	/* (non-Javadoc)
+	 * @see java.lang.Runnable#run()
+	 */
+	public IStatus run(IProgressMonitor monitor) {
+		if (logger.isDebugEnabled()) {
+			logger.debug("run(IProgressMonitor) - start");
+		}
+		
+		IStatus status = null;
+		String fhome = ForrestPlugin.getDefault().getPluginPreferences()
+		  .getString(ForrestPreferences.FORREST_HOME);
+		StringBuffer sb = new StringBuffer("-Dproject.home=");
+		sb.append(workingDir);
+		sb.append(" -Dbasedir=");
+		sb.append(fhome + File.separatorChar + "main");
+        sb.append(" ");
+        sb.append(" -Dforrest.home=");
+        sb.append(fhome);
+		if (this.skinName != null) {
+			sb.append(" -Dproject.skin=");
+			sb.append("plain-dev");
+		}
+		sb.append(" war");
+        status = runAnt(monitor, sb.toString());
+		return status;
+	}
+	
+}

Propchange: forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/job/ForrestWARBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/popup/actions/BuildWARSite.java
URL: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/popup/actions/BuildWARSite.java?rev=208884&view=auto
==============================================================================
--- forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/popup/actions/BuildWARSite.java
(added)
+++ forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/popup/actions/BuildWARSite.java
Sat Jul  2 21:35:50 2005
@@ -0,0 +1,102 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation or its licensors,
+ * as applicable.
+ * 
+ * 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.popup.actions;
+
+import org.apache.forrest.eclipse.ForrestPlugin;
+import org.apache.forrest.eclipse.job.ForrestManager;
+import org.apache.forrest.eclipse.preference.ForrestPreferences;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.jobs.Job;
+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.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IActionDelegate;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+public class BuildWARSite 
+implements IObjectActionDelegate, IJavaLaunchConfigurationConstants {
+
+	private IProject activeProject;
+	
+	/**
+	 * Constructor for Action1.
+	 */
+	public BuildWARSite() {
+		super();
+	}
+
+	/**
+	 * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
+	 */
+	public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+	}
+
+	/**
+	 * @see IActionDelegate#run(IAction)
+	 */
+	public void run(IAction action) {
+		String cmdString = null;
+		IPath path = JavaCore.getClasspathVariable("ECLIPSE_HOME");
+
+		// TODO: move preferences code to utilities class
+		String fhome = ForrestPlugin.getDefault().getPluginPreferences()
+				.getString(ForrestPreferences.FORREST_HOME);
+		
+		if (fhome.equals("")) {
+			Shell dialog = new Shell(new Shell());
+			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;
+		}
+
+		IPath workingDirectory = activeProject.getLocation();
+		
+		Job forrest = ForrestManager.getInstance().getForrestJob(workingDirectory.toOSString(),
ForrestManager.COMMAND_BUILD_WAR);
+		forrest.setUser(true);
+		forrest.schedule();
+	}
+
+	/**
+	 * @see IActionDelegate#selectionChanged(IAction, ISelection)
+	 */
+	public void selectionChanged(IAction action, ISelection selection) {
+		if (selection instanceof IStructuredSelection) {
+			Object first = ((IStructuredSelection)selection).getFirstElement();
+            IResource resource = (IResource)first;
+            if (resource instanceof IProject) {
+                activeProject = (IProject)resource;
+            }            
+		}
+	}
+
+}
\ No newline at end of file

Propchange: forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/popup/actions/BuildWARSite.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/SiteXMLView.java
URL: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/SiteXMLView.java?rev=208884&view=auto
==============================================================================
--- forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/SiteXMLView.java
(added)
+++ forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/SiteXMLView.java
Sat Jul  2 21:35:50 2005
@@ -0,0 +1,212 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation or its licensors,
+ * as applicable.
+ * 
+ * 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.views;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.part.*;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectNature;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.viewers.*;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.jface.action.*;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.ui.*;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.SWT;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.part.ViewPart;
+import org.eclipse.ui.views.navigator.ResourceNavigator;
+
+import com.sun.org.apache.xml.internal.utils.URI;
+
+/**
+ * This sample class demonstrates how to plug-in a new workbench view. The view
+ * shows data obtained from the model. The sample creates a dummy model on the
+ * fly, but a real implementation would connect to the model available either in
+ * this or another plug-in (e.g. the workspace). The view is connected to the
+ * model using a content provider.
+ * <p>
+ * The view uses a label provider to define how model objects should be
+ * presented in the view. Each view can present the same model objects using
+ * different labels and icons, if needed. Alternatively, a single label provider
+ * can be shared between views in order to ensure that objects of the same type
+ * are presented in the same way everywhere.
+ * <p>
+ */
+
+public class SiteXMLView extends ViewPart  implements
+			 IMenuListener, ISelectionListener{
+	private TreeViewer viewer;
+	
+	private IProject activeProject;
+	
+	private Action doubleClickAction;
+
+	/*
+	 * The content provider class is responsible for providing objects to the
+	 * view. It can wrap existing objects in adapters or simply return objects
+	 * as-is. These objects may be sensitive to the current input of the view,
+	 * or ignore it and always show the same content (like Task List, for
+	 * example).
+	 */
+
+
+	class NameSorter extends ViewerSorter {
+	}
+
+	/**
+	 * The constructor.
+	 */
+	public SiteXMLView() {
+	}
+
+	/**
+	 * This is a callback that will allow us to create the viewer and initialize
+	 * it.
+	 */
+	public void createPartControl(Composite parent) {
+		viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+		getSite().setSelectionProvider(viewer);
+		viewer.setContentProvider(new ITreeContentProvider() {
+			public Object[] getChildren(Object element) {
+				ArrayList ch = new ArrayList();
+				NamedNodeMap atrs = ((Node) element).getAttributes();
+				if (atrs != null)
+					for (int i = 0; i < atrs.getLength(); i++)
+						ch.add(atrs.item(i));
+				NodeList nl = ((Node) element).getChildNodes();
+				for (int i = 0; i < nl.getLength(); i++)
+					if (nl.item(i).getNodeType() == Node.ELEMENT_NODE)
+						ch.add(nl.item(i));
+				return ch.toArray();
+			}
+
+			public Object getParent(Object element) {
+				return ((Node) element).getParentNode();
+			}
+
+			public Object[] getElements(Object element) {
+				return getChildren(element);
+			}
+
+			public boolean hasChildren(Object element) {
+				return getChildren(element).length > 0;
+			}
+
+			public void dispose() {
+			}
+
+			public void inputChanged(Viewer viewer, Object old_input,
+					Object new_input) {
+			}
+		});
+
+		viewer.setLabelProvider(new LabelProvider() {
+			public String getText(Object element) {
+				if (element instanceof Attr)
+					return "@" + ((Attr) element).getNodeName();
+				else
+					return ((Node) element).getNodeName();
+			}
+		});
+		
+		
+		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+		Document document = null;
+		try {
+			DocumentBuilder parser;
+			parser = factory.newDocumentBuilder();
+			document = parser.parse(new File(""));
+		} catch (SAXException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (ParserConfigurationException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		viewer.setInput(document);
+	}
+   
+	
+	public void setFocus() {
+		// TODO Auto-generated method stub
+		
+	}
+
+	public void menuAboutToShow(IMenuManager manager) {
+		// TODO Auto-generated method stub
+		
+	}
+
+	public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+		if (selection instanceof IStructuredSelection) {
+			Object first = ((IStructuredSelection)selection).getFirstElement();
+            IResource resource = (IResource)first;
+            if (resource instanceof IProject) {
+                activeProject = (IProject)resource;
+            }            
+		}
+		
+	}
+
+	/**
+	 * Passing the focus request to the viewer's control.
+	 */
+	
+}

Propchange: forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/SiteXMLView.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message