forrest-svn mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgard...@apache.org
Subject svn commit: r219138 - in /forrest/trunk/tools/eclipse/plugins/org.apache.forrest: ./ src/org/apache/forrest/eclipse/views/ src/org/apache/forrest/eclipse/wizards/
Date Thu, 14 Jul 2005 23:37:11 GMT
Author: rgardler
Date: Thu Jul 14 16:37:10 2005
New Revision: 219138

URL: http://svn.apache.org/viewcvs?rev=219138&view=rev
Log:
tabs view and wizards to add elements to both site and tabs view

Added:
    forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/DOMUtilities.java
  (with props)
    forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/TabsXMLView.java
  (with props)
    forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/NewSiteElement.java
  (with props)
    forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/NewSiteElementPage.java
  (with props)
    forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/NewTabElement.java
  (with props)
    forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/NewTabElementPage.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/views/SiteXMLView.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=219138&r1=219137&r2=219138&view=diff
==============================================================================
--- forrest/trunk/tools/eclipse/plugins/org.apache.forrest/plugin.xml (original)
+++ forrest/trunk/tools/eclipse/plugins/org.apache.forrest/plugin.xml Thu Jul 14 16:37:10
2005
@@ -126,14 +126,20 @@
   <extension
         point="org.eclipse.ui.views">
      <category
-           id="StructureViewer"
-           name="StructureViewer"/>
+           id="Forrest"
+           name="Forrest"/>
      <view
-           category="StructureView"
+           category="Forrest"
            class="org.apache.forrest.eclipse.views.SiteXMLView"
            icon="icons/start.png"
            id="SiteXML"
            name="SiteXML"/>
+     <view
+           category="Forrest"
+           class="org.apache.forrest.eclipse.views.TabsXMLView"
+           icon="icons/start.png"
+           id="TabsXML"
+           name="TabsXML"/>
   </extension>
   
    <extension

Added: forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/DOMUtilities.java
URL: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/DOMUtilities.java?rev=219138&view=auto
==============================================================================
--- forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/DOMUtilities.java
(added)
+++ forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/DOMUtilities.java
Thu Jul 14 16:37:10 2005
@@ -0,0 +1,87 @@
+/*
+ * Copyright 1999-2005 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 javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+public class DOMUtilities {
+	private static Document document;
+
+	/**
+	 * This loads an XML file into a DOM called document
+	 * 
+	 */
+	public static Document loadDOM(String path) {
+		// Loads the XML file iton the DOM document
+		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+		DocumentBuilder parser;
+		try {
+			parser = factory.newDocumentBuilder();
+			document = null;
+			document = parser.parse(new File(path));
+		} 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();
+		}
+		return document;
+
+	}
+
+	/**
+	 * This writes the DOM to an XML file
+	 * 
+	 */
+	public static void SaveDOM(Document document, String filename) {
+		try {
+
+			Source source = new DOMSource(document);
+			File file = new File(filename);
+			Result result = new StreamResult(file);
+			Transformer transformer = TransformerFactory.newInstance()
+					.newTransformer();
+			transformer.transform(source, result);
+		} catch (TransformerConfigurationException e) {
+		} catch (TransformerException e) {
+		}
+	}
+
+	
+
+}

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

Modified: 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=219138&r1=219137&r2=219138&view=diff
==============================================================================
--- forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/SiteXMLView.java
(original)
+++ forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/SiteXMLView.java
Thu Jul 14 16:37:10 2005
@@ -17,23 +17,11 @@
 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 javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
+import java.util.ArrayList;
 
 import org.apache.forrest.eclipse.actions.Utilities;
+import org.apache.forrest.eclipse.wizards.NewSiteElement;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.jface.action.Action;
@@ -50,20 +38,13 @@
 import org.eclipse.jface.viewers.SelectionChangedEvent;
 import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.dnd.DND;
 import org.eclipse.swt.dnd.FileTransfer;
 import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
 import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.ISelectionListener;
 import org.eclipse.ui.ISharedImages;
 import org.eclipse.ui.IWorkbenchActionConstants;
@@ -75,11 +56,6 @@
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-
-
-
 
 /**
  * A tree view for site.xml files. The view handles drag and
@@ -89,7 +65,6 @@
 public class SiteXMLView extends ViewPart implements IMenuListener,
 		ISelectionListener {
 	private TreeViewer treeViewer;
-	private DocumentBuilder parser;
 	private Document document;
 	private String projectName;
 	private String path;
@@ -97,13 +72,6 @@
 	private Action AddElement;
 	private Action RemoveElement;
 	private Action SaveDocument;
-	private Text elementText;
-	private Text hrefText;
-	private Text locationText;
-	private Text labelText;
-	private Text descriptionText;
-	
-	
 	
 	protected IProject activeProject;
 	
@@ -161,23 +129,6 @@
 					return ((Node) element).getNodeName();
 			}
 		});
-
-		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-
-		try {
-
-			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();
-		}
 		getViewSite().getPage().addSelectionListener(this);
 		
 		
@@ -188,8 +139,6 @@
 					IStructuredSelection selection = (IStructuredSelection) event
 							.getSelection();
 					treeSelection = selection;
-					
-					
 				}
 			}
 		});
@@ -228,24 +177,8 @@
 						+ java.io.File.separator
 						+ Utilities.getPathToXDocs()
 						+ java.io.File.separator + "site.xml");
-				try {
-					
-				
-					Document newDocument = parser.parse(new File(path));
-					if ((document != (newDocument))) {
-							document = newDocument;
-							treeViewer.setInput(document);
-					}
-				} catch (SAXException e) {
-					// TODO Auto-generated catch block
-					e.printStackTrace();
-				} catch (IOException e) {
-					// TODO Auto-generated catch block
-					e.printStackTrace();
-				}
-				
-				
-	
+				document = DOMUtilities.loadDOM(path);
+				treeViewer.setInput(document);
 			}
 		}
 
@@ -264,8 +197,6 @@
 		getSite().registerContextMenu(menuMgr, treeViewer);
 	}
 
-
-
 		private void fillContextMenu(IMenuManager manager) {
 			manager.add(AddElement);
 			manager.add(RemoveElement);
@@ -273,13 +204,15 @@
 			manager.add(SaveDocument);
 		}
 	
-
-
 		private void makeActions() {
 		AddElement = new Action() {
 			public void run() {
 				if (treeSelection != null) {
-				insertElementDialog();
+				NewSiteElement elementCreation_ = new NewSiteElement(treeSelection,document);
+				elementCreation_.init(PlatformUI.getWorkbench(), null); // initializes the wizard
+				WizardDialog dialog = new WizardDialog(treeViewer.getControl().getShell(), elementCreation_);
+				dialog.open(); // This opens a dialog
+				treeViewer.refresh();
 				}
 			}
 		};
@@ -307,7 +240,7 @@
 		
 		SaveDocument = new Action() {
 			public void run() {
-				SaveXmlFile(document,path);
+				DOMUtilities.SaveDOM(document,path);
 			}
 		};
 		
@@ -317,19 +250,6 @@
 				getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
 	}
 
-	 public static void SaveXmlFile(Document document, String filename) {
-	        try {
-	           
-	            Source source = new DOMSource(document);
-	            File file = new File(filename);
-	            Result result = new StreamResult(file);
-	            Transformer transformer = TransformerFactory.newInstance().newTransformer();
-	            transformer.transform(source, result);
-	        } catch (TransformerConfigurationException e) {
-	        } catch (TransformerException e) {
-	        }
-	    }
-
 	private void showMessage(String message) {
 		MessageDialog.openInformation(
 			treeViewer.getControl().getShell(),
@@ -337,66 +257,6 @@
 			message);
 	}
 
-    /**
-     * Create and display a dialog in which the user can enter a new
-     * elements attributes when it is created.
-     */
-	private void insertElementDialog () {
-		
-			
-			Shell shell = treeViewer.getControl().getShell();
-			shell.open ();
-			
-			final Shell dialog = new Shell (shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
-			GridData data = new GridData();
-			
-			dialog.setLayout(new GridLayout(2, true));
-			dialog.setText("Add Element");
-			dialog.setSize(300,150);
-			Label elementLabel = new Label (dialog, SWT.FLAT);
-			elementLabel.setText ("Element Name");
-			elementText = new Text (dialog, SWT.FILL);
-			
-			Label descriptionLabel = new Label (dialog, SWT.FLAT);
-			descriptionLabel.setText ("Description");
-			descriptionText = new Text (dialog, SWT.FILL);
-			
-			Label hrefLabel = new Label (dialog, SWT.FLAT);
-			hrefLabel.setText ("Href");
-			hrefText = new Text (dialog, SWT.FILL);
-			
-			Label labelLabel = new Label (dialog, SWT.FLAT);
-			labelLabel.setText ("Label");
-			labelText = new Text (dialog, SWT.FILL);
-			
-			final Button ok = new Button (dialog, SWT.PUSH);
-			ok.setText ("Ok");
-			Button cancel = new Button (dialog, SWT.PUSH);
-			cancel.setText ("Cancel");
-			
-			ok.addListener(SWT.Selection, new Listener() {
-			      public void handleEvent(Event event) {
-			    	  Node insertionElement = (Element) treeSelection.getFirstElement();	
-					  
-			    	  Element element = document.createElement(elementText.getText());
-			    	  element.setAttribute("href", hrefText.getText());
-			    	  element.setAttribute("description", descriptionText.getText());
-			    	  element.setAttribute("label", labelText.getText());
-			    	  insertionElement.appendChild(element);
-	  
-					  treeViewer.refresh();
-				      dialog.close();
-			      }
-			    });
-
-			 cancel.addListener(SWT.Selection, new Listener() {
-			      public void handleEvent(Event event) {
-			       dialog.close();
-			      }
-			    });
-			
-			dialog.open ();
-		
-		
-		}
+   
+	
 }

Added: forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/TabsXMLView.java
URL: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/TabsXMLView.java?rev=219138&view=auto
==============================================================================
--- forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/TabsXMLView.java
(added)
+++ forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/TabsXMLView.java
Thu Jul 14 16:37:10 2005
@@ -0,0 +1,262 @@
+/*
+ * Copyright 1999-2005 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.util.ArrayList;
+
+import org.apache.forrest.eclipse.actions.Utilities;
+import org.apache.forrest.eclipse.wizards.NewTabElement;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.FileTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.ViewPart;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * A tree view for tabs.xml files. The view handles drag and
+ * drop from the navigator and supports a number of context 
+ * menus for editing. 
+ */
+public class TabsXMLView extends ViewPart implements IMenuListener,
+		ISelectionListener {
+	private TreeViewer tree;
+	private Document tabsDocument;
+	private String projectName;
+	private String path;
+	private IStructuredSelection treeSelection;
+	private Action AddElement;
+	private Action RemoveElement;
+	private Action SaveDocument;
+	
+	protected IProject activeProject;
+	/**
+	 * The constructor.
+	 */
+	public TabsXMLView() {
+	}
+	/**
+	 * This is a callback that will allow us to create the viewer and initialize
+	 * it.
+	 */
+	public void createPartControl(Composite parent) {
+		tree = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+		getSite().setSelectionProvider(tree);
+		int operations = DND.DROP_COPY | DND.DROP_MOVE;
+		Transfer[] types = new Transfer[] { FileTransfer.getInstance()};
+		//tree.addDropSupport(operations, types, new SiteDropListener(projectName ,tabsDocument,
tree));
+		tree.setContentProvider(new ITreeContentProvider() {
+			public Object[] getChildren(Object element) {
+				ArrayList ch = new ArrayList();
+				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) {
+			}
+		});
+		tree.setLabelProvider(new LabelProvider() {
+			public String getText(Object element) {
+				if (element instanceof Attr)
+					return "@" + ((Attr) element).getNodeName() + " " +((Attr) element).getNodeValue();
+				else
+					return ((Node) element).getNodeName();
+			}
+		});
+		getViewSite().getPage().addSelectionListener(this);
+		tree.addSelectionChangedListener(new ISelectionChangedListener() {
+		public void selectionChanged(SelectionChangedEvent event) {
+					if (event.getSelection() instanceof IStructuredSelection) {
+					IStructuredSelection selection = (IStructuredSelection) event
+							.getSelection();
+					treeSelection = selection;
+				}
+			}
+		});
+	
+		//System.out.println(document.toString());
+		if (path != null) { tabsDocument = DOMUtilities.loadDOM(path);}
+		tree.setInput(tabsDocument);
+		makeActions();
+		hookContextMenu();
+	}
+
+	public void setFocus() {
+		// TODO Auto-generated method stub
+
+	}
+
+	public void menuAboutToShow(IMenuManager manager) {
+		// TODO Auto-generated method stub
+
+	}
+
+	/**
+     * When the selection in the navigator view is changed 
+     * we look to see if the new selection is an IProject.
+     * If it is then we load the tabs.xml file into this
+     * TabsXMLView.
+	 */
+	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;
+				projectName = activeProject.getProject().getName();
+				path = (activeProject.getProject().getLocation()
+						.toString()
+						+ java.io.File.separator
+						+ Utilities.getPathToXDocs()
+						+ java.io.File.separator + "tabs.xml");
+				
+				tabsDocument = DOMUtilities.loadDOM(path);
+				tree.setInput(tabsDocument);
+				
+	
+			}
+		}
+
+	}
+
+    private void hookContextMenu() {
+		MenuManager menuMgr = new MenuManager("#PopupMenu");
+		menuMgr.setRemoveAllWhenShown(true);
+		menuMgr.addMenuListener(new IMenuListener() {
+			public void menuAboutToShow(IMenuManager manager) {
+            TabsXMLView.this.fillContextMenu(manager);
+			}
+		});
+		Menu menu = menuMgr.createContextMenu(tree.getControl());
+		tree.getControl().setMenu(menu);
+		getSite().registerContextMenu(menuMgr, tree);
+	}
+
+
+
+		private void fillContextMenu(IMenuManager manager) {
+			manager.add(AddElement);
+			manager.add(RemoveElement);
+			manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+			manager.add(SaveDocument);
+		}
+	
+		private void makeActions() {
+		AddElement = new Action() {
+			public void run() {
+				if (treeSelection != null) {
+					NewTabElement elementCreation_ = new NewTabElement(treeSelection,tabsDocument);
+					elementCreation_.init(PlatformUI.getWorkbench(), null); // initializes the wizard
+					WizardDialog dialog = new WizardDialog(tree.getControl().getShell(), elementCreation_);
+					dialog.open();
+				tree.refresh();
+				}
+			}
+		};
+		AddElement.setText("Add Element");
+		AddElement.setToolTipText("Add Element tooltip");
+		AddElement.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
+			getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
+		
+		RemoveElement = new Action() {
+			public void run() {
+				if (treeSelection != null) {
+					//TODO: Code to remove Element does here.
+					Node deletionElement = (Element) treeSelection.getFirstElement();	
+					Node deletionParent = deletionElement.getParentNode();
+					deletionParent.removeChild(deletionElement);
+					tree.refresh();
+					
+				}
+			}
+		};
+		RemoveElement.setText("DeleteElement");
+		RemoveElement.setToolTipText("Delete Element");
+		RemoveElement.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
+				getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
+		
+		SaveDocument = new Action() {
+			public void run() {
+				DOMUtilities.SaveDOM(tabsDocument,path);
+			}
+		};
+		
+		SaveDocument.setText("Save");
+		SaveDocument.setToolTipText("Save XML Document");
+		SaveDocument.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
+				getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
+	}
+
+	private void showMessage(String message) {
+		MessageDialog.openInformation(
+			tree.getControl().getShell(),
+			"Sample View",
+			message);
+	}
+
+   
+	
+}

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

Added: forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/NewSiteElement.java
URL: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/NewSiteElement.java?rev=219138&view=auto
==============================================================================
--- forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/NewSiteElement.java
(added)
+++ forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/NewSiteElement.java
Thu Jul 14 16:37:10 2005
@@ -0,0 +1,112 @@
+/*
+ * 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.wizards;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.log4j.Logger;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Create a new Site Element project.
+ */
+
+public class NewSiteElement extends Wizard implements INewWizard {
+	protected IStructuredSelection selection;
+	private Document document;
+	
+	
+	/**
+	 * Logger for this class
+	 */
+	private static final Logger logger = Logger
+			.getLogger(NewSiteElement.class);
+
+	private NewSiteElementPage page;
+
+	/**
+	 * Constructor for New Site Element.
+	 * @param treeSelection 
+	 * @param document 
+	 */
+	public NewSiteElement(IStructuredSelection treeSelection, Document newDocument) {
+		super();
+		setWindowTitle("New Element");
+		setNeedsProgressMonitor(true);
+		selection= treeSelection;
+		document = newDocument;
+	}
+	
+	/**
+	 * Adding the page to the wizard.
+	 */
+
+	public void addPages() {
+		page = new NewSiteElementPage();
+		addPage(page);
+	}
+
+	/**
+	 * This method is called when 'Finish' button is pressed in
+	 * the wizard. We will create an operation and run it
+	 * using wizard as execution context.
+	 */
+	public boolean performFinish() {
+		WorkspaceModifyOperation op= new WorkspaceModifyOperation() {
+			protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException,
InterruptedException {
+				 Node insertionElement = (Element) selection.getFirstElement();	
+		    	  Element element = document.createElement(page.getElementName());
+		    	  element.setAttribute("href", page.getHref());
+		    	  element.setAttribute("description", page.getDescription());
+		    	  element.setAttribute("label", page.getLabel());
+		    	  insertionElement.appendChild(element);
+							}
+		};
+		try {
+			getContainer().run(false, true, op);
+		} catch (InvocationTargetException e) {
+			return false; // TODO: should open error dialog and log
+		} catch  (InterruptedException e) {
+			return false; // canceled
+		}
+		return true;
+	}
+	
+	
+	public void createControl(Composite parent) {
+		// TODO Auto-generated method stub
+		
+	}
+
+
+	
+	public void init(IWorkbench workbench, IStructuredSelection selection) {
+		// TODO Auto-generated method stub
+		
+	}
+}
+

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

Added: forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/NewSiteElementPage.java
URL: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/NewSiteElementPage.java?rev=219138&view=auto
==============================================================================
--- forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/NewSiteElementPage.java
(added)
+++ forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/NewSiteElementPage.java
Thu Jul 14 16:37:10 2005
@@ -0,0 +1,111 @@
+/*
+ * 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.wizards;
+
+import org.eclipse.jface.dialogs.IDialogPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * The "New Element" wizard page allows you to insert a 
+ * new element into the site.xml file and specify the element
+ * name, location, path and descriotion.
+ * 
+ */
+
+public class NewSiteElementPage extends WizardPage {
+    
+	private Text hrefText;
+	private Text descriptionText;
+	private Text labelText;
+	private Text elementName;
+	
+
+	/**
+	 * Create the new page.
+	 * @param selection 
+	 * @param selection 
+	 * @param pageName
+	 */
+	public NewSiteElementPage() {
+		super("wizardPage");
+		setTitle("New Site Element");
+		setDescription("This wizard creates a new element in site.xml.");
+		
+	}
+
+	/**
+	 * @see IDialogPage#createControl(Composite)
+	 */
+	public void createControl(Composite parent) {
+		Composite container = new Composite(parent, SWT.NULL);
+		GridLayout layout = new GridLayout();
+		container.setLayout(layout);
+		layout.numColumns = 2;
+		layout.verticalSpacing = 9;
+		Label label = new Label(container, SWT.NULL);
+		label.setText("&HREF:");
+
+		hrefText = new Text(container, SWT.BORDER | SWT.SINGLE);
+		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+		hrefText.setLayoutData(gd);
+				
+		label = new Label(container, SWT.NULL);
+		label.setText("&Description:");
+
+		descriptionText = new Text(container, SWT.BORDER | SWT.SINGLE);
+		gd = new GridData(GridData.FILL_HORIZONTAL);
+		descriptionText.setLayoutData(gd);
+		
+		label = new Label(container, SWT.NULL);
+		label.setText("&Label:");
+
+		labelText = new Text(container, SWT.BORDER | SWT.SINGLE);
+		gd = new GridData(GridData.FILL_HORIZONTAL);
+		labelText.setLayoutData(gd);
+
+		label = new Label(container, SWT.NULL);
+		label.setText("&Element Name:");
+
+		elementName = new Text(container, SWT.BORDER | SWT.SINGLE);
+		gd = new GridData(GridData.FILL_HORIZONTAL);
+		elementName.setLayoutData(gd);
+		setControl(container);
+	}
+	
+	public String getElementName() {
+		return elementName.getText();
+	}
+	
+	public String getDescription() {
+		return descriptionText.getText();
+	}
+	
+	public String getLabel() {
+		return labelText.getText();
+	}
+	
+	public String getHref() {
+		return hrefText.getText();
+	}
+	
+}
\ No newline at end of file

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

Added: forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/NewTabElement.java
URL: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/NewTabElement.java?rev=219138&view=auto
==============================================================================
--- forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/NewTabElement.java
(added)
+++ forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/NewTabElement.java
Thu Jul 14 16:37:10 2005
@@ -0,0 +1,113 @@
+/*
+ * 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.wizards;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.log4j.Logger;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Create a new Tab Element.
+ */
+
+public class NewTabElement extends Wizard implements INewWizard {
+	protected IStructuredSelection selection;
+	private Document document;
+	
+	
+	/**
+	 * Logger for this class
+	 */
+	private static final Logger logger = Logger
+			.getLogger(NewTabElement.class);
+
+	private NewTabElementPage page;
+
+	/**
+	 * Constructor for New Tab Element.
+	 * @param treeSelection 
+	 * @param document 
+	 */
+	public NewTabElement(IStructuredSelection treeSelection, Document newDocument) {
+		super();
+		setWindowTitle("New Element");
+		setNeedsProgressMonitor(true);
+		selection= treeSelection;
+		document = newDocument;
+	}
+	
+	/**
+	 * Adding the page to the wizard.
+	 */
+
+	public void addPages() {
+		page = new NewTabElementPage();
+		addPage(page);
+	}
+
+	/**
+	 * This method is called when 'Finish' button is pressed in
+	 * the wizard. We will create an operation and run it
+	 * using wizard as execution context.
+	 */
+	public boolean performFinish() {
+		WorkspaceModifyOperation op= new WorkspaceModifyOperation() {
+			protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException,
InterruptedException {
+				 Node insertionElement = (Element) selection.getFirstElement();	
+		    	  Element element = document.createElement("tab");
+		    	  element.setAttribute("id", page.getId());
+		    	  element.setAttribute("label", page.getLabel());
+		    	  element.setAttribute("dir", page.getDir());
+		    	  element.setAttribute("indexfile", page.getIndexFile());
+		    	  insertionElement.appendChild(element);
+							}
+		};
+		try {
+			getContainer().run(false, true, op);
+		} catch (InvocationTargetException e) {
+			return false; // TODO: should open error dialog and log
+		} catch  (InterruptedException e) {
+			return false; // canceled
+		}
+		return true;
+	}
+	
+	
+	public void createControl(Composite parent) {
+		// TODO Auto-generated method stub
+		
+	}
+
+
+	
+	public void init(IWorkbench workbench, IStructuredSelection selection) {
+		// TODO Auto-generated method stub
+		
+	}
+}
+

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

Added: forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/NewTabElementPage.java
URL: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/NewTabElementPage.java?rev=219138&view=auto
==============================================================================
--- forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/NewTabElementPage.java
(added)
+++ forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/wizards/NewTabElementPage.java
Thu Jul 14 16:37:10 2005
@@ -0,0 +1,111 @@
+/*
+ * 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.wizards;
+
+import org.eclipse.jface.dialogs.IDialogPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * The "New Element" wizard page allows you to insert a 
+ * new element into the site.xml file and specify the element
+ * name, location, path and descriotion.
+ * 
+ */
+
+public class NewTabElementPage extends WizardPage {
+    
+	private Text idText;
+	private Text dirText;
+	private Text labelText;
+	private Text indexFileText;
+	
+
+	/**
+	 * Create the new page.
+	 * @param selection 
+	 * @param selection 
+	 * @param pageName
+	 */
+	public NewTabElementPage() {
+		super("wizardPage");
+		setTitle("New Site Element");
+		setDescription("This wizard creates a new element in site.xml.");
+		
+	}
+
+	/**
+	 * @see IDialogPage#createControl(Composite)
+	 */
+	public void createControl(Composite parent) {
+		Composite container = new Composite(parent, SWT.NULL);
+		GridLayout layout = new GridLayout();
+		container.setLayout(layout);
+		layout.numColumns = 2;
+		layout.verticalSpacing = 9;
+		Label label = new Label(container, SWT.NULL);
+		label.setText("&ID:");
+
+		idText = new Text(container, SWT.BORDER | SWT.SINGLE);
+		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+		idText.setLayoutData(gd);
+				
+		label = new Label(container, SWT.NULL);
+		label.setText("&Dir:");
+
+		dirText = new Text(container, SWT.BORDER | SWT.SINGLE);
+		gd = new GridData(GridData.FILL_HORIZONTAL);
+		dirText.setLayoutData(gd);
+		
+		label = new Label(container, SWT.NULL);
+		label.setText("&Label:");
+
+		labelText = new Text(container, SWT.BORDER | SWT.SINGLE);
+		gd = new GridData(GridData.FILL_HORIZONTAL);
+		labelText.setLayoutData(gd);
+
+		label = new Label(container, SWT.NULL);
+		label.setText("&Index File:");
+
+		indexFileText = new Text(container, SWT.BORDER | SWT.SINGLE);
+		gd = new GridData(GridData.FILL_HORIZONTAL);
+		indexFileText.setLayoutData(gd);
+		setControl(container);
+	}
+	
+	public String getId() {
+		return idText.getText();
+	}
+	
+	public String getDir() {
+		return dirText.getText();
+	}
+	
+	public String getLabel() {
+		return labelText.getText();
+	}
+	
+	public String getIndexFile() {
+		return indexFileText.getText();
+	}
+	
+}
\ No newline at end of file

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



Mime
View raw message