[jboss-svn-commits] JBL Code SVN: r6638 - in labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms: client/breditor public

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Oct 6 06:42:56 EDT 2006


Author: michael.neale at jboss.com
Date: 2006-10-06 06:42:51 -0400 (Fri, 06 Oct 2006)
New Revision: 6638

Modified:
   labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/breditor/BREditor.java
   labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/breditor/EditableLine.java
   labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/public/JBRMS.css
Log:
tweaks to business rule editor

Modified: labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/breditor/BREditor.java
===================================================================
--- labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/breditor/BREditor.java	2006-10-06 09:17:01 UTC (rev 6637)
+++ labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/breditor/BREditor.java	2006-10-06 10:42:51 UTC (rev 6638)
@@ -35,27 +35,32 @@
     
     private FlexTable table = null;
     private boolean editMode = false;
+    private ChoiceList lhsSuggestionPopup;
+    private ChoiceList rhsSuggestionPopup;
+    private Image addLhsPopupButton;
+    private Image editButton;
+    private Image addRhsPopupButton;
     
     
     public BREditor() {
         panel = new VerticalPanel();
+        
         initData();
+        initEditorActions();        
         refreshLayoutTable();
         initWidget( panel );
+                
     }
 
-    /** This will populate and refresh the overall layout table. */
-    private void refreshLayoutTable() {
-        
-        resetTableWidget();
-        table.setText( 0, DESC_COLUMN, "IF" );
-        
+    private void initEditorActions() {
         //DSL suggestions/pick list
-        final ChoiceList lhsSuggestionPopup = getLHSChoiceList();
+        lhsSuggestionPopup = getLHSChoiceList();
+        rhsSuggestionPopup = getRhsChoiceList();
+
         
         //button to add a new item for lhs (using the choice list).
-        Image addLhs = new Image("images/new_item.gif");
-        addLhs.addClickListener( new ClickListener() {
+        addLhsPopupButton = new Image("images/new_item.gif");
+        addLhsPopupButton.addClickListener( new ClickListener() {
             public void onClick(Widget sender) {
                 int left = sender.getAbsoluteLeft() + 10;
                 int top = sender.getAbsoluteTop() + 10;
@@ -63,33 +68,22 @@
                 lhsSuggestionPopup.show();                
             }            
         });
+        addLhsPopupButton.setVisible( false );
         
         //button to toggle edit mode
-        Image edit = new Image("images/edit.gif");
-        edit.addClickListener( new ClickListener() {
+        editButton = new Image("images/edit.gif");
+        editButton.addClickListener( new ClickListener() {
             public void onClick(Widget w) {
                 switchModes(lhs, editMode);
                 switchModes(rhs, editMode);
-                showHideLineEditorWidgets( editMode );
+                showHideLineEditorWidgets( editMode );                
                 editMode = !editMode;
             }            
-        });
+        });        
         
-        table.setWidget( 0, ACTION_COLUMN, addLhs );
-        table.setWidget( 0, ACTION_COLUMN + 1, edit );
-        
-        int rowOffset = 1;
-        
-        //setup LHS
-        displayEditorWidgets( rowOffset, lhs );        
-        rowOffset = lhs.size() + 1;        
-        table.setText( rowOffset, DESC_COLUMN, "THEN" );
-        
-        final ChoiceList rhsSuggestionPopup = getRhsChoiceList();
-        
         //the new button for the RHS
-        Image newRhsPopup = new Image("images/new_item.gif");
-        newRhsPopup.addClickListener( new ClickListener() {
+        addRhsPopupButton = new Image("images/new_item.gif");
+        addRhsPopupButton.addClickListener( new ClickListener() {
 
             public void onClick(Widget sender) {
                 int left = sender.getAbsoluteLeft() + 10;
@@ -99,8 +93,28 @@
             }
             
         });
-        table.setWidget( rowOffset, ACTION_COLUMN, newRhsPopup );
+        addRhsPopupButton.setVisible( false );
+    }
+
+    /** This will populate and refresh the overall layout table. */
+    private void refreshLayoutTable() {
         
+        resetTableWidget();
+        table.setText( 0, DESC_COLUMN, "IF" );
+        
+        table.setWidget( 0, ACTION_COLUMN, addLhsPopupButton );
+        table.setWidget( 0, ACTION_COLUMN + 1, editButton );
+        
+        int rowOffset = 1;
+        
+        //setup LHS
+        displayEditorWidgets( rowOffset, lhs );        
+        rowOffset = lhs.size() + 1;        
+        table.setText( rowOffset, DESC_COLUMN, "THEN" );
+        
+
+        table.setWidget( rowOffset, ACTION_COLUMN, addRhsPopupButton );
+        
         rowOffset++;
         
         //setup RHS
@@ -156,6 +170,10 @@
 
     /** Switch all the line editor widgets on or off */
     private void showHideLineEditorWidgets(boolean readOnly) {
+        
+        this.addLhsPopupButton.setVisible(!readOnly);
+        this.addRhsPopupButton.setVisible( !readOnly );
+        
         for (int row = 1; row <= lhs.size(); row++ ) {
             showHideLineEditorWidget( readOnly, row );
         }
@@ -251,14 +269,27 @@
      */
     private void initData() {
 
-        lhsSuggestions.add( "Hello {world}" );
-        lhsSuggestions.add( "Goodbye {world}" );
+        //the suggestion data
+        lhsSuggestions.add("There is a Driver");
+        lhsSuggestions.add("- age less than {age} years old");
+        lhsSuggestions.add("- age greater than {age} years old");
+        lhsSuggestions.add("- has had more than {number} prior claims");
+        lhsSuggestions.add("- has a location risk profile of '{risk}'");
+        lhsSuggestions.add("- age is at least {age}");
+        lhsSuggestions.add("- age is between {lower} and {upper} years old");
+        lhsSuggestions.add("- has had exactly {number} prior claims");
+        lhsSuggestions.add("Policy type is '{type}'");
+        lhsSuggestions.add("Policy has not been rejected");
+        
+        rhsSuggestions.add("Reject Policy with explanation : '{reason}'");        
+        rhsSuggestions.add("Approve Policy with the reason : '{reason}'");                
         rhsSuggestions.add( "Log '{message}'" );
-        rhsSuggestions.add( "Do nothing" );
-
-        lhs.add( new EditableLine("this is a {bam}"));
-        lhs.add( new EditableLine("this is a {bam}"));
-        rhs.add( new EditableLine("this is a {bam}"));
+        
+        //now the actual data, which in reality would have to be parsed out
+//        lhs.add( new EditableLine("this is a {bam}"));
+//        lhs.add( new EditableLine("this is a {bam}"));
+//        rhs.add( new EditableLine("this is a {bam}"));
+        
     }
 
     /** Adjust items up and down in a list.

Modified: labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/breditor/EditableLine.java
===================================================================
--- labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/breditor/EditableLine.java	2006-10-06 09:17:01 UTC (rev 6637)
+++ labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/breditor/EditableLine.java	2006-10-06 10:42:51 UTC (rev 6638)
@@ -73,10 +73,12 @@
             char c = chars[i];
             if (c == '{') {
                 currentLabel = null;
-                currentBox = new TextBox();
-                currentBox.setVisibleLength( 3 );
+                currentBox = new TextBox(); 
+                currentBox.setStyleName( "dsl-field-TextBox" );
                 widgets.add( currentBox );
+                
             } else if (c == '}') {
+                currentBox.setVisibleLength( currentBox.getText().length() );
                 currentBox = null;
             } else {
                 if (currentBox == null && currentLabel == null) {

Modified: labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/public/JBRMS.css
===================================================================
--- labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/public/JBRMS.css	2006-10-06 09:17:01 UTC (rev 6637)
+++ labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/public/JBRMS.css	2006-10-06 10:42:51 UTC (rev 6638)
@@ -254,6 +254,11 @@
   padding: 4px;
 }
 
+.dsl-field-TextBox {
+  border: 1px solid #87B3FF;
+  padding: 0px;	
+}
+
 .rule-viewer-Documentation {
   background-color: #FDFCDC;
   font-family: Arial, sans-serif;




More information about the jboss-svn-commits mailing list