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 [5/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/wizard/NewPolicyEditorPageWizard.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/NewPolicyEditorPageWizard.java?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/NewPolicyEditorPageWizard.java (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/NewPolicyEditorPageWizard.java Mon Jan 14 22:52:53 2008
@@ -0,0 +1,300 @@
+/*
+ * 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 org.apache.imperius.spl.editor.tool.internal.messages.PolicyMessages;
+import org.apache.imperius.spl.editor.tool.utils.EclipseFileUtil;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+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.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.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.ContainerSelectionDialog;
+
+
+public class NewPolicyEditorPageWizard extends WizardPage {
+
+	private ISelection cSelection;
+	
+	private String defaultFileName;
+	
+	private Text containerText;
+	
+	private Text fileText;
+	
+	private static final String SPL_FILE_EXTENSION = "spl";
+
+	/**
+	 * 
+	 * @param wizard
+	 * @param selection
+	 */
+	public NewPolicyEditorPageWizard(NewPolicyEditorWizard wizard, ISelection selection) {
+		super("wizardPage");
+		setTitle(PolicyMessages.getString("SPL_EDITOR_PAGE_WINDOW_TITLE"));
+		setDescription(PolicyMessages.getString("SPL_WIZARD_PAGE_DESC"));
+		this.cSelection = selection;
+		this.defaultFileName = "new_file";
+	}
+
+	/**
+	 * 
+	 * @param title
+	 * @param selection
+	 */
+	public NewPolicyEditorPageWizard(String title, ISelection selection) {
+		super(title);
+		setTitle(PolicyMessages.getString("SPL_EDITOR_PAGE_WINDOW_TITLE"));
+		setDescription(PolicyMessages.getString("SPL_WIZARD_PAGE_DESC"));
+		this.defaultFileName = "new_file";
+		this.cSelection = selection;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+	 */
+	public void createControl(Composite parent) {
+		Composite container = new Composite(parent, SWT.NULL);
+		GridLayout layout = new GridLayout();
+		container.setLayout(layout);
+		layout.numColumns = 3;
+		layout.verticalSpacing = 9;
+
+		Label label = new Label(container, SWT.NULL);
+		label.setText(PolicyMessages.getString("SPL_FILE_LABEL_NAME"));
+		fileText = new Text(container, SWT.BORDER | SWT.SINGLE);
+		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+		fileText.setLayoutData(gd);
+		fileText.addModifyListener(new ModifyListener() {
+			public void modifyText(ModifyEvent e) {
+				dialogChanged();
+			}
+		});
+		label = new Label(container, SWT.NULL); // dummy label
+		label = new Label(container, SWT.NULL);
+		label.setText(PolicyMessages.getString("SPL_PROJECT"));
+		containerText = new Text(container, SWT.BORDER | SWT.SINGLE);
+		gd = new GridData(GridData.FILL_HORIZONTAL);
+		containerText.setLayoutData(gd);
+		containerText.addModifyListener(new ModifyListener() {
+			public void modifyText(ModifyEvent e) {
+				dialogChanged();
+			}
+		});
+
+		Button button = new Button(container, SWT.PUSH);
+		button.setText(PolicyMessages.getString("SPL_BROWSE"));
+		button.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent e) {
+				handleBrowse();
+			}
+		});
+		initialize();
+		dialogChanged();
+		setControl(container);
+	}
+
+	/**
+	 * 
+	 */
+	public void dialogChanged() {
+		String container = getContainerName();
+		String filename = getTargetFileName();
+		
+		if (container.length() == 0) {
+			updateStatus(PolicyMessages.getString("SPL_PROJECT_MUST_BE_SPECIFIED"));
+			return;
+		}
+		
+		if (filename.length() == 0) {
+			updateStatus(PolicyMessages.getString("SPL_FILE_NAME_CANNOT_BE_BLANK"));
+			return;
+		}
+
+		try {
+			if(filename.endsWith(".spl")) {
+				// get the path
+				String splFilePath = null;
+				if (!container.endsWith("/")) {
+					splFilePath = container + "/" + filename;
+				} else {
+					splFilePath = container + filename;
+				}
+				IFile file = EclipseFileUtil.getIFile(splFilePath);
+				if(file.exists()) {
+					updateStatus(PolicyMessages.getString("SPL_FILE_ALREADY_EXISTS"));
+					return;
+				}
+			} else {
+				updateStatus(PolicyMessages.getString("SPL_FILE_EXTENSION_MUST_BE_SPECIFIED"));
+				return;
+			}
+		} catch (CoreException e) {
+			e.printStackTrace();
+		}
+		setErrorMessage(null);
+		setPageComplete(true);
+	}	
+
+	/**
+	 * 
+	 */
+	public void initialize() {
+		setContainerText(getSelectedIResourceName());
+		
+		if("".equals(getContainerName())) {
+			setFileNameText("");
+			return;
+		}
+		
+		// check if any file exists with the default file name
+		setFileNameText(getDefaultFileName());
+	}
+	
+	/**
+	 * 
+	 * @return
+	 */
+	private String getDefaultFileName() {
+		try {
+			defaultFileName = defaultFileName+"_"+(int)(Math.random()*10)+ "." + SPL_FILE_EXTENSION;
+			String container = getContainerName();
+			String splFilePath = null;
+			if (!container.endsWith("/")) {
+				splFilePath = container + "/" + defaultFileName;
+			} else {
+				splFilePath = container + defaultFileName;
+			}
+			IFile file = EclipseFileUtil.getIFile(splFilePath);
+			if(file.exists()) {
+				getDefaultFileName();
+			}
+		} catch(Exception e) {
+			e.printStackTrace();
+		}
+		return defaultFileName;
+	}	
+
+	/**
+	 * 
+	 * @param filename
+	 */
+	private void setFileNameText(String filename) {
+		fileText.setText(filename);
+	}
+
+
+	/**
+	 * 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) {
+				setContainerText(((Path) result[0]).toOSString());
+			}
+		}
+	}
+
+	/**
+	 * this function returns the container specified for CIM SPL file
+	 */
+	public String getContainerName() {
+		return containerText.getText();
+	}
+
+	/**
+	 * 
+	 * @param text
+	 */
+	public void setContainerText(String text) {
+		containerText.setText(text);
+	}
+
+	/**
+	 * 
+	 * @return
+	 */
+	private String getSelectedIResourceName() {
+		String selectedPath = "";
+		if (cSelection != null && cSelection.isEmpty() == false
+				&& cSelection instanceof IStructuredSelection) {
+			IStructuredSelection structuredSel = (IStructuredSelection) cSelection;
+			Object obj = structuredSel.getFirstElement();
+			if (obj instanceof IResource) {
+				IContainer container;
+				if (obj instanceof IContainer)
+					container = (IContainer) obj;
+				else
+					container = ((IResource) obj).getParent();
+				selectedPath = container.getFullPath().toOSString();
+			} else if(obj instanceof IJavaProject) {
+				IJavaProject javaProject = (IJavaProject)obj;
+				selectedPath = javaProject.getPath().toOSString();
+			} else if(obj instanceof IPackageFragment) {
+				IPackageFragment pkgFrag = (IPackageFragment)obj;
+				selectedPath = pkgFrag.getPath().toOSString();
+			}
+		}
+		return selectedPath;
+	}
+
+	/**
+	 * Returns the file name for CIM SPL.
+	 */
+	public String getTargetFileName() {
+		return fileText.getText();
+	}
+
+	/**
+	 * 
+	 * @param message
+	 */
+	private void updateStatus(String message) {
+		setErrorMessage(message);
+		setPageComplete(false);
+	}
+}

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

Added: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/NewPolicyEditorWizard.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/NewPolicyEditorWizard.java?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/NewPolicyEditorWizard.java (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/NewPolicyEditorWizard.java Mon Jan 14 22:52:53 2008
@@ -0,0 +1,179 @@
+/*
+ * 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.IOException;
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.imperius.spl.editor.tool.internal.messages.PolicyMessages;
+import org.apache.imperius.spl.editor.tool.ui.PolicyEditor;
+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.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+
+
+public class NewPolicyEditorWizard extends Wizard implements INewWizard {
+
+	private NewPolicyEditorPageWizard cWizardPage;
+	
+	private PolicyTemplatePage policyTemplatePage;
+	
+	private ISelection cSelection;
+	
+//	private IWorkbench cWorkbench;
+	
+	private IFile splPolicyFile;
+
+	/**
+	 * creates new object of this class
+	 */
+	public NewPolicyEditorWizard() {
+		super();
+		setNeedsProgressMonitor(true);
+	}
+
+	/**
+	 * 
+	 */
+	public void init(IWorkbench workbench, IStructuredSelection selection) {
+		cSelection = selection;
+//		cWorkbench = workbench;
+		setWindowTitle(PolicyMessages.getString("SPL_EDITOR_PAGE_WINDOW_TITLE"));
+	}
+
+	/**
+	 * add the pages to the wizard
+	 */
+	public void addPages() {
+		cWizardPage = new NewPolicyEditorPageWizard(this, cSelection);
+		addPage(cWizardPage);
+		
+		policyTemplatePage = new PolicyTemplatePage(this, cSelection);
+		addPage(policyTemplatePage);
+	}
+
+	/**
+	 * 
+	 */
+	public boolean performFinish() {
+		String containerName = cWizardPage.getContainerName();
+		String targetCimSplFileName = cWizardPage.getTargetFileName();
+		
+		String content = policyTemplatePage.getSelectedTemplate();
+
+		// get the path
+		String splFilePath = null;
+		//System.out.println("containerName"+containerName);
+		if (!containerName.endsWith("/")) {
+			splFilePath = containerName + "/" + targetCimSplFileName;
+		} else {
+			splFilePath = containerName + targetCimSplFileName;
+		}
+		
+		final NewPolicyFileCreationConfigData data = new NewPolicyFileCreationConfigData();
+		data.addParameter(NewPolicyFileCreationConfigData.SPL_CONTAINER_NAME_KEY,containerName);
+		data.addParameter(NewPolicyFileCreationConfigData.SPL_FILE_NAME_KEY,targetCimSplFileName);
+		data.addParameter(NewPolicyFileCreationConfigData.SPL_FILE_PATH_KEY,splFilePath);
+		data.addParameter(NewPolicyFileCreationConfigData.SPL_FILE_CONTENT,content);
+		
+
+		IRunnableWithProgress op = new IRunnableWithProgress() {
+			public void run(IProgressMonitor monitor)
+			throws InvocationTargetException {
+				try {
+					doFinish(data, monitor);
+				} catch (CoreException e) {
+					PolicyPluginLogUtil.logError(PolicyMessages.getString("SPL_FILE_CREATION_ERROR_") + " ", e);
+				} catch (IOException e) {
+					PolicyPluginLogUtil.logError(PolicyMessages.getString("SPL_FILE_CREATION_ERROR_") + " ", e);
+				} catch (InterruptedException 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;
+	}
+
+	/**
+	 * 
+	 * @param data
+	 * @param monitor
+	 * @throws CoreException
+	 * @throws IOException
+	 * @throws InvocationTargetException
+	 * @throws InterruptedException
+	 */
+	private void doFinish(NewPolicyFileCreationConfigData data, IProgressMonitor monitor) throws CoreException, IOException,
+			InvocationTargetException, InterruptedException {
+		
+		NewPolicyFileCreationAction newCimSplCreationAction = new NewPolicyFileCreationAction(data);
+		splPolicyFile = newCimSplCreationAction.run(monitor);
+		openFile(monitor);
+	}
+
+	/**
+	 * 
+	 * @param monitor
+	 */
+	private void openFile(IProgressMonitor monitor) {
+		monitor.beginTask(PolicyMessages.getString("OPENING_SPL_EDITOR"), IProgressMonitor.UNKNOWN);
+		getShell().getDisplay().asyncExec(new Runnable() {
+			public void run() {
+				IWorkbenchPage pg = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+				try {
+					IDE.openEditor(pg, splPolicyFile, PolicyEditor.EDITOR_ID);
+				} catch (PartInitException e) {
+					PolicyPluginLogUtil.logError(PolicyMessages.getString("FAILED_TO_OPEN_FILE_ERROR_") + " ", e);
+				}
+			}
+		});
+	}
+
+}

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

Added: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/NewPolicyFileCreationAction.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/NewPolicyFileCreationAction.java?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/NewPolicyFileCreationAction.java (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/NewPolicyFileCreationAction.java Mon Jan 14 22:52:53 2008
@@ -0,0 +1,130 @@
+/*
+ * 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.ByteArrayInputStream;
+
+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.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+
+
+public class NewPolicyFileCreationAction {
+	
+	private NewPolicyFileCreationConfigData configData;
+	private IFile splPolicyFile;
+
+	/**
+	 * 
+	 * @param data
+	 */
+	public NewPolicyFileCreationAction(NewPolicyFileCreationConfigData data) {
+		configData = data;
+	}
+
+	/**
+	 * 
+	 * @param monitor
+	 * @return
+	 * @throws CoreException
+	 */
+	public IFile run(IProgressMonitor monitor) throws CoreException {
+		doFinishCimSplFile(monitor);
+		refreshContainer(monitor);
+		return splPolicyFile;
+	}
+
+	/**
+	 * 
+	 * @param monitor
+	 * @throws CoreException
+	 */
+	private void doFinishCimSplFile(IProgressMonitor monitor) throws CoreException {
+		String splFilePath = (String) configData.getParameter(NewPolicyFileCreationConfigData.SPL_FILE_PATH_KEY);
+		String fileContent = (String) configData.getParameter(NewPolicyFileCreationConfigData.SPL_FILE_CONTENT);
+		splPolicyFile = EclipseFileUtil.getIFile(splFilePath);
+		if(splPolicyFile.exists()) {
+			// do nothing
+		} else {
+			monitor.beginTask(PolicyMessages.getString("SPL_FILE_CREATION"), IProgressMonitor.UNKNOWN);
+			createSPLFile(splPolicyFile, fileContent, monitor);
+			splPolicyFile.refreshLocal(IResource.DEPTH_ZERO, monitor);
+		}
+	}
+
+	/**
+	 * 
+	 * @param splsplFile
+	 * @param monitor
+	 */
+	private void createSPLFile(IFile cimsplFile, String fileContent, IProgressMonitor monitor) {
+		String contents = fileContent;
+		try {
+			ByteArrayInputStream baInputStream = new ByteArrayInputStream(contents.getBytes());
+			if(cimsplFile.exists()) {
+				cimsplFile.delete(true, null);
+			}
+			cimsplFile.create(baInputStream, true, null);
+		} catch (CoreException ce) {
+			PolicyPluginLogUtil.logError(PolicyMessages.getString("SPL_FILE_CREATION_ERROR_") + " ", ce);
+		}
+	}
+
+	/**
+	 * 
+	 * @param monitor
+	 * @throws CoreException
+	 */
+	private void refreshContainer(IProgressMonitor monitor) throws CoreException {
+		String containerName = (String) configData.getParameter(NewPolicyFileCreationConfigData.SPL_CONTAINER_NAME_KEY);
+		IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+		IResource resource = root.findMember(new Path(containerName));
+		if (!resource.exists() || !(resource instanceof IContainer)) {
+			throwCoreException(PolicyMessages.bind(PolicyMessages.getString("CONTAINER_DOES_NOT_EXISTS_ERROR_"), containerName));
+		}
+		IContainer container = (IContainer) resource;
+		container.refreshLocal(IResource.DEPTH_ONE, monitor);
+	}
+
+	/**
+	 * 
+	 * @param message
+	 * @throws CoreException
+	 */
+	private void throwCoreException(String message) throws CoreException {
+		IStatus status = new Status(IStatus.ERROR, "CIMSPLEditor", IStatus.OK,message, null);
+		throw new CoreException(status);
+	}
+}

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

Added: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/NewPolicyFileCreationConfigData.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/NewPolicyFileCreationConfigData.java?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/NewPolicyFileCreationConfigData.java (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/NewPolicyFileCreationConfigData.java Mon Jan 14 22:52:53 2008
@@ -0,0 +1,55 @@
+/*
+ * 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.util.HashMap;
+import java.util.Map;
+
+public class NewPolicyFileCreationConfigData {
+
+	private Map parameterMap = null;
+	public static final String SPL_FILE_NAME_KEY = "SPL_FILE_NAME";
+	public static final String SPL_CONTAINER_NAME_KEY = "SPL_CONTAINER_NAME";
+	public static final String SPL_FILE_PATH_KEY = "SPL_FILE_PATH";
+	public static final String SPL_FILE_CONTENT = "SPL_FILE_CONTENT";
+	
+
+	public NewPolicyFileCreationConfigData() {
+		parameterMap = new HashMap();
+	}
+
+	public void addParameter(String key, String value) {
+		if (parameterMap != null) {
+			parameterMap.put(key, value);
+		}
+	}
+
+	public String getParameter(String key) {
+		if (parameterMap != null && parameterMap.containsKey(key)) {
+			return (String) parameterMap.get(key);
+		}
+		return null;
+	}
+}
\ No newline at end of file

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

Added: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/NewPolicyProjectWizard.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/NewPolicyProjectWizard.java?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/NewPolicyProjectWizard.java (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/NewPolicyProjectWizard.java Mon Jan 14 22:52:53 2008
@@ -0,0 +1,401 @@
+/*
+ * 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.ByteArrayInputStream;
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+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.internal.nature.PolicyNature;
+import org.apache.imperius.spl.editor.tool.utils.EclipseFileUtil;
+import org.apache.imperius.spl.editor.tool.utils.PolicyPluginLogUtil;
+import org.apache.imperius.spl.editor.tool.utils.SPLPolicyUtil;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
+
+
+public class NewPolicyProjectWizard extends Wizard implements INewWizard {
+
+	private NewPolicyProjectWizardCreationPage projectPage;
+	
+	private DomainPolicyProjectSelectionPage domainSelectionPage;
+	
+	private final static String IMPERIUS_SPL_CORE_JAR = "imperius-splcore-1.0.0.jar";
+	
+	private static NewPolicyProjectWizard projectWizard = null;
+
+	public NewPolicyProjectWizard() {
+		setWindowTitle(PolicyMessages.getString("SPL_NEWPROJECT_WIZARD_TITLE"));
+		setNeedsProgressMonitor(true);
+		projectWizard = this;
+	}
+	
+
+	/**
+	 * Adds wizard pages.
+	 */
+	public void addPages() {
+		domainSelectionPage = new DomainPolicyProjectSelectionPage(PolicyMessages.getString("SPL_DOMAIN_SELECTION_PAGE"));
+		domainSelectionPage.setTitle(PolicyMessages.getString("SPL_DOMAIN_LANGUAGE_SELECTION"));
+		domainSelectionPage.setDescription(PolicyMessages.getString("SPL_DOMAIN_LANGUAGE_SELECTION_DESC"));
+		addPage(domainSelectionPage);
+		
+		projectPage = new NewPolicyProjectWizardCreationPage(PolicyMessages.getString("SPL_PROJECT_PAGE_TITLE"));
+		projectPage.setTitle(PolicyMessages.getString("SPL_PROJECT_CREATION"));
+		projectPage.setDescription(PolicyMessages.getString("SPL_NAME_FOR_NEW_PROJECT"));
+		addPage(projectPage);
+	}
+
+	public boolean performFinish() {
+		
+		// Get project from projectPage
+		final IProject newProject = projectPage.getProjectHandle();
+		
+		// Get project location as required
+		final IPath projectLoc = getProjectLocation();
+		
+		WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
+			protected void execute(IProgressMonitor monitor)
+			throws CoreException, InvocationTargetException,
+			InterruptedException {
+				monitor.beginTask(PolicyMessages.getString("SPL_PROJECT_CREATION"), 3000);
+				monitor.worked(1000);
+				createProject(newProject, projectLoc, new SubProgressMonitor(monitor, 1000));
+				monitor.done();
+			}
+		};
+		
+		try {
+			getContainer().run(true, false, op);
+		} catch (InvocationTargetException ex) {
+			PolicyPluginLogUtil.logError(ex);
+		} catch (InterruptedException e) {
+			PolicyPluginLogUtil.logError(e);
+		} catch (Exception e) {
+			PolicyPluginLogUtil.logError(e);
+		}
+		
+		// If project exists, return true, if not return false
+		if (newProject.exists()) {
+ 			return true;
+		} else {
+			return false;
+		}
+	}
+	
+	/**
+	 * 
+	 * @param monitor
+	 * @throws CoreException
+	 */
+	private void doCreateSPLCacheFiles(String projectname) throws CoreException {
+		String filePath = "/" + projectname + "/" + PluginActivator.getDefault().getMessage("CIMSPL_CACHE_FILE_NAME");
+		IFile splCacheFile = EclipseFileUtil.getIFile(filePath);
+		createSPLCacheFileAction("", splCacheFile);
+		
+		filePath = "/" + projectname + "/" + PluginActivator.getDefault().getMessage("SPL_OPTIONS_FILE_NAME");
+		splCacheFile = EclipseFileUtil.getIFile(filePath);
+		PluginActivator.getDefault().setProjectType(projectname, domainSelectionPage.getSelectedLanguage());
+		String contents = "SPL_LANGUAGE:="+domainSelectionPage.getSelectedLanguage();
+		createSPLCacheFileAction(contents, splCacheFile);
+		
+		filePath = "/" + projectname + "/" + PluginActivator.getDefault().getMessage("SPL_CUSTOM_EXPR_FILE_NAME");
+		splCacheFile = EclipseFileUtil.getIFile(filePath);
+		createSPLCacheFileAction("", splCacheFile);
+	}
+
+	/**
+	 * 
+	 * @param splsplFile
+	 * @param monitor
+	 */
+	private void createSPLCacheFileAction(String contents, IFile cimsplFile) {
+		try {
+			ByteArrayInputStream baInputStream = new ByteArrayInputStream(contents.getBytes());
+			if(cimsplFile.exists()) {
+				cimsplFile.delete(true, null);
+			}
+			cimsplFile.create(baInputStream, true, null);
+		} catch (CoreException ce) {
+			PolicyPluginLogUtil.logError(PolicyMessages.getString("CACHE_FILE_CREATION_ERROR_") + " ", ce);
+		}
+	}	
+
+	public void init(IWorkbench workbench, IStructuredSelection selection) {
+		// do nothing
+	}
+
+	private IPath getProjectLocation() {
+		IPath projectLoc = null;
+		if (!projectPage.useDefaults())
+			projectLoc = projectPage.getLocationPath();
+		return projectLoc;
+	}
+
+	private void createProject(IProject newProject, IPath projectLoc, IProgressMonitor monitor) {
+		
+		// Create project description
+		IProjectDescription projectDesc = PluginActivator.getWorkspace().newProjectDescription(newProject.getName());
+		projectDesc.setLocation(projectLoc);
+		
+		// Create project
+		try {
+			// check the name of the domain selected
+//			String configJavaProjList = PluginActivator.getDefault().getResourceBundle().getString("CONFIGURE_JAVA_PROJECTS");
+//			if(configJavaProjList.indexOf(domainSelectionPage.getSelectedLanguage()) != -1) {
+				newProject.create(null);
+				newProject.open(null);
+
+				IProjectDescription desc = newProject.getDescription();
+				desc.setNatureIds(new String[] {JavaCore.NATURE_ID,PolicyNature.SPL_NATURE_ID});
+				newProject.setDescription(desc,monitor);		
+   
+				IJavaProject javaProj = JavaCore.create(newProject);
+				
+				IFolder binDir = newProject.getFolder("bin");
+				IPath binPath = binDir.getFullPath();
+				javaProj.setOutputLocation(binPath, null);
+
+				Set entries = new HashSet();
+				entries.addAll(Arrays.asList(javaProj.getRawClasspath()));
+				entries.add(JavaRuntime.getDefaultJREContainerEntry());
+				
+//				System.out.println("KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK"+PluginActivator.getDefault().getBundle().getEntry("/splcore.jar").getPath());
+//				System.out.println(PluginActivator.getDefault().getBundle().getEntry("/splcore.jar").getFile());
+//				
+//				System.out.println(PluginActivator.getDefault().getBundle().getLocation());
+				
+//				String splcorePath = PluginActivator.getDefault().getBundle().getLocation() + "splcore.jar";
+//				String splcorePath = "C:\\2007\\ACProject\\PlugInDevelopment\\eclipse\\workspace\\October\\Oct17\\org.apache.imperius.spl.editor.tool\\" + "splcore.jar";				
+
+				String splcorePath = System.getProperty("user.dir") + "\\" + IMPERIUS_SPL_CORE_JAR;
+				javaProj.setRawClasspath((IClasspathEntry[])entries.toArray(new IClasspathEntry[entries.size()]),monitor);
+				SPLPolicyUtil.addSPLCoreJarToProjectsClasspath(newProject,splcorePath);			
+
+//			} else {
+//				newProject.create(projectDesc, monitor);
+//				newProject.open(monitor);
+//				projectDesc = newProject.getDescription();
+//			
+//				// Set SPL nature
+//				PolicyNature.addNature(newProject, monitor);
+//			}
+
+			// create cache files
+			doCreateSPLCacheFiles(newProject.getName());
+		} catch (CoreException e) {
+			e.printStackTrace();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+	
+	public static NewPolicyProjectWizard getProjectWizard() {
+		return projectWizard;
+	}
+}
+
+class DomainPolicyProjectSelectionPage extends WizardPage {
+	
+	private String languageSelected = "";
+	
+	private Button languageButton = null;
+	
+//	private static int pageCnt = 0;
+	
+
+	/**
+	 * 
+	 * @param title
+	 */
+	public DomainPolicyProjectSelectionPage(String title) {
+		super(title);
+	}
+	
+//	public IWizardPage getNextPage() {
+//		if(pageCnt==1) {
+//			if(!doCheckConfiguration()) {
+//				new DomainConfigurationErrorWindow(getShell(), getConfigInstructions()).open();
+//				return this;
+//			} else {
+//				return super.getNextPage();
+//			}
+//		}
+//		pageCnt++;
+//		return super.getNextPage();
+//	}
+
+//	public boolean doCheckConfiguration() {
+//		boolean successFlag = true;
+//		try {
+//			// get Binders Map
+//			Map extnMapObj = (Map)PluginActivator.getDefault().getLanguageBinders();
+//			Object object = extnMapObj.get(languageSelected);
+//			if(object instanceof IConfigurationElement) {
+//				IConfigurationElement configChild = (IConfigurationElement)object;
+//				configChild.createExecutableExtension("class");
+//			}
+//		} catch(Exception _ex) {
+//			successFlag = false;
+//		}
+//		return successFlag;
+//	}
+
+
+	/**
+	 * 
+	 */
+	public void createControl(Composite parent) {
+		Composite container = new Composite(parent, SWT.NULL);
+		
+		GridLayout layout = new GridLayout();
+		container.setLayout(layout);
+		layout.numColumns = 1;
+		layout.verticalSpacing = 9;
+
+		Label label = new Label(container, SWT.NULL);
+		label.setText(PolicyMessages.getString("SPL_DOMAIN_SELECTION_LABEL"));
+		
+		// get languages supported
+		String languageStr = PluginActivator.getDefault().getBinderNames();
+		if(languageStr != null) {
+			String[] languagesSupported = languageStr.split(",");
+			if(languagesSupported != null && languagesSupported.length > 0) {
+				for(int i=0;i<languagesSupported.length;i++) {
+					languageButton = new Button(container, SWT.RADIO | SWT.LEFT);
+					languageButton.setText(languagesSupported[i]);
+					languageButton.addSelectionListener(new SelectionAdapter() {
+						public void widgetSelected(SelectionEvent event) {
+							languageSelected = ((Button)event.getSource()).getText();
+						}
+					});
+				}
+				if(languagesSupported.length == 1) {
+					languageButton.setSelection(true);
+					languageSelected = languageButton.getText();
+				} 
+				setPageComplete(true);
+			}
+		} else {
+			setPageComplete(false);
+		}
+		setControl(container);
+	}
+
+	
+//	public String getConfigInstructions() {
+//		StringBuffer sbContents = new StringBuffer();
+//		sbContents.append("<form> <p> <b>Instructions to set up CIM environment</b> </p>" );
+//		sbContents.append("<li><b>Step 0:</b> goto eclipse_home\\plugins\\com.ibm.ac.cimspl.extension\\</li>" );
+//		sbContents.append("<li><b>Step 1:</b> copy JMPIImpl.jar from Pegasus site to the path mentioned in Step 0.</li>" );
+//		sbContents.append("<li><b>Step 2:</b> copy the following dll's from Pegasus site to the path mentioned in Step 0. " );
+//		sbContents.append("(JMPIProviderManager.dll, pegclient.dll, pegconfig.dll, pegprovidermanager.dll, pegslp_client.dll, pegcommon.dll, pegslp_client.dll, pegprovider.dll, pegquerycommon.dll, pegwql.dll )</li>" );
+//		sbContents.append("<li><b>Step 3:</b> restart eclipse</li>" );
+//		sbContents.append("</form>" );
+//
+//		return sbContents.toString();
+//	}
+	
+	/**
+	 * 
+	 * @return
+	 */
+	public String getSelectedLanguage() {
+		return languageSelected;
+	}
+
+}
+
+/**
+ * 
+ * 
+ *
+ */
+
+class NewPolicyProjectWizardCreationPage extends WizardNewProjectCreationPage {
+
+	/**
+	 * 
+	 * @param pageName
+	 */
+	public NewPolicyProjectWizardCreationPage(String pageName) {
+		super(pageName);
+	}
+
+	/**
+	 * 
+	 */
+	protected boolean validatePage() {
+		boolean superValidation = super.validatePage();
+		if (!superValidation)
+			return false;
+		try {
+			if(!super.useDefaults()) {
+				String locationPath = super.getLocationPath().toOSString(); 
+				if(locationPath != null && locationPath.indexOf(File.separator) == -1) {
+					setErrorMessage(PolicyMessages.getString("PROJECT_CREATION_LOCATION_ERROR_"));
+					return false;
+				}
+			}
+			//URI.create(getProjectName());
+		} catch (Throwable t) {
+			setErrorMessage(PolicyMessages.getString("PROJECT_CONTAINS_ERROR_"));
+			return false;
+		}
+		setErrorMessage(null);
+		setMessage(null);
+		return true;
+	}
+}

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

Added: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/PolicyTemplatePage.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/PolicyTemplatePage.java?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/PolicyTemplatePage.java (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/PolicyTemplatePage.java Mon Jan 14 22:52:53 2008
@@ -0,0 +1,222 @@
+/*
+ * 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.InputStream;
+import java.io.InputStreamReader;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.imperius.spl.editor.tool.internal.messages.PolicyMessages;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+
+
+
+public class PolicyTemplatePage extends WizardPage {
+
+	private SourceViewer templateViewer;
+	
+	private Map templatesMap;
+	
+	private Combo templateCombo = null;
+	
+	private String selectedTemplateStr = "";
+	
+	private String defaultTemplateKey = null;
+	
+	/**
+	 * 
+	 * @param wizard
+	 * @param selection
+	 */
+	public PolicyTemplatePage(NewPolicyEditorWizard wizard, ISelection selection) {
+		super("wizardPage");
+		setTitle(PolicyMessages.getString("SPL_EDITOR_PAGE_WINDOW_TITLE"));
+		setDescription(PolicyMessages.getString("SPL_TEMPLATE_SELECTION_PAGE_DESC"));
+		templatesMap = new HashMap();
+		loadTemplatesFromFile();
+	}
+
+	/**
+	 * 
+	 */
+	private void loadTemplatesFromFile() {
+		try {
+			InputStream in = getClass().getResourceAsStream("/org/apache/imperius/spl/editor/tool/ui/wizard/templates.txt");
+			BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+			String str = null;
+			String templateStr = "";
+			int templateCnt = 0;
+			String templateKey = "";
+			while((str = reader.readLine()) != null) {
+				if(str.startsWith("!")) {
+					if(templateCnt > 0) {
+						templatesMap.put(templateKey, templateStr);
+						templateStr = "";
+					}
+					templateKey = str.trim();
+					templateCnt++;
+				} else {
+					templateStr = templateStr + str + "\n";
+				}
+			}
+			if(templateCnt > 0) {
+				templatesMap.put(templateKey, templateStr);
+			}
+		} catch(Exception e) {
+			e.printStackTrace();
+		}
+	}
+	
+	/**
+	 * @param aParent
+	 */
+	public void createControl(Composite aParent) {
+		Composite container = new Composite(aParent, SWT.NULL);
+		GridLayout layout = new GridLayout();
+		container.setLayout(layout);
+		layout.numColumns = 2;
+		layout.verticalSpacing = 9;
+		
+		// drop down to list template names
+		Label label = new Label(container, SWT.NULL);
+		label.setText(PolicyMessages.getString("SPL_TEMPLATE_SELECTION_LABEL"));
+		
+		templateCombo = new Combo(container, SWT.READ_ONLY|SWT.DROP_DOWN);
+		String[] templates = getTemplateNamesString().split(",");
+		if(templates != null && templates.length > 0) {
+			for (int i = 0; i < templates.length; i++) {
+				templateCombo.add(templates[i]);
+			}
+			templateCombo.select(0);
+			defaultTemplateKey = templates[0];
+			templateCombo.addSelectionListener(new SelectionAdapter() {
+				public void widgetSelected(SelectionEvent event) {
+					if(event.getSource() instanceof Combo) {
+						int selectedIndex = ((Combo)event.getSource()).getSelectionIndex();
+						changeTemplatePreview((String)templateCombo.getItem(selectedIndex));
+					}
+				}
+			});
+		}
+		
+		// viewer to see the selected template
+		label = new Label(container, SWT.NULL);
+		label.setText(PolicyMessages.getString("SPL_TEMPLATE_PREVIEW_SECTION"));
+		label = new Label(container, SWT.NULL); // dummy one
+		Control previewControl = createPreviewer(container);
+		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+		gd.horizontalSpan = 2;
+        gd.widthHint = convertWidthInCharsToPixels(25);
+        gd.heightHint = 200;
+        previewControl.setLayoutData(gd);
+        
+        initializeDefault();
+		setControl(container);
+	}
+
+	/**
+	 * 
+	 */
+	private void initializeDefault() {
+		changeTemplatePreview(defaultTemplateKey);
+	}
+
+	/**
+	 * 
+	 * @return
+	 */
+	private String getTemplateNamesString() {
+		String templateNameStr = "";
+		try {
+			if(templatesMap != null && templatesMap.size() > 0) {
+				Iterator iterObj = templatesMap.keySet().iterator();
+				while(iterObj.hasNext()) {
+					String key = (String)iterObj.next();
+					templateNameStr = templateNameStr + key.substring(key.indexOf("!")+1) + (iterObj.hasNext()?",":"");
+				}
+			}
+		} catch(Exception e) {
+			// do nothing
+		}
+		return templateNameStr;
+	}
+	
+	/**
+	 * 
+	 * @param container
+	 * @return
+	 */
+	private Control createPreviewer(Composite container) {
+		templateViewer = new SourceViewer(container, null, null, false, 2816);
+        templateViewer.configure(new TemplateSourceViewerConfiguration());
+        //templateViewer.setEditable(false);
+        Font font = JFaceResources.getFont("org.eclipse.jface.textfont");
+        templateViewer.getTextWidget().setFont(font);
+        templateViewer.setDocument(new Document(""));
+		return templateViewer.getControl();
+	}
+
+	/**
+	 * 
+	 * @param templateKey
+	 */
+	private void changeTemplatePreview(String templateKey) {
+		if(templateKey != null && templateKey.length() > 0) {
+			try {
+				selectedTemplateStr = (String)templatesMap.get("!"+templateKey);
+				templateViewer.getDocument().set(selectedTemplateStr);
+				templateViewer.refresh();
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+		}
+	}
+
+	/**
+	 * 
+	 * @return
+	 */
+	public String getSelectedTemplate() {
+		return selectedTemplateStr;
+	}
+	
+}

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

Added: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/TemplateSourceViewerConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/TemplateSourceViewerConfiguration.java?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/TemplateSourceViewerConfiguration.java (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/TemplateSourceViewerConfiguration.java Mon Jan 14 22:52:53 2008
@@ -0,0 +1,80 @@
+/*
+ * 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 org.apache.imperius.spl.editor.tool.ui.IPolicyTokenColorManager;
+import org.apache.imperius.spl.editor.tool.ui.PolicyTokenColorManagerImpl;
+import org.apache.imperius.spl.editor.tool.ui.internal.scanners.IPolicyPartitionScanner;
+import org.apache.imperius.spl.editor.tool.ui.internal.scanners.PolicyFileCommentScanner;
+import org.apache.imperius.spl.editor.tool.ui.internal.scanners.PolicyFileDefaultCodeScanner;
+import org.apache.imperius.spl.editor.tool.ui.internal.scanners.PolicyPartitionScannerImpl;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.presentation.IPresentationReconciler;
+import org.eclipse.jface.text.presentation.PresentationReconciler;
+import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;
+
+
+public class TemplateSourceViewerConfiguration extends TextSourceViewerConfiguration {
+
+	public TemplateSourceViewerConfiguration() {
+		
+	}
+	public String[] getConfiguredContentTypes(ISourceViewer aSourceViewer) {
+		return PolicyPartitionScannerImpl.getDocumentPartitionTypes();
+	}
+	
+    /**
+	 * Returns the presentation reconciler ready to be used with the given source viewer.
+	 *
+	 * @param sourceViewer the source viewer
+	 * @return the presentation reconciler or <code>null</code> if presentation reconciling should not be supported
+     */
+	public IPresentationReconciler getPresentationReconciler(ISourceViewer aViewer) {
+		
+		PresentationReconciler reconciler = new PresentationReconciler();
+
+		// get Token Color Manager
+		IPolicyTokenColorManager pTokenColorManager = PolicyTokenColorManagerImpl.getTokenColorManagerInstance();
+
+		// set reconciler to generic partitions ie comments
+		DefaultDamagerRepairer damagerRepairer = new DefaultDamagerRepairer(new PolicyFileCommentScanner(pTokenColorManager));
+		reconciler.setDamager(damagerRepairer, IPolicyPartitionScanner.SPL_SINGLELINE_COMMENT);
+		reconciler.setRepairer(damagerRepairer, IPolicyPartitionScanner.SPL_SINGLELINE_COMMENT);
+
+		damagerRepairer = new DefaultDamagerRepairer(new PolicyFileCommentScanner(pTokenColorManager));
+		reconciler.setDamager(damagerRepairer, IPolicyPartitionScanner.SPL_MULTILINE_COMMENT);
+		reconciler.setRepairer(damagerRepairer, IPolicyPartitionScanner.SPL_MULTILINE_COMMENT);
+		
+		damagerRepairer = new DefaultDamagerRepairer(new PolicyFileDefaultCodeScanner(pTokenColorManager));
+		reconciler.setDamager(damagerRepairer, IDocument.DEFAULT_CONTENT_TYPE);
+		reconciler.setRepairer(damagerRepairer, IDocument.DEFAULT_CONTENT_TYPE);
+
+		return reconciler;
+	}
+	
+
+}

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

Added: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/templates.txt
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/templates.txt?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/templates.txt (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/ui/wizard/templates.txt Mon Jan 14 22:52:53 2008
@@ -0,0 +1,58 @@
+/*
+ * 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>
+ *
+ */
+
+!default
+Import <stmt>;
+Strategy Execute_All_Applicable;
+Declaration
+{
+	<stmts>
+    Macro
+    {
+    	<stmts>
+    }
+}
+
+!policy1
+Import <stmt>;
+Strategy Execute_All_Applicable;
+Declaration
+{
+	<stmts>
+    Macro
+    {
+    	<stmts>
+    }
+}
+Policy 
+{
+    Condition 
+    {
+    	<stmts>
+    }   
+    Decision 
+    {   
+        <stmts>
+    }
+}:<priority_number>;

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

Added: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/utils/AbstractClassDetails.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/utils/AbstractClassDetails.java?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/utils/AbstractClassDetails.java (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/utils/AbstractClassDetails.java Mon Jan 14 22:52:53 2008
@@ -0,0 +1,114 @@
+/*
+ * 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.utils;
+
+import java.util.List;
+
+public class AbstractClassDetails {
+
+	private String domain;
+	
+	private String classname;
+	
+	private List properties;
+	
+	private List methods;
+	
+	public AbstractClassDetails() {
+		
+	}
+	
+	
+
+	/**
+	 * @return the classname
+	 */
+	public String getClassname() {
+		return classname;
+	}
+
+	/**
+	 * @param classname the classname to set
+	 */
+	public void setClassname(String classname) {
+		this.classname = classname;
+	}
+
+
+
+	/**
+	 * @return the properties
+	 */
+	public List getProperties() {
+		return properties;
+	}
+
+
+
+	/**
+	 * @param properties the properties to set
+	 */
+	public void setProperties(List properties) {
+		this.properties = properties;
+	}
+
+
+
+	/**
+	 * @return the methods
+	 */
+	public List getMethods() {
+		return methods;
+	}
+
+
+
+	/**
+	 * @param methods the methods to set
+	 */
+	public void setMethods(List methods) {
+		this.methods = methods;
+	}
+
+
+
+	/**
+	 * @return the domain
+	 */
+	public String getDomain() {
+		return domain;
+	}
+
+
+
+	/**
+	 * @param domain the domain to set
+	 */
+	public void setDomain(String domain) {
+		this.domain = domain;
+	}
+	
+}

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

Added: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/utils/ClassMethod.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/utils/ClassMethod.java?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/utils/ClassMethod.java (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/utils/ClassMethod.java Mon Jan 14 22:52:53 2008
@@ -0,0 +1,113 @@
+/*
+ * 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.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ClassMethod {
+
+	private String methodName;
+	
+	private String methodType;
+	
+	private List methodParameterList;
+
+	/**
+	 * 
+	 */
+	public ClassMethod() {
+		
+	}
+
+	/**
+	 * 
+	 * @return
+	 */
+	public int getParamCount() {
+		if(methodParameterList == null) {
+			return 0;
+		}
+		return methodParameterList.size();
+	}
+
+	/**
+	 * 
+	 * @param mp
+	 */
+	public void addMethodParameter(MethodParameter mp) {
+		if(methodParameterList == null) {
+			methodParameterList = new ArrayList();
+		}
+		methodParameterList.add(mp);
+	}
+
+	/**
+	 * 
+	 * @param index
+	 * @return
+	 */
+	public MethodParameter getParameter(int index) {
+		if(methodParameterList != null && index < methodParameterList.size()) {
+			return (MethodParameter)methodParameterList.get(index);
+		}
+		return null;
+	}
+
+	/**
+	 * @return the methodName
+	 */
+	public String getMethodName() {
+		return methodName;
+	}
+
+	/**
+	 * @param methodName the methodName to set
+	 */
+	public void setMethodName(String methodName) {
+		this.methodName = methodName;
+	}
+
+	/**
+	 * @return the methodType
+	 */
+	public String getMethodType() {
+		return methodType;
+	}
+
+	/**
+	 * @param methodType the methodType to set
+	 */
+	public void setMethodType(String methodType) {
+		this.methodType = methodType;
+	}
+
+	/**
+	 * @return the methodParameterList
+	 */
+	public List getMethodParameterList() {
+		return methodParameterList;
+	}
+}

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

Added: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/utils/ClassProperty.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/utils/ClassProperty.java?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/utils/ClassProperty.java (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/utils/ClassProperty.java Mon Jan 14 22:52:53 2008
@@ -0,0 +1,67 @@
+/*
+ * 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.utils;
+
+public class ClassProperty {
+	
+	private String propertyName;
+	
+	private String propertyType;
+	
+	public ClassProperty() {
+		
+	}
+
+	/**
+	 * @return the propertyName
+	 */
+	public String getPropertyName() {
+		return propertyName;
+	}
+
+	/**
+	 * @param propertyName the propertyName to set
+	 */
+	public void setPropertyName(String propertyName) {
+		this.propertyName = propertyName;
+	}
+
+	/**
+	 * @return the propertyType
+	 */
+	public String getPropertyType() {
+		return propertyType;
+	}
+
+	/**
+	 * @param propertyType the propertyType to set
+	 */
+	public void setPropertyType(String propertyType) {
+		this.propertyType = propertyType;
+	}
+	
+	
+}

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

Added: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/utils/ClasspathChangeListener.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/utils/ClasspathChangeListener.java?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/utils/ClasspathChangeListener.java (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/utils/ClasspathChangeListener.java Mon Jan 14 22:52:53 2008
@@ -0,0 +1,225 @@
+/*
+ * 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.utils;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+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.PluginActivator;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.runtime.CoreException;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+
+public class ClasspathChangeListener implements IResourceChangeListener {
+
+//	private static final IPath CLASS_PATH = new Path("test/.classpath");
+	
+	private IProject fProject = null;
+	
+//	private boolean isChanged = false;
+	
+	public void resourceChanged(IResourceChangeEvent event) {
+
+		if (event.getType() != IResourceChangeEvent.POST_CHANGE)
+           return;
+		
+        IResourceDelta rootDelta = event.getDelta();
+        
+        //get the delta, if any, for the .classpath file
+//        IResourceDelta docDelta = rootDelta.findMember(CLASS_PATH);
+//        if (docDelta == null)
+//           return;
+        
+        IResourceDeltaVisitor visitor = new IResourceDeltaVisitor() {
+           public boolean visit(IResourceDelta delta) {
+
+        	   //only interested in changed resources (not added or removed)
+              if (delta.getKind() != IResourceDelta.CHANGED)
+                 return true;
+              
+              //only interested in content changes
+              if ((delta.getFlags() & IResourceDelta.CONTENT) == 0)
+                 return true;
+
+              IResource resource = delta.getResource();
+
+              //only interested in files with the "txt" extension
+              if (resource.getType() == IResource.FILE  && resource.getName().equals(".classpath")) {
+            	  IFile file = (IFile)resource;
+            	  fProject = file.getProject();
+            	  if(PluginActivator.getDefault().getProjectType(fProject.getName()) != null ) {
+            		  checkClassPathEntries(fProject, file);
+            	  }
+              }
+              return true;
+           }
+        };
+        
+        try {
+        	rootDelta.accept(visitor);
+//    		if(isChanged) {
+//    			PluginActivator.getDefault().getPreferenceStore().setValue("CUSTOM_EXPR_CHANGED", isChanged);
+//    			isChanged = false;
+//    		}
+        	
+        } catch (CoreException e) {
+           //open error dialog with syncExec or print to plugin log file
+        }
+	}
+	
+	private void checkClassPathEntries(IProject aProject, IFile classpathFile) {
+		try {
+			if(classpathFile != null) {
+				SaxXMLHandler handler = new SaxXMLHandler();
+				SAXParserFactory factory = SAXParserFactory.newInstance();
+				SAXParser saxParser = factory.newSAXParser();
+				saxParser.parse(classpathFile.getContents(), handler);
+				List clspathList = handler.getJarFilesList();
+				
+				// get plugins list
+				Map innerMap = PluginActivator.getDefault().getCustomExprMap(aProject.getName());
+				
+				if(innerMap != null) {
+					Map tempInnerMap = new HashMap();
+					tempInnerMap.putAll(innerMap);
+//					System.out.println("Hi I am innerMap"+innerMap);
+//					System.out.println("Hi I am uuu"+clspathList);
+					if(clspathList != null && (clspathList.size() < innerMap.size())) {
+						// loop thru map
+						Iterator iter = tempInnerMap.keySet().iterator();
+						while(iter.hasNext()) {
+							String key = (String)iter.next();
+							if(!clspathList.contains(key)) {
+								innerMap.remove(key);
+//								isChanged = true;
+							}
+						}
+						// update the file and map
+						PluginActivator.getDefault().setCustomExprMap(aProject, innerMap);
+					}
+				}
+			}
+		} catch(Exception e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+}
+
+class SaxXMLHandler 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 String strJarPath;
+	
+	private List jarpathEntriesList;
+	
+	public SaxXMLHandler() {
+		jarpathEntriesList = new ArrayList();
+	}
+	
+	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) {
+					jarpathEntriesList.add(new File(strJarPath).getName());
+				}
+				
+			}
+		}
+	}
+	
+	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 List getJarFilesList() {
+		return jarpathEntriesList;
+	}
+
+}

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

Added: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/utils/ClasspathXMLHandler.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/utils/ClasspathXMLHandler.java?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/utils/ClasspathXMLHandler.java (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/utils/ClasspathXMLHandler.java Mon Jan 14 22:52:53 2008
@@ -0,0 +1,147 @@
+/*
+ * 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.utils;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+public class ClasspathXMLHandler extends DefaultHandler {
+	
+	private final static String CLASSPATH_ENTRY = "classpathentry";
+	
+	public final static String IMPERIUS_SPL_CORE_JAR = "imperius-splcore-1.0.0.jar";
+	
+	private final static String LIB = "lib";
+	
+	private final static String KIND = "kind";
+	
+	private final static String PATH = "path";
+	
+	private List classpathEntriesList = null;
+	
+	private String projectPath = "";
+	
+	private final static String ATTRIBUTE = "attribute";
+	
+	private final static String ATTRI_NAME = "name";
+
+	private String pathValue = null;
+	
+	private boolean isCustom = false;
+	
+	public ClasspathXMLHandler() {
+		classpathEntriesList = new ArrayList();
+	}
+	
+	public void startElement(String uri, String localName, String name,
+			Attributes attributes) throws SAXException {
+		// check for classpath entry
+		if(CLASSPATH_ENTRY.equals(name)) {
+			isCustom = false;
+			pathValue = null;
+			addEntriesToList(attributes);
+		} else if(ATTRIBUTE.equals(name)) {
+			if(isCustomAttributeElement(attributes)) {
+				isCustom = true;
+			} 
+		}
+	}
+	
+	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 addEntriesToList(Attributes attributes) {
+		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(KIND.equals(qName) && LIB.equals(value)) {
+					continue;
+				} else if(PATH.equals(qName) && !"".equals(value)) {
+					pathValue = value;
+					break;
+				} else {
+					continue;
+				}
+			}
+		}
+	}
+	
+	
+	public void endElement(String uri, String localName, String name)
+			throws SAXException {
+		// do nothing
+		if(CLASSPATH_ENTRY.equals(name)) {
+			if(!isCustom) {
+				if(pathValue != null) {
+					//if(pathValue.endsWith(IMPERIUS_SPL_CORE_JAR)) 
+					{
+						classpathEntriesList.add(pathValue);
+					} 
+					/*else 
+					{
+						classpathEntriesList.add(projectPath + File.separator +  pathValue);
+					}*/
+					
+					
+				}
+			}
+		} else if(ATTRIBUTE.equals(name)) {
+			if(isCustom && pathValue != null) { 
+				classpathEntriesList.add(pathValue);
+			} 
+		}
+//		System.out.println("classpathEntriesList"+classpathEntriesList);
+	}
+	
+	public List getClassPathEntriesList() {
+		return classpathEntriesList;
+	}
+	
+	public void setProjectPath(String aProjectPath) {
+		projectPath = aProjectPath;
+	}
+	
+
+}

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

Added: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/utils/DomainConfigurationErrorWindow.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/utils/DomainConfigurationErrorWindow.java?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/utils/DomainConfigurationErrorWindow.java (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/utils/DomainConfigurationErrorWindow.java Mon Jan 14 22:52:53 2008
@@ -0,0 +1,130 @@
+/*
+ * 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.utils;
+
+import org.eclipse.jface.window.ApplicationWindow;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.forms.events.ExpansionAdapter;
+import org.eclipse.ui.forms.events.ExpansionEvent;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.Form;
+import org.eclipse.ui.forms.widgets.FormText;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.TableWrapLayout;
+
+public class DomainConfigurationErrorWindow extends ApplicationWindow {
+
+	private FormToolkit toolkit = null;
+
+	private Form form = null;
+
+	private String configInstructions = null;
+
+	public DomainConfigurationErrorWindow(Shell parentShell, String fConfigInstr) {
+		super(parentShell);
+		configInstructions = fConfigInstr;
+	}
+
+	public void openApplication() {
+		// Don't return from open() until window closes
+		setBlockOnOpen(true);
+
+		// Open the main window
+		open();
+
+		// Dispose the display
+		Display.getCurrent().dispose();
+	}
+
+	protected void configureShell(Shell shell) {
+		super.configureShell(shell);
+		shell.setText("Simulated Run Application");
+	}
+
+	protected void initializeBounds() {
+		getShell().setSize(500, 400);
+	}
+
+	protected Control createContents(Composite parent) {
+		Composite composite = new Composite(parent, SWT.NULL);
+		composite.setLayout(new GridLayout());
+
+		// Sets up the toolkit.
+		toolkit = new FormToolkit(getShell().getDisplay());
+
+		// Creates a form instance.
+		form = toolkit.createForm(composite);
+		form.setLayoutData(new GridData(GridData.FILL_BOTH));
+	
+		// Sets title.
+		form.setText("Configuaration Error");
+		createGUI();
+		return composite;
+	}
+	
+	private void createGUI() {
+		form.getBody().setLayout(new GridLayout());
+		toolkit.createLabel(form.getBody(), "Environment is not configured to run");
+		form.getBody().setLayout(new TableWrapLayout());
+	
+		ExpandableComposite ec1 = toolkit.createExpandableComposite(form.getBody(), ExpandableComposite.TREE_NODE | ExpandableComposite.EXPANDED);
+		ec1.setText("Click here to see Instructions");
+		FormText text = toolkit.createFormText(ec1, false);
+		text.setText(configInstructions, true, false);
+		ec1.setClient(text);
+		ec1.addExpansionListener(new ExpansionAdapter() {
+			public void expansionStateChanged(ExpansionEvent e) {
+				// resizes the application window.
+				if(e.getState()) {
+					getShell().setSize(500, 400);
+				}
+			}
+		});
+	}
+
+	public static String getConfigInstructions() {
+		StringBuffer sbContents = new StringBuffer();
+		sbContents.append("<form> <p> <b>Instructions to set up CIM environment</b> </p>" );
+		sbContents.append("<li><b>Step 0:</b> goto eclipse_home\\plugins\\com.ibm.ac.cimspl.extension\\</li>" );
+		sbContents.append("<li><b>Step 1:</b> copy JMPIImpl.jar from Pegasus site to the path mentioned in Step 0.</li>" );
+		sbContents.append("<li><b>Step 2:</b> copy the following dll's from Pegasus site to the path mentioned in Step 0. " );
+		sbContents.append("(JMPIProviderManager.dll, pegclient.dll, pegconfig.dll, pegprovidermanager.dll, pegslp_client.dll, pegcommon.dll, pegslp_client.dll, pegprovider.dll, pegquerycommon.dll, pegwql.dll )</li>" );
+		sbContents.append("<li><b>Step 3:</b> restart eclipse</li>" );
+		sbContents.append("</form>" );
+		return sbContents.toString();
+	}
+	
+	public static void main(String[] args) {
+		DomainConfigurationErrorWindow win = new DomainConfigurationErrorWindow(new Shell(), getConfigInstructions());
+		win.setBlockOnOpen(true);
+		win.open();
+	}
+}

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

Added: incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/utils/EclipseFileUtil.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/utils/EclipseFileUtil.java?rev=612031&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/utils/EclipseFileUtil.java (added)
+++ incubator/imperius/trunk/imperius-spleditorcore/src/org/apache/imperius/spl/editor/tool/utils/EclipseFileUtil.java Mon Jan 14 22:52:53 2008
@@ -0,0 +1,176 @@
+/*
+ * 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.utils;
+
+import java.io.ByteArrayInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import org.apache.imperius.spl.editor.tool.PluginActivator;
+import org.apache.imperius.spl.editor.tool.internal.messages.PolicyMessages;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+//import org.eclipse.emf.common.util.URI;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.osgi.framework.Bundle;
+
+
+public class EclipseFileUtil {
+
+	/**
+	 * 
+	 * @param root
+	 * @param filePath
+	 * @return
+	 * @throws CoreException
+	 */
+	public static IFile getIFile(IWorkspaceRoot root, String filePath) throws CoreException {
+		if (filePath.startsWith("platform:/resource/")) {
+			int beginIndex = filePath.lastIndexOf("platform:/resource/") + "platform:/resource/".length();
+			//filePath = URI.decode(filePath.substring(beginIndex));
+		} else if (filePath.startsWith("platform:/plugin/")) {
+			IPath path = new Path(filePath);
+			return root.getFile(path);
+		}
+		String fileName = filePath.substring(filePath.lastIndexOf('/') + 1);
+		String parentContainer = filePath.substring(0, filePath.lastIndexOf('/'));
+		IResource resource = root.findMember(new Path(parentContainer));
+		if (!resource.exists() || !(resource instanceof IContainer)) {
+			throw new CoreException(PolicyPluginLogUtil.createStatus(IStatus.ERROR, IStatus.OK, NLS.bind(PolicyMessages.getString("CONTAINER_DOES_NOT_EXISTS_ERROR_"), parentContainer), null));
+		}
+		IContainer container = (IContainer) resource;
+		return container.getFile(new Path(fileName));
+	}
+
+	/**
+	 * 
+	 * @param filePath
+	 * @return
+	 * @throws CoreException
+	 */
+	public static IFile getIFile(String filePath) throws CoreException {
+		IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+		return getIFile(root, filePath);
+	}
+
+	/**
+	 * 
+	 * @param filePath
+	 * @return
+	 * @throws CoreException
+	 */
+	public static IFile getCacheFile(String filePath) throws CoreException {
+		IFile file = getIFile(filePath);
+		if(!file.exists()) {
+			// create file
+			ByteArrayInputStream iSource = new ByteArrayInputStream("".getBytes());
+			file.create(iSource, true, null);
+		}
+		return file;
+	}
+	
+	private static InputStream relativeStream(String relName)
+			throws IOException {
+		Bundle bundle = PluginActivator.getDefault().getBundle();
+		Path path = new Path(relName);
+		URL fileURL = Platform.find(bundle, path);
+		if (fileURL == null) {
+			throw new FileNotFoundException(relName);
+		}
+
+		InputStream is = fileURL.openStream();
+		return is;
+	}
+
+	/**
+	 * Load an image, such as icons/foo.gif, from the icons directory.
+	 */
+	public static Image loadImage(Display display, String relName) {
+		InputStream is = null;
+		Image img;
+		try {
+			is = relativeStream(relName);
+			img = new Image(display, is);
+		} catch (IOException e) {
+			return null;
+		} finally {
+			if (is != null) {
+				try {
+					is.close();
+				} catch (IOException e1) {
+					// If close fails, ignore.
+				}
+			}
+		}
+		return img;
+	}
+	
+	/**
+	 * 
+	 * @param root
+	 * @param filePath
+	 * @return
+	 * @throws CoreException
+	 */
+	public static IFolder getIFolder(IWorkspaceRoot root, String filePath) throws CoreException {
+		if (filePath.startsWith("platform:/resource/")) {
+			int beginIndex = filePath.lastIndexOf("platform:/resource/") + "platform:/resource/".length();
+			//filePath = URI.decode(filePath.substring(beginIndex));
+		} else if (filePath.startsWith("platform:/plugin/")) {
+			IPath path = new Path(filePath);
+			return root.getFolder(path);
+		}
+		String fileName = filePath.substring(filePath.lastIndexOf('/') + 1);
+		String parentContainer = filePath.substring(0, filePath.lastIndexOf('/'));
+		IResource resource = root.findMember(new Path(parentContainer));
+		if (!resource.exists() || !(resource instanceof IContainer)) {
+			throw new CoreException(PolicyPluginLogUtil.createStatus(IStatus.ERROR, IStatus.OK, NLS.bind(PolicyMessages.getString("CONTAINER_DOES_NOT_EXISTS_ERROR_"), parentContainer), null));
+		}
+		IContainer container = (IContainer) resource;
+		return container.getFolder(new Path(fileName));
+	}
+
+	
+	
+	public static IFolder createFolder(String filePath) throws CoreException {
+		IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+		return getIFolder(root, filePath);
+	}
+	
+}

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



Mime
View raw message