[jboss-svn-commits] JBL Code SVN: r9134 - in labs/jbossrules/trunk: org and 10 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Jan 30 08:22:43 EST 2007


Author: mshaw
Date: 2007-01-30 08:22:43 -0500 (Tue, 30 Jan 2007)
New Revision: 9134

Added:
   labs/jbossrules/trunk/org/
   labs/jbossrules/trunk/org/drools/
   labs/jbossrules/trunk/org/drools/testing/
   labs/jbossrules/trunk/org/drools/testing/plugin/
   labs/jbossrules/trunk/org/drools/testing/plugin/action/
   labs/jbossrules/trunk/org/drools/testing/plugin/action/RtlAction.java
   labs/jbossrules/trunk/org/drools/testing/plugin/editors/
   labs/jbossrules/trunk/org/drools/testing/plugin/editors/EditorConstants.java
   labs/jbossrules/trunk/org/drools/testing/plugin/editors/RTLEditor.java
   labs/jbossrules/trunk/org/drools/testing/plugin/editors/RTLEditorContributor.java
   labs/jbossrules/trunk/org/drools/testing/plugin/listeners/
   labs/jbossrules/trunk/org/drools/testing/plugin/listeners/TreeViewSelectionListener.java
   labs/jbossrules/trunk/org/drools/testing/plugin/mockobjects/
   labs/jbossrules/trunk/org/drools/testing/plugin/mockobjects/MockObject.java
   labs/jbossrules/trunk/org/drools/testing/plugin/views/
   labs/jbossrules/trunk/org/drools/testing/plugin/views/RtlOutlinePage.java
   labs/jbossrules/trunk/org/drools/testing/plugin/wizards/
   labs/jbossrules/trunk/org/drools/testing/plugin/wizards/GenerateRtlWizard.java
   labs/jbossrules/trunk/org/drools/testing/plugin/wizards/RtlNewPage.java
   labs/jbossrules/trunk/org/drools/testing/plugin/wizards/SelectRulesPage.java
   labs/jbossrules/trunk/org/drools/testing/plugin/wizards/model/
   labs/jbossrules/trunk/org/drools/testing/plugin/wizards/model/RtlModel.java
Log:


Added: labs/jbossrules/trunk/org/drools/testing/plugin/action/RtlAction.java
===================================================================
--- labs/jbossrules/trunk/org/drools/testing/plugin/action/RtlAction.java	                        (rev 0)
+++ labs/jbossrules/trunk/org/drools/testing/plugin/action/RtlAction.java	2007-01-30 13:22:43 UTC (rev 9134)
@@ -0,0 +1,40 @@
+package org.drools.testing.plugin.action;
+
+import org.drools.testing.plugin.wizards.GenerateRtlWizard;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.PlatformUI;
+
+public class RtlAction implements IWorkbenchWindowActionDelegate {
+	
+	private IWorkbenchWindow window;
+
+	public void dispose() {
+		// TODO Auto-generated method stub
+
+	}
+
+	public void init(IWorkbenchWindow window) {
+		this.window = window;
+
+	}
+
+	public void run(IAction action) {
+		GenerateRtlWizard generateRtlWizard = new GenerateRtlWizard();
+		generateRtlWizard.init(PlatformUI.getWorkbench(), new StructuredSelection(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection()));
+		WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), 
+				generateRtlWizard);
+		dialog.open();
+
+	}
+
+	public void selectionChanged(IAction action, ISelection selection) {
+		// TODO Auto-generated method stub
+
+	}
+
+}

Added: labs/jbossrules/trunk/org/drools/testing/plugin/editors/EditorConstants.java
===================================================================
--- labs/jbossrules/trunk/org/drools/testing/plugin/editors/EditorConstants.java	                        (rev 0)
+++ labs/jbossrules/trunk/org/drools/testing/plugin/editors/EditorConstants.java	2007-01-30 13:22:43 UTC (rev 9134)
@@ -0,0 +1,24 @@
+package org.drools.testing.plugin.editors;
+
+public final class EditorConstants {
+
+	public static final String name = "Rtl";
+	
+	public interface MenuTitles {
+		
+		public final static String MENU_HEADER = "Rtl";
+		
+		public final static String GENERATE_RTL = "Generate Rtl";
+	}
+	
+	public interface ToolBar {
+		
+		public final static String GENERATE = "Generate";
+		
+		public final static String GENERATE_TOOLTIP = "Click here to generate an Rtl file";
+		
+		public final static String GENERATE_IMG = "/icons/RTL_small.gif";
+	}
+	
+	
+}

Added: labs/jbossrules/trunk/org/drools/testing/plugin/editors/RTLEditor.java
===================================================================
--- labs/jbossrules/trunk/org/drools/testing/plugin/editors/RTLEditor.java	                        (rev 0)
+++ labs/jbossrules/trunk/org/drools/testing/plugin/editors/RTLEditor.java	2007-01-30 13:22:43 UTC (rev 9134)
@@ -0,0 +1,244 @@
+package org.drools.testing.plugin.editors;
+
+
+import java.io.StringWriter;
+import java.text.Collator;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.layout.FillLayout;
+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.Display;
+import org.eclipse.swt.widgets.FontDialog;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.editors.text.TextEditor;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.part.MultiPageEditorPart;
+
+/**
+ * An example showing how to create a multi-page editor.
+ * This example has 3 pages:
+ * <ul>
+ * <li>page 0 contains a nested text editor.
+ * <li>page 1 allows you to change the font used in page 2
+ * <li>page 2 shows the words in page 0 in sorted order
+ * </ul>
+ */
+public class RTLEditor extends MultiPageEditorPart implements IResourceChangeListener{
+
+	/** The text editor used in page 0. */
+	private TextEditor editor;
+
+	/** The font chosen in page 1. */
+	private Font font;
+
+	/** The text widget used in page 2. */
+	private StyledText text;
+	/**
+	 * Creates a multi-page editor example.
+	 */
+	public RTLEditor() {
+		super();
+		ResourcesPlugin.getWorkspace().addResourceChangeListener(this);
+	}
+	/**
+	 * Creates page 0 of the multi-page editor,
+	 * which contains a text editor.
+	 */
+	void createPage0() {
+		try {
+			editor = new TextEditor();
+			int index = addPage(editor, getEditorInput());
+		} catch (PartInitException e) {
+			ErrorDialog.openError(
+				getSite().getShell(),
+				"Error creating nested text editor",
+				null,
+				e.getStatus());
+		}
+	}
+	/**
+	 * Creates page 1 of the multi-page editor,
+	 * which allows you to change the font used in page 2.
+	 */
+	void createPage1() {
+
+		Composite composite = new Composite(getContainer(), SWT.NONE);
+		GridLayout layout = new GridLayout();
+		composite.setLayout(layout);
+		layout.numColumns = 2;
+		
+		Button fontButton = new Button(composite, SWT.NONE);
+		GridData gd = new GridData(GridData.BEGINNING);
+		gd.horizontalSpan = 2;
+		fontButton.setLayoutData(gd);
+		fontButton.setText("Change Font...");
+		
+		fontButton.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent event) {
+				setFont();
+			}
+		});
+
+		int index = addPage(composite);
+		setPageText(index, "Properties");
+	}
+	/**
+	 * Creates page 2 of the multi-page editor,
+	 * which shows the sorted text.
+	 */
+	void createPage2() {
+		Composite composite = new Composite(getContainer(), SWT.NONE);
+		FillLayout layout = new FillLayout();
+		composite.setLayout(layout);
+		text = new StyledText(composite, SWT.H_SCROLL | SWT.V_SCROLL);
+		text.setEditable(false);
+
+		int index = addPage(composite);
+		setPageText(index, "Preview");
+	}
+	/**
+	 * Creates the pages of the multi-page editor.
+	 */
+	protected void createPages() {
+		createPage0();
+		createPage1();
+		createPage2();
+	}
+	/**
+	 * The <code>MultiPageEditorPart</code> implementation of this 
+	 * <code>IWorkbenchPart</code> method disposes all nested editors.
+	 * Subclasses may extend.
+	 */
+	public void dispose() {
+		ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
+		super.dispose();
+	}
+	/**
+	 * Saves the multi-page editor's document.
+	 */
+	public void doSave(IProgressMonitor monitor) {
+		getEditor(0).doSave(monitor);
+	}
+	/**
+	 * Saves the multi-page editor's document as another file.
+	 * Also updates the text for page 0's tab, and updates this multi-page editor's input
+	 * to correspond to the nested editor's.
+	 */
+	public void doSaveAs() {
+		IEditorPart editor = getEditor(0);
+		editor.doSaveAs();
+		setPageText(0, editor.getTitle());
+		setInput(editor.getEditorInput());
+	}
+	/* (non-Javadoc)
+	 * Method declared on IEditorPart
+	 */
+	public void gotoMarker(IMarker marker) {
+		setActivePage(0);
+		IDE.gotoMarker(getEditor(0), marker);
+	}
+	/**
+	 * The <code>MultiPageEditorExample</code> implementation of this method
+	 * checks that the input is an instance of <code>IFileEditorInput</code>.
+	 */
+	public void init(IEditorSite site, IEditorInput editorInput)
+		throws PartInitException {
+		if (!(editorInput instanceof IFileEditorInput))
+			throw new PartInitException("Invalid Input: Must be IFileEditorInput");
+		super.init(site, editorInput);
+	}
+	/* (non-Javadoc)
+	 * Method declared on IEditorPart.
+	 */
+	public boolean isSaveAsAllowed() {
+		return true;
+	}
+	/**
+	 * Calculates the contents of page 2 when the it is activated.
+	 */
+	protected void pageChange(int newPageIndex) {
+		super.pageChange(newPageIndex);
+		if (newPageIndex == 2) {
+			sortWords();
+		}
+	}
+	/**
+	 * Closes all project files on project close.
+	 */
+	public void resourceChanged(final IResourceChangeEvent event){
+		if(event.getType() == IResourceChangeEvent.PRE_CLOSE){
+			Display.getDefault().asyncExec(new Runnable(){
+				public void run(){
+					IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
+					for (int i = 0; i<pages.length; i++){
+						if(((FileEditorInput)editor.getEditorInput()).getFile().getProject().equals(event.getResource())){
+							IEditorPart editorPart = pages[i].findEditor(editor.getEditorInput());
+							pages[i].closeEditor(editorPart,true);
+						}
+					}
+				}            
+			});
+		}
+	}
+	/**
+	 * Sets the font related data to be applied to the text in page 2.
+	 */
+	void setFont() {
+		FontDialog fontDialog = new FontDialog(getSite().getShell());
+		fontDialog.setFontList(text.getFont().getFontData());
+		FontData fontData = fontDialog.open();
+		if (fontData != null) {
+			if (font != null)
+				font.dispose();
+			font = new Font(text.getDisplay(), fontData);
+			text.setFont(font);
+		}
+	}
+	/**
+	 * Sorts the words in page 0, and shows them in page 2.
+	 */
+	void sortWords() {
+
+		String editorText =
+			editor.getDocumentProvider().getDocument(editor.getEditorInput()).get();
+
+		StringTokenizer tokenizer =
+			new StringTokenizer(editorText, " \t\n\r\f!@#\u0024%^&*()-_=+`~[]{};:'\",.<>/?|\\");
+		ArrayList editorWords = new ArrayList();
+		while (tokenizer.hasMoreTokens()) {
+			editorWords.add(tokenizer.nextToken());
+		}
+
+		Collections.sort(editorWords, Collator.getInstance());
+		StringWriter displayText = new StringWriter();
+		for (int i = 0; i < editorWords.size(); i++) {
+			displayText.write(((String) editorWords.get(i)));
+			displayText.write(System.getProperty("line.separator"));
+		}
+		text.setText(displayText.toString());
+	}
+	
+}

Added: labs/jbossrules/trunk/org/drools/testing/plugin/editors/RTLEditorContributor.java
===================================================================
--- labs/jbossrules/trunk/org/drools/testing/plugin/editors/RTLEditorContributor.java	                        (rev 0)
+++ labs/jbossrules/trunk/org/drools/testing/plugin/editors/RTLEditorContributor.java	2007-01-30 13:22:43 UTC (rev 9134)
@@ -0,0 +1,111 @@
+package org.drools.testing.plugin.editors;
+
+import org.drools.testing.plugin.wizards.GenerateRtlWizard;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.ide.IDEActionFactory;
+import org.eclipse.ui.part.MultiPageEditorActionBarContributor;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.ITextEditorActionConstants;
+
+/**
+ * Manages the installation/deinstallation of global actions for multi-page editors.
+ * Responsible for the redirection of global actions to the active editor.
+ * Multi-page contributor replaces the contributors for the individual editors in the multi-page editor.
+ */
+public class RTLEditorContributor extends MultiPageEditorActionBarContributor {
+	private IEditorPart activeEditorPart;
+	private Action generateRtlAction;
+	/**
+	 * Creates a multi-page contributor.
+	 */
+	public RTLEditorContributor() {
+		super();
+		createActions();
+	}
+	/**
+	 * Returns the action registed with the given text editor.
+	 * @return IAction or null if editor is null.
+	 */
+	protected IAction getAction(ITextEditor editor, String actionID) {
+		return (editor == null ? null : editor.getAction(actionID));
+	}
+	/* (non-JavaDoc)
+	 * Method declared in AbstractMultiPageEditorActionBarContributor.
+	 */
+
+	public void setActivePage(IEditorPart part) {
+		if (activeEditorPart == part)
+			return;
+
+		activeEditorPart = part;
+
+		IActionBars actionBars = getActionBars();
+		if (actionBars != null) {
+
+			ITextEditor editor = (part instanceof ITextEditor) ? (ITextEditor) part : null;
+
+			actionBars.setGlobalActionHandler(
+				ActionFactory.DELETE.getId(),
+				getAction(editor, ITextEditorActionConstants.DELETE));
+			actionBars.setGlobalActionHandler(
+				ActionFactory.UNDO.getId(),
+				getAction(editor, ITextEditorActionConstants.UNDO));
+			actionBars.setGlobalActionHandler(
+				ActionFactory.REDO.getId(),
+				getAction(editor, ITextEditorActionConstants.REDO));
+			actionBars.setGlobalActionHandler(
+				ActionFactory.CUT.getId(),
+				getAction(editor, ITextEditorActionConstants.CUT));
+			actionBars.setGlobalActionHandler(
+				ActionFactory.COPY.getId(),
+				getAction(editor, ITextEditorActionConstants.COPY));
+			actionBars.setGlobalActionHandler(
+				ActionFactory.PASTE.getId(),
+				getAction(editor, ITextEditorActionConstants.PASTE));
+			actionBars.setGlobalActionHandler(
+				ActionFactory.SELECT_ALL.getId(),
+				getAction(editor, ITextEditorActionConstants.SELECT_ALL));
+			actionBars.setGlobalActionHandler(
+				ActionFactory.FIND.getId(),
+				getAction(editor, ITextEditorActionConstants.FIND));
+			actionBars.setGlobalActionHandler(
+				IDEActionFactory.BOOKMARK.getId(),
+				getAction(editor, IDEActionFactory.BOOKMARK.getId()));
+			actionBars.updateActionBars();
+		}
+	}
+	private void createActions() {
+		generateRtlAction = new Action () {
+			public void run() {
+				GenerateRtlWizard generateRtlWizard = new GenerateRtlWizard();
+				activeEditorPart.getSite().getSelectionProvider().getSelection();
+				generateRtlWizard.init(PlatformUI.getWorkbench(), new StructuredSelection(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection()));
+				WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), 
+						generateRtlWizard);
+				dialog.open();
+			}
+		};
+		generateRtlAction.setText(EditorConstants.ToolBar.GENERATE);
+		generateRtlAction.setToolTipText(EditorConstants.ToolBar.GENERATE_TOOLTIP);
+		generateRtlAction.setImageDescriptor(ImageDescriptor.createFromFile(this.getClass(), EditorConstants.ToolBar.GENERATE_IMG));
+		
+	}
+	public void contributeToMenu(IMenuManager manager) {
+		
+	}
+	public void contributeToToolBar(IToolBarManager manager) {
+		manager.add(new Separator());
+		manager.add(generateRtlAction);
+	}
+}

Added: labs/jbossrules/trunk/org/drools/testing/plugin/listeners/TreeViewSelectionListener.java
===================================================================
--- labs/jbossrules/trunk/org/drools/testing/plugin/listeners/TreeViewSelectionListener.java	                        (rev 0)
+++ labs/jbossrules/trunk/org/drools/testing/plugin/listeners/TreeViewSelectionListener.java	2007-01-30 13:22:43 UTC (rev 9134)
@@ -0,0 +1,15 @@
+package org.drools.testing.plugin.listeners;
+
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+
+public class TreeViewSelectionListener implements ISelectionChangedListener {
+
+	public TreeViewSelectionListener () {
+		 
+	}
+	
+	public void selectionChanged(SelectionChangedEvent event) {
+		
+	}
+}

Added: labs/jbossrules/trunk/org/drools/testing/plugin/mockobjects/MockObject.java
===================================================================
--- labs/jbossrules/trunk/org/drools/testing/plugin/mockobjects/MockObject.java	                        (rev 0)
+++ labs/jbossrules/trunk/org/drools/testing/plugin/mockobjects/MockObject.java	2007-01-30 13:22:43 UTC (rev 9134)
@@ -0,0 +1,28 @@
+package org.drools.testing.plugin.mockobjects;
+
+public class MockObject {
+
+	private String a = "a";
+	
+	private String b = "b";
+	
+	public MockObject () {
+		
+	}
+
+	public String getA() {
+		return a;
+	}
+
+	public void setA(String a) {
+		this.a = a;
+	}
+
+	public String getB() {
+		return b;
+	}
+
+	public void setB(String b) {
+		this.b = b;
+	}
+}

Added: labs/jbossrules/trunk/org/drools/testing/plugin/views/RtlOutlinePage.java
===================================================================
--- labs/jbossrules/trunk/org/drools/testing/plugin/views/RtlOutlinePage.java	                        (rev 0)
+++ labs/jbossrules/trunk/org/drools/testing/plugin/views/RtlOutlinePage.java	2007-01-30 13:22:43 UTC (rev 9134)
@@ -0,0 +1,284 @@
+package org.drools.testing.plugin.views;
+
+import java.util.ArrayList;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.part.*;
+import org.eclipse.jface.viewers.*;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.jface.action.*;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.ui.*;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.SWT;
+import org.eclipse.core.runtime.IAdaptable;
+
+
+/**
+ * This sample class demonstrates how to plug-in a new
+ * workbench view. The view shows data obtained from the
+ * model. The sample creates a dummy model on the fly,
+ * but a real implementation would connect to the model
+ * available either in this or another plug-in (e.g. the workspace).
+ * The view is connected to the model using a content provider.
+ * <p>
+ * The view uses a label provider to define how model
+ * objects should be presented in the view. Each
+ * view can present the same model objects using
+ * different labels and icons, if needed. Alternatively,
+ * a single label provider can be shared between views
+ * in order to ensure that objects of the same type are
+ * presented in the same way everywhere.
+ * <p>
+ */
+
+public class RtlOutlinePage extends ViewPart {
+	private TreeViewer viewer;
+	private DrillDownAdapter drillDownAdapter;
+	private Action action1;
+	private Action action2;
+	private Action doubleClickAction;
+
+	/*
+	 * The content provider class is responsible for
+	 * providing objects to the view. It can wrap
+	 * existing objects in adapters or simply return
+	 * objects as-is. These objects may be sensitive
+	 * to the current input of the view, or ignore
+	 * it and always show the same content 
+	 * (like Task List, for example).
+	 */
+	 
+	class TreeObject implements IAdaptable {
+		private String name;
+		private TreeParent parent;
+		
+		public TreeObject(String name) {
+			this.name = name;
+		}
+		public String getName() {
+			return name;
+		}
+		public void setParent(TreeParent parent) {
+			this.parent = parent;
+		}
+		public TreeParent getParent() {
+			return parent;
+		}
+		public String toString() {
+			return getName();
+		}
+		public Object getAdapter(Class key) {
+			return null;
+		}
+	}
+	
+	class TreeParent extends TreeObject {
+		private ArrayList children;
+		public TreeParent(String name) {
+			super(name);
+			children = new ArrayList();
+		}
+		public void addChild(TreeObject child) {
+			children.add(child);
+			child.setParent(this);
+		}
+		public void removeChild(TreeObject child) {
+			children.remove(child);
+			child.setParent(null);
+		}
+		public TreeObject [] getChildren() {
+			return (TreeObject [])children.toArray(new TreeObject[children.size()]);
+		}
+		public boolean hasChildren() {
+			return children.size()>0;
+		}
+	}
+
+	class ViewContentProvider implements IStructuredContentProvider, 
+										   ITreeContentProvider {
+		private TreeParent invisibleRoot;
+
+		public void inputChanged(Viewer v, Object oldInput, Object newInput) {
+		}
+		public void dispose() {
+		}
+		public Object[] getElements(Object parent) {
+			if (parent.equals(getViewSite())) {
+				if (invisibleRoot==null) initialize();
+				return getChildren(invisibleRoot);
+			}
+			return getChildren(parent);
+		}
+		public Object getParent(Object child) {
+			if (child instanceof TreeObject) {
+				return ((TreeObject)child).getParent();
+			}
+			return null;
+		}
+		public Object [] getChildren(Object parent) {
+			if (parent instanceof TreeParent) {
+				return ((TreeParent)parent).getChildren();
+			}
+			return new Object[0];
+		}
+		public boolean hasChildren(Object parent) {
+			if (parent instanceof TreeParent)
+				return ((TreeParent)parent).hasChildren();
+			return false;
+		}
+/*
+ * We will set up a dummy model to initialize tree heararchy.
+ * In a real code, you will connect to a real model and
+ * expose its hierarchy.
+ */
+		private void initialize() {
+			TreeObject to1 = new TreeObject("Leaf 1");
+			TreeObject to2 = new TreeObject("Leaf 2");
+			TreeObject to3 = new TreeObject("Leaf 3");
+			TreeParent p1 = new TreeParent("Parent 1");
+			p1.addChild(to1);
+			p1.addChild(to2);
+			p1.addChild(to3);
+			
+			TreeObject to4 = new TreeObject("Leaf 4");
+			TreeParent p2 = new TreeParent("Parent 2");
+			p2.addChild(to4);
+			
+			TreeParent root = new TreeParent("Root");
+			root.addChild(p1);
+			root.addChild(p2);
+			
+			invisibleRoot = new TreeParent("");
+			invisibleRoot.addChild(root);
+		}
+	}
+	class ViewLabelProvider extends LabelProvider {
+
+		public String getText(Object obj) {
+			return obj.toString();
+		}
+		public Image getImage(Object obj) {
+			String imageKey = ISharedImages.IMG_OBJ_ELEMENT;
+			if (obj instanceof TreeParent)
+			   imageKey = ISharedImages.IMG_OBJ_FOLDER;
+			return PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
+		}
+	}
+	class NameSorter extends ViewerSorter {
+	}
+
+	/**
+	 * The constructor.
+	 */
+	public RtlOutlinePage() {
+	}
+
+	/**
+	 * This is a callback that will allow us
+	 * to create the viewer and initialize it.
+	 */
+	public void createPartControl(Composite parent) {
+		viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+		drillDownAdapter = new DrillDownAdapter(viewer);
+		viewer.setContentProvider(new ViewContentProvider());
+		viewer.setLabelProvider(new ViewLabelProvider());
+		viewer.setSorter(new NameSorter());
+		viewer.setInput(getViewSite());
+		makeActions();
+		hookContextMenu();
+		hookDoubleClickAction();
+		contributeToActionBars();
+	}
+
+	private void hookContextMenu() {
+		MenuManager menuMgr = new MenuManager("#PopupMenu");
+		menuMgr.setRemoveAllWhenShown(true);
+		menuMgr.addMenuListener(new IMenuListener() {
+			public void menuAboutToShow(IMenuManager manager) {
+				RtlOutlinePage.this.fillContextMenu(manager);
+			}
+		});
+		Menu menu = menuMgr.createContextMenu(viewer.getControl());
+		viewer.getControl().setMenu(menu);
+		getSite().registerContextMenu(menuMgr, viewer);
+	}
+
+	private void contributeToActionBars() {
+		IActionBars bars = getViewSite().getActionBars();
+		fillLocalPullDown(bars.getMenuManager());
+		fillLocalToolBar(bars.getToolBarManager());
+	}
+
+	private void fillLocalPullDown(IMenuManager manager) {
+		manager.add(action1);
+		manager.add(new Separator());
+		manager.add(action2);
+	}
+
+	private void fillContextMenu(IMenuManager manager) {
+		manager.add(action1);
+		manager.add(action2);
+		manager.add(new Separator());
+		drillDownAdapter.addNavigationActions(manager);
+		// Other plug-ins can contribute there actions here
+		manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+	}
+	
+	private void fillLocalToolBar(IToolBarManager manager) {
+		manager.add(action1);
+		manager.add(action2);
+		manager.add(new Separator());
+		drillDownAdapter.addNavigationActions(manager);
+	}
+
+	private void makeActions() {
+		action1 = new Action() {
+			public void run() {
+				showMessage("Action 1 executed");
+			}
+		};
+		action1.setText("Action 1");
+		action1.setToolTipText("Action 1 tooltip");
+		action1.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
+			getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
+		
+		action2 = new Action() {
+			public void run() {
+				showMessage("Action 2 executed");
+			}
+		};
+		action2.setText("Action 2");
+		action2.setToolTipText("Action 2 tooltip");
+		action2.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
+				getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
+		doubleClickAction = new Action() {
+			public void run() {
+				ISelection selection = viewer.getSelection();
+				Object obj = ((IStructuredSelection)selection).getFirstElement();
+				showMessage("Double-click detected on "+obj.toString());
+			}
+		};
+	}
+
+	private void hookDoubleClickAction() {
+		viewer.addDoubleClickListener(new IDoubleClickListener() {
+			public void doubleClick(DoubleClickEvent event) {
+				doubleClickAction.run();
+			}
+		});
+	}
+	private void showMessage(String message) {
+		MessageDialog.openInformation(
+			viewer.getControl().getShell(),
+			"Rtl Outline",
+			message);
+	}
+
+	/**
+	 * Passing the focus request to the viewer's control.
+	 */
+	public void setFocus() {
+		viewer.getControl().setFocus();
+	}
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/org/drools/testing/plugin/wizards/GenerateRtlWizard.java
===================================================================
--- labs/jbossrules/trunk/org/drools/testing/plugin/wizards/GenerateRtlWizard.java	                        (rev 0)
+++ labs/jbossrules/trunk/org/drools/testing/plugin/wizards/GenerateRtlWizard.java	2007-01-30 13:22:43 UTC (rev 9134)
@@ -0,0 +1,203 @@
+package org.drools.testing.plugin.wizards;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+
+import org.drools.lang.descr.RuleDescr;
+import org.drools.testing.plugin.wizards.model.RtlModel;
+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;
+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.IWorkbenchWizard;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+
+/**
+ * This is a sample new wizard. Its role is to create a new file 
+ * resource in the provided container. If the container resource
+ * (a folder or a project) is selected in the workspace 
+ * when the wizard is opened, it will accept it as the target
+ * container. The wizard creates one file with the extension
+ * "rtl". If a sample multi-page editor (also available
+ * as a template) is registered for the same extension, it will
+ * be able to open it.
+ */
+
+public class GenerateRtlWizard extends Wizard implements INewWizard {
+	private RtlNewPage rtlNewPage;
+	private SelectRulesPage selectRulesPage;
+	private ISelection selection;
+	private RtlModel rtlModel;
+	
+	/**
+	 * Constructor for RtlWizard.
+	 */
+	public GenerateRtlWizard() {
+		super();
+		setNeedsProgressMonitor(true);
+		setRtlModel(new RtlModel());
+	}
+	
+	/**
+	 * Adding the page to the wizard.
+	 */
+
+	public void addPages() {
+		rtlNewPage = new RtlNewPage(selection);
+		selectRulesPage = new SelectRulesPage(selection);
+		addPage(rtlNewPage);
+		addPage(selectRulesPage);
+		
+	}
+
+	/**
+	 * This method is called when 'Finish' button is pressed in
+	 * the wizard. We will create an operation and run it
+	 * using wizard as execution context.
+	 */
+	public boolean performFinish() {
+		
+		Object[] ruleDescrs = selectRulesPage.getViewer().getCheckedElements();
+		for (int i=0; i<ruleDescrs.length; i++) {
+			rtlModel.getRuleDescrs().add((RuleDescr) ruleDescrs[i]);
+		}
+		
+		final String fileName = rtlNewPage.getRtlFileName()+".rtl";
+		final String containerName = rtlNewPage.getContainerName();
+		IRunnableWithProgress op = new IRunnableWithProgress() {
+			public void run(IProgressMonitor monitor) throws InvocationTargetException {
+				try {
+					doFinish(containerName, fileName, monitor);
+				} catch (CoreException e) {
+					throw new InvocationTargetException(e);
+				} finally {
+					monitor.done();
+				}
+			}
+		};
+		try {
+			getContainer().run(true, false, op);
+		} catch (InterruptedException e) {
+			return false;
+		} catch (InvocationTargetException e) {
+			Throwable realException = e.getTargetException();
+			MessageDialog.openError(getShell(), "Error", realException.getMessage());
+			return false;
+		}
+		return true;
+	}
+	
+	/**
+	 * The worker method. It will find the container, create the
+	 * file if missing or just replace its contents, and open
+	 * the editor on the newly created file.
+	 */
+
+	private void doFinish(
+		String containerName,	
+		String fileName,
+		IProgressMonitor monitor)
+		throws CoreException {
+		// create a sample file
+		monitor.beginTask("Creating " + fileName, 2);
+		//String containerName = "test";
+		IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+		IResource resource = root.findMember(new Path(containerName));
+		if (!resource.exists() || !(resource instanceof IContainer)) {
+			throwCoreException("Container \"" + containerName +  "\" does not exist.");
+		}
+		IContainer container = (IContainer) resource;
+		final IFile file = container.getFile(new Path(fileName));
+		try {
+			InputStream stream = openContentStream();
+			if (file.exists()) {
+				file.setContents(stream, true, true, monitor);
+			} else {
+				file.create(stream, true, monitor);
+			}
+			stream.close();
+		} catch (IOException e) {
+		}
+		monitor.worked(1);
+		monitor.setTaskName("Opening file for editing...");
+		getShell().getDisplay().asyncExec(new Runnable() {
+			public void run() {
+				IWorkbenchPage page =
+					PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+				try {
+					IDE.openEditor(page, file, true);
+				} catch (PartInitException e) {
+				}
+			}
+		});
+		
+		monitor.worked(1);
+	}
+	
+	/**
+	 * We will initialize file contents with a sample text.
+	 */
+
+	private InputStream openContentStream() {
+		String contents =
+			"This is the initial file contents for *.rtl file that should be word-sorted in the Preview page of the multi-page editor";
+		return new ByteArrayInputStream(contents.getBytes());
+	}
+
+	private void throwCoreException(String message) throws CoreException {
+		IStatus status =
+			new Status(IStatus.ERROR, "org.drools.testing.plugin", IStatus.OK, message, null);
+		throw new CoreException(status);
+	}
+
+	/**
+	 * We will accept the selection in the workbench to see if
+	 * we can initialize from it.
+	 * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
+	 */
+	public void init(IWorkbench workbench, IStructuredSelection selection) {
+		this.selection = selection;
+	}
+
+	public RtlModel getRtlModel() {
+		return rtlModel;
+	}
+
+	public void setRtlModel(RtlModel rtlModel) {
+		this.rtlModel = rtlModel;
+	}
+
+	public RtlNewPage getRtlNewPage() {
+		return rtlNewPage;
+	}
+
+	public void setRtlNewPage(RtlNewPage rtlNewPage) {
+		this.rtlNewPage = rtlNewPage;
+	}
+
+	public SelectRulesPage getSelectRulesPage() {
+		return selectRulesPage;
+	}
+
+	public void setSelectRulesPage(SelectRulesPage selectRulesPage) {
+		this.selectRulesPage = selectRulesPage;
+	}
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/org/drools/testing/plugin/wizards/RtlNewPage.java
===================================================================
--- labs/jbossrules/trunk/org/drools/testing/plugin/wizards/RtlNewPage.java	                        (rev 0)
+++ labs/jbossrules/trunk/org/drools/testing/plugin/wizards/RtlNewPage.java	2007-01-30 13:22:43 UTC (rev 9134)
@@ -0,0 +1,228 @@
+package org.drools.testing.plugin.wizards;
+
+import org.drools.testing.plugin.wizards.model.RtlModel;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.IDialogPage;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.wizard.IWizardPage;
+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.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.ContainerSelectionDialog;
+
+/**
+ * The "New" wizard page allows setting the container for the new file as well
+ * as the file name. The page will only accept file name without the extension
+ * OR with the extension that matches the expected one (rtl).
+ */
+
+public class RtlNewPage extends WizardPage {
+	
+	private Text rtlFileText;
+	
+	private Text fileText;
+	
+	private Text containerText;
+	
+	/**
+	 * Constructor for SampleNewWizardPage.
+	 * 
+	 * @param pageName
+	 */
+	public RtlNewPage(ISelection selection) {
+		super("wizardPage");
+		setTitle("Rtl Creation");
+		setDescription("This wizard creates a new file with *.rtl extension that can be opened by a multi-page editor.\n" +
+				"Please enter the location of the Drools drl file.");
+		
+	}
+
+	/**
+	 * @see IDialogPage#createControl(Composite)
+	 */
+	public void createControl(Composite parent) {
+		Composite container = new Composite(parent, SWT.NULL);
+		GridLayout layout = new GridLayout();
+		container.setLayout(layout);
+		layout.numColumns = 4;
+		layout.verticalSpacing = 9;
+		
+		Label label = new Label(container, SWT.NULL);
+		label = new Label(container, SWT.NULL);
+		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+		label.setText("&File name:");
+
+		fileText = new Text(container, SWT.BORDER | SWT.SINGLE);
+		gd = new GridData(GridData.FILL_HORIZONTAL);
+		fileText.setLayoutData(gd);
+		fileText.addModifyListener(new ModifyListener() {
+			public void modifyText(ModifyEvent e) {
+				dialogChanged();
+			}
+		});
+		
+		Button buttonFileName = new Button(container, SWT.PUSH);
+		buttonFileName.setText("Browse...");
+		buttonFileName.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent e) {
+				handleFileBrowse();
+			}
+		});
+		
+		label = new Label(container, SWT.NULL);
+		label = new Label(container, SWT.NULL);
+		label.setText("&Rtl name:");
+
+		rtlFileText = new Text(container, SWT.BORDER | SWT.SINGLE);
+		gd = new GridData(GridData.FILL_HORIZONTAL);
+		rtlFileText.setLayoutData(gd);
+		rtlFileText.addModifyListener(new ModifyListener() {
+			public void modifyText(ModifyEvent e) {
+				dialogChanged();
+			}
+		});
+		
+		label = new Label(container, SWT.NULL);
+		label.setText("Container:");
+
+		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("Browse...");
+		button.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent e) {
+				handleBrowse();
+			}
+		});
+		
+		initialize();
+		dialogChanged();
+		setControl(container);
+		
+	}
+
+	/**
+	 * Tests if the current workbench selection is a suitable container to use.
+	 */
+
+	private void initialize() {
+		
+	}
+
+	private void handleFileBrowse () {
+		FileDialog dialog = new FileDialog(getShell());
+		String[] extensions = {"*.drl"};
+		dialog.setFilterExtensions(extensions);
+		dialog.setFilterPath(".");
+		fileText.setText(dialog.open());
+	}
+	
+	private void handleBrowse() {
+		ContainerSelectionDialog dialog = new ContainerSelectionDialog(
+				getShell(), ResourcesPlugin.getWorkspace().getRoot(), false,
+				"Select new file container");
+		if (dialog.open() == ContainerSelectionDialog.OK) {
+			Object[] result = dialog.getResult();
+			if (result.length == 1) {
+				containerText.setText(((Path) result[0]).toString());
+			}
+		}
+	}
+	
+	/**
+	 * Ensures that both text fields are set.
+	 */
+
+	private void dialogChanged() {
+		String fileName = getFileName();
+		String rtlFileName = rtlFileText.getText();
+		IResource container = ResourcesPlugin.getWorkspace().getRoot()
+		.findMember(new Path(getContainerName()));
+
+		if (fileName.length() == 0) {
+			updateStatus("File name must be specified");
+			return;
+		}
+		if (rtlFileName.length() == 0) {
+			updateStatus("Rtl file name must be specified");
+			return;
+		}
+		if (rtlFileName.indexOf(".") != -1) {
+			updateStatus("Rtl file name must be valid");
+			return;
+		}
+		if (getContainerName().length() == 0) {
+			updateStatus("File container must be specified");
+			return;
+		}
+		if (container == null
+				|| (container.getType() & (IResource.PROJECT | IResource.FOLDER)) == 0) {
+			updateStatus("File container must exist");
+			return;
+		}
+		if (!container.isAccessible()) {
+			updateStatus("Project must be writable");
+			return;
+		}
+		int dotLoc = fileName.lastIndexOf('.');
+		if (dotLoc != -1) {
+			String ext = fileName.substring(dotLoc + 1);
+			if (ext.equalsIgnoreCase("drl") == false) {
+				updateStatus("File extension must be \"drl\"");
+				return;
+			}
+		}
+		updateStatus(null);
+	}
+
+	private void updateStatus(String message) {
+		setErrorMessage(message);
+		setPageComplete(message == null);
+	}
+
+	public String getFileName() {
+		return fileText.getText();
+	}
+	
+	public String getRtlFileName() {
+		return rtlFileText.getText();
+	}
+	
+	public String getContainerName() {
+		return containerText.getText();
+	}
+	
+	public IWizardPage getNextPage()
+	{
+		saveDataToModel();
+		SelectRulesPage page = ((GenerateRtlWizard)getWizard()).getSelectRulesPage();
+		page.onEnterPage();
+		return page;
+	}
+	
+	public void saveDataToModel () {
+		GenerateRtlWizard wizard = (GenerateRtlWizard)getWizard();
+		RtlModel model = wizard.getRtlModel();
+		model.setFileName(fileText.getText());
+	}
+	
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/org/drools/testing/plugin/wizards/SelectRulesPage.java
===================================================================
--- labs/jbossrules/trunk/org/drools/testing/plugin/wizards/SelectRulesPage.java	                        (rev 0)
+++ labs/jbossrules/trunk/org/drools/testing/plugin/wizards/SelectRulesPage.java	2007-01-30 13:22:43 UTC (rev 9134)
@@ -0,0 +1,208 @@
+package org.drools.testing.plugin.wizards;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.drools.compiler.DrlParser;
+import org.drools.lang.descr.PackageDescr;
+import org.drools.lang.descr.RuleDescr;
+import org.drools.testing.plugin.listeners.TreeViewSelectionListener;
+import org.drools.testing.plugin.wizards.model.RtlModel;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.dialogs.IDialogPage;
+import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * The "New" wizard page allows setting the container for the new file as well
+ * as the file name. The page will only accept file name without the extension
+ * OR with the extension that matches the expected one (rtl).
+ */
+
+public class SelectRulesPage extends WizardPage {
+	
+	private ISelection selection;
+	
+	private CheckboxTreeViewer viewer;
+	
+	private String fileName;
+	
+	/**
+	 * Constructor for SampleNewWizardPage.
+	 * 
+	 * @param pageName
+	 */
+	public SelectRulesPage(ISelection selection) {
+		super("wizardPage");
+		setTitle("Rtl Creation");
+		setDescription("Please select the rules you wish to test.");
+		this.selection = selection;
+	}
+
+	/**
+	 * @see IDialogPage#createControl(Composite)
+	 */
+	public void createControl(Composite parent) {
+		Composite container = new Composite(parent, SWT.NULL);
+		
+		FillLayout layout = new FillLayout();
+		container.setLayout(layout);
+		layout.type = SWT.VERTICAL;
+		
+		viewer = new CheckboxTreeViewer(container, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+		viewer.setContentProvider(new ViewContentProvider());
+		viewer.setLabelProvider(new ViewLabelProvider());
+		viewer.setSorter(new NameSorter());
+		viewer.addSelectionChangedListener(new TreeViewSelectionListener());
+		initialize();
+		setControl(container);
+		
+	}
+
+	/**
+	 * Tests if the current workbench selection is a suitable container to use.
+	 */
+
+	private void initialize() {
+		if (selection != null && selection.isEmpty() == false
+				&& selection instanceof IStructuredSelection) {
+			IStructuredSelection ssel = (IStructuredSelection) selection;
+			if (ssel.size() > 2)
+				return;
+			Object obj = ssel.getFirstElement();
+			if (obj instanceof IResource) {
+				IContainer container;
+				if (obj instanceof IContainer)
+					container = (IContainer) obj;
+				else
+					container = ((IResource) obj).getParent();
+			}
+		}
+	}
+
+	private void updateStatus(String message) {
+		setErrorMessage(message);
+		setPageComplete(message == null);
+	}
+
+	public String getFileName() {
+		return fileName;
+	}
+	
+	public void onEnterPage () {
+		
+		GenerateRtlWizard wizard = (GenerateRtlWizard)getWizard();
+		RtlModel model = wizard.getRtlModel();
+		fileName = model.getFileName();
+		File in = new File(getFileName());
+		DrlParser drlParser = new DrlParser();
+		try {
+			Reader reader = new FileReader(in);
+			PackageDescr packageDescr = drlParser.parse(reader);
+			model.setPackageDescr(packageDescr);
+			viewer.setInput(packageDescr);
+		}catch (Exception e) {
+			System.out.println(e);
+		}
+		
+	}
+	
+	private void saveDataToModel() {
+		GenerateRtlWizard wizard = (GenerateRtlWizard)getWizard();
+		RtlModel model = wizard.getRtlModel();
+		
+	}
+	
+	
+	class ViewContentProvider implements IStructuredContentProvider, 
+										   ITreeContentProvider {
+		
+		public void inputChanged(Viewer v, Object oldInput, Object newInput) {
+			
+		}
+		
+		public void dispose() {
+		}
+		
+		public Object[] getElements(Object element) { 
+			return getChildren(element); 
+		}
+		
+		public Object getParent(Object element) {
+			if (element instanceof PackageDescr)
+				return ((PackageDescr)element);
+			else
+				return null;
+		}
+		
+		/**
+		 * This method has been modified heavily to just return the rule elements of the drl
+		 */
+		public Object[] getChildren(Object element)
+	      {
+			ArrayList ch = new ArrayList();
+			PackageDescr packageDescr;
+			try {
+				packageDescr = (PackageDescr) element;
+			}catch (ClassCastException e) {
+				return ch.toArray();
+			}
+			
+			List rules = packageDescr.getRules();
+	        Iterator i = rules.iterator();
+	        while (i.hasNext()) {
+	        	RuleDescr ruleDescr = (RuleDescr) i.next();
+	        	ch.add(ruleDescr);
+	        }
+	        
+	        return ch.toArray();
+	      }
+
+		public boolean hasChildren(Object element) { 
+			return getChildren(element).length > 0; 
+		}
+
+	}	
+		class ViewLabelProvider extends LabelProvider {
+
+		public String getText(Object element) {
+			
+			return ((RuleDescr)element).getName();
+		}
+
+		public Image getImage(Object obj) {
+			String imageKey = ISharedImages.IMG_OBJ_ELEMENT;
+			return PlatformUI.getWorkbench().getSharedImages().getImage(
+					imageKey);
+		}
+	}
+
+	class NameSorter extends ViewerSorter {
+	}
+
+	public CheckboxTreeViewer getViewer() {
+		return viewer;
+	}
+
+	public void setViewer(CheckboxTreeViewer viewer) {
+		this.viewer = viewer;
+	}
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/org/drools/testing/plugin/wizards/model/RtlModel.java
===================================================================
--- labs/jbossrules/trunk/org/drools/testing/plugin/wizards/model/RtlModel.java	                        (rev 0)
+++ labs/jbossrules/trunk/org/drools/testing/plugin/wizards/model/RtlModel.java	2007-01-30 13:22:43 UTC (rev 9134)
@@ -0,0 +1,41 @@
+package org.drools.testing.plugin.wizards.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.drools.lang.descr.PackageDescr;
+
+public class RtlModel {
+
+	private String fileName;
+	private PackageDescr packageDescr;
+	private List ruleDescrs = new ArrayList();
+	
+	public RtlModel () {
+		
+	}
+
+	public String getFileName() {
+		return fileName;
+	}
+
+	public void setFileName(String fileName) {
+		this.fileName = fileName;
+	}
+
+	public PackageDescr getPackageDescr() {
+		return packageDescr;
+	}
+
+	public void setPackageDescr(PackageDescr packageDescr) {
+		this.packageDescr = packageDescr;
+	}
+
+	public List getRuleDescrs() {
+		return ruleDescrs;
+	}
+
+	public void setRuleDescrs(List ruleDescrs) {
+		this.ruleDescrs = ruleDescrs;
+	}
+}




More information about the jboss-svn-commits mailing list