[jboss-svn-commits] JBL Code SVN: r31169 - labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Jan 20 15:29:03 EST 2010


Author: baunax
Date: 2010-01-20 15:29:03 -0500 (Wed, 20 Jan 2010)
New Revision: 31169

Modified:
   labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java
Log:
added expression editor

Modified: labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java	2010-01-20 20:27:01 UTC (rev 31168)
+++ labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java	2010-01-20 20:29:03 UTC (rev 31169)
@@ -115,16 +115,12 @@
         layout.getColumnFormatter().setWidth(1, "87%");
         layout.getColumnFormatter().setWidth(2, "5%");
 
-
-
         layout.setWidget( 0, 0, new SmallLabel(constants.WHEN()) );
 
         if (!lockLHS()) {
             layout.setWidget( 0, 2, addPattern );
         }
 
-
-
         layout.setWidget( 1, 1, renderLhs(this.model) );
         layout.getFlexCellFormatter().setHorizontalAlignment(1, 1, HasHorizontalAlignment.ALIGN_LEFT);
         layout.getFlexCellFormatter().setVerticalAlignment(1, 1, HasVerticalAlignment.ALIGN_TOP);
@@ -352,7 +348,7 @@
      * Pops up the fact selector.
      */
     protected void showConditionSelector(final Widget w) {
-
+    	//XXX {bauna} add actions for LHS
         final FormStylePopup popup = new FormStylePopup();
         popup.setWidth(-1);
         popup.setTitle(constants.AddAConditionToTheRule());
@@ -361,15 +357,10 @@
 
         final ListBox choices = new ListBox(true);
 
-        
-
         //
         // The list of DSL sentences
         //
         if (completions.getDSLConditions().length > 0) {
-
-
-
             for(int i = 0; i < completions.getDSLConditions().length; i++ ) {
                 final DSLSentence sen = completions.getDSLConditions()[i];
                 String key = "DSL" + i;
@@ -381,7 +372,6 @@
                     }
                 });
             }
-
         }
 
         //
@@ -405,7 +395,6 @@
             }
         }
 
-
         //
         // The list of top level CEs
         //
@@ -422,15 +411,8 @@
                     popup.hide();
                 }
             });
-
-
         }
 
-
-
-
-
-
         if (ExplorerLayoutManager.shouldShow(Capabilities.SHOW_PACKAGE_VIEW)) {
             choices.addItem("..................");
             choices.addItem(constants.FreeFormDrl(), "FF");
@@ -441,9 +423,18 @@
                     popup.hide();
                 }
             });
+            
+            choices.addItem("..................");
+            choices.addItem(constants.ExpressionEditor(), "EE");
+            cmds.put("EE", new Command() {
+                public void execute() {
+                    model.addLhsItem(new ExpressionFormLine());
+                    refreshWidget();
+                    popup.hide();
+                }
+            });
         }
-
-
+        
         if (completions.getDSLConditions().length == 0 && facts.length == 0) {
         	popup.addRow(new HTML("<div class='highlight'>" + constants.NoModelTip() + "</div>")); //NON-NLS
         }
@@ -468,7 +459,6 @@
             }
         });
 
-
         HorizontalPanel hp = new HorizontalPanel();
         hp.add(choices);
         Button b = new Button(constants.OK());
@@ -488,18 +478,15 @@
                 choices.setFocus(true);
             }
         });
-
     }
 
-
     protected void addNewDSLLhs(DSLSentence sentence) {
         model.addLhsItem( sentence.copy() );
         refreshWidget();
-
     }
 
-
     protected void showActionSelector(Widget w) {
+    	//XXX {Bauna} add RHS Actions
         final FormStylePopup popup = new FormStylePopup();
         popup.setWidth(-1);
         popup.setTitle(constants.AddANewAction());
@@ -540,8 +527,8 @@
 
 
         //Do Set field (NOT modify)
-        for ( Iterator iter = vars.iterator(); iter.hasNext(); ) {
-            final String v = (String) iter.next();
+        for ( Iterator<String> iter = vars.iterator(); iter.hasNext(); ) {
+            final String v = iter.next();
 
             //varBox.addItem( v );
             choices.addItem(Format.format(constants.ChangeFieldValuesOf0(), v), "VAR" + v); //NON-NLS
@@ -568,8 +555,8 @@
 
 
         //RETRACT
-        for ( Iterator iter = vars.iterator(); iter.hasNext(); ) {
-            final String v = (String) iter.next();
+        for ( Iterator<String> iter = vars.iterator(); iter.hasNext(); ) {
+            final String v = iter.next();
             //retractBox.addItem( v );
             choices.addItem(Format.format(constants.Retract0(), v), "RET" + v); //NON-NLS
             cmds.put("RET" + v, new Command() {                                          //NON-NLS
@@ -581,8 +568,8 @@
         }
 
         //MODIFY
-        for ( Iterator iter = vars.iterator(); iter.hasNext(); ) {
-            final String v = (String) iter.next();
+        for ( Iterator<String> iter = vars.iterator(); iter.hasNext(); ) {
+            final String v = iter.next();
             // modifyBox.addItem( v );
 
             choices.addItem(Format.format(constants.Modify0(), v), "MOD" + v);    //NON-NLS
@@ -622,12 +609,7 @@
             });
         }
 
-
-
-
         choices.addItem("................");
-
-
         //now global collections
         if (completions.getGlobalCollections().length > 0 && vars.size() > 0) {
             for (String bf : vars) {
@@ -649,7 +631,6 @@
             }
         }
 
-
         if (ExplorerLayoutManager.shouldShow(Capabilities.SHOW_PACKAGE_VIEW)) {
             choices.addItem(constants.AddFreeFormDrl(), "FF");  //NON-NLS
             cmds.put("FF", new Command() {                     //NON-NLS
@@ -671,9 +652,9 @@
 
             }
 
-                    //CALL methods
-            for ( Iterator iter = vars.iterator(); iter.hasNext(); ) {
-                final String v = (String) iter.next();
+            //CALL methods
+            for ( Iterator<String> iter = vars.iterator(); iter.hasNext(); ) {
+                final String v = iter.next();
 
                 choices.addItem(Format.format(constants.CallMethodOn0(), v ), "CALL" + v); //NON-NLS
                 cmds.put("CALL" + v, new Command() { //NON-NLS
@@ -684,8 +665,8 @@
                 });
             }
             //Do Set field (NOT modify)
-            for ( Iterator iter = vars2.iterator(); iter.hasNext(); ) {
-                final String v = (String) iter.next();
+            for ( Iterator<String> iter = vars2.iterator(); iter.hasNext(); ) {
+                final String v = iter.next();
 
                 choices.addItem(Format.format(constants.CallMethodOn0(), v), "CALL" + v); //NON-NLS
                 cmds.put("CALL" + v, new Command() {        //NON-NLS
@@ -694,10 +675,7 @@
                         popup.hide();
                     }
                 });
-
-
             }
-
         }
 
         HorizontalPanel hp = new HorizontalPanel();
@@ -729,13 +707,9 @@
         choices.setFocus(true);
     }
 
-
-
-
     protected void addModify(String itemText) {
         this.model.addRhsItem(new ActionUpdateField(itemText));
         refreshWidget();
-
     }
 
     protected void addNewDSLRhs(DSLSentence sentence) {
@@ -761,7 +735,6 @@
     protected void addNewCE(String s) {
         this.model.addLhsItem( new CompositeFactPattern(s) );
         refreshWidget();
-        
     }
 
     /**
@@ -782,13 +755,13 @@
             IPattern pattern = model.lhs[i];
             Widget w = null;
             if (pattern instanceof FactPattern) {
-                w = new FactPatternWidget(this, pattern, completions, true) ;
+                w = new FactPatternWidget(this, pattern, true) ;
                 vert.add( wrapLHSWidget( model,
                               i,
                               w ) );
                 vert.add( spacerWidget() );
             } else if (pattern instanceof CompositeFactPattern) {
-                w = new CompositeFactPatternWidget(this, (CompositeFactPattern) pattern, completions) ;
+                w = new CompositeFactPatternWidget(this, (CompositeFactPattern) pattern) ;
                 vert.add( wrapLHSWidget( model, i, w ));
                 vert.add( spacerWidget() );
             } else if (pattern instanceof DSLSentence) {
@@ -805,13 +778,17 @@
             	});
             	vert.add(wrapLHSWidget(model, i, tb));
             	vert.add( spacerWidget() );
+            } else if (pattern instanceof ExpressionFormLine) {
+            	final ExpressionFormLine efl = (ExpressionFormLine) pattern;
+            	final ExpressionBuilder eb = new ExpressionBuilder(this, efl.text);
+            	vert.add(wrapLHSWidget(model, i, eb));
+            	vert.add( spacerWidget() );
             } else {
                 throw new RuntimeException("I don't know what type of pattern that is.");
             }
 
         }
 
-
         DirtyableVerticalPane dsls = new DirtyableVerticalPane();
         for ( int i = 0; i < model.lhs.length; i++ ) {
             IPattern pattern = model.lhs[i];



More information about the jboss-svn-commits mailing list