incubator-imperius-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jnee...@apache.org
Subject svn commit: r612031 [4/6] - in /incubator/imperius/trunk: ./ imperius-javasplextension/ imperius-javasplextension/META-INF/ imperius-javasplextension/src/ imperius-javasplextension/src/org/ imperius-javasplextension/src/org/apache/ imperius-javasplexte...
Date Tue, 15 Jan 2008 06:53:02 GMT
Added: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/properties/DeletePolicyCustomJarPropertyPage.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/properties/DeletePolicyCustomJarPropertyPage.java?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/properties/DeletePolicyCustomJarPropertyPage.java (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/properties/DeletePolicyCustomJarPropertyPage.java Mon Jan 14 22:52:53 2008
@@ -0,0 +1,372 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.  
+ */
+
+/**
+ * @author Naidu Javvadi <njavvadi@in.ibm.com>
+ *
+ */
+
+package org.apache.imperius.spl.editor.tool.ui.internal.properties;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.apache.imperius.spl.editor.tool.internal.messages.PolicyMessages;
+import org.apache.imperius.spl.editor.tool.utils.SPLPolicyUtil;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableLayout;
+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.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.ui.dialogs.PropertyPage;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+
+
+public class DeletePolicyCustomJarPropertyPage extends PropertyPage {
+
+	private CheckboxTableViewer viewer;
+
+	private Button removeBtn;
+	
+	private IProject fProject;
+
+	private Map customJarsMap;
+	
+	private boolean isRemoved;
+
+	protected Control createContents(Composite aParent) {
+		setSelectedProject();
+		Composite container = addGridLayout(new Composite(aParent, SWT.NULL), 1);
+		createGUI(container);
+		return container;
+	}
+
+	private void createGUI(Composite aParent) {
+		Label label = new Label(aParent, SWT.NULL);
+		label.setText(PolicyMessages.getString("SPL_CUSTOM_ACTION_JARS_LIST"));
+		GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+		gridData.horizontalSpan = 1;
+		gridData.widthHint = 100;
+		label.setLayoutData(gridData);
+
+		// add table to show files in the directory
+		viewer = createTable(aParent, 1);
+		viewer.setContentProvider(new CustomJarsContentProvider());
+		viewer.setLabelProvider(new CustomJarsLabelProvider());
+		viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+			public void selectionChanged(SelectionChangedEvent event) {
+				dialogChanged();
+			}
+		});
+
+		removeBtn = new Button(aParent, SWT.PUSH);
+		gridData = new GridData(GridData.END);
+		gridData.horizontalSpan = 1;
+		removeBtn.setLayoutData(gridData);
+		removeBtn.setAlignment(SWT.RIGHT);
+		removeBtn.setText(PolicyMessages.getString("STR_REMOVE_LABEL_NAME"));
+		removeBtn.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent event) {
+				removeSelectedJars();
+			}
+		});
+		initializeDefaults();
+		dialogChanged();
+	}
+	
+	private void setSelectedProject() {
+		IAdaptable adaptable = (IAdaptable) getElement();
+		fProject = (IProject) adaptable.getAdapter(IProject.class);
+	}
+
+	/**
+	 * 
+	 */
+	private void initializeDefaults() {
+		customJarsMap = new HashMap();
+		try {
+			if(fProject != null) {
+				IFile classpathFile = fProject.getFile(".classpath");
+				if(classpathFile != null) {
+					List filesList = new ArrayList();
+					ClasspathXMLHandler handler = new ClasspathXMLHandler();
+					SAXParserFactory factory = SAXParserFactory.newInstance();
+					SAXParser saxParser = factory.newSAXParser();
+					saxParser.parse(classpathFile.getContents(), handler);
+					customJarsMap = handler.getJarFilesMap();
+					filesList.addAll(customJarsMap.keySet());
+					viewer.setInput(filesList);
+					viewer.refresh();
+				}
+			}
+		} catch (Exception e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+	
+	private void removeSelectedJars() {
+		Object[] checkedObjects = viewer.getCheckedElements();
+		if(checkedObjects != null && checkedObjects.length > 0) {
+			for(int i=0;i<checkedObjects.length;i++) {
+				customJarsMap.remove(checkedObjects[i]);
+				isRemoved = true;
+			}
+		}
+		List filesList = new ArrayList();
+		filesList.addAll(customJarsMap.keySet());
+		viewer.setInput(filesList);
+		viewer.refresh();
+	}
+
+	/**
+	 * 
+	 * @param parent
+	 * @param span
+	 * @return
+	 */
+	private CheckboxTableViewer createTable(Composite parent, int span) {
+		Table table = new Table(parent, SWT.CHECK | SWT.BORDER | SWT.MULTI
+				| SWT.FULL_SELECTION);
+		GridData data = new GridData(GridData.FILL_HORIZONTAL);
+		data.horizontalSpan = span;
+		data.widthHint = 400;
+		data.heightHint = 200;
+		table.setLayoutData(data);
+		TableLayout layout = new TableLayout();
+		layout.addColumnData(new ColumnWeightData(100, true));
+		table.setLayout(layout);
+		TableColumn col = new TableColumn(table, SWT.NONE);
+		col.setText("File Name");
+		col.setResizable(true);
+		return new CheckboxTableViewer(table);
+	}
+
+	/**
+	 * 
+	 * @param composite
+	 * @param noOfCols
+	 * @return
+	 */
+	private Composite addGridLayout(Composite composite, int noOfCols) {
+		GridLayout layout = new GridLayout();
+		layout.numColumns = noOfCols;
+		composite.setLayout(layout);
+		return composite;
+	}
+
+	private void dialogChanged() {
+		Object[] checkedObjects = viewer.getCheckedElements();
+		if (checkedObjects.length == 0) {
+			removeBtn.setEnabled(false);
+		} else {
+			removeBtn.setEnabled(true);
+		}
+	}
+	
+	public void performApply() {
+		try {
+			if(isRemoved) {
+				SPLPolicyUtil.addJarToProjectsClasspath(fProject, customJarsMap);
+			}
+		} catch (Exception e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		super.performApply();
+	}
+
+	class CustomJarsContentProvider implements IStructuredContentProvider {
+
+		/**
+		 * Called when the input changes
+		 */
+		public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
+
+		}
+
+		/**
+		 * Gets the files in the specified directory
+		 * 
+		 * @param arg0 a String containing the directory
+		 */
+		public Object[] getElements(Object input) {
+			
+			if(input instanceof List) {
+				List list = (List)input;
+				if(list.size() > 0) {
+					return list.toArray();
+				}
+			}
+			return new Object[0];
+		}
+
+		/**
+		 * Disposes any created resources
+		 */
+		public void dispose() {
+
+		}
+	}
+
+	class CustomJarsLabelProvider implements ILabelProvider {
+
+		public Image getImage(Object arg0) {
+			return null;
+		}
+
+		public String getText(Object arg0) {
+			if (arg0 instanceof String) {
+				return (String) arg0;
+			}
+			return ((File) arg0).getName();
+		}
+
+		public void addListener(ILabelProviderListener arg0) {
+		}
+
+		public void dispose() {
+		}
+
+		public boolean isLabelProperty(Object arg0, String arg1) {
+			return false;
+		}
+
+		public void removeListener(ILabelProviderListener arg0) {
+		}
+	}
+
+	class ClasspathXMLHandler extends DefaultHandler {
+		
+		private final static String CLASSPATH_ENTRY = "classpathentry";
+		
+		private final static String ATTRIBUTE = "attribute";
+		
+		private final static String ATTRI_NAME = "name";
+		
+		private final static String LIB = "lib";
+		
+		private final static String KIND = "kind";
+		
+		private final static String PATH = "path";
+		
+		private final static String CUSTOM = "custom";
+		
+		private String strJarPath;
+		
+		private Map customJarsInfo;
+
+		public ClasspathXMLHandler() {
+			customJarsInfo = new HashMap();
+		}
+		
+		public void startElement(String uri, String localName, String name,
+				Attributes attributes) throws SAXException {
+			// check for classpath entry
+			if(CLASSPATH_ENTRY.equals(name)) {
+				setPathToString(attributes);
+			} else if(ATTRIBUTE.equals(name)) {
+				if(isCustomAttributeElement(attributes)) {
+					if(strJarPath != null) {
+//						File file = new File(strJarPath);
+						customJarsInfo.put(new File(strJarPath).getName(), strJarPath);
+					}
+					
+				}
+			}
+		}
+		
+		private boolean isCustomAttributeElement(Attributes attributes) {
+			boolean flag = false;
+			if(attributes != null && attributes.getLength() > 0) {
+				for(int i=0;i<attributes.getLength();i++) {
+					String qName = attributes.getQName(i);
+					String value = attributes.getValue(qName);
+					if(ATTRI_NAME.equals(qName)) {
+						if(value.equals(CUSTOM)) {
+							flag = true;
+							break;
+						}
+					} 
+				}
+			}
+			return flag;
+		}
+		
+		private void setPathToString(Attributes attributes) {
+			if(attributes != null && attributes.getLength() > 0) {
+				boolean flag = false;
+				for(int i=0;i<attributes.getLength();i++) {
+					String qName = attributes.getQName(i);
+					String value = attributes.getValue(qName);
+					if(KIND.equals(qName) && LIB.equals(value)) {
+						flag = true;
+						continue;
+					} else if(PATH.equals(qName) && !"".equals(value)) {
+						if(flag) {
+							strJarPath = value;
+						}
+					} else {
+						continue;
+					}
+				}
+			}
+		}
+		
+		
+		public void endElement(String uri, String localName, String name)
+				throws SAXException {
+			// do nothing
+		}
+		
+		public Map getJarFilesMap() {
+			return customJarsInfo;
+		}
+
+	}
+
+}

Propchange: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/properties/DeletePolicyCustomJarPropertyPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/properties/PolicyFilePropertyPage.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/properties/PolicyFilePropertyPage.java?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/properties/PolicyFilePropertyPage.java (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/properties/PolicyFilePropertyPage.java Mon Jan 14 22:52:53 2008
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.  
+ */
+
+/**
+ * @author Naidu Javvadi <njavvadi@in.ibm.com>
+ *
+ */
+ 
+package org.apache.imperius.spl.editor.tool.ui.internal.properties;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+public class PolicyFilePropertyPage extends PropertyPage {
+
+	protected Control createContents(Composite aParent) {
+		return aParent;
+	}
+}

Propchange: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/properties/PolicyFilePropertyPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/properties/PolicyPropertyPage.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/properties/PolicyPropertyPage.java?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/properties/PolicyPropertyPage.java (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/properties/PolicyPropertyPage.java Mon Jan 14 22:52:53 2008
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.  
+ */
+
+/**
+ * @author Naidu Javvadi <njavvadi@in.ibm.com>
+ *
+ */
+
+package org.apache.imperius.spl.editor.tool.ui.internal.properties;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+public class PolicyPropertyPage extends PropertyPage {
+
+	protected Control createContents(Composite aParent) {
+		super.noDefaultAndApplyButton();
+		Composite container = new Composite(aParent, SWT.NULL);
+		return container;
+	}
+	
+}

Propchange: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/properties/PolicyPropertyPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/properties/PolicyServerPropertyPage.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/properties/PolicyServerPropertyPage.java?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/properties/PolicyServerPropertyPage.java (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/properties/PolicyServerPropertyPage.java Mon Jan 14 22:52:53 2008
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.  
+ */
+
+/**
+ * @author Naidu Javvadi <njavvadi@in.ibm.com>
+ *
+ */
+ 
+package org.apache.imperius.spl.editor.tool.ui.internal.properties;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+public class PolicyServerPropertyPage extends PropertyPage {
+
+	protected Control createContents(Composite aParent) {
+		super.noDefaultAndApplyButton();
+		Composite container = new Composite(aParent, SWT.NULL);
+		return container;
+	}
+}

Propchange: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/properties/PolicyServerPropertyPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/IPolicyFileCodeSyntax.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/IPolicyFileCodeSyntax.java?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/IPolicyFileCodeSyntax.java (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/IPolicyFileCodeSyntax.java Mon Jan 14 22:52:53 2008
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.  
+ */
+
+/**
+ * @author Naidu Javvadi <njavvadi@in.ibm.com>
+ *
+ */
+
+
+package org.apache.imperius.spl.editor.tool.ui.internal.scanners;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+
+public interface IPolicyFileCodeSyntax {
+
+	public List getPolicyKeywords();
+	
+	public List getPolicyExpressions();
+	
+	public List getCustomActions(IProject aProject);
+	
+	public List getCustomExpressions(IProject aProject);
+	
+}

Propchange: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/IPolicyFileCodeSyntax.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/IPolicyPartitionScanner.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/IPolicyPartitionScanner.java?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/IPolicyPartitionScanner.java (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/IPolicyPartitionScanner.java Mon Jan 14 22:52:53 2008
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.  
+ */
+
+/**
+ * @author Naidu Javvadi <njavvadi@in.ibm.com>
+ *
+ */
+
+package org.apache.imperius.spl.editor.tool.ui.internal.scanners;
+
+public interface IPolicyPartitionScanner {
+	
+	public final static String SPL_SINGLELINE_COMMENT = "spl_singleline_comment";
+	public final static String SPL_MULTILINE_COMMENT  = "spl_multiline_comment";	
+
+	public void setGenericPartitionRules();
+	
+}

Propchange: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/IPolicyPartitionScanner.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/PolicyFileCodeSyntaxImpl.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/PolicyFileCodeSyntaxImpl.java?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/PolicyFileCodeSyntaxImpl.java (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/PolicyFileCodeSyntaxImpl.java Mon Jan 14 22:52:53 2008
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.  
+ */
+
+/**
+ * @author Naidu Javvadi <njavvadi@in.ibm.com>
+ *
+ */
+ 
+package org.apache.imperius.spl.editor.tool.ui.internal.scanners;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.imperius.spl.editor.tool.PluginActivator;
+import org.apache.imperius.spl.editor.tool.internal.messages.PolicyMessages;
+import org.eclipse.core.resources.IProject;
+
+import org.apache.imperius.spl.parser.util.ExpressionUtility;
+
+public class PolicyFileCodeSyntaxImpl implements IPolicyFileCodeSyntax {
+
+	public PolicyFileCodeSyntaxImpl() {
+	}
+	
+	public List getPolicyKeywords() {
+		return Arrays.asList(PolicyMessages.getString("POLICY_KEYWORDS").split(","));
+	}
+	
+	public List getPolicyExpressions() {
+		return Arrays.asList(PolicyMessages.getString("POLICY_EXPRESSIONS").split(","));
+	}
+	
+	public List getCustomActions(IProject aProject) {
+		List newList = new ArrayList();
+		try {
+//			newList = getNamesOf(ExpressionUtility.getListOfCustomActionTypes(), "Action");
+			
+			// get from project
+			Map innerMap = PluginActivator.getDefault().getCustomExprMap(aProject.getName());
+			if(innerMap != null && innerMap.size() > 0) {
+				Iterator iter = innerMap.keySet().iterator();
+				while(iter.hasNext()) {
+					String key = (String)iter.next();
+					String value = ((Properties)innerMap.get(key)).getProperty(PolicyMessages.SPL_CUSTOM_ACTIONS);
+					if(value != null) {
+						newList.addAll( getNamesOf(Arrays.asList(value.split(",")), "Action"));
+					}
+				}
+			}
+		} catch(Exception e) {
+			
+		}
+		return newList;
+	}
+	
+	public List getCustomExpressions(IProject aProject) {
+		List newList = new ArrayList();
+		try {
+//			newList = getNamesOf(ExpressionUtility.getListOfCustomExpressionTypes(), "Expression");
+
+			// get from project
+			Map innerMap = PluginActivator.getDefault().getCustomExprMap(aProject.getName());
+			if(innerMap != null && innerMap.size() > 0) {
+				Iterator iter = innerMap.keySet().iterator();
+				while(iter.hasNext()) {
+					String key = (String)iter.next();
+					String value = ((Properties)innerMap.get(key)).getProperty(PolicyMessages.SPL_CUSTOM_EXPRESSIONS);
+					if(value != null) {
+						newList.addAll( getNamesOf(Arrays.asList(value.split(",")), "Expression"));
+					}
+				}
+			}
+		} catch(Exception e) {
+		}
+		return newList;
+	}
+	
+	private List getNamesOf(List oList, String type) {
+		List newList = new ArrayList();
+		if(oList != null && oList.size() > 0) {
+			Iterator iter = oList.iterator();
+			while(iter.hasNext()) {
+				String name = (String)iter.next();
+				newList.add(name.substring(name.lastIndexOf(".")+1)+ " - custom "+type);
+			}
+		}
+		return newList;
+	}
+}

Propchange: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/PolicyFileCodeSyntaxImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/PolicyFileCommentScanner.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/PolicyFileCommentScanner.java?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/PolicyFileCommentScanner.java (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/PolicyFileCommentScanner.java Mon Jan 14 22:52:53 2008
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.  
+ */
+
+/**
+ * @author Naidu Javvadi <njavvadi@in.ibm.com>
+ *
+ */
+
+
+package org.apache.imperius.spl.editor.tool.ui.internal.scanners;
+
+import org.apache.imperius.spl.editor.tool.ui.IPolicyTokenColorManager;
+import org.apache.imperius.spl.editor.tool.ui.internal.preferences.IPolicyPreferenceColorConstants;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.RuleBasedScanner;
+
+
+public class PolicyFileCommentScanner extends RuleBasedScanner implements IPolicyPreferenceColorConstants {
+
+	public PolicyFileCommentScanner(IPolicyTokenColorManager tokenColorMgr) {
+		IToken commentToken = tokenColorMgr.getToken(IPolicyPreferenceColorConstants.SPL_PREF_COMMENT_COLOR_ID);
+		setDefaultReturnToken(commentToken);
+	}
+}

Propchange: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/PolicyFileCommentScanner.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/PolicyFileDefaultCodeScanner.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/PolicyFileDefaultCodeScanner.java?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/PolicyFileDefaultCodeScanner.java (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/PolicyFileDefaultCodeScanner.java Mon Jan 14 22:52:53 2008
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.  
+ */
+
+/**
+ * @author Naidu Javvadi <njavvadi@in.ibm.com>
+ *
+ */
+
+
+package org.apache.imperius.spl.editor.tool.ui.internal.scanners;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.imperius.spl.editor.tool.ui.IPolicyTokenColorManager;
+import org.apache.imperius.spl.editor.tool.ui.internal.preferences.IPolicyPreferenceColorConstants;
+import org.eclipse.jface.text.rules.IRule;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.RuleBasedScanner;
+import org.eclipse.jface.text.rules.WhitespaceRule;
+import org.eclipse.jface.text.rules.WordRule;
+
+
+public class PolicyFileDefaultCodeScanner extends RuleBasedScanner implements IPolicyPreferenceColorConstants {
+	
+	private IPolicyTokenColorManager tokenColorManager;
+	private IPolicyFileCodeSyntax policySyntaxDetails;
+
+	public PolicyFileDefaultCodeScanner(IPolicyTokenColorManager pTokenColorManager) {
+		this.tokenColorManager = pTokenColorManager;
+		policySyntaxDetails = new PolicyFileCodeSyntaxImpl();
+		setPolicySyntaxRules();
+	}
+	
+	public void setPolicySyntaxRules() {
+		
+		IToken keywordToken = tokenColorManager.getToken(IPolicyPreferenceColorConstants.SPL_PREF_KEYWORD_COLOR_ID);
+		IToken otherToken = tokenColorManager.getToken(IPolicyPreferenceColorConstants.SPL_PREF_DEFAULT_COLOR_ID);
+
+		List rules = new ArrayList();
+		// Add rule for white spaces
+		rules.add(new WhitespaceRule(new PolicyFileWhitespaceDetector()));
+
+		// define word rule for other tokens
+		WordRule otherWordRule = new WordRule(new PolicyFileWordDetector(), otherToken, true);
+		
+		// define word rule for keywords
+		List policyKeywords = policySyntaxDetails.getPolicyKeywords();
+		for (int i = 0; i < policyKeywords.size(); i++) {
+			otherWordRule.addWord((String)policyKeywords.get(i), keywordToken);
+		}
+
+//		// define word rule for expressions
+//		List policyExpressions = policySyntaxDetails.getPolicyExpressions();
+//		for (int i = 0; i < policyExpressions.size(); i++) {
+//			otherWordRule.addWord((String)policyExpressions.get(i), keywordToken);
+//		}
+		
+		rules.add(otherWordRule);
+		IRule result[] = new IRule[rules.size()];
+		rules.toArray(result);
+		setRules(result);		
+	}
+	
+}

Propchange: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/PolicyFileDefaultCodeScanner.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/PolicyFileWhitespaceDetector.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/PolicyFileWhitespaceDetector.java?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/PolicyFileWhitespaceDetector.java (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/PolicyFileWhitespaceDetector.java Mon Jan 14 22:52:53 2008
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.  
+ */
+
+/**
+ * @author Naidu Javvadi <njavvadi@in.ibm.com>
+ *
+ */
+
+
+package org.apache.imperius.spl.editor.tool.ui.internal.scanners;
+
+import org.eclipse.jface.text.rules.IWhitespaceDetector;
+
+public class PolicyFileWhitespaceDetector implements IWhitespaceDetector {
+
+	/**
+	 * creates new object
+	 */
+	public PolicyFileWhitespaceDetector() {
+	}
+
+	/**
+	 * Returns whether the specified character is whitespace.
+	 *
+	 * @param c the character to be checked
+	 * @return true if the specified character is a whitespace char
+	 */
+	public boolean isWhitespace(char aChar) {
+		return Character.isWhitespace(aChar);
+	}
+}

Propchange: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/PolicyFileWhitespaceDetector.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/PolicyFileWordDetector.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/PolicyFileWordDetector.java?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/PolicyFileWordDetector.java (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/PolicyFileWordDetector.java Mon Jan 14 22:52:53 2008
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.  
+ */
+
+/**
+ * @author Naidu Javvadi <njavvadi@in.ibm.com>
+ *
+ */
+
+package org.apache.imperius.spl.editor.tool.ui.internal.scanners;
+
+import org.eclipse.jface.text.rules.IWordDetector;
+
+public class PolicyFileWordDetector implements IWordDetector {
+
+	public PolicyFileWordDetector() {
+		
+	}
+	
+	public boolean isWordStart(char pChar) {
+		return Character.isLetter(pChar) || pChar == '_';
+	}
+	
+	public boolean isWordPart(char pChar) {
+		return Character.isLetterOrDigit(pChar) || pChar == '_';
+	}
+}

Propchange: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/PolicyFileWordDetector.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/PolicyPartitionScannerImpl.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/PolicyPartitionScannerImpl.java?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/PolicyPartitionScannerImpl.java (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/PolicyPartitionScannerImpl.java Mon Jan 14 22:52:53 2008
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.  
+ */
+
+/**
+ * @author Naidu Javvadi <njavvadi@in.ibm.com>
+ *
+ */
+
+
+package org.apache.imperius.spl.editor.tool.ui.internal.scanners;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.rules.IPredicateRule;
+import org.eclipse.jface.text.rules.MultiLineRule;
+import org.eclipse.jface.text.rules.RuleBasedPartitionScanner;
+import org.eclipse.jface.text.rules.SingleLineRule;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.jface.text.rules.WordPatternRule;
+
+public class PolicyPartitionScannerImpl extends RuleBasedPartitionScanner implements IPolicyPartitionScanner {
+
+	public PolicyPartitionScannerImpl() {
+		super();
+	}
+	
+
+	public void setGenericPartitionRules() {
+		Token singleLineComment = new Token(IPolicyPartitionScanner.SPL_SINGLELINE_COMMENT);
+		Token multiLineComment = new Token(IPolicyPartitionScanner.SPL_SINGLELINE_COMMENT);
+
+		List rules = new ArrayList();
+
+		// Add rule for single line comments.
+		rules.add(new SingleLineRule("//", null, singleLineComment, (char) 0, true));
+		rules.add(new SingleLineRule("#", null, singleLineComment, (char) 0, true));
+
+		// Add rule for multi-line comments
+		rules.add(new MultiLineRule("/*", "*/", multiLineComment, (char) 0, true));
+		rules.add(new MultiLineRule("/*", "*/", multiLineComment));
+		rules.add(new WordPatternRule(new PolicyFileWordDetector(), "/**/", null, multiLineComment));
+
+		IPredicateRule[] result = new IPredicateRule[rules.size()];
+		rules.toArray(result);
+		setPredicateRules(result);
+		
+	}
+	
+	public static String[] getDocumentPartitionTypes() {
+		return new String[] { IDocument.DEFAULT_CONTENT_TYPE,
+				IPolicyPartitionScanner.SPL_SINGLELINE_COMMENT,
+				IPolicyPartitionScanner.SPL_MULTILINE_COMMENT };
+	}
+}

Propchange: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/internal/scanners/PolicyPartitionScannerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/CustomActionImportPage.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/CustomActionImportPage.java?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/CustomActionImportPage.java (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/CustomActionImportPage.java Mon Jan 14 22:52:53 2008
@@ -0,0 +1,301 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.imperius.spl.editor.tool.ui.wizard;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.jar.JarFile;
+
+import org.apache.imperius.spl.editor.tool.PluginActivator;
+import org.apache.imperius.spl.editor.tool.internal.messages.PolicyMessages;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+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.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.ContainerSelectionDialog;
+
+
+public class CustomActionImportPage extends WizardPage {
+	
+	private Text fJarFileText;
+	
+	private TableViewer viewer;
+	
+	private Text _projectFolderText;
+	
+	public CustomActionImportPage(ImportCustomActionWizard wizard, ISelection selection) {
+		super(PolicyMessages.getString("SPL_IMPORT_CUSTOM_WIZARD_PAGE_NAME"));
+		setTitle(PolicyMessages.getString("SPL_IMPORT_CUSTOM_WIZARD_TITLE"));
+		setDescription(PolicyMessages.getString("SPL_IMPORT_CUSTOM_WIZARD_DESC"));
+	}
+	
+	public void createControl(Composite parent) {
+		Composite container = addGridLayout(new Composite(parent, SWT.NULL), 1);
+		
+		{
+			Composite container1 = addGridLayout(new Composite(container, 0),3);
+			Label jarFileLabel = new Label(container1, SWT.NONE);
+			GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+			gridData.horizontalSpan = 1;
+			jarFileLabel.setLayoutData(gridData);
+			jarFileLabel.setText(PolicyMessages.getString("SPL_IMPORT_CUSTOM_JAR_SELECTION_LABEL"));
+			
+			fJarFileText = new Text(container1, SWT.BORDER | SWT.SINGLE);
+			gridData = new GridData(GridData.FILL_HORIZONTAL);
+			gridData.horizontalSpan = 1;
+			gridData.widthHint = 330;
+			fJarFileText.setLayoutData(gridData);		
+			fJarFileText.addModifyListener(new ModifyListener() {
+				public void modifyText(ModifyEvent e) {
+					validate();
+				}
+			});
+
+			Button fBrowseButton = new Button(container1, SWT.PUSH | SWT.CENTER);
+			fBrowseButton.setText(PolicyMessages.getString("SPL_BROWSE"));
+			gridData = new GridData(GridData.FILL_HORIZONTAL);
+			gridData.horizontalSpan = 1;
+			fBrowseButton.setLayoutData(gridData);	
+			fBrowseButton.addSelectionListener(new SelectionAdapter() {
+				public void widgetSelected(SelectionEvent event) {
+					FileDialog fileSelectionDialog = new FileDialog(PluginActivator.getActiveWorkbenchShell(), SWT.NULL);
+					fileSelectionDialog.setFilterExtensions(new String[]{"*.jar"});
+					String filePath = fileSelectionDialog.open();
+					fJarFileText.setText(filePath == null?"":filePath);
+					if(filePath != null) {
+						viewer.setInput(getJarEntries(filePath));
+						viewer.refresh();
+					}
+				}
+			});
+
+		}
+		// add table to show files in the directory
+		viewer = createTableViewer(container, 1);
+		viewer.setContentProvider(new ContentProvider());
+		viewer.setLabelProvider(new LabelProvider());
+		
+		{
+			Composite innerBrowserContainer = addGridLayout(new Composite(container, 0),3);
+			Label projectFolderLabel = new Label(innerBrowserContainer, SWT.NONE);
+			GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+			gridData.horizontalSpan = 1;
+			projectFolderLabel.setLayoutData(gridData);
+			projectFolderLabel.setText(PolicyMessages.getString("IMPORT_POLICY_DESTINATION_DIRECTORY"));
+			_projectFolderText = new Text(innerBrowserContainer, SWT.BORDER | SWT.SINGLE);
+			gridData = new GridData(GridData.FILL_HORIZONTAL);
+			gridData.horizontalSpan = 1;
+			gridData.widthHint = 400;
+			_projectFolderText.setLayoutData(gridData);		
+			_projectFolderText.addModifyListener(new ModifyListener() {
+				public void modifyText(ModifyEvent e) {
+					validate();
+				}
+			});
+			Button projectBrowseButton = new Button(innerBrowserContainer, SWT.PUSH | SWT.CENTER);
+			projectBrowseButton.setText(PolicyMessages.getString("SPL_BROWSE"));
+			gridData = new GridData(GridData.FILL_HORIZONTAL);
+			gridData.horizontalSpan = 1;
+			projectBrowseButton.setLayoutData(gridData);	
+			projectBrowseButton.addSelectionListener(new SelectionAdapter() {
+				public void widgetSelected(SelectionEvent event) {
+					handleBrowse();
+				}
+			});
+		}
+		
+		setControl(container);
+	}
+	
+	private TableViewer createTableViewer(Composite parent, int span) {
+		Table table = new Table(parent, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
+		GridData data = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL);
+		data.horizontalSpan = span;
+		data.widthHint = 150;
+		table.setLayoutData(data);
+		TableLayout layout = new TableLayout();
+		layout.addColumnData(new ColumnWeightData(100, true));
+		table.setLayout(layout);
+		TableColumn col = new TableColumn(table, SWT.NONE);
+		col.setText("File Name");
+		col.setResizable(true);
+		return new TableViewer(table);
+	}
+	
+	private List getJarEntries(String filePath) {
+		List jarClassEntriesList = new ArrayList();
+		try {
+			JarFile jarFile = new JarFile(filePath);
+			if(jarFile != null) {
+				Enumeration enumerator = jarFile.entries();
+				while(enumerator.hasMoreElements()) {
+					String name = enumerator.nextElement().toString();
+					if(name.indexOf("class") != -1) {
+						if(name.indexOf("$") == -1) {
+							jarClassEntriesList.add(name);
+						}
+					}
+				}
+			}
+		} catch(Exception ex) {
+			System.out.println(ex.getMessage());
+		}
+		return jarClassEntriesList;
+	}
+	
+	public void validate() {
+		
+		String projectFolderTxt = _projectFolderText.getText();
+		
+		if(viewer.getTable().getItemCount() == 0 && projectFolderTxt.trim().length() == 0) {
+			setPageComplete(false);
+			return;
+		}
+		
+		setPageComplete(true);
+	}
+	
+	/**
+	 * 
+	 * @return
+	 */
+	public String getDestinationProjectName() {
+		return _projectFolderText.getText();
+	}
+	
+	/**
+	 * 
+	 * @return
+	 */
+	public TableViewer getTableViewer() {
+		return viewer;
+	}
+	
+	public String getJarFilePath() {
+		return fJarFileText.getText();
+	}
+	
+	/**
+	 * 
+	 * @param composite
+	 * @param noOfCols
+	 * @return
+	 */
+	private Composite addGridLayout(Composite composite, int noOfCols) {
+		GridLayout layout = new GridLayout();
+		layout.numColumns = noOfCols;
+		composite.setLayout(layout);
+		return composite;
+	}
+	
+	/**
+	 * Uses the standard container selection dialog to choose the new value for
+	 * the container field.
+	 */
+	private void handleBrowse() {
+		ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot(), false,PolicyMessages.getString("SPL_SELECT_NEW_FILE_CONTAINER"));
+		if (dialog.open() == ContainerSelectionDialog.OK) {
+			Object[] result = dialog.getResult();
+			if (result.length == 1) {
+				String projectName = ((Path) result[0]).toOSString();
+				String tempStr = projectName.substring(1);
+				_projName = tempStr.substring(0, (tempStr.indexOf("\\")==-1?tempStr.length():tempStr.indexOf("\\")));
+//				System.out.println("_projName"+_projName);
+				String path = ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString()+projectName;
+				_projectFolderText.setText(path);
+			}
+		}
+	}
+	private String _projName = null;
+	
+	public IProject getProject() {
+		if(_projName != null) {
+			return ResourcesPlugin.getWorkspace().getRoot().getProject(_projName);
+		}
+		return null;
+	}
+}
+
+class ContentProvider implements IStructuredContentProvider {
+
+		public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
+
+		}
+
+		public Object[] getElements(Object input) {
+			if (input instanceof List) {
+				return ((List)input).toArray(); 
+			}
+			return new Object[0];
+		}
+		
+		public void dispose() {
+		}
+}
+
+class LabelProvider implements ILabelProvider {
+
+	public Image getImage(Object arg0) {
+		return null;
+	}
+
+	public String getText(Object arg0) {
+		if (arg0 instanceof String) {
+			return (String) arg0;
+		}
+		return "";
+	}
+
+	public void addListener(ILabelProviderListener arg0) {
+	}
+
+	public void dispose() {
+	}
+
+	public boolean isLabelProperty(Object arg0, String arg1) {
+		return false;
+	}
+
+	public void removeListener(ILabelProviderListener arg0) {
+	}
+}
\ No newline at end of file

Propchange: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/CustomActionImportPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/ImportCustomActionWizard.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/ImportCustomActionWizard.java?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/ImportCustomActionWizard.java (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/ImportCustomActionWizard.java Mon Jan 14 22:52:53 2008
@@ -0,0 +1,194 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.imperius.spl.editor.tool.ui.wizard;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Enumeration;
+import java.util.Properties;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+import org.apache.imperius.spl.editor.tool.internal.messages.PolicyMessages;
+import org.apache.imperius.spl.editor.tool.utils.PolicyPluginLogUtil;
+import org.apache.imperius.spl.editor.tool.utils.SPLPolicyUtil;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.IWorkbench;
+
+import org.apache.imperius.spl.parser.factory.ACPLParserMap;
+
+public class ImportCustomActionWizard extends Wizard implements IImportWizard {
+
+	private CustomActionImportPage fCustomActionImportPage;
+
+	private ISelection fSelection;
+
+	private String jarFileName = null;
+	
+	private IProject iProject = null;
+
+
+	public ImportCustomActionWizard() {
+		super();
+		setNeedsProgressMonitor(true);		
+	}
+	
+	public void init(IWorkbench workbench, IStructuredSelection selection) {
+		setWindowTitle(PolicyMessages.getString("SPL_IMPORT_CUSTOM_EXPRESSION_WINDOW_TITLE"));
+	}
+	
+	public void addPages() {
+		fCustomActionImportPage = new CustomActionImportPage(this, fSelection);
+		addPage(fCustomActionImportPage);
+	}
+	
+	public boolean performFinish() {
+		final String destPath = fCustomActionImportPage.getDestinationProjectName();
+		final String srcPath = fCustomActionImportPage.getJarFilePath();
+		TableViewer viewer = fCustomActionImportPage.getTableViewer(); 
+
+		if(viewer.getTable().getItemCount() == 0) {
+			return false;
+		}
+
+		IRunnableWithProgress op = new IRunnableWithProgress() {
+			public void run(IProgressMonitor monitor)
+			throws InvocationTargetException {
+				try {
+					doImportJarFile(srcPath, destPath, monitor);
+					if(jarFileName != null) {
+
+						// get Project
+						iProject = fCustomActionImportPage.getProject();
+						extractPropsFileFromJar(srcPath);
+						
+						// add the jar to the class path
+						addJarToClassPath(destPath, jarFileName);
+					}
+					ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE ,monitor);
+				} catch (Exception e) {
+					e.printStackTrace();
+				} finally {
+					monitor.done();
+				}
+			}
+		};
+		try {
+			getContainer().run(true, false, op);
+		} catch (InterruptedException e) {
+			PolicyPluginLogUtil.logError(PolicyMessages.getString("SPL_JAR_FILE_IMPORT_ERROR_") + " ", e);
+			return false;
+		} catch (InvocationTargetException e) {
+			e.printStackTrace();
+			Throwable realException = e.getTargetException();
+			MessageDialog.openError(getShell(), "Error", realException.getMessage());
+			return false;
+		}		
+		return true;
+
+	}
+	
+	/**
+	 * 
+	 * @param srcPath
+	 * @param destPath
+	 * @param monitor
+	 */
+	private void doImportJarFile(String srcPath, String destPath, IProgressMonitor monitor) {
+		try {
+			File srcFile = new File(srcPath);
+			jarFileName = srcFile.getName();
+			File destFile = new File(destPath + File.separator + srcFile.getName());
+			InputStream in = new FileInputStream(srcFile);
+			OutputStream out = new FileOutputStream(destFile);
+			byte[] buf = new byte[1024];
+			int len;
+			while ((len = in.read(buf)) > 0) {
+				out.write(buf, 0, len);
+			}
+			in.close();
+			out.close();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+	
+	/**
+	 * this function adds the imported jar file to the classpath
+	 */
+	private void addJarToClassPath(String destPath, String customActJarFileName) {
+		try {
+			// add jar to class path
+			SPLPolicyUtil.addJarToProjectsClasspath(iProject, destPath, customActJarFileName);
+			
+			// load in SPL Core
+			ACPLParserMap.loadCustomActionExpressionTypes(SPLPolicyUtil
+					.getCustomActionsList(iProject), SPLPolicyUtil
+					.createURLs(iProject));
+
+		} catch(Exception e) {
+			e.printStackTrace();
+		}
+	}
+	
+	private void extractPropsFileFromJar(String srcPath) {
+		try {
+			Properties customProps = new Properties();
+			File jarFileObj = new File(srcPath);
+			JarFile jarFile = new JarFile(jarFileObj);
+			if(jarFile != null) {
+				Enumeration enumerator = jarFile.entries();
+				JarEntry entry = null;
+				String entryName = "";
+				String propsFileName = PolicyMessages.SPL_CUSTOM_EXPR_FILE_NAME+".properties";
+				while(enumerator.hasMoreElements()) {
+					entry = (JarEntry)enumerator.nextElement();
+					entryName = entry.getName();
+					if(entryName.equals(propsFileName)) {
+						InputStream in = jarFile.getInputStream(entry);
+						customProps.load(in);
+						break;
+					}
+				}
+			}
+			
+			if(customProps.size() > 0 && customProps.containsKey(PolicyMessages.SPL_CUSTOM_ACTIONS)) {
+				SPLPolicyUtil.loadCustomActions(iProject, customProps, jarFileObj.getName());
+			}
+		} catch(Exception e) {
+			e.printStackTrace();
+		}
+	}
+	
+	
+}

Propchange: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/ImportCustomActionWizard.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/ImportPolicyWizard.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/ImportPolicyWizard.java?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/ImportPolicyWizard.java (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/ImportPolicyWizard.java Mon Jan 14 22:52:53 2008
@@ -0,0 +1,183 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.  
+ */
+
+/**
+ * @author Naidu Javvadi <njavvadi@in.ibm.com>
+ *
+ */
+
+
+package org.apache.imperius.spl.editor.tool.ui.wizard;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileReader;
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.imperius.spl.editor.tool.PluginActivator;
+import org.apache.imperius.spl.editor.tool.internal.messages.PolicyMessages;
+import org.apache.imperius.spl.editor.tool.utils.EclipseFileUtil;
+import org.apache.imperius.spl.editor.tool.utils.PolicyPluginLogUtil;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.IWorkbench;
+
+
+
+public class ImportPolicyWizard extends Wizard implements IImportWizard {
+
+	private ImportPolicyWizardPage cImportWizardPage;
+	private ISelection cImportSelection;
+//	private IWorkbench cImportWorkbench;
+	
+	public ImportPolicyWizard() {
+		super();
+		setNeedsProgressMonitor(true);		
+	}
+	
+	public void init(IWorkbench workbench, IStructuredSelection selection) {
+		cImportSelection = selection;
+//		cImportWorkbench = workbench;
+		setWindowTitle("Import");
+	}
+
+	public void addPages() {
+		cImportWizardPage = new ImportPolicyWizardPage(this, cImportSelection);
+		addPage(cImportWizardPage);
+	}
+	
+	
+	public boolean performFinish() {
+		final String containerName = cImportWizardPage.getDestinationProjectName();
+		CheckboxTableViewer viewer = cImportWizardPage.getTableViewer(); 
+		String splFilePath1 = null;
+		if (!containerName.endsWith("/")) {
+			splFilePath1 = containerName + "/";
+		} else {
+			splFilePath1 = containerName;
+		}
+		final String splFilePath = splFilePath1;
+		final Object[] files = viewer.getCheckedElements();
+
+		IRunnableWithProgress op = new IRunnableWithProgress() {
+			public void run(IProgressMonitor monitor)
+			throws InvocationTargetException {
+				try {
+					doImportFiles(files, containerName, splFilePath, monitor);
+				} catch (Exception e) {
+					e.printStackTrace();
+				} finally {
+					monitor.done();
+				}
+			}
+		};
+		
+		try {
+			getContainer().run(true, false, op);
+		} catch (InterruptedException e) {
+			PolicyPluginLogUtil.logError(PolicyMessages.getString("SPL_FILE_CREATION_ERROR_") + " ", e);
+			return false;
+		} catch (InvocationTargetException e) {
+			Throwable realException = e.getTargetException();
+			MessageDialog.openError(getShell(), "Error", realException.getMessage());
+			return false;
+		}		
+		return true;
+	}
+	
+	private void doImportFiles(Object[] files, String containerName, String filePath, IProgressMonitor monitor) {
+		if (files.length > 0) {
+			for (int i = 0, n = files.length; i < n; i++) {
+				try {
+					String fileName = "";
+					if(files[i] instanceof File) {
+						fileName = ((File)files[i]).getName();
+					} else {
+						fileName = (String)files[i];
+					}
+					IFile splPolicyFile = EclipseFileUtil.getIFile(filePath + fileName);
+					if(splPolicyFile.exists()) {
+						final IFile tempFile = splPolicyFile;
+						final Object fileObj = files[i];
+						final String filename = splPolicyFile.getName();
+						Display.getDefault().syncExec(new Runnable() {
+							 public void run() {
+								String message = filename+" already exists.Do you want to overwrite it?";
+								boolean bConfirm = MessageDialog.openConfirm(PluginActivator.getActiveWorkbenchShell(), "File Exists", message);
+								if(bConfirm) {
+									// then over write the file
+									createImportedFile(tempFile, fileObj);
+								}
+							 }
+						});
+					} else {
+						monitor.beginTask(PolicyMessages.getString("SPL_FILE_CREATION"), IProgressMonitor.UNKNOWN);
+						createImportedFile(splPolicyFile, files[i]);
+					}
+				} catch (CoreException e) {
+					e.printStackTrace();
+				}
+			}
+		}
+	}
+	
+	private void createImportedFile(IFile splPolicyFile, Object obj) {
+		try {
+			String contents = "";
+			if(obj instanceof File) {
+				contents = getContentsOfFile((File)obj);
+			} else if(obj instanceof String) {
+				contents = (String)cImportWizardPage.getServerPolicyFilesMap().get((String)obj);
+			}
+			ByteArrayInputStream baInputStream = new ByteArrayInputStream(contents==null?"".getBytes():contents.getBytes());
+			if(splPolicyFile.exists()) {
+				splPolicyFile.delete(true, null);
+			}
+			splPolicyFile.create(baInputStream, true, null);
+		} catch(Exception e) {
+			PolicyPluginLogUtil.logError(PolicyMessages.getString("SPL_FILE_CREATION_ERROR_") + " ", e);
+		}
+	}
+	
+	 private String getContentsOfFile(File file) {
+		StringBuffer sbFileContents = new StringBuffer("");
+		try {
+			BufferedReader in = null;
+			in = new BufferedReader(new FileReader(file));
+			String str = null;
+			while ((str = in.readLine()) != null) {
+				sbFileContents.append(str+"\n");
+			}
+		} catch (Exception e) {
+			PolicyPluginLogUtil.logError(PolicyMessages.getString("SPL_FILES_IMPORT_ERROR_"), e);
+		} 
+		return sbFileContents.toString();
+	 }	
+	
+}

Propchange: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/ImportPolicyWizard.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/ImportPolicyWizardPage.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/ImportPolicyWizardPage.java?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/ImportPolicyWizardPage.java (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/ImportPolicyWizardPage.java Mon Jan 14 22:52:53 2008
@@ -0,0 +1,611 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.  
+ */
+
+/**
+ * @author Naidu Javvadi <njavvadi@in.ibm.com>
+ *
+ */
+ 
+package org.apache.imperius.spl.editor.tool.ui.wizard;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.imperius.spl.editor.tool.PluginActivator;
+import org.apache.imperius.spl.editor.tool.internal.client.IPolicyClient;
+import org.apache.imperius.spl.editor.tool.internal.client.IPolicyClientFactory;
+import org.apache.imperius.spl.editor.tool.internal.client.PolicyClientFactoryImpl;
+import org.apache.imperius.spl.editor.tool.internal.messages.PolicyMessages;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+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.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.ContainerSelectionDialog;
+
+
+
+/**
+ * @author Naidu Javvadi <njavvadi@in.ibm.com>
+ *
+ */
+
+public class ImportPolicyWizardPage extends WizardPage {
+
+//	private ImportPolicyWizard importPolicyWizard;
+	
+//	private ISelection cSelection;
+	
+	private CheckboxTableViewer viewer;
+	
+	private Button _serverImportButton;
+	
+	private Button _localImportButton;
+	
+	private Button srcBrowseButton;
+	
+	private Text _directoryText;
+	
+	private Text _projectFolderText;
+	
+	private boolean localFlag = false;
+	
+	private Map serverPolicyFilesMap = null;
+	
+	private String domainSelected = "";
+
+	private Combo languageCombo = null;
+
+	/**
+	 * 
+	 * @param wizard
+	 * @param selection
+	 */
+	public ImportPolicyWizardPage(ImportPolicyWizard wizard, ISelection selection) {
+		super(PolicyMessages.getString("SPL_IMPORT_WIZARD_PAGE"));
+		setTitle(PolicyMessages.getString("SPL_IMPORT_WIZARD_PAGE_TITLE"));
+		setDescription(PolicyMessages.getString("SPL_IMPORT_WIZARD_PAGE_DESC"));
+//		this.cSelection = selection;
+//		this.importPolicyWizard = wizard;
+	}
+
+	/**
+	 * 
+	 */
+	public void createControl(Composite parent) {
+		Composite container = addGridLayout(new Composite(parent, 0),1);
+		addDomainSelection(container);
+		addImportOptions(container);
+		addSourceFileBrowser(container);
+
+		// add table to show files in the directory
+		viewer = createTable(container, 1);
+		viewer.setContentProvider(new ImportFilesContentProvider());
+		viewer.setLabelProvider(new ImportFilesLabelProvider());		
+		viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+			public void selectionChanged(SelectionChangedEvent event) {
+				dialogChanged();
+			}
+		});
+		addDestinationFileBrowser(container);
+		initializeDefaults();
+		dialogChanged();
+		setControl(container);
+	}
+	
+	/**
+	 * 
+	 * @return
+	 */
+	public String getDestinationProjectName() {
+		return _projectFolderText.getText();
+	}
+	
+	/**
+	 * 
+	 * @return
+	 */
+	public CheckboxTableViewer getTableViewer() {
+		return viewer;
+	}
+	
+	private void addDomainSelection(final Composite container) {
+		Composite container1 = addGridLayout(new Composite(container, 0),2);
+		Label selectLabel = new Label(container1, SWT.NONE);
+		GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+		gridData.horizontalSpan = 1;
+		//gridData.widthHint = 123;
+		selectLabel.setLayoutData(gridData);		
+		selectLabel.setText(PolicyMessages.getString("POLICY_BINDING_LABEL"));
+		languageCombo = new Combo(container1, SWT.READ_ONLY|SWT.DROP_DOWN);
+		String[] supportedLangs = PluginActivator.getDefault().getBinderNames().split(",");
+		languageCombo.add("Select Domain");
+		for (int i = 0; i < supportedLangs.length; i++) {
+			languageCombo.add(supportedLangs[i]);
+		}
+		languageCombo.select(0);
+		languageCombo.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent event) {
+				if(event.getSource() instanceof Combo) {
+					int selectedIndex = ((Combo)event.getSource()).getSelectionIndex();
+					enableOrDisableServer(selectedIndex);
+					dialogChanged();
+				}
+			}
+		});
+
+	}
+	
+	private void enableOrDisableServer(int selectedIndex) {
+		domainSelected = languageCombo.getItem(selectedIndex);
+		if(!"CIM".equals(domainSelected)) {
+			disableServerButton();
+		} else {
+			enableServerButton();
+		}
+		if("Select Domain".equals(domainSelected)) {
+			updateStatus("Select domain language");
+			setPageComplete(false);
+		} else {
+			updateStatus(null);
+		}
+	}
+	
+	private void disableServerButton() {
+		if(_serverImportButton.getSelection()) {
+			_serverImportButton.setSelection(false);
+			srcBrowseButton.setEnabled(true);
+			_directoryText.setEnabled(true);
+			_localImportButton.setSelection(true);
+			_serverImportButton.setEnabled(false);
+		} else {
+			_localImportButton.setSelection(true);
+			_serverImportButton.setEnabled(false);
+		}
+	}
+	
+	private void enableServerButton() {
+		if(!_serverImportButton.getEnabled()) {
+			_serverImportButton.setEnabled(true);
+		}
+	}
+
+	/**
+	 * 
+	 * @param container
+	 */
+	private void addImportOptions(Composite container) {
+		Label selectLabel = new Label(container, SWT.NONE);
+		selectLabel.setText(PolicyMessages.getString("POLICY_IMPORT_SELECTION_LABEL"));
+		_serverImportButton = new Button(container, SWT.RADIO | SWT.LEFT);
+		_serverImportButton.setText(PolicyMessages.getString("POLICY_IMPORT_SERVER_LABEL"));
+		_serverImportButton.setEnabled(false);
+		_serverImportButton.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent event) {
+				if(((Button)event.getSource()).getSelection()) {
+					localFlag = false;
+					// if server option is selected disable the source browse button
+					srcBrowseButton.setEnabled(false);
+					_directoryText.setEnabled(false);
+					getPolicyFilesFromServer();
+				}
+			}
+		});
+		_localImportButton 	= new Button(container, SWT.RADIO | SWT.LEFT);
+		_localImportButton.setText("Local");
+		_localImportButton.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent event) {
+				if(((Button)event.getSource()).getSelection()) {
+					localFlag = true;
+					// if local option is selected enable the source browse button
+					srcBrowseButton.setEnabled(true);
+					_directoryText.setEnabled(true);
+				}
+			}
+		});
+	}
+
+	/**
+	 * function that gets client to get policy files resided in server
+	 */
+	private void getPolicyFilesFromServer() {
+		IPolicyClientFactory factory = new PolicyClientFactoryImpl();
+		IPolicyClient policyClient = null;
+		try {
+			String domainLanguage = domainSelected;
+			if("".equals(domainLanguage)) {
+				_serverImportButton.setSelection(false);
+				return;
+			}
+			policyClient = factory.getClient(domainLanguage);
+			if(policyClient != null) {
+				setServerPolicyFilesMap(policyClient.getPolicyFiles());
+				// add to the table and refresh table
+				viewer.setInput(getCommaSeperatedString(getServerPolicyFilesMap()));
+				viewer.refresh();
+				
+			} else {
+				_serverImportButton.setSelection(false);
+			}
+		} catch(Exception _ex) {
+			_serverImportButton.setSelection(false);
+			_localImportButton.setSelection(true);
+			localFlag = true;
+			srcBrowseButton.setEnabled(true);
+			_directoryText.setEnabled(true);
+			if(_ex.getMessage().indexOf("was unable to instantiate class") != -1) {
+//				DomainConfigurationErrorWindow win = new DomainConfigurationErrorWindow(getShell(),DomainConfigurationErrorWindow.getConfigInstructions());
+//				win.setBlockOnOpen(true);
+//				win.open();
+			} else {
+				MessageDialog.openError(PluginActivator.getActiveWorkbenchShell(), "ERROR", _ex.getMessage());
+			}
+
+		} 
+	}
+
+	/**
+	 * 
+	 * @param policyNamesMap
+	 * @return
+	 */
+	private String getCommaSeperatedString(Map policyNamesMap) {
+		String policyNames = null;
+		if(policyNamesMap != null && policyNamesMap.size() > 0) {
+			Iterator iter = policyNamesMap.keySet().iterator();
+			while(iter.hasNext()) {
+				policyNames = (policyNames == null?"":policyNames) + (String)iter.next() + ",";
+			}
+			policyNames = policyNames.substring(0,policyNames.length()-1);
+		}
+		return policyNames;
+	}
+	
+
+	/**
+	 * 
+	 * @param container
+	 */
+	private void addSourceFileBrowser(Composite container) {
+		Composite browserContainer = addGridLayout(new Composite(container, 0),3);
+		
+		Label fileDirectoryLabel = new Label(browserContainer, SWT.NONE);
+		GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+		gridData.horizontalSpan = 1;
+		fileDirectoryLabel.setLayoutData(gridData);
+		fileDirectoryLabel.setText(PolicyMessages.getString("IMPORT_POLICY_SOURCE_DIRECTORY"));
+		
+		_directoryText = new Text(browserContainer, SWT.BORDER | SWT.SINGLE);
+		gridData = new GridData(GridData.FILL_HORIZONTAL);
+		gridData.horizontalSpan = 1;
+		gridData.widthHint = 420;
+		_directoryText.setLayoutData(gridData);		
+		
+		_directoryText.addModifyListener(new ModifyListener() {
+			public void modifyText(ModifyEvent e) {
+				dialogChanged();
+			}
+		});
+
+		srcBrowseButton = new Button(browserContainer, SWT.PUSH | SWT.CENTER);
+		srcBrowseButton.setText(PolicyMessages.getString("SPL_BROWSE"));
+		gridData = new GridData(GridData.FILL_HORIZONTAL);
+		gridData.horizontalSpan = 1;
+		srcBrowseButton.setLayoutData(gridData);	
+		srcBrowseButton.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent event) {
+				if(localFlag) {
+					DirectoryDialog dialog = new DirectoryDialog(PluginActivator.getActiveWorkbenchShell(), SWT.NULL);
+					String filePath = dialog.open();
+					_directoryText.setText(filePath == null?"":filePath);
+					if(filePath != null) {
+						viewer.setInput(new File(filePath));
+						viewer.refresh();
+					}
+				} 
+			}
+		});
+	}
+
+	/**
+	 * 
+	 * @param container
+	 */
+	private void addDestinationFileBrowser(Composite container) {
+		Composite innerBrowserContainer = addGridLayout(new Composite(container, 0),3);
+		Label projectFolderLabel = new Label(innerBrowserContainer, SWT.NONE);
+		GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+		gridData.horizontalSpan = 1;
+		projectFolderLabel.setLayoutData(gridData);
+		projectFolderLabel.setText(PolicyMessages.getString("IMPORT_POLICY_DESTINATION_DIRECTORY"));
+		_projectFolderText = new Text(innerBrowserContainer, SWT.BORDER | SWT.SINGLE);
+		gridData = new GridData(GridData.FILL_HORIZONTAL);
+		gridData.horizontalSpan = 1;
+		gridData.widthHint = 400;
+		_projectFolderText.setLayoutData(gridData);		
+		_projectFolderText.addModifyListener(new ModifyListener() {
+			public void modifyText(ModifyEvent e) {
+				dialogChanged();
+			}
+		});
+		Button projectBrowseButton = new Button(innerBrowserContainer, SWT.PUSH | SWT.CENTER);
+		projectBrowseButton.setText(PolicyMessages.getString("SPL_BROWSE"));
+		gridData = new GridData(GridData.FILL_HORIZONTAL);
+		gridData.horizontalSpan = 1;
+		projectBrowseButton.setLayoutData(gridData);	
+		projectBrowseButton.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent event) {
+				handleBrowse();
+			}
+		});		
+	}
+	
+	/**
+	 * 
+	 * @param composite
+	 * @param noOfCols
+	 * @return
+	 */
+	private Composite addGridLayout(Composite composite, int noOfCols) {
+		GridLayout layout = new GridLayout();
+		layout.numColumns = noOfCols;
+		composite.setLayout(layout);
+		return composite;
+	}
+
+	/**
+	 * 
+	 * @param parent
+	 * @param span
+	 * @return
+	 */
+	private CheckboxTableViewer createTable(Composite parent, int span) {
+		Table table = new Table(parent, SWT.CHECK | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
+		GridData data = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL);
+		data.horizontalSpan = span;
+		data.widthHint = 200;
+		table.setLayoutData(data);
+		TableLayout layout = new TableLayout();
+		layout.addColumnData(new ColumnWeightData(100, true));
+		table.setLayout(layout);
+		TableColumn col = new TableColumn(table, SWT.NONE);
+		col.setText("File Name");
+		col.setResizable(true);
+		return new CheckboxTableViewer(table);
+	}
+
+	/**
+	 * 
+	 */
+	private void initializeDefaults() {
+		_localImportButton.setSelection(true);
+		localFlag = true;
+	}
+
+	/**
+	 * 
+	 */
+	private void dialogChanged() {
+		String projectFolderTxt = _projectFolderText.getText();
+		Object[] checkedObjects = viewer.getCheckedElements();
+		if (projectFolderTxt.length() == 0) {
+			setPageComplete(false);
+			return;
+		}
+		// if some files are selected and folder is empty or if folder is selected and selected files is empty
+		if(checkedObjects.length > 0 && projectFolderTxt.length() == 0) {
+			updateStatus("Destination folder can not be empty");
+			setPageComplete(false);
+			return;
+		}
+		if(checkedObjects.length == 0 && projectFolderTxt.length() != 0) {
+			updateStatus("Select files to import");
+			setPageComplete(false);
+			return;
+		}
+		
+		int selectedIndex = languageCombo.getSelectionIndex();
+		domainSelected = languageCombo.getItem(selectedIndex);
+		if("Select Domain".equals(domainSelected)) {
+			updateStatus("Select domain language");
+			return;
+		}
+
+		
+		updateStatus(null);
+		setPageComplete(true);
+	}	
+	
+	/**
+	 * 
+	 * @param message
+	 */
+	private void updateStatus(String message) {
+		setErrorMessage(message);
+	}	
+	
+	/**
+	 * Uses the standard container selection dialog to choose the new value for
+	 * the container field.
+	 */
+	private void handleBrowse() {
+		ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot(), false,PolicyMessages.getString("SPL_SELECT_NEW_FILE_CONTAINER"));
+		if (dialog.open() == ContainerSelectionDialog.OK) {
+			Object[] result = dialog.getResult();
+			if (result.length == 1) {
+				_projectFolderText.setText(((Path) result[0]).toOSString());
+			}
+		}
+	}
+
+
+	/**
+	 * @return the serverPolicyFilesMap
+	 */
+	public Map getServerPolicyFilesMap() {
+		return serverPolicyFilesMap;
+	}
+
+
+	/**
+	 * @param serverPolicyFilesMap the serverPolicyFilesMap to set
+	 */
+	public void setServerPolicyFilesMap(Map serverPolicyFilesMap) {
+		this.serverPolicyFilesMap = serverPolicyFilesMap;
+	}	
+}
+
+class ImportFilesContentProvider implements IStructuredContentProvider {
+
+	/**
+	 * Called when the input changes
+	 */
+	public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
+
+	}
+
+	/**
+	 * Gets the files in the specified directory
+	 * 
+	 * @param arg0 a String containing the directory
+	 */
+	public Object[] getElements(Object input) {
+		if (input instanceof File) {
+			File dir = (File) input;
+			File[] filesList = dir.listFiles();
+			if(filesList != null) {
+				List fileArrayList = new ArrayList();
+				for (int i = 0; i < filesList.length; i++) {
+					if(filesList[i].isFile() && filesList[i].getName().endsWith(".spl")) {
+						fileArrayList.add(new File(dir, filesList[i].getName()));
+					}
+				}
+				return fileArrayList.toArray();
+			}
+		} else if(input instanceof String) {
+			String str = (String) input;
+			return str.split(",");
+		}
+		return new File[0];
+	}
+	
+	/**
+	 * Disposes any created resources
+	 */
+	public void dispose() {
+
+	}
+}
+
+
+/**
+ * This class provides the labels for files
+ */
+
+class ImportFilesLabelProvider implements ILabelProvider {
+  /**
+	 * Returns the image
+	 * 
+	 * @param arg0 the file
+	 * @return Image
+	 */
+  public Image getImage(Object arg0) {
+    return null;
+  }
+
+  /**
+	 * Returns the name of the file
+	 * 
+	 * @param arg0 the name of the file
+	 * @return String
+	 */
+  public String getText(Object arg0) {
+	  if(arg0 instanceof File) {
+		  return ((File) arg0).getName();
+	  } else if(arg0 instanceof String) {
+		  return (String)arg0;
+	  }
+	  return ((File) arg0).getName();
+  }
+
+  /**
+	 * Adds a listener
+	 * 
+	 * @param arg0 the listener
+	 */
+  public void addListener(ILabelProviderListener arg0) {
+
+  }
+
+  /**
+	 * Disposes any created resources
+	 */
+  public void dispose() {
+
+  }
+
+  /**
+	 * Returns whether changing this property for this element affects the label
+	 * 
+	 * @param arg0
+	 *            the element
+	 * @param arg1
+	 *            the property
+	 */
+  public boolean isLabelProperty(Object arg0, String arg1) {
+    return false;
+  }
+
+  /**
+	 * Removes a listener
+	 * 
+	 * @param arg0 the listener
+	 */
+  public void removeListener(ILabelProviderListener arg0) {
+
+  }
+}

Propchange: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/ImportPolicyWizardPage.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message