forrest-svn mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cross...@apache.org
Subject svn commit: r239298 - in /forrest/trunk/tools/eclipse/plugins/org.apache.forrest: META-INF/ src/org/apache/forrest/eclipse/views/
Date Tue, 23 Aug 2005 02:47:38 GMT
Author: crossley
Date: Mon Aug 22 19:47:31 2005
New Revision: 239298

URL: http://svn.apache.org/viewcvs?rev=239298&view=rev
Log:
Add a custom eclipse view to enable "Forrest=>Properties Editor"
for site.xml and tabs.xml and locationmap.xml files.
Submitted by: Anil Ramnanan
Issue: FOR-641 "Ability to edit properties in Site.xml and tabs.xml editors"

Modified:
    forrest/trunk/tools/eclipse/plugins/org.apache.forrest/META-INF/MANIFEST.MF
    forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/ForrestPropertiesView.java
    forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/LocationmapView.java
    forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/NavigationView.java
    forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/SiteXMLView.java
    forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/TabsXMLView.java

Modified: forrest/trunk/tools/eclipse/plugins/org.apache.forrest/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/plugins/org.apache.forrest/META-INF/MANIFEST.MF?rev=239298&r1=239297&r2=239298&view=diff
==============================================================================
--- forrest/trunk/tools/eclipse/plugins/org.apache.forrest/META-INF/MANIFEST.MF (original)
+++ forrest/trunk/tools/eclipse/plugins/org.apache.forrest/META-INF/MANIFEST.MF Mon Aug 22
19:47:31 2005
@@ -49,6 +49,5 @@
  org.eclipse.ui.ide,
  org.eclipse.debug.ui,
  org.apache.forrest.eclipse.servletEngine,
- org.eclipse.ui.views,
- org.eclipse.wst.web.ui
+ org.eclipse.ui.views
 Eclipse-AutoStart: true

Modified: forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/ForrestPropertiesView.java
URL: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/ForrestPropertiesView.java?rev=239298&r1=239297&r2=239298&view=diff
==============================================================================
--- forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/ForrestPropertiesView.java
(original)
+++ forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/ForrestPropertiesView.java
Mon Aug 22 19:47:31 2005
@@ -16,19 +16,30 @@
  */
 package org.apache.forrest.eclipse.views;
 
+import java.util.Vector;
+
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.viewers.CellEditor;
 import org.eclipse.jface.viewers.CheckboxCellEditor;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
 import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Table;
 import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
 import org.eclipse.swt.widgets.Text;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
 
 /**
  * A table view for forrest.properties files. 
@@ -36,24 +47,24 @@
 public class ForrestPropertiesView extends NavigationView {
 	
 	private Table table;
-	private TableViewer tableViewer;
+	public static TableViewer tableViewer;
+	public static Element editorElement;
 	
 	//	 Set the table column property names
-	private final String ACTIVE_PROPERTY 		= "Active";
 	private final String PROPERTY_NAME_COLUMN 	= "Property";
 	private final String PROPERTY_VALUE_COLUMN 	= "Value";
 	
+	
+
 
 	// Set column names
 	private String[] columnNames = new String[] { 
-			ACTIVE_PROPERTY, 
+			 
 			PROPERTY_NAME_COLUMN,
 			PROPERTY_VALUE_COLUMN
 			
 			};
-	// Combo box choices
-	static final String[] OWNERS_ARRAY = { "?", "Nancy", "Larry", "Joe" };
-
+	
 	/**
 	 * The constructor.
 	 */
@@ -88,27 +99,23 @@
 		int style = SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | 
 					SWT.FULL_SELECTION | SWT.HIDE_SELECTION;
 
-		final int NUMBER_COLUMNS = 3;
+		
 
 		table = new Table(parent, style);
 		
 		GridData gridData = new GridData(GridData.FILL_BOTH);
 		gridData.grabExcessVerticalSpace = true;
-		gridData.horizontalSpan = 3;
+		gridData.horizontalSpan = 2;
 		table.setLayoutData(gridData);		
 					
 		table.setLinesVisible(true);
 		table.setHeaderVisible(true);
 
-		// 1st column with image/checkboxes - NOTE: The SWT.CENTER has no effect!!
-		TableColumn column = new TableColumn(table, SWT.CENTER, 0);		
-		column.setText("ACTIVE");
-		column.setWidth(20);
 		
-		// 2nd column with task Description
-		column = new TableColumn(table, SWT.LEFT, 1);
+		// 1st column with Property
+		TableColumn column = new TableColumn(table, SWT.LEFT, 0);
 		column.setText("PROPERTY");
-		column.setWidth(400);
+		column.setWidth(100);
 		// Add listener to column so tasks are sorted by description when clicked 
 		column.addSelectionListener(new SelectionAdapter() {
        	
@@ -118,8 +125,8 @@
 		});
 
 
-		// 3rd column with task Owner
-		column = new TableColumn(table, SWT.LEFT, 2);
+		// 2nd column with Value
+		column = new TableColumn(table, SWT.LEFT, 1);
 		column.setText("VALUE");
 		column.setWidth(100);
 		// Add listener to column so tasks are sorted by owner when clicked
@@ -132,7 +139,16 @@
 
 		
 	}
-
+	 public static  Vector getContent(Element element){
+		 Vector objectList =  new Vector(); 
+		 if (element != null) {
+		 NamedNodeMap atrs = element.getAttributes();
+		 if(atrs != null) 
+			 for(int i=0; i<atrs.getLength(); i++) objectList.add(new EditableTableItem(atrs.item(i).getNodeName(),atrs.item(i).getNodeValue()));
+		 }
+		 return objectList; 
+	      
+	 };
 	/**
 	 * Create the TableViewer 
 	 */
@@ -145,21 +161,117 @@
 
 		// Create the cell editors
 		CellEditor[] editors = new CellEditor[columnNames.length];
-
-		// Column 1 : Completed (Checkbox)
-		editors[0] = new CheckboxCellEditor(table);
-
-		// Column 2 : Description (Free text)
 		TextCellEditor textEditor = new TextCellEditor(table);
 		((Text) textEditor.getControl()).setTextLimit(60);
-		editors[1] = textEditor;
+		editors[0] = textEditor;
 		
 		// Column 3 : Owner (Combo Box) 
-		editors[2] = textEditor;
+		editors[1] = textEditor;
 
 			// Assign the cell editors to the viewer 
 		tableViewer.setCellEditors(editors);
+		
+		tableViewer.setContentProvider(new IStructuredContentProvider() {
+		      public Object[] getElements(Object inputElement) {
+		    	  Vector v = (Vector)inputElement;
+		          return v.toArray();
+		      }
+
+		      public void dispose() {
+		      }
+
+		  
+
+			public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+				// TODO Auto-generated method stub
+				
+			}
+    });
+		 
+		tableViewer.setLabelProvider(new ITableLabelProvider() {
+		      public Image getColumnImage(Object element, int columnIndex) {
+		        return null;
+		      }
+
+		      public String getColumnText(Object element, int columnIndex) {
+		        switch (columnIndex) {
+		        case 0:
+		          return ((EditableTableItem) element).name;
+		        case 1:
+		          return ((EditableTableItem) element).value;
+		          
+		        default:
+		          return "Invalid column: " + columnIndex;
+		        }
+		      }
+
+		      public void dispose() {
+		      }
+
+		      public boolean isLabelProperty(Object element, String property) {
+		        return false;
+		      }
+
+			public void addListener(ILabelProviderListener listener) {
+				
+			}
+
+			public void removeListener(ILabelProviderListener listener) {
+				// TODO Auto-generated method stub
+				
+			}
+
+		    
+		    });
+		   
+		 tableViewer.setCellModifier(new ICellModifier() {
+		      public boolean canModify(Object element, String property) {
+		        return true;
+		      }
+
+		      public Object getValue(Object element, String property) {
+		        if (property.equals("name"))
+		          return ((EditableTableItem) element).name;
+		        else
+		          return ((EditableTableItem) element).value;
+		      }
+
+		      public void modify(Object element, String property, Object value) {
+		        TableItem tableItem = (TableItem) element;
+		        EditableTableItem data = (EditableTableItem) tableItem
+		            .getData();
+		        if (property.equals("name"))
+		            data.name = value.toString();
+		          else
+		            data.value = value.toString();
+		        
+		        if (editorElement != null) {
+					System.out.println(editorElement.getNodeName());}
+					
+		       
+		        tableViewer.refresh(data);
+		      }
+		    });
+		tableViewer.setInput(getContent(editorElement));
 	
 	}
+
+	private static class EditableTableItem {
+		  public String name;
+
+		  public String value;
+
+		  public EditableTableItem(String n, String v) {
+		    name = n;
+		    value = v;
+		  }
+	}
+	
+	public static void setElement(Element newElement) { 
+	editorElement = newElement;	
+	};
 	
+	public static void refreshTree() { 
+		tableViewer.setInput(getContent(editorElement));
+		};
 }

Modified: forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/LocationmapView.java
URL: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/LocationmapView.java?rev=239298&r1=239297&r2=239298&view=diff
==============================================================================
--- forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/LocationmapView.java
(original)
+++ forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/LocationmapView.java
Mon Aug 22 19:47:31 2005
@@ -20,9 +20,14 @@
 
 import java.util.ArrayList;
 
+
 import org.apache.forrest.eclipse.actions.Utilities;
 import org.apache.forrest.eclipse.wizards.NewLocationElement;
 import org.apache.forrest.eclipse.wizards.NewMatchElement;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IAdapterManager;
+import org.eclipse.core.runtime.Platform;
 import org.eclipse.jface.action.Action;
 import org.eclipse.jface.action.IMenuListener;
 import org.eclipse.jface.action.IMenuManager;
@@ -38,12 +43,28 @@
 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.DropTargetEvent;
+import org.eclipse.swt.dnd.DropTargetListener;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Button;
 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.PlatformUI;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySheetPage;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.IPropertySourceProvider;
+import org.eclipse.ui.views.properties.PropertyDescriptor;
+import org.eclipse.ui.views.properties.PropertySheetPage;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -60,12 +81,16 @@
 	private Action AddLocation;
 	private Action RemoveElement;
 	private Action SaveDocument;
+	protected PropertySheetPage propertySheetPage;
+	
     
 	/**
 	 * The constructor.
 	 */
 	public LocationmapView() {
+		
 	}
+	 
 	/**
 	 * This is a callback that will allow us to create the viewer and initialize
 	 * it.
@@ -118,6 +143,8 @@
 							.getSelection();
 					treeSelection = selection;
 					Element element = (Element) selection.getFirstElement();
+					ForrestPropertiesView.setElement(element);
+					ForrestPropertiesView.refreshTree();
 					AddLocation.setEnabled(false);
 					AddMatch.setEnabled(false);
 					if (element.getNodeName().equals("locator")){
@@ -133,13 +160,56 @@
 			}
 		});
 	
-		//System.out.println(document.toString());
+		int operations = DND.DROP_COPY | DND.DROP_MOVE;
+		Transfer[] types = new Transfer[] { TextTransfer.getInstance() };
+		
+		treeViewer.addDropSupport(operations, types, new DropTargetListener() {
+
+			public void dragEnter(DropTargetEvent event) {
+				// TODO Auto-generated method stub
+
+			}
+
+			public void dragLeave(DropTargetEvent event) {
+				// TODO Auto-generated method stub
+
+			}
+
+			public void dragOperationChanged(DropTargetEvent event) {
+				// TODO Auto-generated method stub
+
+			}
+
+			public void dragOver(DropTargetEvent event) {
+				// TODO Auto-generated method stub
+
+			}
+
+			/**
+			 * Handle files that are dropped into the site tree.
+			 */
+			public void drop(DropTargetEvent event) {
+				
+				System.out.println(event.data);	
+			}
+
+			public void dropAccept(DropTargetEvent event) {
+				// TODO Auto-generated method stub
+
+			}
+
+		});
+		
 		if (path != null) { document = DOMUtilities.loadDOM(path);}
 		treeViewer.setInput(document);
 		makeActions();
 		hookContextMenu();
+		
 	}
 
+	
+
+
 	public void setFocus() {
 		// TODO Auto-generated method stub
 
@@ -254,5 +324,7 @@
     protected String getFilename() {
         return Utilities.getPathToContent() + java.io.File.separator + "locationmap.xml";
     }
-	
+ 
 }
+
+

Modified: forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/NavigationView.java
URL: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/NavigationView.java?rev=239298&r1=239297&r2=239298&view=diff
==============================================================================
--- forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/NavigationView.java
(original)
+++ forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/NavigationView.java
Mon Aug 22 19:47:31 2005
@@ -96,7 +96,7 @@
                      // TODO: only attempt to load config file if this is a Forrest project
             		 activeProject = newActiveProject;
             		 projectName = activeProject.getProject().getName();
-            		xDocPath = (activeProject.getProject().getLocation()
+            		 xDocPath = (activeProject.getProject().getLocation()
                         .toString()
                         + java.io.File.separator);
             		path = xDocPath + getFilename();

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=239298&r1=239297&r2=239298&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 Aug 22 19:47:31 2005
@@ -183,6 +183,10 @@
 					IStructuredSelection selection = (IStructuredSelection) event
 							.getSelection();
 					treeSelection = selection;
+					Element element = (Element) selection.getFirstElement();
+					ForrestPropertiesView.setElement(element);
+					ForrestPropertiesView.refreshTree();
+					
 
 				}
 			}

Modified: 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=239298&r1=239297&r2=239298&view=diff
==============================================================================
--- forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/TabsXMLView.java
(original)
+++ forrest/trunk/tools/eclipse/plugins/org.apache.forrest/src/org/apache/forrest/eclipse/views/TabsXMLView.java
Mon Aug 22 19:47:31 2005
@@ -119,6 +119,9 @@
 					IStructuredSelection selection = (IStructuredSelection) event
 							.getSelection();
 					treeSelection = selection;
+					Element element = (Element) selection.getFirstElement();
+					ForrestPropertiesView.setElement(element);
+					ForrestPropertiesView.refreshTree();
 				}
 			}
 		});



Mime
View raw message