[jboss-svn-commits] JBL Code SVN: r12760 - in labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin: icons and 7 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Jun 21 20:27:12 EDT 2007


Author: ahtik
Date: 2007-06-21 20:27:12 -0400 (Thu, 21 Jun 2007)
New Revision: 12760

Added:
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/icons/add_connective.gif
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/icons/add_field_to_fact.gif
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/icons/delete_item_small.gif
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/icons/delete_obj.gif
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/icons/edit.gif
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/icons/function_assets.gif
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/icons/new_item.gif
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/icons/sample.gif
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/editors/
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/modeldriven/
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/wizards/
Modified:
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/plugin.xml
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/DroolsEclipsePlugin.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/menu/RuleHelperActionDelegate.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/editors/RuleEditor.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/modeldriven/HumanReadable.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ActionInsertFactWidget.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ActionRetractFactWidget.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ActionSetFieldDialog.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ActionSetFieldWidget.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddCompositeConstraintOptionDialog.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewActionDialog.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewConditionDialog.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewFactConstraintDialog.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewFieldConstraintDialog.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewInsertedFactFieldDialog.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AssignFieldVariableDialog.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/CompositeFactPatternWidget.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/DSLSentenceWidget.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/FactPatternWidget.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/LHSDSLSentenceWidget.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RHSDSLSentenceWidget.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RuleAttributeWidget.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RuleAttributesDialog.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RuleDialog.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RuleModeller.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ValueEditorTypeSelectionDialog.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/Widget.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/wizards/NewBrxmlFileWizard.java
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/wizards/NewBrxmlFileWizardPage.java
Log:
[JBRULES:878] Implemented rule builder and moved to drools-eclipse-plugin project

Added: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/icons/add_connective.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/icons/add_connective.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/icons/add_field_to_fact.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/icons/add_field_to_fact.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/icons/delete_item_small.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/icons/delete_item_small.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/icons/delete_obj.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/icons/delete_obj.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/icons/edit.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/icons/edit.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/icons/function_assets.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/icons/function_assets.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/icons/new_item.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/icons/new_item.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/icons/sample.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/icons/sample.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/plugin.xml
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/plugin.xml	2007-06-21 23:04:33 UTC (rev 12759)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/plugin.xml	2007-06-22 00:27:12 UTC (rev 12760)
@@ -375,5 +375,27 @@
 	  </wizard>
    </extension>
    
+   <!-- RuleBuilder Extensions -->
+      <extension
+         point="org.eclipse.ui.editors">
+      <editor
+            class="org.drools.eclipse.rulebuilder.editors.RuleEditor"
+            extensions="brxml"
+            icon="icons/drools.gif"
+            id="org.drools.eclipse.ide.rulebuilder.brxml.editors.RuleEditor"
+            name="RuleBuilder Editor"/>
+   </extension>
+
+   <extension
+         point="org.eclipse.ui.newWizards">
+
+      <wizard
+            category="org.drools.eclipse.new"
+            class="org.drools.eclipse.rulebuilder.wizards.NewBrxmlFileWizard"
+            icon="icons/drools.gif"
+            id="org.drools.eclipse.rulebuilder.wizards.NewBrxmlFileWizard"
+            name="Guided DRL Editor"/>
+   </extension>
    
+   
 </plugin>

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/DroolsEclipsePlugin.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/DroolsEclipsePlugin.java	2007-06-21 23:04:33 UTC (rev 12759)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/DroolsEclipsePlugin.java	2007-06-22 00:27:12 UTC (rev 12760)
@@ -49,6 +49,8 @@
 import org.eclipse.jface.util.IPropertyChangeListener;
 import org.eclipse.jface.util.PropertyChangeEvent;
 import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.forms.FormColors;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.osgi.framework.BundleContext;
 
@@ -74,7 +76,9 @@
 	private Map ruleInfoByClassNameMap = new HashMap();
 	private Map functionInfoByClassNameMap = new HashMap();
 	private boolean useCachePreference;
-	
+
+    private FormColors               ruleBuilderFormColors;
+
 	/**
 	 * The constructor.
 	 */
@@ -372,4 +376,18 @@
 		return (FunctionInfo) functionInfoByClassNameMap.get(functionClassName);
 	}
 
+    /**
+     * Form Colors, default colors for now.
+     * 
+     * @param display
+     * @return
+     */
+    public FormColors getRuleBuilderFormColors(Display display) {
+        if ( ruleBuilderFormColors == null ) {
+            ruleBuilderFormColors = new FormColors( display );
+            ruleBuilderFormColors.markShared();
+        }
+        return ruleBuilderFormColors;
+    }
+
 }

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/menu/RuleHelperActionDelegate.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/menu/RuleHelperActionDelegate.java	2007-06-21 23:04:33 UTC (rev 12759)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/menu/RuleHelperActionDelegate.java	2007-06-22 00:27:12 UTC (rev 12760)
@@ -4,6 +4,7 @@
 import java.util.Iterator;
 import java.util.List;
 
+import org.drools.eclipse.rulebuilder.wizards.NewBrxmlFileWizard;
 import org.drools.eclipse.wizard.decisiontable.NewDTFileWizard;
 import org.drools.eclipse.wizard.dsl.NewDSLFileWizard;
 import org.drools.eclipse.wizard.project.NewDroolsProjectWizard;
@@ -56,6 +57,9 @@
         addDTWizard( menu,
                       shell );        
         
+        addGuidedEditorWizard( menu,
+                               shell );
+        
         return menu;
     }
     
@@ -128,6 +132,24 @@
         });
     }
     
+    private void addGuidedEditorWizard(Menu menu,
+                                       final Shell shell) {
+        MenuItem dsl = new MenuItem( menu,
+                                     SWT.NONE );
+        dsl.setText( "New Guided DRL Editor" );
+        dsl.addSelectionListener( new SelectionListener() {
+
+            public void widgetSelected(SelectionEvent e) {
+                NewBrxmlFileWizard wizard = new NewBrxmlFileWizard();
+                launchWizard( shell,
+                              wizard );
+            }
+
+            public void widgetDefaultSelected(SelectionEvent e) {
+            }
+        } );
+    }
+
     private void launchWizard(Shell shell,
                               INewWizard wizard) {
         wizard.init( workbench,

Copied: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/editors (from rev 12707, labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/editors)

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/editors/RuleEditor.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/editors/RuleEditor.java	2007-06-20 05:16:09 UTC (rev 12707)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/editors/RuleEditor.java	2007-06-22 00:27:12 UTC (rev 12760)
@@ -1,17 +1,27 @@
 package org.drools.eclipse.rulebuilder.editors;
 
 import java.io.ByteArrayInputStream;
+import java.io.IOException;
 import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.StringReader;
+import java.io.StringWriter;
 import java.util.ArrayList;
+import java.util.List;
 
 import org.drools.brms.client.modeldriven.SuggestionCompletionEngine;
 import org.drools.brms.server.rules.SuggestionCompletionLoader;
+import org.drools.brms.server.util.BRDRLPersistence;
 import org.drools.brms.server.util.BRXMLPersistence;
-import org.drools.eclipse.rulebuilder.RuleBuilderPlugin;
+import org.drools.eclipse.DroolsEclipsePlugin;
 import org.drools.eclipse.util.ProjectClassLoader;
+import org.drools.lang.dsl.DSLMappingFile;
+import org.eclipse.core.internal.resources.Container;
 import org.eclipse.core.resources.IFile;
+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.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
@@ -19,6 +29,9 @@
 import org.eclipse.jdt.core.IJavaProject;
 import org.eclipse.jdt.core.JavaCore;
 import org.eclipse.jface.text.IDocument;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IEditorPart;
@@ -35,11 +48,11 @@
     implements
     IResourceChangeListener {
 
-    private BrxmlPage                  brxmlPage;
+    private BrxmlPage                  guidedEditor;
 
-    private TextEditor                 editor        = new TextEditor();
+    private TextEditor                 xmlEditor          = new TextEditor();
 
-    private TextEditor                 packageEditor = new TextEditor();
+    private StyledText                 drlPreviewText;
 
     private SuggestionCompletionEngine completion;
 
@@ -47,28 +60,45 @@
 
     private FileEditorInput            packageEditorInput;
 
+    private IResourceChangeListener    packageFileTracker = new IResourceChangeListener() {
+
+                                                              public void resourceChanged(IResourceChangeEvent event) {
+                                                                  IResourceDelta delta = getRootDelta( event.getDelta() );
+
+                                                                  IPath p1 = delta.getFullPath();
+                                                                  IPath p2 = packageEditorInput.getFile().getFullPath();
+                                                                  if ( p1.equals( p2 ) ) {
+                                                                      reloadCompletionEngine();
+                                                                  }
+
+                                                              }
+
+                                                          };
+
     public RuleEditor() {
         super();
         ResourcesPlugin.getWorkspace().addResourceChangeListener( this );
+        ResourcesPlugin.getWorkspace().addResourceChangeListener( packageFileTracker,
+                                                                  IResourceChangeEvent.POST_CHANGE );
 
     }
 
     protected FormToolkit createToolkit(Display display) {
         // Create a toolkit that shares colors between editors.
-        return new FormToolkit( RuleBuilderPlugin.getDefault().getFormColors( display ) );
+        return new FormToolkit( DroolsEclipsePlugin.getDefault().getRuleBuilderFormColors( display ) );
     }
 
     protected void addPages() {
-        brxmlPage = new BrxmlPage( this );
+        guidedEditor = new BrxmlPage( this );
         try {
-            addPage( brxmlPage );
-            addPage( editor,
+            addPage( guidedEditor );
+            addPage( xmlEditor,
                      getEditorInput() );
 
-            FileEditorInput existingFile = (FileEditorInput) getEditorInput();
-            IPath fullPath = existingFile.getFile().getFullPath();
-            IPath packagePath = fullPath.removeLastSegments( 1 ).addTrailingSeparator().append( "rule.package" );
+            addPage( initializePreviewDRLText() );
 
+            IPath packagePath = getCurrentDirectoryPath( getEditorInput() ).append( "rule.package" );
+
             IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile( packagePath );
 
             IJavaProject javaProject = JavaCore.create( file.getProject() );
@@ -93,23 +123,78 @@
 
             reloadCompletionEngine();
 
-            // addPage(packageEditor, packageEditorInput);
-
             setPageText( 1,
-                         "BRXML Preview" );
-            // setPageText(2, "Package Description");
+                         "BRXML Source" );
 
+            setPageText( 2,
+                         "Generated DRL (read-only)" );
+
+            setPartName( xmlEditor.getTitle() );
+            
         } catch ( PartInitException e ) {
             e.printStackTrace();
         }
     }
 
+    private IPath getCurrentDirectoryPath(IEditorInput editorInput) {
+        return ((FileEditorInput) editorInput).getFile().getFullPath().removeLastSegments( 1 ).addTrailingSeparator();
+    }
+
+    private Composite initializePreviewDRLText() {
+
+        drlPreviewText = new StyledText( getContainer(),
+                                         SWT.V_SCROLL | SWT.H_SCROLL );
+        drlPreviewText.setEditable( false );
+        drlPreviewText.setCaret( null );
+
+        return drlPreviewText;
+    }
+
     private void reloadCompletionEngine() {
         try {
 
-            String str = "";
+            // Load all .dsl files from current dir
+            IPath p = (packageEditorInput).getFile().getFullPath().removeLastSegments( 1 );
 
-            InputStream is = packageEditorInput.getFile().getContents();
+            Container folder = (Container) ResourcesPlugin.getWorkspace().getRoot().findMember( p,
+                                                                                                false );
+
+            IResource[] files = folder.members( false );
+
+            List dslList = new ArrayList();
+
+            for ( int i = 0; i < files.length; i++ ) {
+                if ( files[i].getName().endsWith( ".dsl" ) ) {
+                    String contents = getFileContents( (IFile) files[i] );
+                    DSLMappingFile dsl = new DSLMappingFile();
+
+                    if ( dsl.parseAndLoad( new StringReader( contents ) ) ) {
+                        dslList.add( dsl );
+                    } else {
+                        //TODO report dsl parse error
+                    }
+                }
+            }
+
+            // Load suggestion engine
+            String str = getFileContents( packageEditorInput.getFile() );
+
+            completion = loader.getSuggestionEngine( str,
+                                                     dslList,
+                                                     dslList );
+
+        } catch ( Exception e ) {
+            // TODO Handle problem with the completion engine reloading
+            e.printStackTrace();
+        }
+    }
+
+    private String getFileContents(IFile file) {
+
+        InputStream is;
+        try {
+            is = file.getContents();
+
             StringBuffer out = new StringBuffer();
             byte[] b = new byte[4096];
             for ( int n; (n = is.read( b )) != -1; ) {
@@ -117,28 +202,20 @@
                                         0,
                                         n ) );
             }
-            str = out.toString();
-            System.out.println( "GOT " + str );
 
-            completion = loader.getSuggestionEngine( str,
-                                                     new ArrayList(),
-                                                     new ArrayList() );
+            return out.toString();
+        } catch ( CoreException e ) {
+            //TODO Report problem with the file loading
+            return "";
+        } catch ( IOException e ) {
+            //TODO Report problem with the file loading
+            return "";
+        }
 
-            String[] facts = completion.getFactTypes();
-            System.out.println( "NUMBER OF FACTS NOW " + facts.length );
-            
-            for(int i=0; i<facts.length; i++) {
-                System.out.println("F "+facts[i]);
-            }
-
-        } catch ( Exception e ) {
-            // TODO Handle
-            e.printStackTrace();
-        }
     }
 
     public boolean isDirty() {
-        return editor.isDirty() || brxmlPage.isDirty() || packageEditor.isDirty();
+        return xmlEditor.isDirty() || guidedEditor.isDirty();
     }
 
     protected void pageChange(int newPageIndex) {
@@ -147,13 +224,42 @@
         IDocument document = getInputDocument();
 
         if ( newPageIndex == 0 ) {
-            brxmlPage.setModelXML( document.get() );
-            brxmlPage.refresh();
-        }
-        if ( newPageIndex == 1 ) {
-            if ( brxmlPage.isDirty() ) {
-                document.set( BRXMLPersistence.getInstance().marshal( brxmlPage.getRuleModel() ) );
+
+            boolean newModel = guidedEditor.getModeller().getModel() == null;
+            if ( xmlEditor.isDirty() || newModel ) {
+                guidedEditor.setModelXML( document.get() );
+                if ( newModel ) {
+                    guidedEditor.getModeller().setDirty( false );
+                }
             }
+
+            guidedEditor.refresh();
+
+        } else if ( newPageIndex == 1 ) {
+
+            if ( guidedEditor.isDirty() ) {
+                document.set( BRXMLPersistence.getInstance().marshal( guidedEditor.getRuleModel() ) );
+            }
+        } else if ( newPageIndex == 2 ) {
+
+            //Updating main document for proper workflow when page is switched back to "0"
+            if ( guidedEditor.isDirty() ) {
+                document.set( BRXMLPersistence.getInstance().marshal( guidedEditor.getRuleModel() ) );
+            } else if ( xmlEditor.isDirty() ) {
+                guidedEditor.setModelXML( document.get() );
+            }
+
+            String drl;
+            try {
+                drl = BRDRLPersistence.getInstance().marshal( guidedEditor.getRuleModel() );
+            } catch ( Throwable t ) {
+
+                StringWriter strwriter = new StringWriter();
+                t.printStackTrace( new PrintWriter( strwriter ) );
+                drl = strwriter.toString();
+            }
+            drlPreviewText.setText( drl );
+
         }
 
     }
@@ -161,17 +267,18 @@
     public void doSave(IProgressMonitor monitor) {
         IDocument document = getInputDocument();
 
-        if ( brxmlPage.isDirty() ) {
-            document.set( BRXMLPersistence.getInstance().marshal( brxmlPage.getRuleModel() ) );
+        if (xmlEditor.isDirty()) {
+            guidedEditor.setModelXML( document.get() );
+        } else if ( guidedEditor.isDirty() ) {
+            document.set( BRXMLPersistence.getInstance().marshal( guidedEditor.getRuleModel() ) );
         }
 
-        editor.doSave( monitor );
-        packageEditor.doSave( monitor );
+        xmlEditor.doSave( monitor );
 
-        brxmlPage.getModeller().setDirty( false );
+        guidedEditor.getModeller().setDirty( false );
 
-        reloadCompletionEngine();
-
+        guidedEditor.refresh();
+        
     }
 
     private IDocument getInputDocument() {
@@ -182,11 +289,13 @@
     }
 
     public void doSaveAs() {
-        editor.doSaveAs();
-        brxmlPage.getModeller().setDirty( false );
-        setPageText( 0,
-                     editor.getTitle() );
-        setInput( editor.getEditorInput() );
+        xmlEditor.doSaveAs();
+        guidedEditor.getModeller().setDirty( false );
+        setPartName( xmlEditor.getTitle() );
+        setInput( xmlEditor.getEditorInput() );
+        
+        guidedEditor.refresh();
+        
     }
 
     public boolean isSaveAsAllowed() {
@@ -199,8 +308,8 @@
                 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() );
+                        if ( ((FileEditorInput) xmlEditor.getEditorInput()).getFile().getProject().equals( event.getResource() ) ) {
+                            IEditorPart editorPart = pages[i].findEditor( xmlEditor.getEditorInput() );
                             pages[i].closeEditor( editorPart,
                                                   true );
                         }
@@ -212,16 +321,24 @@
 
     public void dispose() {
         ResourcesPlugin.getWorkspace().removeResourceChangeListener( this );
+        ResourcesPlugin.getWorkspace().removeResourceChangeListener( packageFileTracker );
         super.dispose();
     }
 
     public void dirtyPropertyChanged() {
         firePropertyChange( IEditorPart.PROP_DIRTY );
-        brxmlPage.refresh();
+        guidedEditor.refresh();
     }
 
     public SuggestionCompletionEngine getCompletionEngine() {
         return completion;
     }
 
+    private IResourceDelta getRootDelta(IResourceDelta delta) {
+        if ( delta.getAffectedChildren().length > 0 ) {
+            return getRootDelta( delta.getAffectedChildren()[0] );
+        }
+        return delta;
+    }
+
 }
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/modeldriven (from rev 12707, labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/modeldriven)

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/modeldriven/HumanReadable.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/modeldriven/HumanReadable.java	2007-06-20 05:16:09 UTC (rev 12707)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/modeldriven/HumanReadable.java	2007-06-22 00:27:12 UTC (rev 12760)
@@ -16,91 +16,124 @@
  */
 public class HumanReadable {
 
-	public static Map operatorDisplayMap = new HashMap();
+    public static Map            operatorDisplayMap   = new HashMap();
 
-	public static Map ceDisplayMap = new HashMap();
+    public static Map            ceDisplayMap         = new HashMap();
 
-	public static Map actionDisplayMap = new HashMap();
+    public static Map            actionDisplayMap     = new HashMap();
 
-	public static final String[] CONDITIONAL_ELEMENTS = new String[] { "not",
-			"exists", "or" };
+    public static final String[] CONDITIONAL_ELEMENTS = new String[]{"not", "exists", "or"};
 
-	static {
-		operatorDisplayMap.put( "==", "is equal to" );
-        operatorDisplayMap.put( "!=", "is not equal to" );
-        operatorDisplayMap.put( "<", "is less than" );
-        operatorDisplayMap.put( "<=", "less than or equal to" );
-        operatorDisplayMap.put( ">", "greater than" );
-        operatorDisplayMap.put( ">=", "greater than or equal to" );
-        
-        operatorDisplayMap.put( "|| ==", "or equal to" );
-        operatorDisplayMap.put( "|| !=", "or not equal to" );
-        operatorDisplayMap.put( "&& !=", "and not equal to" );
-        operatorDisplayMap.put( "&& >", "and greater than" );
-        operatorDisplayMap.put( "&& <", "and less than" );
-        operatorDisplayMap.put( "|| >", "or greater than" );
-        operatorDisplayMap.put( "|| <", "or less than" );
-        
-        operatorDisplayMap.put( "|| >=", "or greater than (or equal to)" );
-        operatorDisplayMap.put( "|| <=", "or less than (or equal to)" );
-        operatorDisplayMap.put( "&& >=", "and greater than (or equal to)" );
-        operatorDisplayMap.put( "&& <=", "or less than (or equal to)" );
-        operatorDisplayMap.put( "&& contains", "and contains" );
-        operatorDisplayMap.put( "|| contains", "or contains" );
-        operatorDisplayMap.put( "&& matches", "and matches" );
-        operatorDisplayMap.put( "|| matches", "or matches" );
-        operatorDisplayMap.put( "|| excludes", "or excludes" );
-        operatorDisplayMap.put( "&& excludes", "and excludes" );
+    static {
+        operatorDisplayMap.put( "==",
+                                "is equal to" );
+        operatorDisplayMap.put( "!=",
+                                "is not equal to" );
+        operatorDisplayMap.put( "<",
+                                "is less than" );
+        operatorDisplayMap.put( "<=",
+                                "less than or equal to" );
+        operatorDisplayMap.put( ">",
+                                "greater than" );
+        operatorDisplayMap.put( ">=",
+                                "greater than or equal to" );
 
-		ceDisplayMap.put("not", "There is no");
-		ceDisplayMap.put("exists", "There exists");
-		ceDisplayMap.put("or", "Any of");
+        operatorDisplayMap.put( "|| ==",
+                                "or equal to" );
+        operatorDisplayMap.put( "|| !=",
+                                "or not equal to" );
+        operatorDisplayMap.put( "&& !=",
+                                "and not equal to" );
+        operatorDisplayMap.put( "&& >",
+                                "and greater than" );
+        operatorDisplayMap.put( "&& <",
+                                "and less than" );
+        operatorDisplayMap.put( "|| >",
+                                "or greater than" );
+        operatorDisplayMap.put( "|| <",
+                                "or less than" );
 
-		actionDisplayMap.put( "assert", "Assert" );
-        actionDisplayMap.put( "assertLogical", "Logically assert" );
-        actionDisplayMap.put( "retract", "Retract" );
-        actionDisplayMap.put( "set", "Set" );
-        actionDisplayMap.put( "modify", "Modify" );
+        operatorDisplayMap.put( "|| >=",
+                                "or greater than (or equal to)" );
+        operatorDisplayMap.put( "|| <=",
+                                "or less than (or equal to)" );
+        operatorDisplayMap.put( "&& >=",
+                                "and greater than (or equal to)" );
+        operatorDisplayMap.put( "&& <=",
+                                "or less than (or equal to)" );
+        operatorDisplayMap.put( "&& contains",
+                                "and contains" );
+        operatorDisplayMap.put( "|| contains",
+                                "or contains" );
+        operatorDisplayMap.put( "&& matches",
+                                "and matches" );
+        operatorDisplayMap.put( "|| matches",
+                                "or matches" );
+        operatorDisplayMap.put( "|| excludes",
+                                "or excludes" );
+        operatorDisplayMap.put( "&& excludes",
+                                "and excludes" );
 
-	}
+        ceDisplayMap.put( "not",
+                          "There is no" );
+        ceDisplayMap.put( "exists",
+                          "There exists" );
+        ceDisplayMap.put( "or",
+                          "Any of" );
 
-	public static String getActionDisplayName(String action) {
-		return lookup(action, actionDisplayMap);
-	}
+        actionDisplayMap.put( "assert",
+                              "Assert" );
+        actionDisplayMap.put( "assertLogical",
+                              "Logically assert" );
+        actionDisplayMap.put( "retract",
+                              "Retract" );
+        actionDisplayMap.put( "set",
+                              "Set" );
+        actionDisplayMap.put( "modify",
+                              "Modify" );
 
-	public static String getOperatorDisplayName(String op) {
-		return lookup(op, operatorDisplayMap);
-	}
+    }
 
-	public static String getCEDisplayName(String ce) {
-		return lookup(ce, ceDisplayMap);
-	}
+    public static String getActionDisplayName(String action) {
+        return lookup( action,
+                       actionDisplayMap );
+    }
 
-	private static String lookup(String ce, Map map) {
-		if (map.containsKey(ce)) {
-			return (String) map.get(ce);
-		} else {
-			return ce;
-		}
-	}
+    public static String getOperatorDisplayName(String op) {
+        return lookup( op,
+                       operatorDisplayMap );
+    }
 
-	/**
-	 * get operator by its display name
-	 * 
-	 * @param op
-	 *            operator display name
-	 * @return operator
-	 */
-	public static String getOperatorName(String op) {
-		Set keys = operatorDisplayMap.keySet();
-		for (Iterator iter = keys.iterator(); iter.hasNext();) {
-			String key = (String) iter.next();
-			if (op.equals(operatorDisplayMap.get(key))) {
-				return key;
-			}
-		}
-		throw new RuntimeException("No operator display name '" + op
-				+ "' was found.");
-	}
+    public static String getCEDisplayName(String ce) {
+        return lookup( ce,
+                       ceDisplayMap );
+    }
 
+    private static String lookup(String ce,
+                                 Map map) {
+        if ( map.containsKey( ce ) ) {
+            return (String) map.get( ce );
+        } else {
+            return ce;
+        }
+    }
+
+    /**
+     * get operator by its display name
+     * 
+     * @param op
+     *            operator display name
+     * @return operator
+     */
+    public static String getOperatorName(String op) {
+        Set keys = operatorDisplayMap.keySet();
+        for ( Iterator iter = keys.iterator(); iter.hasNext(); ) {
+            String key = (String) iter.next();
+            if ( op.equals( operatorDisplayMap.get( key ) ) ) {
+                return key;
+            }
+        }
+        throw new RuntimeException( "No operator display name '" + op + "' was found." );
+    }
+
 }

Copied: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui (from rev 12707, labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui)

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ActionInsertFactWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/ActionInsertFactWidget.java	2007-06-20 05:16:09 UTC (rev 12707)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ActionInsertFactWidget.java	2007-06-22 00:27:12 UTC (rev 12760)
@@ -28,7 +28,7 @@
  * 
  */
 public class ActionInsertFactWidget extends Widget {
- 
+
     private final ActionInsertFact fact;
 
     public ActionInsertFactWidget(FormToolkit toolkit,
@@ -36,7 +36,10 @@
                                   RuleModeller mod,
                                   ActionInsertFact fact,
                                   int index) {
-        super(parent,toolkit,mod,index);
+        super( parent,
+               toolkit,
+               mod,
+               index );
 
         this.fact = fact;
 
@@ -55,12 +58,12 @@
     }
 
     private void create() {
-    	
-    	 String assertType = "assert";
-         if (fact instanceof ActionInsertLogicalFact) {
-             assertType = "assertLogical";
-         }
-    	
+
+        String assertType = "assert";
+        if ( fact instanceof ActionInsertLogicalFact ) {
+            assertType = "assertLogical";
+        }
+
         toolkit.createLabel( parent,
                              HumanReadable.getActionDisplayName( assertType ) + " " + this.fact.factType );
         addDeleteRHSAction();
@@ -81,9 +84,9 @@
         link.addHyperlinkListener( new IHyperlinkListener() {
             public void linkActivated(HyperlinkEvent e) {
                 RuleDialog popup = new AddNewInsertedFactFieldDialog( shell,
-                                                                     toolkit,
-                                                                     getModeller(),
-                                                                     fact );
+                                                                      toolkit,
+                                                                      getModeller(),
+                                                                      fact );
                 popup.open();
             }
 

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ActionRetractFactWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/ActionRetractFactWidget.java	2007-06-20 05:16:09 UTC (rev 12707)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ActionRetractFactWidget.java	2007-06-22 00:27:12 UTC (rev 12760)
@@ -21,8 +21,11 @@
                                    ActionRetractFact fact,
                                    int index) {
 
-        super(parent, toolkit, modeller, index);
-        
+        super( parent,
+               toolkit,
+               modeller,
+               index );
+
         this.fact = fact;
 
         GridLayout l = new GridLayout();

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ActionSetFieldDialog.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/ActionSetFieldDialog.java	2007-06-20 05:16:09 UTC (rev 12707)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ActionSetFieldDialog.java	2007-06-22 00:27:12 UTC (rev 12760)
@@ -18,57 +18,65 @@
  */
 public class ActionSetFieldDialog extends RuleDialog {
 
-	private String[] fieldCompletions;
+    private String[]       fieldCompletions;
 
-	private FormToolkit toolkit;
+    private FormToolkit    toolkit;
 
-	private RuleModeller modeller;
+    private RuleModeller   modeller;
 
-	private ActionSetField field;
+    private ActionSetField field;
 
-	private String variableClass;
+    private String         variableClass;
 
-	public ActionSetFieldDialog(FormToolkit toolkit, Shell parent,
-			RuleModeller modeller, ActionSetField field,
-			String[] fieldCompletions, String variableClass) {
-		super(parent, "Add a field", "Add a field");
+    public ActionSetFieldDialog(FormToolkit toolkit,
+                                Shell parent,
+                                RuleModeller modeller,
+                                ActionSetField field,
+                                String[] fieldCompletions,
+                                String variableClass) {
+        super( parent,
+               "Add a field",
+               "Add a field" );
 
-		this.fieldCompletions = fieldCompletions;
-		this.toolkit = toolkit;
-		this.modeller = modeller;
-		this.field = field;
-		this.variableClass = variableClass;
-	}
+        this.fieldCompletions = fieldCompletions;
+        this.toolkit = toolkit;
+        this.modeller = modeller;
+        this.field = field;
+        this.variableClass = variableClass;
+    }
 
-	protected Control createDialogArea(final Composite parent) {
-		Composite composite = (Composite) super.createDialogArea(parent);
-		toolkit.createLabel(composite, "Add a field");
+    protected Control createDialogArea(final Composite parent) {
+        Composite composite = (Composite) super.createDialogArea( parent );
+        createLabel( composite,
+                     "Add a field" );
 
-		final Combo fieldsCombo = new Combo(parent, SWT.READ_ONLY);
-		fieldsCombo.add("Choose field...");
-		for (int i = 0; i < fieldCompletions.length; i++) {
-			fieldsCombo.add(fieldCompletions[i]);
-		}
-		fieldsCombo.select(0);
+        final Combo fieldsCombo = new Combo( parent,
+                                             SWT.READ_ONLY );
+        fieldsCombo.add( "Choose field..." );
+        for ( int i = 0; i < fieldCompletions.length; i++ ) {
+            fieldsCombo.add( fieldCompletions[i] );
+        }
+        fieldsCombo.select( 0 );
 
-		fieldsCombo.addModifyListener(new ModifyListener() {
-			public void modifyText(ModifyEvent e) {
-				if (fieldsCombo.getSelectionIndex() == 0) {
-					return; // no need to change anything
-				}
+        fieldsCombo.addModifyListener( new ModifyListener() {
+            public void modifyText(ModifyEvent e) {
+                if ( fieldsCombo.getSelectionIndex() == 0 ) {
+                    return; // no need to change anything
+                }
 
-				String fieldType = modeller.getSuggestionCompletionEngine()
-						.getFieldType(variableClass, fieldsCombo.getText());
-				field.addFieldValue(new ActionFieldValue(fieldsCombo.getText(),
-						"", fieldType));
+                String fieldType = modeller.getSuggestionCompletionEngine().getFieldType( variableClass,
+                                                                                          fieldsCombo.getText() );
+                field.addFieldValue( new ActionFieldValue( fieldsCombo.getText(),
+                                                           "",
+                                                           fieldType ) );
 
-				modeller.reloadRhs();
-				modeller.setDirty(true);
-				close();
-			}
-		});
+                modeller.reloadRhs();
+                modeller.setDirty( true );
+                close();
+            }
+        } );
 
-		return composite;
-	}
+        return composite;
+    }
 
 }

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ActionSetFieldWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/ActionSetFieldWidget.java	2007-06-20 05:16:09 UTC (rev 12707)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ActionSetFieldWidget.java	2007-06-22 00:27:12 UTC (rev 12760)
@@ -28,147 +28,160 @@
  */
 public class ActionSetFieldWidget extends Widget {
 
-	private ActionSetField set;
+    private ActionSetField set;
 
-	final private String[] fieldCompletions;
+    final private String[] fieldCompletions;
 
-	private boolean isBoundFact = false;
+    private boolean        isBoundFact = false;
 
-	private String variableClass;
+    private String         variableClass;
 
-	public ActionSetFieldWidget(FormToolkit toolkit, Composite parent,
-			RuleModeller mod, RuleModel rule, ActionSetField set, int index) {
+    public ActionSetFieldWidget(FormToolkit toolkit,
+                                Composite parent,
+                                RuleModeller mod,
+                                RuleModel rule,
+                                ActionSetField set,
+                                int index) {
 
-		super(parent, toolkit, mod, index);
+        super( parent,
+               toolkit,
+               mod,
+               index );
 
-		this.set = set;
+        this.set = set;
 
-		if (getCompletion().isGlobalVariable(set.variable)) {
-			this.fieldCompletions = getCompletion()
-					.getFieldCompletionsForGlobalVariable(set.variable);
-			this.variableClass = (String) getCompletion().globalTypes
-					.get(set.variable);
-		} else {
-			FactPattern pattern = rule.getBoundFact(set.variable);
-			this.fieldCompletions = getCompletion().getFieldCompletions(
-					pattern.factType);
-			this.isBoundFact = true;
-			this.variableClass = pattern.factType;
-		}
+        if ( getCompletion().isGlobalVariable( set.variable ) ) {
+            this.fieldCompletions = getCompletion().getFieldCompletionsForGlobalVariable( set.variable );
+            this.variableClass = (String) getCompletion().globalTypes.get( set.variable );
+        } else {
+            FactPattern pattern = rule.getBoundFact( set.variable );
+            this.fieldCompletions = getCompletion().getFieldCompletions( pattern.factType );
+            this.isBoundFact = true;
+            this.variableClass = pattern.factType;
+        }
 
-		GridLayout l = new GridLayout();
-		l.numColumns = 6;
-		l.marginBottom = 0;
-		l.marginHeight = 0;
-		l.marginLeft = 0;
-		l.marginRight = 0;
-		l.marginTop = 0;
-		l.marginWidth = 0;
-		l.verticalSpacing = 0;
-		parent.setLayout(l);
+        GridLayout l = new GridLayout();
+        l.numColumns = 6;
+        l.marginBottom = 0;
+        l.marginHeight = 0;
+        l.marginLeft = 0;
+        l.marginRight = 0;
+        l.marginTop = 0;
+        l.marginWidth = 0;
+        l.verticalSpacing = 0;
+        parent.setLayout( l );
 
-		create();
+        create();
 
-	}
+    }
 
-	private void create() {
-		String modifyType = "set";
-		if (this.set instanceof ActionUpdateField) {
-			modifyType = "modify";
-		}
+    private void create() {
+        String modifyType = "set";
+        if ( this.set instanceof ActionUpdateField ) {
+            modifyType = "modify";
+        }
 
-		toolkit.createLabel(parent, HumanReadable
-				.getActionDisplayName(modifyType)
-				+ " [" + this.set.variable + "]");
-		addDeleteRHSAction();
-		addMoreOptionsAction();
-		addRows();
-	}
+        toolkit.createLabel( parent,
+                             HumanReadable.getActionDisplayName( modifyType ) + " [" + this.set.variable + "]" );
+        addDeleteRHSAction();
+        addMoreOptionsAction();
+        addRows();
+    }
 
-	private void addRows() {
-		Composite constraintComposite = toolkit.createComposite(parent);
-		GridLayout constraintLayout = new GridLayout();
-		constraintLayout.numColumns = 3;
-		constraintComposite.setLayout(constraintLayout);
+    private void addRows() {
+        Composite constraintComposite = toolkit.createComposite( parent );
+        GridLayout constraintLayout = new GridLayout();
+        constraintLayout.numColumns = 3;
+        constraintComposite.setLayout( constraintLayout );
 
-		for (int i = 0; i < set.fieldValues.length; i++) {
-			ActionFieldValue val = set.fieldValues[i];
-			toolkit.createLabel(constraintComposite, val.field);
-			valueEditor(constraintComposite, val);
-			addRemoveFieldAction(constraintComposite, i);
-		}
+        for ( int i = 0; i < set.fieldValues.length; i++ ) {
+            ActionFieldValue val = set.fieldValues[i];
+            toolkit.createLabel( constraintComposite,
+                                 val.field );
+            valueEditor( constraintComposite,
+                         val );
+            addRemoveFieldAction( constraintComposite,
+                                  i );
+        }
 
-		toolkit.paintBordersFor(constraintComposite);
-	}
+        toolkit.paintBordersFor( constraintComposite );
+    }
 
-	private void addMoreOptionsAction() {
-		// ImageHyperlink link = addImage(parent,
-		// "icons/add_field_to_fact.gif");
-		ImageHyperlink link = addImage(parent, "icons/new_item.gif");
+    private void addMoreOptionsAction() {
+        // ImageHyperlink link = addImage(parent,
+        // "icons/add_field_to_fact.gif");
+        ImageHyperlink link = addImage( parent,
+                                        "icons/new_item.gif" );
 
-		link.addHyperlinkListener(new IHyperlinkListener() {
-			public void linkActivated(HyperlinkEvent e) {
-				RuleDialog popup = new ActionSetFieldDialog(toolkit, parent
-						.getShell(), getModeller(), set, fieldCompletions, variableClass);
-				popup.open();
+        link.addHyperlinkListener( new IHyperlinkListener() {
+            public void linkActivated(HyperlinkEvent e) {
+                RuleDialog popup = new ActionSetFieldDialog( toolkit,
+                                                             parent.getShell(),
+                                                             getModeller(),
+                                                             set,
+                                                             fieldCompletions,
+                                                             variableClass );
+                popup.open();
 
-			}
+            }
 
-			public void linkEntered(HyperlinkEvent e) {
-			}
+            public void linkEntered(HyperlinkEvent e) {
+            }
 
-			public void linkExited(HyperlinkEvent e) {
-			}
-		});
-		link.setToolTipText("Add a field");
-	}
+            public void linkExited(HyperlinkEvent e) {
+            }
+        } );
+        link.setToolTipText( "Add a field" );
+    }
 
-	private void addRemoveFieldAction(Composite constraintComposite,
-			final int currentRow) {
-		ImageHyperlink delLink = addImage(constraintComposite,
-				"icons/delete_item_small.gif");
-		delLink.setToolTipText("Remove this field action");
-		delLink.addHyperlinkListener(new IHyperlinkListener() {
-			public void linkActivated(HyperlinkEvent e) {
-				MessageBox dialog = new MessageBox(Display.getCurrent()
-						.getActiveShell(), SWT.YES | SWT.NO | SWT.ICON_WARNING);
-				dialog.setMessage("Remove this item?");
-				dialog.setText("Remove this item?");
-				if (dialog.open() == SWT.YES) {
-					set.removeField(currentRow);
-					getModeller().setDirty(true);
-					getModeller().reloadRhs();
-				}
-			}
+    private void addRemoveFieldAction(Composite constraintComposite,
+                                      final int currentRow) {
+        ImageHyperlink delLink = addImage( constraintComposite,
+                                           "icons/delete_item_small.gif" );
+        delLink.setToolTipText( "Remove this field action" );
+        delLink.addHyperlinkListener( new IHyperlinkListener() {
+            public void linkActivated(HyperlinkEvent e) {
+                MessageBox dialog = new MessageBox( Display.getCurrent().getActiveShell(),
+                                                    SWT.YES | SWT.NO | SWT.ICON_WARNING );
+                dialog.setMessage( "Remove this item?" );
+                dialog.setText( "Remove this item?" );
+                if ( dialog.open() == SWT.YES ) {
+                    set.removeField( currentRow );
+                    getModeller().setDirty( true );
+                    getModeller().reloadRhs();
+                }
+            }
 
-			public void linkEntered(HyperlinkEvent e) {
-			}
+            public void linkEntered(HyperlinkEvent e) {
+            }
 
-			public void linkExited(HyperlinkEvent e) {
-			}
-		});
-	}
+            public void linkExited(HyperlinkEvent e) {
+            }
+        } );
+    }
 
-	private void valueEditor(Composite parent, final ActionFieldValue val) {
-		final Text box = toolkit.createText(parent, "");
+    private void valueEditor(Composite parent,
+                             final ActionFieldValue val) {
+        final Text box = toolkit.createText( parent,
+                                             "" );
 
-		if (val.value != null) {
-			box.setText(val.value);
-		}
+        if ( val.value != null ) {
+            box.setText( val.value );
+        }
 
-		box.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+        box.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
 
-		box.addModifyListener(new ModifyListener() {
-			public void modifyText(ModifyEvent e) {
-				val.value = box.getText();
-				getModeller().setDirty(true);
-			}
-		});
+        box.addModifyListener( new ModifyListener() {
+            public void modifyText(ModifyEvent e) {
+                val.value = box.getText();
+                getModeller().setDirty( true );
+            }
+        } );
 
-	}
+    }
 
-	private SuggestionCompletionEngine getCompletion() {
-		return getModeller().getSuggestionCompletionEngine();
-	}
+    private SuggestionCompletionEngine getCompletion() {
+        return getModeller().getSuggestionCompletionEngine();
+    }
 
 }

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddCompositeConstraintOptionDialog.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/AddCompositeConstraintOptionDialog.java	2007-06-20 05:16:09 UTC (rev 12707)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddCompositeConstraintOptionDialog.java	2007-06-22 00:27:12 UTC (rev 12760)
@@ -15,101 +15,116 @@
 import org.eclipse.ui.forms.widgets.FormToolkit;
 
 public class AddCompositeConstraintOptionDialog extends RuleDialog {
-	
-	private final FormToolkit toolkit;
 
-	private RuleModeller modeller;
-	
-	private FactPattern pattern;
-	
-	private final CompositeFieldConstraint constraint;
-	
-	public AddCompositeConstraintOptionDialog(Shell parent, FormToolkit toolkit,
-			RuleModeller modeller, CompositeFieldConstraint constraint, FactPattern pattern) {
-		super(parent, "Add fields to this constriant", "Pick the value from combo.");
-		
-		this.toolkit = toolkit;
-		this.modeller = modeller;
-		this.constraint = constraint;
-		this.pattern = pattern;
-	}
+    private final FormToolkit              toolkit;
 
-	protected Control createDialogArea(final Composite parent) {
-		Composite composite = (Composite) super.createDialogArea(parent);
+    private RuleModeller                   modeller;
 
-		GridLayout l = new GridLayout();
-		l.numColumns = 3;
-		l.marginBottom = 0;
-		l.marginHeight = 0;
-		l.marginLeft = 0;
-		l.marginRight = 0;
-		l.marginTop = 0;
-		l.marginWidth = 0;
-		composite.setLayout(l);
+    private FactPattern                    pattern;
 
-		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
-		gd.horizontalSpan = 2;
+    private final CompositeFieldConstraint constraint;
 
-		createFieldRestrictionCombo(composite, gd);
-		createMultiFieldCombo(composite, gd);
+    public AddCompositeConstraintOptionDialog(Shell parent,
+                                              FormToolkit toolkit,
+                                              RuleModeller modeller,
+                                              CompositeFieldConstraint constraint,
+                                              FactPattern pattern) {
+        super( parent,
+               "Add fields to this constriant",
+               "Pick the value from combo." );
 
-		return composite;
-	}
-	
-	private void createFieldRestrictionCombo(Composite composite, GridData gd) {
-		toolkit.createLabel(composite, "Add a restriction on a field");
-		final Combo combo = new Combo(composite, SWT.READ_ONLY);
-		combo.setLayoutData(gd);
-		combo.add("...");
-		String[] fields = this.modeller.getSuggestionCompletionEngine().getFieldCompletions( this.pattern.factType );
+        this.toolkit = toolkit;
+        this.modeller = modeller;
+        this.constraint = constraint;
+        this.pattern = pattern;
+    }
+
+    protected Control createDialogArea(final Composite parent) {
+        Composite composite = (Composite) super.createDialogArea( parent );
+
+        GridLayout l = new GridLayout();
+        l.numColumns = 3;
+        l.marginBottom = 0;
+        l.marginHeight = 0;
+        l.marginLeft = 0;
+        l.marginRight = 0;
+        l.marginTop = 0;
+        l.marginWidth = 0;
+        composite.setLayout( l );
+
+        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = 2;
+
+        createFieldRestrictionCombo( composite,
+                                     gd );
+        createMultiFieldCombo( composite,
+                               gd );
+
+        return composite;
+    }
+
+    private void createFieldRestrictionCombo(Composite composite,
+                                             GridData gd) {
+        createLabel( composite,
+                     "Add a restriction on a field" );
+        final Combo combo = new Combo( composite,
+                                       SWT.READ_ONLY );
+        combo.setLayoutData( gd );
+        combo.add( "..." );
+        String[] fields = this.modeller.getSuggestionCompletionEngine().getFieldCompletions( this.pattern.factType );
         for ( int i = 0; i < fields.length; i++ ) {
             combo.add( fields[i] );
         }
-		combo.select(0);
-		
-		combo.addListener(SWT.Selection, new Listener() {
-			public void handleEvent(Event event) {
-				if (combo.getSelectionIndex() == 0) {
-					return;
-				}
-				
-				constraint.addConstraint( new SingleFieldConstraint( combo.getText() ));
-				modeller.setDirty(true);
-				modeller.reloadLhs();
-				close();
-			}
-		});
+        combo.select( 0 );
 
-	}
-	
-	private void createMultiFieldCombo(Composite composite, GridData gd) {
-		toolkit.createLabel(composite, "Multiple field constraint");
-		final Combo combo = new Combo(composite, SWT.READ_ONLY);
-		combo.setLayoutData(gd);
-		combo.add("...");
-		combo.add("All of (And)");
-		combo.add("Any of (Or)");
-		combo.setData("All of (And)",
-				CompositeFieldConstraint.COMPOSITE_TYPE_AND);
-		combo.setData("Any of (Or)",
-				CompositeFieldConstraint.COMPOSITE_TYPE_OR);
-		combo.select(0);
-		
-		combo.addListener(SWT.Selection, new Listener() {
-			public void handleEvent(Event event) {
-				if (combo.getSelectionIndex() == 0) {
-					return;
-				}
-				CompositeFieldConstraint comp = new CompositeFieldConstraint();
-                comp.compositeJunctionType = combo.getText();
-                constraint.addConstraint( comp );
-                
-				modeller.reloadLhs();
-				modeller.setDirty(true);
-				close();
-			}
-		});
+        combo.addListener( SWT.Selection,
+                           new Listener() {
+                               public void handleEvent(Event event) {
+                                   if ( combo.getSelectionIndex() == 0 ) {
+                                       return;
+                                   }
 
-	}
-	
+                                   constraint.addConstraint( new SingleFieldConstraint( combo.getText() ) );
+                                   modeller.setDirty( true );
+                                   modeller.reloadLhs();
+                                   close();
+                               }
+                           } );
+
+    }
+
+    private void createMultiFieldCombo(Composite composite,
+                                       GridData gd) {
+        createLabel( composite,
+                     "Multiple field constraint" );
+        final Combo combo = new Combo( composite,
+                                       SWT.READ_ONLY );
+        combo.setLayoutData( gd );
+        combo.add( "..." );
+        combo.add( "All of (And)" );
+        combo.add( "Any of (Or)" );
+        combo.setData( "All of (And)",
+                       CompositeFieldConstraint.COMPOSITE_TYPE_AND );
+        combo.setData( "Any of (Or)",
+                       CompositeFieldConstraint.COMPOSITE_TYPE_OR );
+        combo.select( 0 );
+
+        combo.addListener( SWT.Selection,
+                           new Listener() {
+                               public void handleEvent(Event event) {
+                                   if ( combo.getSelectionIndex() == 0 ) {
+                                       return;
+                                   }
+                                   CompositeFieldConstraint comp = new CompositeFieldConstraint();
+                                   comp.compositeJunctionType = combo.getText();
+                                   constraint.addConstraint( comp );
+
+                                   modeller.reloadLhs();
+                                   modeller.setDirty( true );
+                                   close();
+                               }
+                           } );
+
+    }
+
 }

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewActionDialog.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/AddNewActionDialog.java	2007-06-20 05:16:09 UTC (rev 12707)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewActionDialog.java	2007-06-22 00:27:12 UTC (rev 12760)
@@ -22,142 +22,166 @@
  */
 public class AddNewActionDialog extends RuleDialog {
 
-	private final FormToolkit toolkit;
+    private final FormToolkit toolkit;
 
-	private RuleModeller modeller;
+    private RuleModeller      modeller;
 
-	public AddNewActionDialog(Shell parent, FormToolkit toolkit,
-			RuleModeller modeller) {
-		super(parent, "Add a new action",
-				"Pick the values from combos and confirm the selection.");
-		this.toolkit = toolkit;
-		this.modeller = modeller;
-	}
+    public AddNewActionDialog(Shell parent,
+                              FormToolkit toolkit,
+                              RuleModeller modeller) {
+        super( parent,
+               "Add a new action",
+               "Pick the values from combos and confirm the selection." );
+        this.toolkit = toolkit;
+        this.modeller = modeller;
+    }
 
-	protected Control createDialogArea(final Composite parent) {
-		Composite composite = (Composite) super.createDialogArea(parent);
-		String heading = "Choose...";
+    protected Control createDialogArea(final Composite parent) {
+        Composite composite = (Composite) super.createDialogArea( parent );
+        String heading = "Choose...";
 
-		createGlobalVariablesPart(composite, heading);
+        createGlobalVariablesPart( composite,
+                                   heading );
 
-		String[] facts = getCompletion().getFactTypes();
+        String[] facts = getCompletion().getFactTypes();
 
-		createFactAssertionPart(composite, heading, facts);
+        createFactAssertionPart( composite,
+                                 heading,
+                                 facts );
 
-		createFactLogicalAssertionPart(composite, heading, facts);
+        createFactLogicalAssertionPart( composite,
+                                        heading,
+                                        facts );
 
-		createDslSentences(composite, heading);
+        createDslSentences( composite,
+                            heading );
 
-		return composite;
-	}
+        return composite;
+    }
 
-	private void createDslSentences(Composite composite, String heading) {
-		if (getCompletion().getDSLActions().length > 0) {
-			toolkit.createLabel(composite, "Actions");
+    private void createDslSentences(Composite composite,
+                                    String heading) {
+        if ( getCompletion().getDSLActions().length > 0 ) {
+            createLabel( composite,
+                         "Actions" );
 
-			final Combo dslCombo = new Combo(composite, SWT.READ_ONLY);
-			dslCombo.add(heading);
-			for (int i = 0; i < getCompletion().getDSLActions().length; i++) {
-				DSLSentence sen = (DSLSentence) getCompletion().getDSLActions()[i];
-				dslCombo.add(sen.toString());
+            final Combo dslCombo = new Combo( composite,
+                                              SWT.READ_ONLY );
+            dslCombo.add( heading );
+            for ( int i = 0; i < getCompletion().getDSLActions().length; i++ ) {
+                DSLSentence sen = getCompletion().getDSLActions()[i];
+                dslCombo.add( sen.toString() );
+            }
 
-				dslCombo.addListener(SWT.Selection, new Listener() {
-					public void handleEvent(Event event) {
-						if (dslCombo.getSelectionIndex() == 0) {
-							return;
-						}
+            dslCombo.select( 0 );
 
-						modeller.getModel()
-								.addRhsItem(
-										(DSLSentence) getCompletion()
-												.getDSLActions()[dslCombo
-												.getSelectionIndex()]);
-						modeller.setDirty(true);
-						modeller.reloadRhs();
-						close();
-					}
-				});
-			}
-		}
-	}
+            dslCombo.addListener( SWT.Selection,
+                                  new Listener() {
+                                      public void handleEvent(Event event) {
+                                          if ( dslCombo.getSelectionIndex() == 0 ) {
+                                              return;
+                                          }
 
-	private void createFactLogicalAssertionPart(Composite composite,
-			String heading, String[] facts) {
-		toolkit.createLabel(composite, "Logically assert a new fact");
-		final Combo factsCombo = createFactsCombo(composite, heading, facts);
-		factsCombo.addListener(SWT.Selection, new Listener() {
-			public void handleEvent(Event event) {
+                                          modeller.getModel().addRhsItem( getCompletion().getDSLActions()[dslCombo.getSelectionIndex() - 1] );
+                                          modeller.setDirty( true );
+                                          modeller.reloadRhs();
+                                          close();
+                                      }
+                                  } );
 
-				if (factsCombo.getSelectionIndex() == 0) {
-					return;
-				}
+        }
+    }
 
-				modeller.getModel().addRhsItem(
-						new ActionInsertLogicalFact(factsCombo.getText()));
-				modeller.setDirty(true);
-				modeller.reloadRhs();
-				close();
-			}
-		});
-	}
+    private void createFactLogicalAssertionPart(Composite composite,
+                                                String heading,
+                                                String[] facts) {
+        createLabel( composite,
+                     "Logically assert a new fact" );
+        final Combo factsCombo = createFactsCombo( composite,
+                                                   heading,
+                                                   facts );
+        factsCombo.addListener( SWT.Selection,
+                                new Listener() {
+                                    public void handleEvent(Event event) {
 
-	private void createFactAssertionPart(Composite composite, String heading,
-			String[] facts) {
-		toolkit.createLabel(composite, "Assert a new fact");
-		final Combo factsCombo = createFactsCombo(composite, heading, facts);
-		factsCombo.addListener(SWT.Selection, new Listener() {
-			public void handleEvent(Event event) {
-				if (factsCombo.getSelectionIndex() == 0) {
-					return;
-				}
+                                        if ( factsCombo.getSelectionIndex() == 0 ) {
+                                            return;
+                                        }
 
-				modeller.getModel().addRhsItem(
-						new ActionInsertFact(factsCombo.getText()));
-				modeller.setDirty(true);
-				modeller.reloadRhs();
-				close();
-			}
-		});
-	}
+                                        modeller.getModel().addRhsItem( new ActionInsertLogicalFact( factsCombo.getText() ) );
+                                        modeller.setDirty( true );
+                                        modeller.reloadRhs();
+                                        close();
+                                    }
+                                } );
+    }
 
-	private Combo createFactsCombo(Composite composite, String heading,
-			String[] facts) {
-		Combo factsCombo = new Combo(composite, SWT.READ_ONLY);
-		factsCombo.add(heading);
-		for (int i = 0; i < facts.length; i++) {
-			factsCombo.add(facts[i]);
-		}
-		factsCombo.select(0);
-		return factsCombo;
-	}
+    private void createFactAssertionPart(Composite composite,
+                                         String heading,
+                                         String[] facts) {
+        createLabel( composite,
+                     "Assert a new fact" );
+        final Combo factsCombo = createFactsCombo( composite,
+                                                   heading,
+                                                   facts );
+        factsCombo.addListener( SWT.Selection,
+                                new Listener() {
+                                    public void handleEvent(Event event) {
+                                        if ( factsCombo.getSelectionIndex() == 0 ) {
+                                            return;
+                                        }
 
-	private void createGlobalVariablesPart(Composite composite, String heading) {
-		toolkit.createLabel(composite, "Set the values of a field on");
-		final Combo globalVarsCombo = new Combo(composite, SWT.READ_ONLY);
-		globalVarsCombo.add(heading);
-		String[] globalVars = getCompletion().getGlobalVariables();
-		for (int i = 0; i < globalVars.length; i++) {
-			globalVarsCombo.add(globalVars[i]);
-		}
-		globalVarsCombo.select(0);
+                                        modeller.getModel().addRhsItem( new ActionInsertFact( factsCombo.getText() ) );
+                                        modeller.setDirty( true );
+                                        modeller.reloadRhs();
+                                        close();
+                                    }
+                                } );
+    }
 
-		globalVarsCombo.addListener(SWT.Selection, new Listener() {
-			public void handleEvent(Event event) {
-				if (globalVarsCombo.getSelectionIndex() == 0) {
-					return;
-				}
+    private Combo createFactsCombo(Composite composite,
+                                   String heading,
+                                   String[] facts) {
+        Combo factsCombo = new Combo( composite,
+                                      SWT.READ_ONLY );
+        factsCombo.add( heading );
+        for ( int i = 0; i < facts.length; i++ ) {
+            factsCombo.add( facts[i] );
+        }
+        factsCombo.select( 0 );
+        return factsCombo;
+    }
 
-				modeller.getModel().addRhsItem(
-						new ActionSetField(globalVarsCombo.getText()));
-				modeller.setDirty(true);
-				modeller.reloadRhs();
-				close();
-			}
-		});
-	}
+    private void createGlobalVariablesPart(Composite composite,
+                                           String heading) {
+        createLabel( composite,
+                     "Set the values of a field on" );
+        final Combo globalVarsCombo = new Combo( composite,
+                                                 SWT.READ_ONLY );
+        globalVarsCombo.add( heading );
+        String[] globalVars = getCompletion().getGlobalVariables();
+        for ( int i = 0; i < globalVars.length; i++ ) {
+            globalVarsCombo.add( globalVars[i] );
+        }
+        globalVarsCombo.select( 0 );
 
-	public SuggestionCompletionEngine getCompletion() {
-		return modeller.getSuggestionCompletionEngine();
-	}
+        globalVarsCombo.addListener( SWT.Selection,
+                                     new Listener() {
+                                         public void handleEvent(Event event) {
+                                             if ( globalVarsCombo.getSelectionIndex() == 0 ) {
+                                                 return;
+                                             }
 
+                                             modeller.getModel().addRhsItem( new ActionSetField( globalVarsCombo.getText() ) );
+                                             modeller.setDirty( true );
+                                             modeller.reloadRhs();
+                                             close();
+                                         }
+                                     } );
+    }
+
+    public SuggestionCompletionEngine getCompletion() {
+        return modeller.getSuggestionCompletionEngine();
+    }
+
 }

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewConditionDialog.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/AddNewConditionDialog.java	2007-06-20 05:16:09 UTC (rev 12707)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewConditionDialog.java	2007-06-22 00:27:12 UTC (rev 12760)
@@ -6,8 +6,6 @@
 import org.drools.brms.client.modeldriven.brxml.FactPattern;
 import org.drools.brms.client.modeldriven.brxml.IPattern;
 import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
 import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
@@ -24,129 +22,137 @@
  */
 public class AddNewConditionDialog extends RuleDialog {
 
-	private final FormToolkit toolkit;
+    private final FormToolkit toolkit;
 
-	private IPattern pattern;
+    private IPattern          pattern;
 
-	private RuleModeller modeller;
+    private RuleModeller      modeller;
 
-	public AddNewConditionDialog(Shell parent, FormToolkit toolkit,
-			RuleModeller modeller) {
+    public AddNewConditionDialog(Shell parent,
+                                 FormToolkit toolkit,
+                                 RuleModeller modeller) {
 
-		super(parent, "Add new condition to the rule",
-				"Pick the values from combos and confirm the selection.");
+        super( parent,
+               "Add new condition to the rule",
+               "Pick the values from combos and confirm the selection." );
 
-		this.toolkit = toolkit;
-		this.modeller = modeller;
-	}
+        this.toolkit = toolkit;
+        this.modeller = modeller;
+    }
 
-	protected Control createDialogArea(final Composite parent) {
-		Control dialog = super.createDialogArea(parent);
+    protected Control createDialogArea(final Composite parent) {
+        Control dialog = super.createDialogArea( parent );
 
-		Composite composite = (Composite) dialog;
+        Composite composite = (Composite) dialog;
 
-		addFacts(composite);
+        addFacts( composite );
 
-		addConditionType(composite);
+        addConditionType( composite );
 
-		addDSLSentences(composite);
+        addDSLSentences( composite );
 
-		return composite;
-	}
+        return composite;
+    }
 
-	private void addFacts(Composite composite) {
-		toolkit.createLabel(composite, "Fact");
+    private void addFacts(Composite composite) {
+        createLabel( composite,
+                     "Fact" );
 
-		String[] factTypes = getCompletion().getFactTypes();
-		final Combo factsCombo = new Combo(composite, SWT.READ_ONLY);
-		factsCombo.add("Choose fact type...");
-		for (int i = 0; i < factTypes.length; i++) {
-			factsCombo.add(factTypes[i]);
-		}
-		factsCombo.select(0);
+        String[] factTypes = getCompletion().getFactTypes();
+        final Combo factsCombo = new Combo( composite,
+                                            SWT.READ_ONLY );
+        factsCombo.add( "Choose fact type..." );
+        for ( int i = 0; i < factTypes.length; i++ ) {
+            factsCombo.add( factTypes[i] );
+        }
+        factsCombo.select( 0 );
 
-		factsCombo.addListener(SWT.Selection, new Listener() {
-			public void handleEvent(Event event) {
-				if (factsCombo.getSelectionIndex() == 0) {
-					return;
-				}
-				modeller.getModel().addLhsItem(
-						new FactPattern(factsCombo.getText()));
-				modeller.reloadLhs();
-				modeller.setDirty(true);
-				close();
-			}
-		});
-	}
+        factsCombo.addListener( SWT.Selection,
+                                new Listener() {
+                                    public void handleEvent(Event event) {
+                                        if ( factsCombo.getSelectionIndex() == 0 ) {
+                                            return;
+                                        }
+                                        modeller.getModel().addLhsItem( new FactPattern( factsCombo.getText() ) );
+                                        modeller.reloadLhs();
+                                        modeller.setDirty( true );
+                                        close();
+                                    }
+                                } );
+    }
 
-	private void addConditionType(Composite composite) {
-		toolkit.createLabel(composite, "Condition type");
+    private void addConditionType(Composite composite) {
+        createLabel( composite,
+                     "Condition type" );
 
-		final Combo conditionalsCombo = new Combo(composite, SWT.READ_ONLY);
-		String[] conditionalElements = getCompletion().getConditionalElements();
-		conditionalsCombo.add("Choose condition type...");
-		for (int i = 0; i < conditionalElements.length; i++) {
-			conditionalsCombo.add(conditionalElements[i]);
-		}
-		conditionalsCombo.select(0);
+        final Combo conditionalsCombo = new Combo( composite,
+                                                   SWT.READ_ONLY );
+        String[] conditionalElements = getCompletion().getConditionalElements();
+        conditionalsCombo.add( "Choose condition type..." );
+        for ( int i = 0; i < conditionalElements.length; i++ ) {
+            conditionalsCombo.add( conditionalElements[i] );
+        }
+        conditionalsCombo.select( 0 );
 
-		conditionalsCombo.addListener(SWT.Selection, new Listener() {
-			public void handleEvent(Event event) {
-				if (conditionalsCombo.getSelectionIndex() == 0) {
-					return;
-				}
+        conditionalsCombo.addListener( SWT.Selection,
+                                       new Listener() {
+                                           public void handleEvent(Event event) {
+                                               if ( conditionalsCombo.getSelectionIndex() == 0 ) {
+                                                   return;
+                                               }
 
-				modeller.getModel().addLhsItem(
-						new CompositeFactPattern(conditionalsCombo.getText()));
-				modeller.reloadLhs();
-				modeller.setDirty(true);
-				close();
-			}
-		});
-	}
+                                               modeller.getModel().addLhsItem( new CompositeFactPattern( conditionalsCombo.getText() ) );
+                                               modeller.reloadLhs();
+                                               modeller.setDirty( true );
+                                               close();
+                                           }
+                                       } );
+    }
 
-	
-	//
-	// The list of DSL sentences
-	//
-	private void addDSLSentences(Composite composite) {
-		if (getCompletion().getDSLConditions().length > 0) {
-			toolkit.createLabel(composite, "Condition sentences");
-			
-			final Combo dslCombo = new Combo(composite, SWT.READ_ONLY);
-			dslCombo.add("Choose...");
+    //
+    // The list of DSL sentences
+    //
+    private void addDSLSentences(Composite composite) {
+        if ( getCompletion().getDSLConditions().length > 0 ) {
+            createLabel( composite,
+                         "Condition sentences" );
 
-			for (int i = 0; i < getCompletion().getDSLConditions().length; i++) {
-				DSLSentence sen = getCompletion().getDSLConditions()[i];
-				dslCombo.add(sen.toString());
-			}
+            final Combo dslCombo = new Combo( composite,
+                                              SWT.READ_ONLY );
+            dslCombo.add( "Choose..." );
 
-			dslCombo.addListener(SWT.Selection, new Listener() {
-				public void handleEvent(Event event) {
-					if (dslCombo.getSelectionIndex() == 0) {
-						return;
-					}
+            for ( int i = 0; i < getCompletion().getDSLConditions().length; i++ ) {
+                DSLSentence sen = getCompletion().getDSLConditions()[i];
+                dslCombo.add( sen.toString() );
+            }
 
-					modeller.getModel()
-							.addLhsItem(
-									(DSLSentence) getCompletion()
-											.getDSLConditions()[dslCombo
-											.getSelectionIndex()]);
-					modeller.reloadLhs();
-					modeller.setDirty(true);
-					close();
-				}
-			});
+            dslCombo.select( 0 );
 
-		}
-	}
+            dslCombo.addListener( SWT.Selection,
+                                  new Listener() {
+                                      public void handleEvent(Event event) {
+                                          if ( dslCombo.getSelectionIndex() == 0 ) {
+                                              return;
+                                          }
 
-	public IPattern getPattern() {
-		return pattern;
-	}
+                                          //TODO Handle this kind of situations with care - add* can throw runtime exceptions
+                                          modeller.getModel().addLhsItem( getCompletion().getDSLConditions()[dslCombo.getSelectionIndex() - 1] );
 
-	private SuggestionCompletionEngine getCompletion() {
-		return modeller.getSuggestionCompletionEngine();
-	}
+                                          modeller.reloadLhs();
+                                          modeller.setDirty( true );
+                                          close();
+                                      }
+                                  } );
 
+        }
+    }
+
+    public IPattern getPattern() {
+        return pattern;
+    }
+
+    private SuggestionCompletionEngine getCompletion() {
+        return modeller.getSuggestionCompletionEngine();
+    }
+
 }

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewFactConstraintDialog.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/AddNewFactConstraintDialog.java	2007-06-20 05:16:09 UTC (rev 12707)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewFactConstraintDialog.java	2007-06-22 00:27:12 UTC (rev 12760)
@@ -41,11 +41,9 @@
     protected Control createDialogArea(final Composite parent) {
         Composite composite = (Composite) super.createDialogArea( parent );
 
-        //System.out.println( "Creating new fact constraint" );
+        createLabel( composite,
+                     "Choose fact type" );
 
-        toolkit.createLabel( composite,
-                             "Choose fact type" );
-
         String[] fieldCompletitions = getCompletion().getFactTypes();
         final Combo factsCombo = new Combo( composite,
                                             SWT.READ_ONLY );
@@ -59,8 +57,6 @@
                                 new Listener() {
                                     public void handleEvent(Event event) {
 
-                                        //System.out.println( "HERE! event " + event );
-
                                         if ( factsCombo.getSelectionIndex() == 0 ) {
                                             return;
                                         }

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewFieldConstraintDialog.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/AddNewFieldConstraintDialog.java	2007-06-20 05:16:09 UTC (rev 12707)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewFieldConstraintDialog.java	2007-06-22 00:27:12 UTC (rev 12760)
@@ -3,6 +3,7 @@
 import org.drools.brms.client.modeldriven.SuggestionCompletionEngine;
 import org.drools.brms.client.modeldriven.brxml.CompositeFieldConstraint;
 import org.drools.brms.client.modeldriven.brxml.FactPattern;
+import org.drools.brms.client.modeldriven.brxml.ISingleFieldConstraint;
 import org.drools.brms.client.modeldriven.brxml.SingleFieldConstraint;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.GridData;
@@ -26,152 +27,175 @@
  */
 public class AddNewFieldConstraintDialog extends RuleDialog {
 
-	private final FormToolkit toolkit;
+    private final FormToolkit toolkit;
 
-	private RuleModeller modeller;
+    private RuleModeller      modeller;
 
-	private FactPattern pattern;
+    private FactPattern       pattern;
 
-	private boolean isNested;
+    private boolean           isNested;
 
-	public AddNewFieldConstraintDialog(Shell parent, FormToolkit toolkit,
-			RuleModeller modeller, FactPattern pattern, boolean isNested) {
-		super(parent, "Update constraints",
-				"Pick the values from combos and confirm the selection.");
-		this.toolkit = toolkit;
-		this.modeller = modeller;
-		this.pattern = pattern;
-		this.isNested = isNested;
-	}
+    public AddNewFieldConstraintDialog(Shell parent,
+                                       FormToolkit toolkit,
+                                       RuleModeller modeller,
+                                       FactPattern pattern,
+                                       boolean isNested) {
+        super( parent,
+               "Update constraints",
+               "Pick the values from combos and confirm the selection." );
+        this.toolkit = toolkit;
+        this.modeller = modeller;
+        this.pattern = pattern;
+        this.isNested = isNested;
+    }
 
-	protected Control createDialogArea(final Composite parent) {
-		Composite composite = (Composite) super.createDialogArea(parent);
+    protected Control createDialogArea(final Composite parent) {
+        Composite composite = (Composite) super.createDialogArea( parent );
 
-		GridLayout l = new GridLayout();
-		l.numColumns = 3;
-		l.marginBottom = 0;
-		l.marginHeight = 0;
-		l.marginLeft = 0;
-		l.marginRight = 0;
-		l.marginTop = 0;
-		l.marginWidth = 0;
-		composite.setLayout(l);
+        GridLayout l = new GridLayout();
+        l.numColumns = 3;
+        l.marginBottom = 0;
+        l.marginHeight = 0;
+        l.marginLeft = 0;
+        l.marginRight = 0;
+        l.marginTop = 0;
+        l.marginWidth = 0;
+        composite.setLayout( l );
 
-		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
-		gd.horizontalSpan = 2;
+        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = 2;
 
-		createFieldRestrictionCombo(composite, gd);
-		createMultipleRestrictionCombo(composite, gd);
-		createFormulaRow(composite, gd);
-		if (!isNested) {
-			createVariableBindingRow(composite);
-		}
+        createFieldRestrictionCombo( composite,
+                                     gd );
+        createMultipleRestrictionCombo( composite,
+                                        gd );
+        createFormulaRow( composite,
+                          gd );
+        if ( !isNested ) {
+            createVariableBindingRow( composite );
+        }
 
-		toolkit.paintBordersFor(composite);
-		return composite;
-	}
+        toolkit.paintBordersFor( composite );
+        return composite;
+    }
 
-	private void createMultipleRestrictionCombo(Composite composite, GridData gd) {
-		toolkit.createLabel(composite, "Multiple field constriant");
-		final Combo composites = new Combo(composite, SWT.READ_ONLY);
+    private void createMultipleRestrictionCombo(Composite composite,
+                                                GridData gd) {
+        createLabel( composite,
+                     "Multiple field constriant" );
+        final Combo composites = new Combo( composite,
+                                            SWT.READ_ONLY );
 
-		composites.setLayoutData(gd);
+        composites.setLayoutData( gd );
 
-		composites.add("...");
-		composites.add("All of (And)");
-		composites.add("Any of (Or)");
-		composites.setData("All of (And)",
-				CompositeFieldConstraint.COMPOSITE_TYPE_AND);
-		composites.setData("Any of (Or)",
-				CompositeFieldConstraint.COMPOSITE_TYPE_OR);
-		composites.select(0);
+        composites.add( "..." );
+        composites.add( "All of (And)" );
+        composites.add( "Any of (Or)" );
+        composites.setData( "All of (And)",
+                            CompositeFieldConstraint.COMPOSITE_TYPE_AND );
+        composites.setData( "Any of (Or)",
+                            CompositeFieldConstraint.COMPOSITE_TYPE_OR );
+        composites.select( 0 );
 
-		composites.addListener(SWT.Selection, new Listener() {
-			public void handleEvent(Event event) {
-				if (composites.getSelectionIndex() == 0) {
-					return;
-				}
+        composites.addListener( SWT.Selection,
+                                new Listener() {
+                                    public void handleEvent(Event event) {
+                                        if ( composites.getSelectionIndex() == 0 ) {
+                                            return;
+                                        }
 
-				CompositeFieldConstraint comp = new CompositeFieldConstraint();
-				comp.compositeJunctionType = (String) composites
-						.getData(composites.getText());
+                                        CompositeFieldConstraint comp = new CompositeFieldConstraint();
+                                        comp.compositeJunctionType = (String) composites.getData( composites.getText() );
 
-				pattern.addConstraint(comp);
-				modeller.reloadLhs();    //TODO:review, perhaps should be another order of these calls
-				modeller.setDirty(true); 
-				close();
-			}
-		});
-	}
+                                        pattern.addConstraint( comp );
+                                        modeller.reloadLhs(); //TODO:review, perhaps should be another order of these calls
+                                        modeller.setDirty( true );
+                                        close();
+                                    }
+                                } );
+    }
 
-	private void createFieldRestrictionCombo(Composite composite, GridData gd) {
-		toolkit.createLabel(composite, "Add a restriction on a field");
-		String[] fieldCompletitions = getCompletion().getFieldCompletions(
-				pattern.factType);
-		final Combo fieldsCombo = new Combo(composite, SWT.READ_ONLY);
-		fieldsCombo.setLayoutData(gd);
-		fieldsCombo.add("...");
-		for (int i = 0; i < fieldCompletitions.length; i++) {
-			fieldsCombo.add(fieldCompletitions[i]);
-		}
-		fieldsCombo.select(0);
+    private void createFieldRestrictionCombo(Composite composite,
+                                             GridData gd) {
+        createLabel( composite,
+                     "Add a restriction on a field" );
 
-		fieldsCombo.addListener(SWT.Selection, new Listener() {
-			public void handleEvent(Event event) {
-				if (fieldsCombo.getSelectionIndex() == 0) {
-					return;
-				}
+        String[] fieldCompletitions = getCompletion().getFieldCompletions( pattern.factType );
+        final Combo fieldsCombo = new Combo( composite,
+                                             SWT.READ_ONLY );
+        fieldsCombo.setLayoutData( gd );
+        fieldsCombo.add( "..." );
+        for ( int i = 0; i < fieldCompletitions.length; i++ ) {
+            fieldsCombo.add( fieldCompletitions[i] );
+        }
+        fieldsCombo.select( 0 );
 
-				SingleFieldConstraint constraint = new SingleFieldConstraint();
-				constraint.fieldName = fieldsCombo.getText();
-				pattern.addConstraint(constraint);
-				modeller.setDirty(true);
-				modeller.reloadLhs();
-				close();
-			}
-		});
-	}
+        fieldsCombo.addListener( SWT.Selection,
+                                 new Listener() {
+                                     public void handleEvent(Event event) {
+                                         if ( fieldsCombo.getSelectionIndex() == 0 ) {
+                                             return;
+                                         }
 
-	private void createFormulaRow(Composite composite, GridData gd) {
-		toolkit.createLabel(composite, "Add a new formula style expression");
-		Button formulaButton = toolkit.createButton(composite, "New formula",
-				SWT.PUSH);
+                                         SingleFieldConstraint constraint = new SingleFieldConstraint();
+                                         constraint.fieldName = fieldsCombo.getText();
+                                         pattern.addConstraint( constraint );
+                                         modeller.setDirty( true );
+                                         modeller.reloadLhs();
+                                         close();
+                                     }
+                                 } );
+    }
 
-		formulaButton.addListener(SWT.Selection, new Listener() {
-			public void handleEvent(Event event) {
-				SingleFieldConstraint con = new SingleFieldConstraint();
-				con.constraintValueType = SingleFieldConstraint.TYPE_PREDICATE;
-				pattern.addConstraint(con);
-				modeller.setDirty(true);
-				modeller.reloadLhs();
-				close();
-			}
-		});
+    private void createFormulaRow(Composite composite,
+                                  GridData gd) {
+        createLabel( composite,
+                     "Add a new formula style expression" );
+        Button formulaButton = toolkit.createButton( composite,
+                                                     "New formula",
+                                                     SWT.PUSH );
 
-		formulaButton.setLayoutData(gd);
-	}
+        formulaButton.addListener( SWT.Selection,
+                                   new Listener() {
+                                       public void handleEvent(Event event) {
+                                           SingleFieldConstraint con = new SingleFieldConstraint();
+                                           con.constraintValueType = ISingleFieldConstraint.TYPE_PREDICATE;
+                                           pattern.addConstraint( con );
+                                           modeller.setDirty( true );
+                                           modeller.reloadLhs();
+                                           close();
+                                       }
+                                   } );
 
-	private void createVariableBindingRow(Composite composite) {
-		toolkit.createLabel(composite, "Variable name");
-		final Text variableText = toolkit.createText(composite, "");
+        formulaButton.setLayoutData( gd );
+    }
 
-		if (pattern.boundName != null) {
-			variableText.setText(pattern.boundName);
-		}
+    private void createVariableBindingRow(Composite composite) {
+        createLabel( composite,
+                     "Variable name" );
+        final Text variableText = createText( composite,
+                                              "" );
 
-		Button varButton = toolkit.createButton(composite, "Set", SWT.PUSH);
-		varButton.addListener(SWT.Selection, new Listener() {
-			public void handleEvent(Event event) {
-				pattern.boundName = variableText.getText();
-				modeller.reloadLhs();
-				modeller.setDirty(true);
-				close();
-			}
-		});
-	}
+        if ( pattern.boundName != null ) {
+            variableText.setText( pattern.boundName );
+        }
 
-	private SuggestionCompletionEngine getCompletion() {
-		return modeller.getSuggestionCompletionEngine();
-	}
+        Button varButton = toolkit.createButton( composite,
+                                                 "Set",
+                                                 SWT.PUSH );
+        varButton.addListener( SWT.Selection,
+                               new Listener() {
+                                   public void handleEvent(Event event) {
+                                       pattern.boundName = variableText.getText();
+                                       modeller.reloadLhs();
+                                       modeller.setDirty( true );
+                                       close();
+                                   }
+                               } );
+    }
 
+    private SuggestionCompletionEngine getCompletion() {
+        return modeller.getSuggestionCompletionEngine();
+    }
+
 }

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewInsertedFactFieldDialog.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/AddNewInsertedFactFieldDialog.java	2007-06-20 05:16:09 UTC (rev 12707)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewInsertedFactFieldDialog.java	2007-06-22 00:27:12 UTC (rev 12760)
@@ -27,9 +27,9 @@
     private final ActionInsertFact fact;
 
     public AddNewInsertedFactFieldDialog(Shell parent,
-                                       FormToolkit toolkit,
-                                       RuleModeller modeller,
-                                       ActionInsertFact fact) {
+                                         FormToolkit toolkit,
+                                         RuleModeller modeller,
+                                         ActionInsertFact fact) {
         super( parent,
                "Add new condition to the rule",
                "Pick the values from combos and confirm the selection." );
@@ -39,12 +39,11 @@
     }
 
     protected Control createDialogArea(final Composite parent) {
-        //System.out.println("Creating new ASSERT fact constraint");
 
         Composite composite = (Composite) super.createDialogArea( parent );
 
-        toolkit.createLabel( composite,
-                             "Field:" );
+        createLabel( composite,
+                     "Field:" );
 
         final Combo factsCombo = new Combo( composite,
                                             SWT.READ_ONLY );
@@ -59,9 +58,7 @@
         factsCombo.addListener( SWT.Selection,
                                 new Listener() {
                                     public void handleEvent(Event event) {
-                                        
-                                        System.out.println("HERE2222! event "+event);
-                                        
+
                                         if ( factsCombo.getSelectionIndex() == 0 ) {
                                             return;
                                         }

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AssignFieldVariableDialog.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/AssignFieldVariableDialog.java	2007-06-20 05:16:09 UTC (rev 12707)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AssignFieldVariableDialog.java	2007-06-22 00:27:12 UTC (rev 12760)
@@ -15,66 +15,70 @@
 
 public class AssignFieldVariableDialog extends RuleDialog {
 
-	private final FormToolkit toolkit;
+    private final FormToolkit     toolkit;
 
-	private RuleModeller modeller;
-	
-	private SingleFieldConstraint con;
+    private RuleModeller          modeller;
 
-	public AssignFieldVariableDialog(Shell parent, FormToolkit toolkit,
-			RuleModeller modeller, SingleFieldConstraint con) {
-		super(parent, "Bind the field called [" + con.fieldName
-				+ "] to a variable.",
-				"Type the variable name and hit the button.");
-		
-		this.toolkit = toolkit;
-		this.modeller = modeller;
-		this.con = con;
-	}
-	
-	protected Control createDialogArea(final Composite parent) {
-		Composite composite = (Composite) super.createDialogArea(parent);
-		
-		GridLayout l = new GridLayout();
-		l.numColumns = 5;
-		l.marginBottom = 0;
-		l.marginHeight = 0;
-		l.marginLeft = 0;
-		l.marginRight = 0;
-		l.marginTop = 0;
-		l.marginWidth = 0;
-		composite.setLayout(l);
+    private SingleFieldConstraint con;
 
-		
-		
-		createVariableBindingRow(composite);
-		toolkit.paintBordersFor(composite);
-		return composite;
-	}
-	
-	private void createVariableBindingRow(Composite composite) {
-		toolkit.createLabel(composite, "Variable name");
-		final Text variableText = toolkit.createText(composite, "");
+    public AssignFieldVariableDialog(Shell parent,
+                                     FormToolkit toolkit,
+                                     RuleModeller modeller,
+                                     SingleFieldConstraint con) {
+        super( parent,
+               "Bind the field called [" + con.fieldName + "] to a variable.",
+               "Type the variable name and hit the button." );
 
-		if (con.fieldBinding != null) {
-			variableText.setText(con.fieldBinding);
-		}
+        this.toolkit = toolkit;
+        this.modeller = modeller;
+        this.con = con;
+    }
 
-		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
-		gd.horizontalSpan = 3;
-		
-		variableText.setLayoutData(gd);
-		
-		Button varButton = toolkit.createButton(composite, "Set", SWT.PUSH);
-		varButton.addListener(SWT.Selection, new Listener() {
-			public void handleEvent(Event event) {
-				con.fieldBinding = variableText.getText();
-				modeller.reloadLhs();
-				modeller.setDirty(true);
-				close();
-			}
-		});
-	}
+    protected Control createDialogArea(final Composite parent) {
+        Composite composite = (Composite) super.createDialogArea( parent );
 
+        GridLayout l = new GridLayout();
+        l.numColumns = 5;
+        l.marginBottom = 0;
+        l.marginHeight = 0;
+        l.marginLeft = 0;
+        l.marginRight = 0;
+        l.marginTop = 0;
+        l.marginWidth = 0;
+        composite.setLayout( l );
 
+        createVariableBindingRow( composite );
+        toolkit.paintBordersFor( composite );
+        return composite;
+    }
+
+    private void createVariableBindingRow(Composite composite) {
+        createLabel( composite,
+                     "Variable name" );
+        final Text variableText = toolkit.createText( composite,
+                                                      "" );
+
+        if ( con.fieldBinding != null ) {
+            variableText.setText( con.fieldBinding );
+        }
+
+        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = 3;
+
+        variableText.setLayoutData( gd );
+
+        Button varButton = toolkit.createButton( composite,
+                                                 "Set",
+                                                 SWT.PUSH );
+        varButton.addListener( SWT.Selection,
+                               new Listener() {
+                                   public void handleEvent(Event event) {
+                                       con.fieldBinding = variableText.getText();
+                                       modeller.reloadLhs();
+                                       modeller.setDirty( true );
+                                       close();
+                                   }
+                               } );
+    }
+
 }

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/CompositeFactPatternWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/CompositeFactPatternWidget.java	2007-06-20 05:16:09 UTC (rev 12707)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/CompositeFactPatternWidget.java	2007-06-22 00:27:12 UTC (rev 12760)
@@ -70,10 +70,10 @@
                 dialog.setMessage( "Remove this ENTIRE condition, " + "and all the field constraints that belong to it." );
                 dialog.setText( "Remove this entire condition?" );
                 if ( dialog.open() == SWT.YES ) {
-                    getModeller().setDirty( true );
 
                     if ( getModeller().getModel().removeLhsItem( index ) ) {
                         getModeller().reloadLhs();
+                        getModeller().setDirty( true );
                     } else {
                         showMessage( "Can't remove that item as it is used in the action part of the rule." );
                     }
@@ -97,9 +97,9 @@
         link.addHyperlinkListener( new IHyperlinkListener() {
             public void linkActivated(HyperlinkEvent e) {
                 RuleDialog popup = new AddNewFactConstraintDialog( parent.getShell(),
-                                                                    toolkit,
-                                                                    getModeller(),
-                                                                    pattern );
+                                                                   toolkit,
+                                                                   getModeller(),
+                                                                   pattern );
                 popup.open();
             }
 

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/DSLSentenceWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/DSLSentenceWidget.java	2007-06-20 05:16:09 UTC (rev 12707)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/DSLSentenceWidget.java	2007-06-22 00:27:12 UTC (rev 12760)
@@ -28,101 +28,134 @@
  */
 public abstract class DSLSentenceWidget extends Widget {
 
-	private final DSLSentence sentence;
+    private final DSLSentence sentence;
 
-	private List widgets = new ArrayList();
+    private List              widgets = new ArrayList();
 
-	public DSLSentenceWidget(FormToolkit toolkit, Composite parent,
-			DSLSentence sentence, RuleModeller modeller, int index) {
-		super(parent, toolkit, modeller, index);
+    public DSLSentenceWidget(FormToolkit toolkit,
+                             Composite parent,
+                             DSLSentence sentence,
+                             RuleModeller modeller,
+                             int index) {
+        super( parent,
+               toolkit,
+               modeller,
+               index );
 
-		this.sentence = sentence;
+        this.sentence = sentence;
 
-		GridLayout l = new GridLayout();
-		l.numColumns = sentence.sentence.length() + 1;
-		l.verticalSpacing = 0;
-		l.marginTop = 0;
-		l.marginHeight = 2;
-		l.marginBottom = 0;
-		parent.setLayout(l);
+        makeWidget();
+        addDeleteAction();
+    }
 
-		makeWidget();
-		addDeleteAction();
-	}
+    protected abstract void updateModel();
 
-	protected abstract void updateModel();
+    private void addDeleteAction() {
 
-	private void addDeleteAction() {
-		ImageHyperlink delLink = addImage(parent, "icons/delete_obj.gif");
-		delLink.addHyperlinkListener(new IHyperlinkListener() {
+        ImageHyperlink delLink = addImage( parent,
+                                           "icons/delete_item_small.gif" );
+        delLink.addHyperlinkListener( new IHyperlinkListener() {
 
-			public void linkActivated(HyperlinkEvent e) {
-				MessageBox dialog = new MessageBox(Display.getCurrent()
-						.getActiveShell(), SWT.YES | SWT.NO | SWT.ICON_WARNING);
-				dialog.setMessage("Remove this DSL sentense?");
-				dialog.setText("Remove this DSL sentense?");
-				if (dialog.open() == SWT.YES){
-					updateModel();
-				}
-			}
+            public void linkActivated(HyperlinkEvent e) {
+                MessageBox dialog = new MessageBox( Display.getCurrent().getActiveShell(),
+                                                    SWT.YES | SWT.NO | SWT.ICON_WARNING );
+                dialog.setMessage( "Remove this DSL sentense?" );
+                dialog.setText( "Remove this DSL sentense?" );
+                if ( dialog.open() == SWT.YES ) {
+                    updateModel();
+                }
+            }
 
-			public void linkEntered(HyperlinkEvent e) {
-			}
+            public void linkEntered(HyperlinkEvent e) {
+            }
 
-			public void linkExited(HyperlinkEvent e) {
-			}
-		});
-		delLink.setToolTipText("Remove this condition.");
-	}
+            public void linkExited(HyperlinkEvent e) {
+            }
+        } );
+        delLink.setToolTipText( "Remove this condition." );
+    }
 
-	private void makeWidget() {
-		char[] chars = this.sentence.sentence.toCharArray();
-		Text currentBox = null;
-		Label currentLabel = null;
-		for (int i = 0; i < chars.length; i++) {
-			char c = chars[i];
-			if (c == '{') {
-				currentLabel = null;
-				currentBox = toolkit.createText(parent, "");
+    private void makeWidget() {
 
-				currentBox.addModifyListener(new ModifyListener() {
-					public void modifyText(ModifyEvent e) {
-						updateSentence();
-						getModeller().setDirty(true);
-					}
-				});
+        int elems = 0;
 
-				widgets.add(currentBox);
+        char[] chars = this.sentence.sentence.toCharArray();
+        Text currentBox = null;
+        Label currentLabel = null;
+        for ( int i = 0; i < chars.length; i++ ) {
+            char c = chars[i];
+            if ( c == '{' ) {
+                currentLabel = null;
 
-			} else if (c == '}') {
-				currentBox = null;
-			} else {
-				if (currentBox == null && currentLabel == null) {
-					currentLabel = toolkit.createLabel(parent, "");
-					widgets.add(currentLabel);
-				}
-				if (currentLabel != null) {
-					currentLabel.setText(currentLabel.getText() + c);
-				} else if (currentBox != null) {
-					currentBox.setText(currentBox.getText() + c);
-				}
-			}
-		}
+                currentBox = toolkit.createText( parent,
+                                                 "" );
 
-		toolkit.paintBordersFor(parent);
-	}
+                //final Text thisBox = currentBox;
+                elems++;
 
-	protected void updateSentence() {
-		String newSentence = "";
-		for (Iterator iter = widgets.iterator(); iter.hasNext();) {
-			Control wid = (Control) iter.next();
-			if (wid instanceof Label) {
-				newSentence = newSentence + ((Label) wid).getText();
-			} else if (wid instanceof Text) {
-				newSentence = newSentence + "{" + ((Text) wid).getText() + "}";
-			}
-		}
-		this.sentence.sentence = newSentence.trim();
-	}
+                currentBox.addModifyListener( new ModifyListener() {
+                    public void modifyText(ModifyEvent e) {
+                        updateSentence();
+                        /*                        Point p = thisBox.getSize();
+                         
+                         GC gc = new GC(thisBox);
+                         gc.setFont(thisBox.getFont());
+                         FontMetrics fontMetrics = gc.getFontMetrics();
+                         int w = fontMetrics.getAverageCharWidth()*thisBox.getText().length();
+                         gc.dispose();
+                         
+                         
+                         thisBox.setSize( w, p.y );
+                         thisBox.redraw();
+                         parent.redraw();
+                         */
+                        getModeller().setDirty( true );
+                    }
+                } );
 
+                widgets.add( currentBox );
+
+            } else if ( c == '}' ) {
+                currentBox = null;
+            } else {
+                if ( currentBox == null && currentLabel == null ) {
+                    currentLabel = toolkit.createLabel( parent,
+                                                        "" );
+                    elems++;
+
+                    widgets.add( currentLabel );
+                }
+                if ( currentLabel != null ) {
+                    currentLabel.setText( currentLabel.getText() + c );
+                } else if ( currentBox != null ) {
+                    currentBox.setText( currentBox.getText() + c );
+                }
+            }
+        }
+
+        GridLayout l = new GridLayout();
+        int cols = elems + 1;
+        l.numColumns = cols;
+        l.verticalSpacing = 0;
+        l.marginTop = 0;
+        l.marginHeight = 2;
+        l.marginBottom = 0;
+        parent.setLayout( l );
+
+        toolkit.paintBordersFor( parent );
+    }
+
+    protected void updateSentence() {
+        String newSentence = "";
+        for ( Iterator iter = widgets.iterator(); iter.hasNext(); ) {
+            Control wid = (Control) iter.next();
+            if ( wid instanceof Label ) {
+                newSentence = newSentence + ((Label) wid).getText();
+            } else if ( wid instanceof Text ) {
+                newSentence = newSentence + "{" + ((Text) wid).getText() + "}";
+            }
+        }
+        this.sentence.sentence = newSentence.trim();
+    }
+
 }

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/FactPatternWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/FactPatternWidget.java	2007-06-20 05:16:09 UTC (rev 12707)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/FactPatternWidget.java	2007-06-22 00:27:12 UTC (rev 12760)
@@ -40,584 +40,684 @@
  */
 public class FactPatternWidget extends Widget {
 
-	private final CompositeFactPattern parentPattern;
+    private final CompositeFactPattern parentPattern;
 
-	private final FactPattern pattern;
+    private final FactPattern          pattern;
 
-	private boolean bindable;
+    private boolean                    bindable;
 
-	public FactPatternWidget(FormToolkit toolkit, Composite parent,
-			RuleModeller mod, FactPattern factPattern,
-			CompositeFactPattern parentPattern, int idx, boolean canBind) {
+    public FactPatternWidget(FormToolkit toolkit,
+                             Composite parent,
+                             RuleModeller mod,
+                             FactPattern factPattern,
+                             CompositeFactPattern parentPattern,
+                             int idx,
+                             boolean canBind) {
 
-		super(parent, toolkit, mod, idx);
+        super( parent,
+               toolkit,
+               mod,
+               idx );
 
-		this.pattern = factPattern;
-		this.parentPattern = parentPattern;
-		this.bindable = canBind;
+        this.pattern = factPattern;
+        this.parentPattern = parentPattern;
+        this.bindable = canBind;
 
-		GridLayout l = new GridLayout();
-		l.numColumns = 4;
-		l.marginBottom = 0;
-		l.marginHeight = 0;
-		l.marginLeft = 0;
-		l.marginRight = 0;
-		l.marginTop = 0;
-		l.marginWidth = 0;
-		l.verticalSpacing = 0;
-		parent.setLayout(l);
+        GridLayout l = new GridLayout();
+        l.numColumns = 4;
+        l.marginBottom = 0;
+        l.marginHeight = 0;
+        l.marginLeft = 0;
+        l.marginRight = 0;
+        l.marginTop = 0;
+        l.marginWidth = 0;
+        l.verticalSpacing = 0;
+        parent.setLayout( l );
 
-		create();
-	}
+        create();
+    }
 
-	private void create() {
-		toolkit.createLabel(parent, getPatternLabel());
-		addDeleteAction();
-		addMoreOptionsAction();
-		Composite constraintComposite = toolkit.createComposite(parent);
-		GridLayout constraintLayout = new GridLayout();
-		constraintLayout.numColumns = 8;
-		constraintComposite.setLayout(constraintLayout);
+    private void create() {
+        toolkit.createLabel( parent,
+                             getPatternLabel() );
+        addDeleteAction();
+        addMoreOptionsAction();
+        Composite constraintComposite = toolkit.createComposite( parent );
+        GridLayout constraintLayout = new GridLayout();
+        constraintLayout.numColumns = 8;
+        constraintComposite.setLayout( constraintLayout );
 
-		for (int row = 0; row < pattern.getFieldConstraints().length; row++) {
-			renderFieldConstraints(constraintComposite, pattern
-					.getFieldConstraints()[row], null, row, true, false);
-		}
+        for ( int row = 0; row < pattern.getFieldConstraints().length; row++ ) {
+            renderFieldConstraints( constraintComposite,
+                                    pattern.getFieldConstraints()[row],
+                                    null,
+                                    row,
+                                    true,
+                                    false );
+        }
 
-		toolkit.paintBordersFor(constraintComposite);
-	}
+        toolkit.paintBordersFor( constraintComposite );
+    }
 
-	private void addMoreOptionsAction() {
-		ImageHyperlink link = addImage(parent, "icons/new_item.gif");
+    private void addMoreOptionsAction() {
+        ImageHyperlink link = addImage( parent,
+                                        "icons/new_item.gif" );
 
-		link.addHyperlinkListener(new IHyperlinkListener() {
-			public void linkActivated(HyperlinkEvent e) {
-				RuleDialog popup = new AddNewFieldConstraintDialog(parent
-						.getShell(), toolkit, getModeller(), pattern,
-						parentPattern != null);
-				popup.open();
-			}
+        link.addHyperlinkListener( new IHyperlinkListener() {
+            public void linkActivated(HyperlinkEvent e) {
+                RuleDialog popup = new AddNewFieldConstraintDialog( parent.getShell(),
+                                                                    toolkit,
+                                                                    getModeller(),
+                                                                    pattern,
+                                                                    parentPattern != null );
+                popup.open();
+            }
 
-			public void linkEntered(HyperlinkEvent e) {
-			}
+            public void linkEntered(HyperlinkEvent e) {
+            }
 
-			public void linkExited(HyperlinkEvent e) {
-			}
-		});
-		link
-				.setToolTipText("Add a field to this condition, or bind a varible to this fact.");
-	}
+            public void linkExited(HyperlinkEvent e) {
+            }
+        } );
+        link.setToolTipText( "Add a field to this condition, or bind a varible to this fact." );
+    }
 
-	private void addDeleteAction() {
-		ImageHyperlink delWholeLink = addImage(parent, "icons/delete_obj.gif");
-		delWholeLink.addHyperlinkListener(new IHyperlinkListener() {
-			public void linkActivated(HyperlinkEvent e) {
-				MessageBox dialog = new MessageBox(Display.getCurrent()
-						.getActiveShell(), SWT.YES | SWT.NO | SWT.ICON_WARNING);
-				dialog.setMessage("Remove this ENTIRE condition, "
-						+ "and all the field constraints that belong to it.");
-				dialog.setText("Remove this entire condition?");
-				if (dialog.open() == SWT.YES) {
-					if (parentPattern == null) {
-						if (getModeller().getModel().removeLhsItem(index)) {
-							getModeller().reloadLhs();
-						} else {
-							showMessage("Can't remove that item as it is used in the action part of the rule.");
-						}
-					} else {
-						deleteBindedFact();
-					}
-					getModeller().setDirty(true);
-				}
-			}
+    private void addDeleteAction() {
+        ImageHyperlink delWholeLink = addImage( parent,
+                                                "icons/delete_obj.gif" );
+        delWholeLink.addHyperlinkListener( new IHyperlinkListener() {
+            public void linkActivated(HyperlinkEvent e) {
+                MessageBox dialog = new MessageBox( Display.getCurrent().getActiveShell(),
+                                                    SWT.YES | SWT.NO | SWT.ICON_WARNING );
+                dialog.setMessage( "Remove this ENTIRE condition, " + "and all the field constraints that belong to it." );
+                dialog.setText( "Remove this entire condition?" );
+                if ( dialog.open() == SWT.YES ) {
+                    if ( parentPattern == null ) {
+                        if ( getModeller().getModel().removeLhsItem( index ) ) {
+                            getModeller().reloadLhs();
+                        } else {
+                            showMessage( "Can't remove that item as it is used in the action part of the rule." );
+                        }
+                    } else {
+                        deleteBindedFact();
+                    }
+                    getModeller().setDirty( true );
+                }
+            }
 
-			public void linkEntered(HyperlinkEvent e) {
-			}
+            public void linkEntered(HyperlinkEvent e) {
+            }
 
-			public void linkExited(HyperlinkEvent e) {
-			}
-		});
-		delWholeLink.setToolTipText("Remove this condition.");
-	}
+            public void linkExited(HyperlinkEvent e) {
+            }
+        } );
+        delWholeLink.setToolTipText( "Remove this condition." );
+    }
 
-	private void renderFieldConstraints(Composite constraintComposite,
-			FieldConstraint constraint,
-			final CompositeFieldConstraint parentConstraint, int row,
-			boolean showBinding, boolean nested) {
-		if (constraint instanceof SingleFieldConstraint) {
-			renderSingleFieldConstraint(constraintComposite, row, constraint,
-					parentConstraint, showBinding, nested);
-		} else if (constraint instanceof CompositeFieldConstraint) {
-			compositeFieldConstraintEditor(constraintComposite,
-					(CompositeFieldConstraint) constraint, parentConstraint,
-					row, nested);
-		}
-	}
+    private void renderFieldConstraints(Composite constraintComposite,
+                                        FieldConstraint constraint,
+                                        final CompositeFieldConstraint parentConstraint,
+                                        int row,
+                                        boolean showBinding,
+                                        boolean nested) {
+        if ( constraint instanceof SingleFieldConstraint ) {
+            renderSingleFieldConstraint( constraintComposite,
+                                         row,
+                                         constraint,
+                                         parentConstraint,
+                                         showBinding,
+                                         nested );
+        } else if ( constraint instanceof CompositeFieldConstraint ) {
+            compositeFieldConstraintEditor( constraintComposite,
+                                            (CompositeFieldConstraint) constraint,
+                                            parentConstraint,
+                                            row,
+                                            nested );
+        }
+    }
 
-	private void compositeFieldConstraintEditor(Composite constraintComposite,
-			final CompositeFieldConstraint constraint,
-			final CompositeFieldConstraint parentConstraint, final int row,
-			boolean nested) {
+    private void compositeFieldConstraintEditor(Composite constraintComposite,
+                                                final CompositeFieldConstraint constraint,
+                                                final CompositeFieldConstraint parentConstraint,
+                                                final int row,
+                                                boolean nested) {
 
-		// Label
-		if (constraint.compositeJunctionType
-				.equals(CompositeFieldConstraint.COMPOSITE_TYPE_AND)) {
-			toolkit.createLabel(constraintComposite, "All of:");
-		} else {
-			toolkit.createLabel(constraintComposite, "Any of:");
-		}
+        // Label
+        if ( constraint.compositeJunctionType.equals( CompositeFieldConstraint.COMPOSITE_TYPE_AND ) ) {
+            toolkit.createLabel( constraintComposite,
+                                 "All of:" );
+        } else {
+            toolkit.createLabel( constraintComposite,
+                                 "Any of:" );
+        }
 
-		addRemoveButton(constraintComposite, parentConstraint, row,
-				"icons/delete_obj.gif", nested);
+        addRemoveButton( constraintComposite,
+                         parentConstraint,
+                         row,
+                         "icons/delete_obj.gif",
+                         nested );
 
-		// button "add"
-		ImageHyperlink link = addImage(constraintComposite,
-				"icons/new_item.gif");
-		link.addHyperlinkListener(new IHyperlinkListener() {
-			public void linkActivated(HyperlinkEvent e) {
-				RuleDialog popup = new AddCompositeConstraintOptionDialog(
-						parent.getShell(), toolkit, getModeller(), constraint,
-						pattern);
-				popup.open();
-			}
+        // button "add"
+        ImageHyperlink link = addImage( constraintComposite,
+                                        "icons/new_item.gif" );
+        link.addHyperlinkListener( new IHyperlinkListener() {
+            public void linkActivated(HyperlinkEvent e) {
+                RuleDialog popup = new AddCompositeConstraintOptionDialog( parent.getShell(),
+                                                                           toolkit,
+                                                                           getModeller(),
+                                                                           constraint,
+                                                                           pattern );
+                popup.open();
+            }
 
-			public void linkEntered(HyperlinkEvent e) {
-			}
+            public void linkEntered(HyperlinkEvent e) {
+            }
 
-			public void linkExited(HyperlinkEvent e) {
-			}
-		});
+            public void linkExited(HyperlinkEvent e) {
+            }
+        } );
 
-		addNestedElements(constraintComposite, constraint);
-	}
+        addNestedElements( constraintComposite,
+                           constraint );
+    }
 
-	private void addNestedElements(Composite constraintComposite,
-			final CompositeFieldConstraint constraint) {
-		// Nested elementss
-		FieldConstraint[] nestedConstraints = constraint.constraints;
-		if (nestedConstraints != null) {
-			Composite nestedComposite = toolkit
-					.createComposite(constraintComposite);
-			GridData gd = new GridData(GridData.FILL_HORIZONTAL);
-			gd.horizontalSpan = 5;
-			nestedComposite.setLayoutData(gd);
+    private void addNestedElements(Composite constraintComposite,
+                                   final CompositeFieldConstraint constraint) {
+        // Nested elementss
+        FieldConstraint[] nestedConstraints = constraint.constraints;
+        if ( nestedConstraints != null ) {
+            Composite nestedComposite = toolkit.createComposite( constraintComposite );
+            GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+            gd.horizontalSpan = 5;
+            nestedComposite.setLayoutData( gd );
 
-			GridLayout l = new GridLayout();
-			l.numColumns = 8;
-			l.marginBottom = 0;
-			l.marginHeight = 0;
-			l.marginLeft = 0;
-			l.marginRight = 0;
-			l.marginTop = 0;
-			l.marginWidth = 0;
-			l.verticalSpacing = 0;
-			nestedComposite.setLayout(l);
+            GridLayout l = new GridLayout();
+            l.numColumns = 8;
+            l.marginBottom = 0;
+            l.marginHeight = 0;
+            l.marginLeft = 0;
+            l.marginRight = 0;
+            l.marginTop = 0;
+            l.marginWidth = 0;
+            l.verticalSpacing = 0;
+            nestedComposite.setLayout( l );
 
-			for (int i = 0; i < nestedConstraints.length; i++) {
-				renderFieldConstraints(nestedComposite, nestedConstraints[i],
-						constraint, i, false, true);
-				toolkit.paintBordersFor(nestedComposite);
-			}
-		} else {
-			GridData gd = new GridData(GridData.FILL_HORIZONTAL);
-			gd.horizontalSpan = 5;
-			Label dummyLabel = toolkit.createLabel(constraintComposite, ""); // dummy
-			dummyLabel.setLayoutData(gd);
-		}
-	}
+            for ( int i = 0; i < nestedConstraints.length; i++ ) {
+                renderFieldConstraints( nestedComposite,
+                                        nestedConstraints[i],
+                                        constraint,
+                                        i,
+                                        false,
+                                        true );
+                toolkit.paintBordersFor( nestedComposite );
+            }
+        } else {
+            GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+            gd.horizontalSpan = 5;
+            Label dummyLabel = toolkit.createLabel( constraintComposite,
+                                                    "" ); // dummy
+            dummyLabel.setLayoutData( gd );
+        }
+    }
 
-	private void renderSingleFieldConstraint(Composite constraintComposite,
-			int row, FieldConstraint constraint,
-			CompositeFieldConstraint parentConstraint, boolean showBinding,
-			boolean nested) {
-		final SingleFieldConstraint c = (SingleFieldConstraint) constraint;
-		if (c.constraintValueType != SingleFieldConstraint.TYPE_PREDICATE) {
-			createConstraintRow(constraintComposite, parentConstraint, row, c,
-					showBinding, nested);
-		} else {
-			createPredicateConstraintRow(constraintComposite, row, c);
-		}
-	}
+    private void renderSingleFieldConstraint(Composite constraintComposite,
+                                             int row,
+                                             FieldConstraint constraint,
+                                             CompositeFieldConstraint parentConstraint,
+                                             boolean showBinding,
+                                             boolean nested) {
+        final SingleFieldConstraint c = (SingleFieldConstraint) constraint;
+        if ( c.constraintValueType != ISingleFieldConstraint.TYPE_PREDICATE ) {
+            createConstraintRow( constraintComposite,
+                                 parentConstraint,
+                                 row,
+                                 c,
+                                 showBinding,
+                                 nested );
+        } else {
+            createPredicateConstraintRow( constraintComposite,
+                                          row,
+                                          c );
+        }
+    }
 
-	private void createConstraintRow(Composite constraintComposite,
-			CompositeFieldConstraint parentConstraint, int row,
-			final SingleFieldConstraint c, boolean showBinding, boolean nested) {
-		addBindingField(constraintComposite, c, showBinding);
-		toolkit.createLabel(constraintComposite, c.fieldName);
-		if (c.connectives == null || c.connectives.length == 0) {
-			addRemoveButton(constraintComposite, parentConstraint, row,
-					"icons/delete_item_small.gif", nested);
-		} else {
-			toolkit.createLabel(constraintComposite, "");
-		}
-		operatorDropDown(constraintComposite, c);
-		constraintValueEditor(constraintComposite, c);
-		createConnectives(constraintComposite, c);
-		addConnectiveAction(constraintComposite, c);
-	}
+    private void createConstraintRow(Composite constraintComposite,
+                                     CompositeFieldConstraint parentConstraint,
+                                     int row,
+                                     final SingleFieldConstraint c,
+                                     boolean showBinding,
+                                     boolean nested) {
+        addBindingField( constraintComposite,
+                         c,
+                         showBinding );
+        toolkit.createLabel( constraintComposite,
+                             c.fieldName );
+        if ( c.connectives == null || c.connectives.length == 0 ) {
+            addRemoveButton( constraintComposite,
+                             parentConstraint,
+                             row,
+                             "icons/delete_item_small.gif",
+                             nested );
+        } else {
+            toolkit.createLabel( constraintComposite,
+                                 "" );
+        }
+        operatorDropDown( constraintComposite,
+                          c );
+        constraintValueEditor( constraintComposite,
+                               c );
+        createConnectives( constraintComposite,
+                           c );
+        addConnectiveAction( constraintComposite,
+                             c );
+    }
 
-	private void addBindingField(Composite constraintComposite,
-			final SingleFieldConstraint c, boolean showBinding) {
-		if (!c.isBound()) {
-			if (bindable && showBinding) {
-				ImageHyperlink link = addImage(constraintComposite,
-						"icons/new_item.gif");
-				link.addHyperlinkListener(new IHyperlinkListener() {
-					public void linkActivated(HyperlinkEvent e) {
-						RuleDialog popup = new AssignFieldVariableDialog(
-								parent.getShell(), toolkit, getModeller(), c);
-						popup.open();
-					}
+    private void addBindingField(Composite constraintComposite,
+                                 final SingleFieldConstraint c,
+                                 boolean showBinding) {
+        if ( !c.isBound() ) {
+            if ( bindable && showBinding ) {
+                ImageHyperlink link = addImage( constraintComposite,
+                                                "icons/new_item.gif" );
+                link.addHyperlinkListener( new IHyperlinkListener() {
+                    public void linkActivated(HyperlinkEvent e) {
+                        RuleDialog popup = new AssignFieldVariableDialog( parent.getShell(),
+                                                                          toolkit,
+                                                                          getModeller(),
+                                                                          c );
+                        popup.open();
+                    }
 
-					public void linkEntered(HyperlinkEvent e) {
-					}
+                    public void linkEntered(HyperlinkEvent e) {
+                    }
 
-					public void linkExited(HyperlinkEvent e) {
-					}
-				});
+                    public void linkExited(HyperlinkEvent e) {
+                    }
+                } );
 
-			} else {
-				toolkit.createLabel(constraintComposite, "");
-			}
-		} else {
-			toolkit
-					.createLabel(constraintComposite, "[" + c.fieldBinding
-							+ "]");
-		}
+            } else {
+                toolkit.createLabel( constraintComposite,
+                                     "" );
+            }
+        } else {
+            toolkit.createLabel( constraintComposite,
+                                 "[" + c.fieldBinding + "]" );
+        }
 
-	}
+    }
 
-	private void createPredicateConstraintRow(Composite constraintComposite,
-			int row, final SingleFieldConstraint c) {
-		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
-		gd.horizontalSpan = 6;
-		addImage(constraintComposite, "icons/function_assets.gif");
-		formulaValueEditor(constraintComposite, c, gd);
-		addRemoveButton(constraintComposite, null, row,
-				"icons/delete_item_small.gif", false);
-	}
+    private void createPredicateConstraintRow(Composite constraintComposite,
+                                              int row,
+                                              final SingleFieldConstraint c) {
+        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = 6;
+        addImage( constraintComposite,
+                  "icons/function_assets.gif" );
+        formulaValueEditor( constraintComposite,
+                            c,
+                            gd );
+        addRemoveButton( constraintComposite,
+                         null,
+                         row,
+                         "icons/delete_item_small.gif",
+                         false );
+    }
 
-	private void createConnectives(Composite parent, SingleFieldConstraint c) {
-		if (c.connectives != null && c.connectives.length > 0) {
-			for (int i = 0; i < c.connectives.length; i++) {
-				toolkit.createLabel(parent, ""); // dummy
-				toolkit.createLabel(parent, ""); // dummy
-				toolkit.createLabel(parent, ""); // dummy
-				ConnectiveConstraint con = c.connectives[i];
-				addRemoveConstraintAction(parent, c, con);
-				connectiveOperatorDropDown(parent, con, c.fieldName);
-				constraintValueEditor(parent, con);
-			}
-		}
-	}
+    private void createConnectives(Composite parent,
+                                   SingleFieldConstraint c) {
+        if ( c.connectives != null && c.connectives.length > 0 ) {
+            for ( int i = 0; i < c.connectives.length; i++ ) {
+                toolkit.createLabel( parent,
+                                     "" ); // dummy
+                toolkit.createLabel( parent,
+                                     "" ); // dummy
+                toolkit.createLabel( parent,
+                                     "" ); // dummy
+                ConnectiveConstraint con = c.connectives[i];
+                addRemoveConstraintAction( parent,
+                                           c,
+                                           con );
+                connectiveOperatorDropDown( parent,
+                                            con,
+                                            c.fieldName );
+                constraintValueEditor( parent,
+                                       con );
+            }
+        }
+    }
 
-	private void addConnectiveAction(Composite constraintComposite,
-			final SingleFieldConstraint c) {
-		ImageHyperlink link = addImage(constraintComposite,
-				"icons/add_connective.gif");
-		link.setToolTipText("Add more options to this fields values.");
-		link.addHyperlinkListener(new IHyperlinkListener() {
-			public void linkActivated(HyperlinkEvent e) {
-				c.addNewConnective();
-				getModeller().reloadLhs();
-				getModeller().setDirty(true);
-			}
+    private void addConnectiveAction(Composite constraintComposite,
+                                     final SingleFieldConstraint c) {
+        ImageHyperlink link = addImage( constraintComposite,
+                                        "icons/add_connective.gif" );
+        link.setToolTipText( "Add more options to this fields values." );
+        link.addHyperlinkListener( new IHyperlinkListener() {
+            public void linkActivated(HyperlinkEvent e) {
+                c.addNewConnective();
+                getModeller().reloadLhs();
+                getModeller().setDirty( true );
+            }
 
-			public void linkEntered(HyperlinkEvent e) {
-			}
+            public void linkEntered(HyperlinkEvent e) {
+            }
 
-			public void linkExited(HyperlinkEvent e) {
-			}
-		});
+            public void linkExited(HyperlinkEvent e) {
+            }
+        } );
 
-		link.setLayoutData(new GridData(GridData.FILL_HORIZONTAL
-				| GridData.HORIZONTAL_ALIGN_BEGINNING));
-	}
+        link.setLayoutData( new GridData( GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING ) );
+    }
 
-	private void addRemoveButton(Composite constraintComposite,
-			final CompositeFieldConstraint parentConstraint, final int row,
-			String iconRef, boolean nested) {
-		if (nested) {
-			addNestedConstraintDeleteAction(constraintComposite,
-					parentConstraint, row, iconRef);
-		} else {
-			addRemoveFieldAction(constraintComposite, row, iconRef);
-		}
+    private void addRemoveButton(Composite constraintComposite,
+                                 final CompositeFieldConstraint parentConstraint,
+                                 final int row,
+                                 String iconRef,
+                                 boolean nested) {
+        if ( nested ) {
+            addNestedConstraintDeleteAction( constraintComposite,
+                                             parentConstraint,
+                                             row,
+                                             iconRef );
+        } else {
+            addRemoveFieldAction( constraintComposite,
+                                  row,
+                                  iconRef );
+        }
 
-	}
+    }
 
-	private void addNestedConstraintDeleteAction(Composite constraintComposite,
-			final CompositeFieldConstraint parentConstraint, final int row,
-			String iconRef) {
-		ImageHyperlink delLink = addImage(constraintComposite, iconRef);
-		// "icons/delete_obj.gif");
-		delLink.addHyperlinkListener(new IHyperlinkListener() {
-			public void linkActivated(HyperlinkEvent e) {
-				MessageBox dialog = new MessageBox(Display.getCurrent()
-						.getActiveShell(), SWT.YES | SWT.NO | SWT.ICON_WARNING);
-				dialog.setMessage("Remove this (nested) restriction.");
-				dialog.setText("Remove this item from nested constraint?");
-				if (dialog.open() == SWT.YES) {
-					parentConstraint.removeConstraint(row);
-					getModeller().reloadLhs();
-					getModeller().setDirty(true);
-				}
-			}
+    private void addNestedConstraintDeleteAction(Composite constraintComposite,
+                                                 final CompositeFieldConstraint parentConstraint,
+                                                 final int row,
+                                                 String iconRef) {
+        ImageHyperlink delLink = addImage( constraintComposite,
+                                           iconRef );
+        // "icons/delete_obj.gif");
+        delLink.addHyperlinkListener( new IHyperlinkListener() {
+            public void linkActivated(HyperlinkEvent e) {
+                MessageBox dialog = new MessageBox( Display.getCurrent().getActiveShell(),
+                                                    SWT.YES | SWT.NO | SWT.ICON_WARNING );
+                dialog.setMessage( "Remove this (nested) restriction." );
+                dialog.setText( "Remove this item from nested constraint?" );
+                if ( dialog.open() == SWT.YES ) {
+                    parentConstraint.removeConstraint( row );
+                    getModeller().reloadLhs();
+                    getModeller().setDirty( true );
+                }
+            }
 
-			public void linkEntered(HyperlinkEvent e) {
-			}
+            public void linkEntered(HyperlinkEvent e) {
+            }
 
-			public void linkExited(HyperlinkEvent e) {
-			}
-		});
-	}
+            public void linkExited(HyperlinkEvent e) {
+            }
+        } );
+    }
 
-	private void addRemoveFieldAction(Composite constraintComposite,
-			final int currentRow, String iconRef) {
-		ImageHyperlink delLink = addImage(constraintComposite, iconRef);
-		delLink.setToolTipText("Remove this fieldconstraint");
-		delLink.addHyperlinkListener(new IHyperlinkListener() {
-			public void linkActivated(HyperlinkEvent e) {
-				MessageBox dialog = new MessageBox(Display.getCurrent()
-						.getActiveShell(), SWT.YES | SWT.NO | SWT.ICON_WARNING);
-				dialog.setMessage("Remove this item?");
-				dialog.setText("Remove this item?");
-				if (dialog.open() == SWT.YES) {
-					pattern.removeConstraint(currentRow);
-					getModeller().reloadLhs();
-					getModeller().setDirty(true);
-				}
-			}
+    private void addRemoveFieldAction(Composite constraintComposite,
+                                      final int currentRow,
+                                      String iconRef) {
+        ImageHyperlink delLink = addImage( constraintComposite,
+                                           iconRef );
+        delLink.setToolTipText( "Remove this fieldconstraint" );
+        delLink.addHyperlinkListener( new IHyperlinkListener() {
+            public void linkActivated(HyperlinkEvent e) {
+                MessageBox dialog = new MessageBox( Display.getCurrent().getActiveShell(),
+                                                    SWT.YES | SWT.NO | SWT.ICON_WARNING );
+                dialog.setMessage( "Remove this item?" );
+                dialog.setText( "Remove this item?" );
+                if ( dialog.open() == SWT.YES ) {
+                    pattern.removeConstraint( currentRow );
+                    getModeller().reloadLhs();
+                    getModeller().setDirty( true );
+                }
+            }
 
-			public void linkEntered(HyperlinkEvent e) {
-			}
+            public void linkEntered(HyperlinkEvent e) {
+            }
 
-			public void linkExited(HyperlinkEvent e) {
-			}
-		});
-		delLink.setLayoutData(new GridData(GridData.FILL_HORIZONTAL
-				| GridData.HORIZONTAL_ALIGN_BEGINNING));
-	}
+            public void linkExited(HyperlinkEvent e) {
+            }
+        } );
+        delLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING ) );
+    }
 
-	private void addRemoveConstraintAction(Composite composite,
-			final SingleFieldConstraint constraint,
-			final ConnectiveConstraint connConstraint) {
-		ImageHyperlink delLink = addImage(composite,
-				"icons/delete_item_small.gif");
-		delLink.setToolTipText("Remove this field constraint");
-		delLink.addHyperlinkListener(new IHyperlinkListener() {
-			public void linkActivated(HyperlinkEvent e) {
-				MessageBox dialog = new MessageBox(Display.getCurrent()
-						.getActiveShell(), SWT.YES | SWT.NO | SWT.ICON_WARNING);
-				dialog.setMessage("Remove this item?");
-				dialog.setText("Remove this item?");
-				if (dialog.open() == SWT.YES) {
-					ConnectiveConstraint[] connectives = constraint.connectives;
-					List nConnectives = new ArrayList();
-					for (int i = 0; i < connectives.length; i++) {
-						if (connectives[i] != connConstraint) {
-							nConnectives.add(connectives[i]);
-						}
-					}
-					constraint.connectives = (ConnectiveConstraint[]) nConnectives
-							.toArray(new ConnectiveConstraint[nConnectives
-									.size()]);
+    private void addRemoveConstraintAction(Composite composite,
+                                           final SingleFieldConstraint constraint,
+                                           final ConnectiveConstraint connConstraint) {
+        ImageHyperlink delLink = addImage( composite,
+                                           "icons/delete_item_small.gif" );
+        delLink.setToolTipText( "Remove this field constraint" );
+        delLink.addHyperlinkListener( new IHyperlinkListener() {
+            public void linkActivated(HyperlinkEvent e) {
+                MessageBox dialog = new MessageBox( Display.getCurrent().getActiveShell(),
+                                                    SWT.YES | SWT.NO | SWT.ICON_WARNING );
+                dialog.setMessage( "Remove this item?" );
+                dialog.setText( "Remove this item?" );
+                if ( dialog.open() == SWT.YES ) {
+                    ConnectiveConstraint[] connectives = constraint.connectives;
+                    List nConnectives = new ArrayList();
+                    for ( int i = 0; i < connectives.length; i++ ) {
+                        if ( connectives[i] != connConstraint ) {
+                            nConnectives.add( connectives[i] );
+                        }
+                    }
+                    constraint.connectives = (ConnectiveConstraint[]) nConnectives.toArray( new ConnectiveConstraint[nConnectives.size()] );
 
-					getModeller().reloadLhs();
-					getModeller().setDirty(true);
-				}
-			}
+                    getModeller().reloadLhs();
+                    getModeller().setDirty( true );
+                }
+            }
 
-			public void linkEntered(HyperlinkEvent e) {
-			}
+            public void linkEntered(HyperlinkEvent e) {
+            }
 
-			public void linkExited(HyperlinkEvent e) {
-			}
-		});
-		delLink.setLayoutData(new GridData(GridData.FILL_HORIZONTAL
-				| GridData.HORIZONTAL_ALIGN_END));
-	}
+            public void linkExited(HyperlinkEvent e) {
+            }
+        } );
+        delLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END ) );
+    }
 
-	/**
-	 * This returns the pattern label.
-	 */
-	private String getPatternLabel() {
-		if (pattern.boundName != null) {
-			return pattern.factType + " [" + pattern.boundName + "]";
-		}
-		return pattern.factType;
-	}
+    /**
+     * This returns the pattern label.
+     */
+    private String getPatternLabel() {
+        if ( pattern.boundName != null ) {
+            return pattern.factType + " [" + pattern.boundName + "]";
+        }
+        return pattern.factType;
+    }
 
-	private void operatorDropDown(Composite parent,
-			final SingleFieldConstraint c) {
-		String[] ops = getCompletions().getOperatorCompletions(
-				pattern.factType, c.fieldName);
-		final Combo box = new Combo(parent, SWT.SIMPLE | SWT.DROP_DOWN
-				| SWT.READ_ONLY);
-		for (int i = 0; i < ops.length; i++) {
-			String op = ops[i];
-			box.add(HumanReadable.getOperatorDisplayName(op));
-			if (op.equals(c.operator)) {
-				box.select(i);
-			}
-		}
-		GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
-		gridData.horizontalSpan = 2;
-		box.setLayoutData(gridData);
-		box.addListener(SWT.Selection, new Listener() {
-			public void handleEvent(Event event) {
-				c.operator = HumanReadable.getOperatorName(box.getText());
-				getModeller().setDirty(true);
-			}
-		});
-	}
+    private void operatorDropDown(Composite parent,
+                                  final SingleFieldConstraint c) {
+        String[] ops = getCompletions().getOperatorCompletions( pattern.factType,
+                                                                c.fieldName );
+        final Combo box = new Combo( parent,
+                                     SWT.SIMPLE | SWT.DROP_DOWN | SWT.READ_ONLY );
+        for ( int i = 0; i < ops.length; i++ ) {
+            String op = ops[i];
+            box.add( HumanReadable.getOperatorDisplayName( op ) );
+            if ( op.equals( c.operator ) ) {
+                box.select( i );
+            }
+        }
+        GridData gridData = new GridData( GridData.FILL_HORIZONTAL );
+        gridData.horizontalSpan = 2;
+        box.setLayoutData( gridData );
+        box.addListener( SWT.Selection,
+                         new Listener() {
+                             public void handleEvent(Event event) {
+                                 c.operator = HumanReadable.getOperatorName( box.getText() );
+                                 getModeller().setDirty( true );
+                             }
+                         } );
+    }
 
-	private void connectiveOperatorDropDown(Composite parent,
-			final ConnectiveConstraint con, String fieldName) {
-		String[] ops = getCompletions().getConnectiveOperatorCompletions(
-				pattern.factType, fieldName);
-		final Combo box = new Combo(parent, SWT.SIMPLE | SWT.DROP_DOWN
-				| SWT.READ_ONLY);
-		for (int i = 0; i < ops.length; i++) {
-			String op = ops[i];
-			box.add(HumanReadable.getOperatorDisplayName(op));
-			if (op.equals(con.operator)) {
-				box.select(i);
-			}
-		}
-		GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
-		gridData.horizontalSpan = 2;
-		box.setLayoutData(gridData);
-		box.addModifyListener(new ModifyListener() {
-			public void modifyText(ModifyEvent e) {
-				con.operator = HumanReadable.getOperatorName(box.getText());
-				getModeller().setDirty(true);
-			}
-		});
-	}
+    private void connectiveOperatorDropDown(Composite parent,
+                                            final ConnectiveConstraint con,
+                                            String fieldName) {
+        String[] ops = getCompletions().getConnectiveOperatorCompletions( pattern.factType,
+                                                                          fieldName );
+        final Combo box = new Combo( parent,
+                                     SWT.SIMPLE | SWT.DROP_DOWN | SWT.READ_ONLY );
+        for ( int i = 0; i < ops.length; i++ ) {
+            String op = ops[i];
+            box.add( HumanReadable.getOperatorDisplayName( op ) );
+            if ( op.equals( con.operator ) ) {
+                box.select( i );
+            }
+        }
+        GridData gridData = new GridData( GridData.FILL_HORIZONTAL );
+        gridData.horizontalSpan = 2;
+        box.setLayoutData( gridData );
+        box.addModifyListener( new ModifyListener() {
+            public void modifyText(ModifyEvent e) {
+                con.operator = HumanReadable.getOperatorName( box.getText() );
+                getModeller().setDirty( true );
+            }
+        } );
+    }
 
-	// from org.drools.brms.client.modeldriven.ui.ConstraintValueEditor
-	private void constraintValueEditor(final Composite parent,
-			final ISingleFieldConstraint c) {
-		if (c.constraintValueType == SingleFieldConstraint.TYPE_UNDEFINED) {
-			ImageHyperlink link = addImage(parent, "icons/edit.gif");
-			link.setToolTipText("Choose value editor type");
-			link.addHyperlinkListener(new IHyperlinkListener() {
-				public void linkActivated(HyperlinkEvent e) {
-					RuleDialog popup = new ValueEditorTypeSelectionDialog(
-							parent.getShell(), toolkit, getModeller(), c);
-					popup.open();
-				}
+    // from org.drools.brms.client.modeldriven.ui.ConstraintValueEditor
+    private void constraintValueEditor(final Composite parent,
+                                       final ISingleFieldConstraint c) {
+        if ( c.constraintValueType == ISingleFieldConstraint.TYPE_UNDEFINED ) {
+            ImageHyperlink link = addImage( parent,
+                                            "icons/edit.gif" );
+            link.setToolTipText( "Choose value editor type" );
+            link.addHyperlinkListener( new IHyperlinkListener() {
+                public void linkActivated(HyperlinkEvent e) {
+                    RuleDialog popup = new ValueEditorTypeSelectionDialog( parent.getShell(),
+                                                                           toolkit,
+                                                                           getModeller(),
+                                                                           c );
+                    popup.open();
+                }
 
-				public void linkEntered(HyperlinkEvent e) {
-				}
+                public void linkEntered(HyperlinkEvent e) {
+                }
 
-				public void linkExited(HyperlinkEvent e) {
-				}
-			});
+                public void linkExited(HyperlinkEvent e) {
+                }
+            } );
 
-			toolkit.createLabel(parent, "");// dummy
-		} else {
-			switch (c.constraintValueType) {
-			case SingleFieldConstraint.TYPE_LITERAL:
-				literalValueEditor(parent, c, new GridData(
-						GridData.FILL_HORIZONTAL));
-				break;
-			case SingleFieldConstraint.TYPE_RET_VALUE:
-				addImage(parent, "icons/function_assets.gif");
-				formulaValueEditor(parent, c, new GridData(
-						GridData.FILL_HORIZONTAL));
-				break;
-			case SingleFieldConstraint.TYPE_VARIABLE:
-				variableEditor(parent, c,
-						new GridData(GridData.FILL_HORIZONTAL));
-				break;
-			default:
-				break;
-			}
-		}
-	}
+            toolkit.createLabel( parent,
+                                 "" );// dummy
+        } else {
+            switch ( c.constraintValueType ) {
+                case ISingleFieldConstraint.TYPE_LITERAL :
+                    literalValueEditor( parent,
+                                        c,
+                                        new GridData( GridData.FILL_HORIZONTAL ) );
+                    break;
+                case ISingleFieldConstraint.TYPE_RET_VALUE :
+                    addImage( parent,
+                              "icons/function_assets.gif" );
+                    formulaValueEditor( parent,
+                                        c,
+                                        new GridData( GridData.FILL_HORIZONTAL ) );
+                    break;
+                case ISingleFieldConstraint.TYPE_VARIABLE :
+                    variableEditor( parent,
+                                    c,
+                                    new GridData( GridData.FILL_HORIZONTAL ) );
+                    break;
+                default :
+                    break;
+            }
+        }
+    }
 
-	private void variableEditor(Composite composite,
-			final ISingleFieldConstraint c, GridData gd) {
-		List vars = getModeller().getModel().getBoundVariablesInScope(c);
+    private void variableEditor(Composite composite,
+                                final ISingleFieldConstraint c,
+                                GridData gd) {
+        List vars = getModeller().getModel().getBoundVariablesInScope( c );
 
-		final Combo combo = new Combo(composite, SWT.READ_ONLY);
+        final Combo combo = new Combo( composite,
+                                       SWT.READ_ONLY );
 
-		gd.horizontalSpan = 1;
-		combo.setLayoutData(gd);
-		if (c.value == null) {
-			combo.add("Choose ...");
-		}
+        gd.horizontalSpan = 1;
+        combo.setLayoutData( gd );
+        if ( c.value == null ) {
+            combo.add( "Choose ..." );
+        }
 
-		for (int i = 0; i < vars.size(); i++) {
-			String var = (String) vars.get(i);
-			if (c.value != null && c.value.equals(var)) {
-				combo.select(i);
-			}
-			combo.add(var);
-		}
+        int idx = 0;
 
-		combo.addModifyListener(new ModifyListener() {
-			public void modifyText(ModifyEvent e) {
-				c.value = combo.getText();
-			}
-		});
+        for ( int i = 0; i < vars.size(); i++ ) {
+            String var = (String) vars.get( i );
 
-	}
+            if ( c.value != null && c.value.equals( var ) ) {
+                idx = i;
+            }
+            combo.add( var );
+        }
 
-	private void literalValueEditor(Composite parent,
-			final ISingleFieldConstraint c, GridData gd) {
-		final Text box = toolkit.createText(parent, "");
+        combo.select( idx );
 
-		if (c.value != null) {
-			box.setText(c.value);
-		}
+        combo.addModifyListener( new ModifyListener() {
+            public void modifyText(ModifyEvent e) {
+                c.value = combo.getText();
+            }
+        } );
 
-		gd.horizontalSpan = 2;
-		box.setLayoutData(gd);
+    }
 
-		box.addModifyListener(new ModifyListener() {
-			public void modifyText(ModifyEvent e) {
-				c.value = box.getText();
-				getModeller().setDirty(true);
-			}
-		});
-	}
+    private void literalValueEditor(Composite parent,
+                                    final ISingleFieldConstraint c,
+                                    GridData gd) {
+        final Text box = toolkit.createText( parent,
+                                             "" );
 
-	private void formulaValueEditor(Composite parent,
-			final ISingleFieldConstraint c, GridData gd) {
+        if ( c.value != null ) {
+            box.setText( c.value );
+        }
 
-		final Text box = toolkit.createText(parent, "");
+        gd.horizontalSpan = 2;
+        box.setLayoutData( gd );
 
-		if (c.value != null) {
-			box.setText(c.value);
-		}
+        box.addModifyListener( new ModifyListener() {
+            public void modifyText(ModifyEvent e) {
+                c.value = box.getText();
+                getModeller().setDirty( true );
+            }
+        } );
+    }
 
-		box.setLayoutData(gd);
+    private void formulaValueEditor(Composite parent,
+                                    final ISingleFieldConstraint c,
+                                    GridData gd) {
 
-		box.addModifyListener(new ModifyListener() {
-			public void modifyText(ModifyEvent e) {
-				c.value = box.getText();
-				getModeller().setDirty(true);
-			}
-		});
-	}
+        final Text box = toolkit.createText( parent,
+                                             "" );
 
-	private void deleteBindedFact() {
-		List newPatterns = new ArrayList();
-		for (int i = 0; i < parentPattern.patterns.length; i++) {
-			if (parentPattern.patterns[i] != pattern) {
-				newPatterns.add(parentPattern.patterns[i]);
-			}
-		}
-		parentPattern.patterns = (FactPattern[]) newPatterns
-				.toArray(new FactPattern[newPatterns.size()]);
-		getModeller().reloadLhs();
-	}
+        if ( c.value != null ) {
+            box.setText( c.value );
+        }
 
-	private SuggestionCompletionEngine getCompletions() {
-		return getModeller().getSuggestionCompletionEngine();
-	}
+        box.setLayoutData( gd );
 
+        box.addModifyListener( new ModifyListener() {
+            public void modifyText(ModifyEvent e) {
+                c.value = box.getText();
+                getModeller().setDirty( true );
+            }
+        } );
+    }
+
+    private void deleteBindedFact() {
+        List newPatterns = new ArrayList();
+        for ( int i = 0; i < parentPattern.patterns.length; i++ ) {
+            if ( parentPattern.patterns[i] != pattern ) {
+                newPatterns.add( parentPattern.patterns[i] );
+            }
+        }
+        parentPattern.patterns = (FactPattern[]) newPatterns.toArray( new FactPattern[newPatterns.size()] );
+        getModeller().reloadLhs();
+    }
+
+    private SuggestionCompletionEngine getCompletions() {
+        return getModeller().getSuggestionCompletionEngine();
+    }
+
 }

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/LHSDSLSentenceWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/LHSDSLSentenceWidget.java	2007-06-20 05:16:09 UTC (rev 12707)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/LHSDSLSentenceWidget.java	2007-06-22 00:27:12 UTC (rev 12760)
@@ -6,20 +6,27 @@
 
 public class LHSDSLSentenceWidget extends DSLSentenceWidget {
 
-	public LHSDSLSentenceWidget(FormToolkit toolkit, Composite parent,
-			DSLSentence sentence, RuleModeller modeller, int index) {
-		super(toolkit, parent, sentence, modeller, index);
+    public LHSDSLSentenceWidget(FormToolkit toolkit,
+                                Composite parent,
+                                DSLSentence sentence,
+                                RuleModeller modeller,
+                                int index) {
+        super( toolkit,
+               parent,
+               sentence,
+               modeller,
+               index );
 
-	}
+    }
 
-	protected void updateModel() {
-		if ( getModeller().getModel().removeLhsItem( index ) ) {
+    protected void updateModel() {
+        if ( getModeller().getModel().removeLhsItem( index ) ) {
             getModeller().reloadLhs();
         } else {
             showMessage( "Can't remove that item as it is used in the action part of the rule." );
         }
-		getModeller().reloadLhs();
-		getModeller().setDirty(true);
-	}
+        getModeller().reloadLhs();
+        getModeller().setDirty( true );
+    }
 
 }

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RHSDSLSentenceWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/RHSDSLSentenceWidget.java	2007-06-20 05:16:09 UTC (rev 12707)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RHSDSLSentenceWidget.java	2007-06-22 00:27:12 UTC (rev 12760)
@@ -6,15 +6,22 @@
 
 public class RHSDSLSentenceWidget extends DSLSentenceWidget {
 
-	public RHSDSLSentenceWidget(FormToolkit toolkit, Composite parent,
-			DSLSentence sentence, RuleModeller modeller, int index) {
-		super(toolkit, parent, sentence, modeller, index);
-	}
+    public RHSDSLSentenceWidget(FormToolkit toolkit,
+                                Composite parent,
+                                DSLSentence sentence,
+                                RuleModeller modeller,
+                                int index) {
+        super( toolkit,
+               parent,
+               sentence,
+               modeller,
+               index );
+    }
 
-	protected void updateModel() {
-		getModeller().getModel().removeRhsItem( index );
+    protected void updateModel() {
+        getModeller().getModel().removeRhsItem( index );
         getModeller().reloadRhs();
         getModeller().setDirty( true );
-	}
+    }
 
 }

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RuleAttributeWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/RuleAttributeWidget.java	2007-06-20 05:16:09 UTC (rev 12707)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RuleAttributeWidget.java	2007-06-22 00:27:12 UTC (rev 12760)
@@ -22,151 +22,158 @@
 
 public class RuleAttributeWidget extends Widget {
 
-	public RuleAttributeWidget(FormToolkit toolkit, Composite parent,
-			RuleModeller modeller) {
-		super(parent, toolkit, modeller, 0);
+    public RuleAttributeWidget(FormToolkit toolkit,
+                               Composite parent,
+                               RuleModeller modeller) {
+        super( parent,
+               toolkit,
+               modeller,
+               0 );
 
-		GridLayout l = new GridLayout();
-		l.numColumns = 3;
-		// l.marginBottom = 5;
-		// l.marginHeight = 5;
-		// l.marginLeft = 5;
-		// l.marginRight = 5;
-		// l.marginTop = 10;
-		// l.marginWidth = 10;
-		// l.verticalSpacing = 15;
-		parent.setLayout(l);
+        GridLayout l = new GridLayout();
+        l.numColumns = 3;
+        // l.marginBottom = 5;
+        // l.marginHeight = 5;
+        // l.marginLeft = 5;
+        // l.marginRight = 5;
+        // l.marginTop = 10;
+        // l.marginWidth = 10;
+        // l.verticalSpacing = 15;
+        parent.setLayout( l );
 
-		create();
-	}
+        create();
+    }
 
-	private void create() {
+    private void create() {
 
-		RuleAttribute[] attrs = modeller.getModel().attributes;
-		for (int i = 0; i < attrs.length; i++) {
-			RuleAttribute at = attrs[i];
-			addAttribute(at);
-		}
-		toolkit.paintBordersFor(parent);
-	}
+        RuleAttribute[] attrs = modeller.getModel().attributes;
+        for ( int i = 0; i < attrs.length; i++ ) {
+            RuleAttribute at = attrs[i];
+            addAttribute( at );
+        }
+        toolkit.paintBordersFor( parent );
+    }
 
-	private void addAttribute(RuleAttribute at) {
-		toolkit.createLabel(parent, at.attributeName);
+    private void addAttribute(RuleAttribute at) {
+        toolkit.createLabel( parent,
+                             at.attributeName );
 
-		if (at.attributeName.equals("no-loop")) {
-			toolkit.createLabel(parent, "");
-		} else if (at.attributeName.equals("enabled")
-				|| at.attributeName.equals("auto-focus")
-				|| at.attributeName.equals("lock-on-active")) {
-			createCheckbox(at);
-		} else {
-			createText(at);
-		}
+        if ( at.attributeName.equals( "no-loop" ) ) {
+            toolkit.createLabel( parent,
+                                 "" );
+        } else if ( at.attributeName.equals( "enabled" ) || at.attributeName.equals( "auto-focus" ) || at.attributeName.equals( "lock-on-active" ) ) {
+            createCheckbox( at );
+        } else {
+            createText( at );
+        }
 
-		addDeleteLink(at);
+        addDeleteLink( at );
 
-	}
+    }
 
-	private void createText(final RuleAttribute at) {
-		final Text box = toolkit.createText(parent, "");
+    private void createText(final RuleAttribute at) {
+        final Text box = toolkit.createText( parent,
+                                             "" );
 
-		box.setText(at.value);
-		
-		
-		box.addModifyListener(new ModifyListener() {
-			public void modifyText(ModifyEvent e) {
-				at.value = box.getText();
-				modeller.setDirty(true);
-			}
-		});
+        box.setText( at.value );
 
-		if (at.attributeName.equals( "date-effective" ) || at.attributeName.equals( "date-expires" )) {
-            if (at.value == null || "".equals( at.value.trim() )) {
-            	box.setText( "dd-MMM-yyyy" );
+        box.addModifyListener( new ModifyListener() {
+            public void modifyText(ModifyEvent e) {
+                at.value = box.getText();
+                modeller.setDirty( true );
             }
+        } );
+
+        if ( at.attributeName.equals( "date-effective" ) || at.attributeName.equals( "date-expires" ) ) {
+            if ( at.value == null || "".equals( at.value.trim() ) ) {
+                box.setText( "dd-MMM-yyyy" );
+            }
         }
-		
-	}
 
-	private void createCheckbox(final RuleAttribute at) {
-		final Button checkbox = toolkit.createButton(parent, "", SWT.CHECK);
+    }
 
-		if (at.value == null) {
-			checkbox.setSelection(true);
-			at.value = "true";
-		} else {
-			checkbox.setSelection(at.value.equals("true") ? true : false);
-		}
+    private void createCheckbox(final RuleAttribute at) {
+        final Button checkbox = toolkit.createButton( parent,
+                                                      "",
+                                                      SWT.CHECK );
 
-		checkbox.addSelectionListener(new SelectionListener() {
+        if ( at.value == null ) {
+            checkbox.setSelection( true );
+            at.value = "true";
+        } else {
+            checkbox.setSelection( at.value.equals( "true" ) ? true : false );
+        }
 
-			public void widgetDefaultSelected(SelectionEvent e) {
+        checkbox.addSelectionListener( new SelectionListener() {
 
-			}
+            public void widgetDefaultSelected(SelectionEvent e) {
 
-			public void widgetSelected(SelectionEvent e) {
-				at.value = (checkbox.getSelection()) ? "true" : "false";
-				modeller.setDirty(true);
-			}
+            }
 
-		});
+            public void widgetSelected(SelectionEvent e) {
+                at.value = (checkbox.getSelection()) ? "true" : "false";
+                modeller.setDirty( true );
+            }
 
-	}
+        } );
 
-	private void addDeleteLink(final RuleAttribute at) {
-		ImageHyperlink delLink = addImage(parent, "icons/delete_item_small.gif");
-		delLink.setToolTipText("Remove this fieldconstraint");
-		delLink.addHyperlinkListener(new IHyperlinkListener() {
-			public void linkActivated(HyperlinkEvent e) {
-				MessageBox dialog = new MessageBox(Display.getCurrent()
-						.getActiveShell(), SWT.YES | SWT.NO | SWT.ICON_WARNING);
-				dialog.setMessage("Remove this rule option?");
-				dialog.setText("Remove this rule option?");
-				if (dialog.open() == SWT.YES) {
-					RuleAttribute[] attrs = modeller.getModel().attributes;
-					for (int i = 0; i < attrs.length; i++) {
-						if (attrs[i] == at) {
-							modeller.getModel().removeAttribute(i);
+    }
 
-							modeller.setDirty(true);
-							modeller.reloadOptions();
-						}
-					}
-				}
-			}
+    private void addDeleteLink(final RuleAttribute at) {
+        ImageHyperlink delLink = addImage( parent,
+                                           "icons/delete_item_small.gif" );
+        delLink.setToolTipText( "Remove this fieldconstraint" );
+        delLink.addHyperlinkListener( new IHyperlinkListener() {
+            public void linkActivated(HyperlinkEvent e) {
+                MessageBox dialog = new MessageBox( Display.getCurrent().getActiveShell(),
+                                                    SWT.YES | SWT.NO | SWT.ICON_WARNING );
+                dialog.setMessage( "Remove this rule option?" );
+                dialog.setText( "Remove this rule option?" );
+                if ( dialog.open() == SWT.YES ) {
+                    RuleAttribute[] attrs = modeller.getModel().attributes;
+                    for ( int i = 0; i < attrs.length; i++ ) {
+                        if ( attrs[i] == at ) {
+                            modeller.getModel().removeAttribute( i );
 
-			public void linkEntered(HyperlinkEvent e) {
-			}
+                            modeller.setDirty( true );
+                            modeller.reloadOptions();
+                        }
+                    }
+                }
+            }
 
-			public void linkExited(HyperlinkEvent e) {
-			}
-		});
+            public void linkEntered(HyperlinkEvent e) {
+            }
 
-	}
+            public void linkExited(HyperlinkEvent e) {
+            }
+        } );
 
-	/**
-	 * Return a listbox of choices for rule attributes.
-	 * 
-	 * @return
-	 */
-	public static List getAttributeList() {
-		List list = new ArrayList();
-		list.add("...");
+    }
 
-		list.add("salience");
-		list.add("enabled");
-		list.add("date-effective");
-		list.add("date-expires");
-		list.add("no-loop");
-		list.add("agenda-group");
-		list.add("activation-group");
-		list.add("duration");
-		list.add("auto-focus");
-		list.add("lock-on-active");
-		list.add("ruleflow-group");
-		list.add("dialect");
+    /**
+     * Return a listbox of choices for rule attributes.
+     * 
+     * @return
+     */
+    public static List getAttributeList() {
+        List list = new ArrayList();
+        list.add( "..." );
 
-		return list;
-	}
+        list.add( "salience" );
+        list.add( "enabled" );
+        list.add( "date-effective" );
+        list.add( "date-expires" );
+        list.add( "no-loop" );
+        list.add( "agenda-group" );
+        list.add( "activation-group" );
+        list.add( "duration" );
+        list.add( "auto-focus" );
+        list.add( "lock-on-active" );
+        list.add( "ruleflow-group" );
+        list.add( "dialect" );
 
+        return list;
+    }
+
 }

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RuleAttributesDialog.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/RuleAttributesDialog.java	2007-06-20 05:16:09 UTC (rev 12707)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RuleAttributesDialog.java	2007-06-22 00:27:12 UTC (rev 12760)
@@ -17,64 +17,71 @@
 
 public class RuleAttributesDialog extends RuleDialog {
 
-	private final FormToolkit toolkit;
+    private final FormToolkit toolkit;
 
-	private RuleModeller modeller;
+    private RuleModeller      modeller;
 
-	public RuleAttributesDialog(Shell parent, FormToolkit toolkit,
-			RuleModeller modeller) {
-		super(parent, "Add new option to the rule",
-				"Pick the value from combo.");
+    public RuleAttributesDialog(Shell parent,
+                                FormToolkit toolkit,
+                                RuleModeller modeller) {
+        super( parent,
+               "Add new option to the rule",
+               "Pick the value from combo." );
 
-		this.toolkit = toolkit;
-		this.modeller = modeller;
-	}
+        this.toolkit = toolkit;
+        this.modeller = modeller;
+    }
 
-	protected Control createDialogArea(final Composite parent) {
-		Composite composite = (Composite) super.createDialogArea(parent);
+    protected Control createDialogArea(final Composite parent) {
+        Composite composite = (Composite) super.createDialogArea( parent );
 
-		GridLayout l = new GridLayout();
-		l.numColumns = 3;
-		l.marginBottom = 0;
-		l.marginHeight = 0;
-		l.marginLeft = 0;
-		l.marginRight = 0;
-		l.marginTop = 0;
-		l.marginWidth = 0;
-		composite.setLayout(l);
+        GridLayout l = new GridLayout();
+        l.numColumns = 3;
+        l.marginBottom = 0;
+        l.marginHeight = 0;
+        l.marginLeft = 0;
+        l.marginRight = 0;
+        l.marginTop = 0;
+        l.marginWidth = 0;
+        composite.setLayout( l );
 
-		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
-		gd.horizontalSpan = 2;
+        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = 2;
 
-		createAtributesSelectionCombo(composite, gd);
+        createAtributesSelectionCombo( composite,
+                                       gd );
 
-		return composite;
-	}
+        return composite;
+    }
 
-	private void createAtributesSelectionCombo(Composite composite, GridData gd) {
-		toolkit.createLabel(composite, "Attributes");
-		final Combo combo = new Combo(composite, SWT.READ_ONLY);
-		combo.setLayoutData(gd);
-		List attributes = RuleAttributeWidget.getAttributeList();
-		for (Iterator iterator = attributes.iterator(); iterator.hasNext();) {
-			String attr = (String) iterator.next();
-			combo.add(attr);
-		}
-		combo.select(0);
-		
-		combo.addListener(SWT.Selection, new Listener() {
-			public void handleEvent(Event event) {
-				if (combo.getSelectionIndex() == 0) {
-					return;
-				}
-				modeller.getModel().addAttribute(
-						new RuleAttribute(combo.getText(), ""));
-				modeller.setDirty(true);
-				modeller.reloadOptions();
-				close();
-			}
-		});
+    private void createAtributesSelectionCombo(Composite composite,
+                                               GridData gd) {
+        createLabel( composite,
+                     "Attributes" );
+        final Combo combo = new Combo( composite,
+                                       SWT.READ_ONLY );
+        combo.setLayoutData( gd );
+        List attributes = RuleAttributeWidget.getAttributeList();
+        for ( Iterator iterator = attributes.iterator(); iterator.hasNext(); ) {
+            String attr = (String) iterator.next();
+            combo.add( attr );
+        }
+        combo.select( 0 );
 
-	}
+        combo.addListener( SWT.Selection,
+                           new Listener() {
+                               public void handleEvent(Event event) {
+                                   if ( combo.getSelectionIndex() == 0 ) {
+                                       return;
+                                   }
+                                   modeller.getModel().addAttribute( new RuleAttribute( combo.getText(),
+                                                                                        "" ) );
+                                   modeller.setDirty( true );
+                                   modeller.reloadOptions();
+                                   close();
+                               }
+                           } );
 
+    }
+
 }

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RuleDialog.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/RuleDialog.java	2007-06-20 05:16:09 UTC (rev 12707)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RuleDialog.java	2007-06-22 00:27:12 UTC (rev 12760)
@@ -1,12 +1,120 @@
 package org.drools.eclipse.rulebuilder.ui;
 
-import org.eclipse.jface.dialogs.PopupDialog;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+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.Label;
 import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
 
-public class RuleDialog extends PopupDialog {
+public class RuleDialog extends Dialog {
 
-    public RuleDialog(Shell parent, String title, String hint) {
-        super(parent,INFOPOPUPRESIZE_SHELLSTYLE,true,true,true,true,title,hint);
+    private String title;
+    private String hint;
+
+    public RuleDialog(Shell parent,
+                      String title,
+                      String hint) {
+        //super(parent,INFOPOPUPRESIZE_SHELLSTYLE,true,true,true,true,title,hint);
+        super( (Shell) parent.getParent() );
+        setShellStyle( getShellStyle() | SWT.RESIZE );
+        this.title = title;
+        this.hint = hint;
     }
-    
+
+    protected void configureShell(Shell newShell) {
+        super.configureShell( newShell );
+        newShell.setText( title );
+        newShell.setToolTipText( hint );
+    }
+
+    protected Control createDialogArea(Composite parent) {
+
+        Composite finalComposite = new Composite( parent,
+                                                  SWT.NONE );
+        finalComposite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+        GridLayout finalLayout = new GridLayout();
+        finalComposite.setLayout( finalLayout );
+
+        Composite titleComposite = new Composite( finalComposite,
+                                                  SWT.NONE );
+        GridLayout layout = new GridLayout();
+        layout.marginHeight = convertVerticalDLUsToPixels( IDialogConstants.VERTICAL_MARGIN );
+        layout.marginWidth = convertHorizontalDLUsToPixels( IDialogConstants.HORIZONTAL_MARGIN );
+        layout.verticalSpacing = 8;
+        layout.horizontalSpacing = 8;
+        titleComposite.setLayout( layout );
+        titleComposite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+        applyDialogFont( titleComposite );
+
+        Label l = new Label( titleComposite,
+                             SWT.CENTER );
+        l.setToolTipText( hint );
+        l.setText( title );
+
+        Font exFont = l.getFont();
+
+        FontData[] exfds = l.getFont().getFontData();
+        if ( exfds.length > 0 ) {
+            FontData fd = exfds[0];
+            fd.setHeight( fd.getHeight() + 4 );
+            Font f = new Font( exFont.getDevice(),
+                               fd );
+            l.setFont( f );
+        }
+
+        Composite contentComposite = (Composite) super.createDialogArea( finalComposite );
+
+        return contentComposite;
+    }
+
+    protected void createButtonsForButtonBar(Composite parent) {
+        // We have only cancel button
+        createButton( parent,
+                      IDialogConstants.CANCEL_ID,
+                      IDialogConstants.CANCEL_LABEL,
+                      false );
+
+    }
+
+    /*    
+     protected Control createDialogArea(Composite parent) {
+     Composite composite = new Composite(parent, SWT.NONE);
+     
+     GridLayout layout = new GridLayout();
+     layout.marginHeight = 2;
+     layout.marginWidth = 2;
+     layout.verticalSpacing = 2;
+     layout.horizontalSpacing = 2;
+     composite.setLayout(layout);
+     
+     GridData gd = new GridData(GridData.FILL_BOTH);
+     composite.setLayoutData(gd);
+     
+     return composite;
+     }
+     */
+
+    protected Label createLabel(Composite composite,
+                                String string) {
+        Label l = new Label( composite,
+                             0 );
+        l.setText( string );
+        return l;
+    }
+
+    protected Text createText(Composite composite,
+                              String string) {
+        Text t = new Text( composite,
+                           0 );
+        t.setText( string );
+        return t;
+    }
+
 }

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RuleModeller.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/RuleModeller.java	2007-06-20 05:16:09 UTC (rev 12707)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RuleModeller.java	2007-06-22 00:27:12 UTC (rev 12760)
@@ -41,154 +41,175 @@
  */
 public class RuleModeller {
 
-	private Composite ifComposite;
+    private Composite          ifComposite;
 
-	private Composite thenComposite;
+    private Composite          thenComposite;
 
-	private Composite optionsComposite;
+    private Composite          optionsComposite;
 
-	private final ScrolledForm form;
+    private final ScrolledForm form;
 
-	private final FormToolkit toolkit;
+    private final FormToolkit  toolkit;
 
-	private RuleModel model;
+    private RuleModel          model;
 
-	private boolean dirty;
+    private boolean            dirty;
 
-	private RuleEditor editor;
+    private RuleEditor         editor;
 
-	public boolean isDirty() {
-		return dirty;
-	}
+    public boolean isDirty() {
+        return dirty;
+    }
 
-	public void setDirty(boolean dirty) {
-		this.dirty = dirty;
-		editor.dirtyPropertyChanged();
-	}
+    public void setDirty(boolean dirty) {
+        this.dirty = dirty;
+        editor.dirtyPropertyChanged();
+    }
 
-	public RuleModeller(ScrolledForm form, FormToolkit toolkit,
-			RuleModel model, RuleEditor editor) {
+    public RuleModeller(ScrolledForm form,
+                        FormToolkit toolkit,
+                        RuleModel model,
+                        RuleEditor editor) {
 
-		this.form = form;
-		this.toolkit = toolkit;
-		this.model = model;
-		this.editor = editor;
+        this.form = form;
+        this.toolkit = toolkit;
+        this.model = model;
+        this.editor = editor;
 
-		form.setText("Rule Builder");
+        form.setText( "Rule Builder" );
 
-		ColumnLayout colLayout = new ColumnLayout();
-		colLayout.minNumColumns = 1;
-		colLayout.maxNumColumns = 1;
+        ColumnLayout colLayout = new ColumnLayout();
+        colLayout.minNumColumns = 1;
+        colLayout.maxNumColumns = 1;
 
-		form.getBody().setLayout(colLayout);
+        form.getBody().setLayout( colLayout );
 
-		// addToolBar(toolkit, form);
+        // addToolBar(toolkit, form);
 
-		Shell shell = new Shell(Display.getCurrent());
-		Window conditionPopup = new AddNewConditionDialog(shell, toolkit, this);
-		Window actionPopup = new AddNewActionDialog(shell, toolkit, this);
+        Shell shell = new Shell( Display.getCurrent() );
+        Window conditionPopup = new AddNewConditionDialog( shell,
+                                                           toolkit,
+                                                           this );
+        Window actionPopup = new AddNewActionDialog( shell,
+                                                     toolkit,
+                                                     this );
 
-		Window optionsPopup = new RuleAttributesDialog(shell, toolkit, this);
+        Window optionsPopup = new RuleAttributesDialog( shell,
+                                                        toolkit,
+                                                        this );
 
-		Section ifSection = createMainSection(form, toolkit, "IF",
-				conditionPopup);
-		Section thenSection = createMainSection(form, toolkit, "THEN",
-				actionPopup);
-		Section optionsSection = createMainSection(form, toolkit, "(options)",
-				optionsPopup);
+        Section ifSection = createMainSection( form,
+                                               toolkit,
+                                               "IF",
+                                               conditionPopup );
+        Section thenSection = createMainSection( form,
+                                                 toolkit,
+                                                 "THEN",
+                                                 actionPopup );
+        Section optionsSection = createMainSection( form,
+                                                    toolkit,
+                                                    "(options)",
+                                                    optionsPopup );
 
-		ColumnLayout layout = new ColumnLayout();
-		layout.minNumColumns = 1;
-		layout.maxNumColumns = 1;
-		// layout.verticalSpacing = 0;
+        ColumnLayout layout = new ColumnLayout();
+        layout.minNumColumns = 1;
+        layout.maxNumColumns = 1;
+        // layout.verticalSpacing = 0;
 
-		((Composite) (ifSection.getClient())).setLayout(layout);
-		((Composite) (thenSection.getClient())).setLayout(layout);
-		((Composite) (optionsSection.getClient())).setLayout(layout);
-		ifSection.setLayout(layout);
-		thenSection.setLayout(layout);
-		optionsSection.setLayout(layout);
+        ((Composite) (ifSection.getClient())).setLayout( layout );
+        ((Composite) (thenSection.getClient())).setLayout( layout );
+        ((Composite) (optionsSection.getClient())).setLayout( layout );
+        ifSection.setLayout( layout );
+        thenSection.setLayout( layout );
+        optionsSection.setLayout( layout );
 
-		ifComposite = (Composite) ifSection.getClient();
-		thenComposite = (Composite) thenSection.getClient();
-		optionsComposite = (Composite) optionsSection.getClient();
+        ifComposite = (Composite) ifSection.getClient();
+        thenComposite = (Composite) thenSection.getClient();
+        optionsComposite = (Composite) optionsSection.getClient();
 
-	}
+    }
 
-	public SuggestionCompletionEngine getSuggestionCompletionEngine() {
-		return editor.getCompletionEngine();
-	}
+    public SuggestionCompletionEngine getSuggestionCompletionEngine() {
+        return editor.getCompletionEngine();
+    }
 
-	public RuleModel getModel() {
-		return model;
-	}
+    public RuleModel getModel() {
+        return model;
+    }
 
-	public void setModel(RuleModel model) {
-		this.model = model;
-	}
+    public void setModel(RuleModel model) {
+        this.model = model;
+    }
 
-	private void clearComposite(Composite composite) {
-		if (composite != null) {
-			Control[] c = composite.getChildren();
-			for (int i = 0; i < c.length; i++) {
-				Control c2 = c[i];
-				c2.dispose();
-			}
-		}
-	}
+    private void clearComposite(Composite composite) {
+        if ( composite != null ) {
+            Control[] c = composite.getChildren();
+            for ( int i = 0; i < c.length; i++ ) {
+                Control c2 = c[i];
+                c2.dispose();
+            }
+        }
+    }
 
-	private void reloadCommon() {
-		toolkit.paintBordersFor(form.getBody());
-		form.redraw();
-		Dialog.applyDialogFont(form.getBody());
-		form.reflow(true);
-	}
+    private void reloadCommon() {
+        toolkit.paintBordersFor( form.getBody() );
+        form.redraw();
+        Dialog.applyDialogFont( form.getBody() );
+        form.reflow( true );
+    }
 
-	public void reloadRhs() {
-		clearComposite(thenComposite);
-		redrawRhs();
-		reloadCommon();
-	}
+    public void reloadRhs() {
+        clearComposite( thenComposite );
+        redrawRhs();
+        reloadCommon();
+    }
 
-	public void reloadLhs() {
-		clearComposite(ifComposite);
-		redrawLhs();
-		reloadCommon();
-	}
+    public void reloadLhs() {
+        clearComposite( ifComposite );
+        redrawLhs();
+        reloadCommon();
+    }
 
-	public void reloadOptions() {
-		clearComposite(optionsComposite);
-		redrawOptions();
-		reloadCommon();
-	}
+    public void reloadOptions() {
+        clearComposite( optionsComposite );
+        redrawOptions();
+        reloadCommon();
+    }
 
-	public void reloadWidgets() {
-		reloadLhs();
-		reloadRhs();
-		reloadOptions();
-	}
+    public void reloadWidgets() {
+        reloadLhs();
+        reloadRhs();
+        reloadOptions();
+    }
 
-	private void redrawOptions() {
-		Composite comp = toolkit.createComposite(optionsComposite);
-		new RuleAttributeWidget(toolkit, comp, this);
-	}
+    private void redrawOptions() {
+        Composite comp = toolkit.createComposite( optionsComposite );
+        new RuleAttributeWidget( toolkit,
+                                 comp,
+                                 this );
+    }
 
-	private void redrawRhs() {
-		for (int i = 0; i < model.rhs.length; i++) {
-			IAction action = model.rhs[i];
+    private void redrawRhs() {
+        for ( int i = 0; i < model.rhs.length; i++ ) {
+            IAction action = model.rhs[i];
 
-			if (action instanceof ActionSetField) {
-				addActionSetFieldWidget(action, i);
-			} else if (action instanceof ActionInsertFact) {
-				addActionInsertFactWidget(action, i);
-			} else if (action instanceof ActionRetractFact) {
-				addActionRetractFactWidget(action, i);
-			} else if (action instanceof DSLSentence) {
-				addRHSDSLSentenceWidget(i, (DSLSentence) action);
-			}
+            if ( action instanceof ActionSetField ) {
+                addActionSetFieldWidget( action,
+                                         i );
+            } else if ( action instanceof ActionInsertFact ) {
+                addActionInsertFactWidget( action,
+                                           i );
+            } else if ( action instanceof ActionRetractFact ) {
+                addActionRetractFactWidget( action,
+                                            i );
+            } else if ( action instanceof DSLSentence ) {
+                addRHSDSLSentenceWidget( i,
+                                         (DSLSentence) action );
+            }
 
         }
     }
+
     private void addActionInsertFactWidget(IAction action,
                                            int i) {
         Composite comp = toolkit.createComposite( thenComposite );
@@ -197,115 +218,156 @@
                                     this,
                                     (ActionInsertFact) action,
                                     i );
-	}
+    }
 
-	private void redrawLhs() {
-		for (int i = 0; i < model.lhs.length; i++) {
-			IPattern pattern = model.lhs[i];
+    private void redrawLhs() {
+        for ( int i = 0; i < model.lhs.length; i++ ) {
+            IPattern pattern = model.lhs[i];
 
-			if (pattern instanceof FactPattern) {
-				addFactPatternWidget(i, (FactPattern) pattern);
-			}
-			if (pattern instanceof CompositeFactPattern) {
-				addCompositeFactPatternWidget(i, (CompositeFactPattern) pattern);
-			} else if (pattern instanceof DSLSentence) {
-				// skip for now
-			} else {
-				// dont' care
-			}
-		}
+            if ( pattern instanceof FactPattern ) {
+                addFactPatternWidget( i,
+                                      (FactPattern) pattern );
+            }
+            if ( pattern instanceof CompositeFactPattern ) {
+                addCompositeFactPatternWidget( i,
+                                               (CompositeFactPattern) pattern );
+            } else if ( pattern instanceof DSLSentence ) {
+                // skip for now
+            } else {
+                // dont' care
+            }
+        }
 
-		for (int i = 0; i < model.lhs.length; i++) {
-			IPattern pattern = model.lhs[i];
-			if (pattern instanceof DSLSentence) {
-				addLHSDSLSentenceWidget(i, (DSLSentence) pattern);
-			}
-		}
-	}
+        for ( int i = 0; i < model.lhs.length; i++ ) {
+            IPattern pattern = model.lhs[i];
+            if ( pattern instanceof DSLSentence ) {
+                addLHSDSLSentenceWidget( i,
+                                         (DSLSentence) pattern );
+            }
+        }
+    }
 
-	private void addActionRetractFactWidget(IAction action, int i) {
-		Composite comp = toolkit.createComposite(thenComposite);
-		new ActionRetractFactWidget(toolkit, comp, this,
-				(ActionRetractFact) action, i);
-	}
+    private void addActionRetractFactWidget(IAction action,
+                                            int i) {
+        Composite comp = toolkit.createComposite( thenComposite );
+        new ActionRetractFactWidget( toolkit,
+                                     comp,
+                                     this,
+                                     (ActionRetractFact) action,
+                                     i );
+    }
 
-	private void addActionAssertFactWidget(IAction action, int i) {
-		Composite comp = toolkit.createComposite(thenComposite);
-		new ActionInsertFactWidget(toolkit, comp, this,
-				(ActionInsertFact) action, i);
+    private void addActionAssertFactWidget(IAction action,
+                                           int i) {
+        Composite comp = toolkit.createComposite( thenComposite );
+        new ActionInsertFactWidget( toolkit,
+                                    comp,
+                                    this,
+                                    (ActionInsertFact) action,
+                                    i );
 
-	}
+    }
 
-	private void addActionSetFieldWidget(IAction action, int i) {
-		Composite comp = toolkit.createComposite(thenComposite);
-		new ActionSetFieldWidget(toolkit, comp, this, model,
-				(ActionSetField) action, i);
-	}
+    private void addActionSetFieldWidget(IAction action,
+                                         int i) {
+        Composite comp = toolkit.createComposite( thenComposite );
+        new ActionSetFieldWidget( toolkit,
+                                  comp,
+                                  this,
+                                  model,
+                                  (ActionSetField) action,
+                                  i );
+    }
 
-	private void addRHSDSLSentenceWidget(int idx, DSLSentence pattern) {
-		Composite comp = toolkit.createComposite(thenComposite);
-		new RHSDSLSentenceWidget(toolkit, comp, pattern, this, idx);
-	}
+    private void addRHSDSLSentenceWidget(int idx,
+                                         DSLSentence pattern) {
+        Composite comp = toolkit.createComposite( thenComposite );
+        new RHSDSLSentenceWidget( toolkit,
+                                  comp,
+                                  pattern,
+                                  this,
+                                  idx );
+    }
 
-	private void addLHSDSLSentenceWidget(int idx, DSLSentence pattern) {
-		Composite comp = toolkit.createComposite(ifComposite);
-		new LHSDSLSentenceWidget(toolkit, comp, pattern, this, idx);
-	}
+    private void addLHSDSLSentenceWidget(int idx,
+                                         DSLSentence pattern) {
+        Composite comp = toolkit.createComposite( ifComposite );
+        new LHSDSLSentenceWidget( toolkit,
+                                  comp,
+                                  pattern,
+                                  this,
+                                  idx );
+    }
 
-	private void addCompositeFactPatternWidget(int idx,
-			CompositeFactPattern pattern) {
-		Composite comp = toolkit.createComposite(ifComposite);
-		new CompositeFactPatternWidget(toolkit, comp, this, pattern, idx);
-	}
+    private void addCompositeFactPatternWidget(int idx,
+                                               CompositeFactPattern pattern) {
+        Composite comp = toolkit.createComposite( ifComposite );
+        new CompositeFactPatternWidget( toolkit,
+                                        comp,
+                                        this,
+                                        pattern,
+                                        idx );
+    }
 
-	private void addFactPatternWidget(int idx, FactPattern pattern) {
-		Composite comp = toolkit.createComposite(ifComposite);
-		new FactPatternWidget(toolkit, comp, this, pattern, null, idx, true);
-	}
+    private void addFactPatternWidget(int idx,
+                                      FactPattern pattern) {
+        Composite comp = toolkit.createComposite( ifComposite );
+        new FactPatternWidget( toolkit,
+                               comp,
+                               this,
+                               pattern,
+                               null,
+                               idx,
+                               true );
+    }
 
-	private Section createMainSection(final ScrolledForm form,
-			FormToolkit toolkit, String title, Window popup) {
-		ColumnLayout layout = new ColumnLayout();
-		layout.minNumColumns = 1;
-		layout.maxNumColumns = 1;
-		Section l1Sect = toolkit.createSection(form.getBody(),
-				ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR
-						| ExpandableComposite.EXPANDED);
-		l1Sect.setActiveToggleColor(toolkit.getHyperlinkGroup()
-				.getActiveForeground());
-		l1Sect.setToggleColor(toolkit.getColors()
-				.getColor(FormColors.SEPARATOR));
-		l1Sect.setText(title);
-		createAddToolItem(l1Sect, popup);
-		Composite comp = toolkit.createComposite(l1Sect);
-		l1Sect.setClient(comp);
-		return l1Sect;
-	}
+    private Section createMainSection(final ScrolledForm form,
+                                      FormToolkit toolkit,
+                                      String title,
+                                      Window popup) {
+        ColumnLayout layout = new ColumnLayout();
+        layout.minNumColumns = 1;
+        layout.maxNumColumns = 1;
+        Section l1Sect = toolkit.createSection( form.getBody(),
+                                                ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR | ExpandableComposite.EXPANDED );
+        l1Sect.setActiveToggleColor( toolkit.getHyperlinkGroup().getActiveForeground() );
+        l1Sect.setToggleColor( toolkit.getColors().getColor( FormColors.SEPARATOR ) );
+        l1Sect.setText( title );
+        createAddToolItem( l1Sect,
+                           popup );
+        Composite comp = toolkit.createComposite( l1Sect );
+        l1Sect.setClient( comp );
+        return l1Sect;
+    }
 
-	private void createAddToolItem(Section sect, final Window popup) {
-		ToolBar tbar = new ToolBar(sect, SWT.FLAT | SWT.HORIZONTAL);
-		ToolItem titem = new ToolItem(tbar, SWT.SEPARATOR);
-		titem = new ToolItem(tbar, SWT.PUSH);
-		titem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(
-				ISharedImages.IMG_TOOL_NEW_WIZARD));
+    private void createAddToolItem(Section sect,
+                                   final Window popup) {
+        ToolBar tbar = new ToolBar( sect,
+                                    SWT.FLAT | SWT.HORIZONTAL );
+        ToolItem titem = new ToolItem( tbar,
+                                       SWT.SEPARATOR );
+        titem = new ToolItem( tbar,
+                              SWT.PUSH );
+        titem.setImage( PlatformUI.getWorkbench().getSharedImages().getImage( ISharedImages.IMG_TOOL_NEW_WIZARD ) );
 
-		titem.addListener(SWT.Selection, new Listener() {
-			public void handleEvent(Event event) {
-				popup.open();
-			}
-		});
-		sect.setTextClient(tbar);
-	}
+        titem.addListener( SWT.Selection,
+                           new Listener() {
+                               public void handleEvent(Event event) {
+                                   popup.open();
+                               }
+                           } );
+        sect.setTextClient( tbar );
+    }
 
-	public void refresh() {
-		ifComposite.layout();
-		ifComposite.redraw();
+    public void refresh() {
+        ifComposite.layout();
+        ifComposite.redraw();
 
-		thenComposite.layout();
-		thenComposite.redraw();
+        thenComposite.layout();
+        thenComposite.redraw();
 
-		optionsComposite.layout();
-		optionsComposite.redraw();
-	}
+        optionsComposite.layout();
+        optionsComposite.redraw();
+    }
 
 }

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ValueEditorTypeSelectionDialog.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/ValueEditorTypeSelectionDialog.java	2007-06-20 05:16:09 UTC (rev 12707)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ValueEditorTypeSelectionDialog.java	2007-06-22 00:27:12 UTC (rev 12760)
@@ -12,18 +12,19 @@
 
 public class ValueEditorTypeSelectionDialog extends RuleDialog {
 
-    private final FormToolkit toolkit;
+    private final FormToolkit      toolkit;
 
-    private RuleModeller      modeller;
+    private RuleModeller           modeller;
 
-    private ISingleFieldConstraint   constraint;
+    private ISingleFieldConstraint constraint;
 
     public ValueEditorTypeSelectionDialog(Shell parent,
                                           FormToolkit toolkit,
                                           RuleModeller modeller,
-                                          ISingleFieldConstraint constraint
-                                          ) {
-        super(parent,"Select value editor type","Select value editor type" );
+                                          ISingleFieldConstraint constraint) {
+        super( parent,
+               "Select value editor type",
+               "Select value editor type" );
         this.toolkit = toolkit;
         this.modeller = modeller;
         this.constraint = constraint;
@@ -32,20 +33,23 @@
     protected Control createDialogArea(final Composite parent) {
         Composite composite = (Composite) super.createDialogArea( parent );
 
-        toolkit.createLabel( composite,
-                             "Field value:" );
+        createLabel( composite,
+                     "Field value:" );
         final Combo valueTypeCombo = new Combo( composite,
                                                 SWT.READ_ONLY );
         valueTypeCombo.add( "Literal value" ); // 0
         valueTypeCombo.add( "A formula" ); // 1
 
-        
         if ( modeller.getModel().getBoundVariablesInScope( constraint ).size() > 0 ) {
             valueTypeCombo.add( "Bound variable" ); // 2
         }
 
         valueTypeCombo.addModifyListener( new ModifyListener() {
             public void modifyText(ModifyEvent e) {
+
+                System.out.println( "Modify event " + valueTypeCombo.getSelectionIndex() );
+                System.out.println( "setting constraint for " + constraint );
+
                 switch ( valueTypeCombo.getSelectionIndex() ) {
                     case 0 :
                         constraint.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
@@ -57,9 +61,16 @@
                         constraint.constraintValueType = ISingleFieldConstraint.TYPE_VARIABLE;
                         break;
                 }
-                modeller.reloadLhs();
-                modeller.setDirty( true );
-                close();
+
+                getShell().getDisplay().asyncExec( new Runnable() {
+
+                    public void run() {
+                        modeller.reloadLhs();
+                        modeller.setDirty( true );
+                        close();
+                    }
+
+                } );
             }
         } );
 

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/Widget.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/Widget.java	2007-06-20 05:16:09 UTC (rev 12707)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/Widget.java	2007-06-22 00:27:12 UTC (rev 12760)
@@ -1,6 +1,6 @@
 package org.drools.eclipse.rulebuilder.ui;
 
-import org.drools.eclipse.rulebuilder.RuleBuilderPlugin;
+import org.drools.eclipse.DroolsEclipsePlugin;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Composite;
@@ -13,13 +13,13 @@
 
 public abstract class Widget {
 
-    final protected Composite   parent;
+    final protected Composite    parent;
 
-    final protected FormToolkit toolkit;
+    final protected FormToolkit  toolkit;
 
-    final protected RuleModeller  modeller;
+    final protected RuleModeller modeller;
 
-    final protected int         index;
+    final protected int          index;
 
     public Widget(Composite parent,
                   FormToolkit toolkit,
@@ -35,7 +35,7 @@
                                    String fileName) {
         ImageHyperlink imageHyperlink = toolkit.createImageHyperlink( parent,
                                                                       0 );
-        ImageDescriptor imageDescriptor = RuleBuilderPlugin.getImageDescriptor( fileName );
+        ImageDescriptor imageDescriptor = DroolsEclipsePlugin.getImageDescriptor( fileName );
         imageHyperlink.setImage( imageDescriptor.createImage() );
         return imageHyperlink;
     }

Copied: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/wizards (from rev 12707, labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/wizards)

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/wizards/NewBrxmlFileWizard.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/wizards/NewBrxmlFileWizard.java	2007-06-20 05:16:09 UTC (rev 12707)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/wizards/NewBrxmlFileWizard.java	2007-06-22 00:27:12 UTC (rev 12760)
@@ -26,126 +26,143 @@
  * be able to open it.
  */
 
-public class NewBrxmlFileWizard extends Wizard implements INewWizard {
-	private NewBrxmlFileWizardPage page;
-	private ISelection selection;
+public class NewBrxmlFileWizard extends Wizard
+    implements
+    INewWizard {
+    private NewBrxmlFileWizardPage page;
+    private ISelection             selection;
 
-	/**
-	 * Constructor for NewBrxmlFileWizard.
-	 */
-	public NewBrxmlFileWizard() {
-		super();
-		setNeedsProgressMonitor(true);
-	}
-	
-	/**
-	 * Adding the page to the wizard.
-	 */
+    /**
+     * Constructor for NewBrxmlFileWizard.
+     */
+    public NewBrxmlFileWizard() {
+        super();
+        setNeedsProgressMonitor( true );
+    }
 
-	public void addPages() {
-		page = new NewBrxmlFileWizardPage(selection);
-		addPage(page);
-	}
+    /**
+     * Adding the page to the wizard.
+     */
 
-	/**
-	 * 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() {
-		final String containerName = page.getContainerName();
-		final String fileName = page.getFileName();
-		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.
-	 */
+    public void addPages() {
+        page = new NewBrxmlFileWizardPage( selection );
+        addPage( page );
+    }
 
-	private void doFinish(
-		String containerName,
-		String fileName,
-		IProgressMonitor monitor)
-		throws CoreException {
-		// create a sample file
-		monitor.beginTask("Creating " + fileName, 2);
-		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.
-	 */
+    /**
+     * 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() {
+        final String containerName = page.getContainerName();
+        final String fileName = page.getFileName();
+        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;
+    }
 
-	private InputStream openContentStream() {
-		//String contents =
-		//	"This is the initial file contents for *.brxml file that should be word-sorted in the Preview page of the multi-page editor";
-		String contents = "";
-		return new ByteArrayInputStream(contents.getBytes());
-	}
+    /**
+     * 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 throwCoreException(String message) throws CoreException {
-		IStatus status =
-			new Status(IStatus.ERROR, "org.drools.eclipse.rulebuilder", IStatus.OK, message, null);
-		throw new CoreException(status);
-	}
+    private void doFinish(String containerName,
+                          String fileName,
+                          IProgressMonitor monitor) throws CoreException {
+        // create a sample file
+        monitor.beginTask( "Creating " + fileName,
+                           2 );
+        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 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;
-	}
+    /**
+     * We will initialize file contents with a sample text.
+     */
+
+    private InputStream openContentStream() {
+        //String contents =
+        //	"This is the initial file contents for *.brxml file that should be word-sorted in the Preview page of the multi-page editor";
+        String contents = "";
+        return new ByteArrayInputStream( contents.getBytes() );
+    }
+
+    private void throwCoreException(String message) throws CoreException {
+        IStatus status = new Status( IStatus.ERROR,
+                                     "org.drools.eclipse.rulebuilder",
+                                     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;
+    }
 }
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/wizards/NewBrxmlFileWizardPage.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/wizards/NewBrxmlFileWizardPage.java	2007-06-20 05:16:09 UTC (rev 12707)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/wizards/NewBrxmlFileWizardPage.java	2007-06-22 00:27:12 UTC (rev 12760)
@@ -6,6 +6,7 @@
 import org.eclipse.core.runtime.Path;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ModifyEvent;
@@ -27,159 +28,162 @@
  */
 
 public class NewBrxmlFileWizardPage extends WizardPage {
-	private Text containerText;
+    private Text       containerText;
 
-	private Text fileText;
+    private Text       fileText;
 
-	private ISelection selection;
+    private ISelection selection;
 
-	/**
-	 * Constructor for SampleNewWizardPage.
-	 * 
-	 * @param pageName
-	 */
-	public NewBrxmlFileWizardPage(ISelection selection) {
-		super("wizardPage");
-		setTitle("RuleBuilder Editor File");
-		setDescription("This wizard creates a new file with *.brxml extension that can be opened by a multi-page editor.");
-		this.selection = selection;
-	}
+    /**
+     * Constructor for SampleNewWizardPage.
+     * 
+     * @param pageName
+     */
+    public NewBrxmlFileWizardPage(ISelection selection) {
+        super( "wizardPage" );
+        setTitle( "RuleBuilder Editor File" );
+        setDescription( "This wizard creates a new file with *.brxml extension that can be opened by a multi-page editor." );
+        this.selection = selection;
+    }
 
-	/**
-	 * @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 = 3;
-		layout.verticalSpacing = 9;
-		Label label = new Label(container, SWT.NULL);
-		label.setText("&Container:");
+    /**
+     * @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 = 3;
+        layout.verticalSpacing = 9;
+        Label label = new Label( container,
+                                 SWT.NULL );
+        label.setText( "&Container:" );
 
-		containerText = new Text(container, SWT.BORDER | SWT.SINGLE);
-		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
-		containerText.setLayoutData(gd);
-		containerText.addModifyListener(new ModifyListener() {
-			public void modifyText(ModifyEvent e) {
-				dialogChanged();
-			}
-		});
+        containerText = new Text( container,
+                                  SWT.BORDER | SWT.SINGLE );
+        GridData 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();
-			}
-		});
-		label = new Label(container, SWT.NULL);
-		label.setText("&File name:");
+        Button button = new Button( container,
+                                    SWT.PUSH );
+        button.setText( "Browse..." );
+        button.addSelectionListener( new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent e) {
+                handleBrowse();
+            }
+        } );
+        label = new Label( container,
+                           SWT.NULL );
+        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();
-			}
-		});
-		initialize();
-		dialogChanged();
-		setControl(container);
-	}
+        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();
+            }
+        } );
+        initialize();
+        dialogChanged();
+        setControl( container );
+    }
 
-	/**
-	 * Tests if the current workbench selection is a suitable container to use.
-	 */
+    /**
+     * 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() > 1)
-				return;
-			Object obj = ssel.getFirstElement();
-			if (obj instanceof IResource) {
-				IContainer container;
-				if (obj instanceof IContainer)
-					container = (IContainer) obj;
-				else
-					container = ((IResource) obj).getParent();
-				containerText.setText(container.getFullPath().toString());
-			}
-		}
-		fileText.setText("rules.brxml");
-	}
+    private void initialize() {
+        if ( selection != null && selection.isEmpty() == false && selection instanceof IStructuredSelection ) {
+            IStructuredSelection ssel = (IStructuredSelection) selection;
+            if ( ssel.size() > 1 ) return;
+            Object obj = ssel.getFirstElement();
+            if ( obj instanceof IResource ) {
+                IContainer container;
+                if ( obj instanceof IContainer ) container = (IContainer) obj;
+                else container = ((IResource) obj).getParent();
+                containerText.setText( container.getFullPath().toString() );
+            }
+        }
+        fileText.setText( "rules.brxml" );
+    }
 
-	/**
-	 * Uses the standard container selection dialog to choose the new value for
-	 * the container field.
-	 */
+    /**
+     * 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,
-				"Select new file container");
-		if (dialog.open() == ContainerSelectionDialog.OK) {
-			Object[] result = dialog.getResult();
-			if (result.length == 1) {
-				containerText.setText(((Path) result[0]).toString());
-			}
-		}
-	}
+    private void handleBrowse() {
+        ContainerSelectionDialog dialog = new ContainerSelectionDialog( getShell(),
+                                                                        ResourcesPlugin.getWorkspace().getRoot(),
+                                                                        false,
+                                                                        "Select new file container" );
+        if ( dialog.open() == Window.OK ) {
+            Object[] result = dialog.getResult();
+            if ( result.length == 1 ) {
+                containerText.setText( ((Path) result[0]).toString() );
+            }
+        }
+    }
 
-	/**
-	 * Ensures that both text fields are set.
-	 */
+    /**
+     * Ensures that both text fields are set.
+     */
 
-	private void dialogChanged() {
-		IResource container = ResourcesPlugin.getWorkspace().getRoot()
-				.findMember(new Path(getContainerName()));
-		String fileName = getFileName();
+    private void dialogChanged() {
+        IResource container = ResourcesPlugin.getWorkspace().getRoot().findMember( new Path( getContainerName() ) );
+        String fileName = getFileName();
 
-		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;
-		}
-		if (fileName.length() == 0) {
-			updateStatus("File name must be specified");
-			return;
-		}
-		if (fileName.replace('\\', '/').indexOf('/', 1) > 0) {
-			updateStatus("File name must be valid");
-			return;
-		}
-		int dotLoc = fileName.lastIndexOf('.');
-		if (dotLoc != -1) {
-			String ext = fileName.substring(dotLoc + 1);
-			if (ext.equalsIgnoreCase("brxml") == false) {
-				updateStatus("File extension must be \"brxml\"");
-				return;
-			}
-		}
-		updateStatus(null);
-	}
+        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;
+        }
+        if ( fileName.length() == 0 ) {
+            updateStatus( "File name must be specified" );
+            return;
+        }
+        if ( fileName.replace( '\\',
+                               '/' ).indexOf( '/',
+                                              1 ) > 0 ) {
+            updateStatus( "File name must be valid" );
+            return;
+        }
+        int dotLoc = fileName.lastIndexOf( '.' );
+        if ( dotLoc != -1 ) {
+            String ext = fileName.substring( dotLoc + 1 );
+            if ( ext.equalsIgnoreCase( "brxml" ) == false ) {
+                updateStatus( "File extension must be \"brxml\"" );
+                return;
+            }
+        }
+        updateStatus( null );
+    }
 
-	private void updateStatus(String message) {
-		setErrorMessage(message);
-		setPageComplete(message == null);
-	}
+    private void updateStatus(String message) {
+        setErrorMessage( message );
+        setPageComplete( message == null );
+    }
 
-	public String getContainerName() {
-		return containerText.getText();
-	}
+    public String getContainerName() {
+        return containerText.getText();
+    }
 
-	public String getFileName() {
-		return fileText.getText();
-	}
+    public String getFileName() {
+        return fileText.getText();
+    }
 }
\ No newline at end of file




More information about the jboss-svn-commits mailing list