forrest-svn mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cross...@apache.org
Subject svn commit: r209159 - /forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/SiteXMLView.java
Date Tue, 05 Jul 2005 00:57:12 GMT
Author: crossley
Date: Mon Jul  4 17:57:10 2005
New Revision: 209159

URL: http://svn.apache.org/viewcvs?rev=209159&view=rev
Log:
Display site.xml as a tree view.
Submitted by: Anil Ramnanan
Issue: FOR-565 "site.xml Editor"

Modified:
    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/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=209159&r1=209158&r2=209159&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
Mon Jul  4 17:57:10 2005
@@ -24,53 +24,32 @@
 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.apache.forrest.eclipse.actions.Utilities;
 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.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.jface.viewers.SelectionChangedEvent;
 import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.viewers.Viewer;
 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.ISelectionListener;
+import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.part.ViewPart;
-import org.eclipse.ui.views.navigator.ResourceNavigator;
-
-import com.sun.org.apache.xml.internal.utils.URI;
+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;
 
 /**
  * This sample class demonstrates how to plug-in a new workbench view. The view
@@ -87,13 +66,15 @@
  * <p>
  */
 
-public class SiteXMLView extends ViewPart  implements
-			 IMenuListener, ISelectionListener{
+public class SiteXMLView extends ViewPart implements IMenuListener,
+		ISelectionListener {
 	private TreeViewer viewer;
-	
+
 	private IProject activeProject;
-	
-	private Action doubleClickAction;
+
+	private DocumentBuilder parser;
+
+	private Document document;
 
 	/*
 	 * The content provider class is responsible for providing objects to the
@@ -103,7 +84,6 @@
 	 * example).
 	 */
 
-
 	class NameSorter extends ViewerSorter {
 	}
 
@@ -162,12 +142,11 @@
 					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) {
@@ -180,33 +159,61 @@
 			// TODO Auto-generated catch block
 			e.printStackTrace();
 		}
-		viewer.setInput(document);
+		getViewSite().getPage().addSelectionListener(this);
+		viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+			public void selectionChanged(SelectionChangedEvent event) {
+				Text text = null;
+				// if the selection is empty clear the label
+				if (event.getSelection().isEmpty()) {
+					text.setText("");
+					return;
+				}
+				if (event.getSelection() instanceof IStructuredSelection) {
+					IStructuredSelection selection = (IStructuredSelection) event
+							.getSelection();
+
+				}
+			}
+		});
+		// 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;
-            }            
+			Object first = ((IStructuredSelection) selection).getFirstElement();
+			IResource resource = (IResource) first;
+			if (resource instanceof IProject) {
+				activeProject = (IProject) resource;
+				String path = (activeProject.getProject().getLocation()
+						.toString()
+						+ java.io.File.separator
+						+ Utilities.getPathToXDocs()
+						+ java.io.File.separator + "site.xml");
+				try {
+					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();
+				}
+				viewer.setInput(document);
+
+			}
 		}
-		
+
 	}
 
-	/**
-	 * Passing the focus request to the viewer's control.
-	 */
 	
 }



Mime
View raw message