[jboss-svn-commits] JBL Code SVN: r8152 - in labs/jbossrules/trunk/drools-jbrms/src: main/java/org/drools/brms/client/modeldriven main/java/org/drools/brms/client/modeldriven/model main/java/org/drools/brms/client/modeldriven/ui test/java/org/drools/brms/client/modeldriven
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Dec 8 16:15:31 EST 2006
Author: michael.neale at jboss.com
Date: 2006-12-08 16:15:15 -0500 (Fri, 08 Dec 2006)
New Revision: 8152
Added:
labs/jbossrules/trunk/drools-jbrms/src/test/java/org/drools/brms/client/modeldriven/ConstraintTest.java
Modified:
labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/SuggestionCompletionEngine.java
labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/model/ActionFieldList.java
labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/model/ActionSetField.java
labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/model/CompositeFactPattern.java
labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/model/ConnectiveConstraint.java
labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/model/Constraint.java
labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/model/RuleModel.java
labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/ui/ActionSetFieldWidget.java
labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/ui/CompositeFactPatternWidget.java
labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/ui/FactPatternWidget.java
labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/ui/RuleModeller.java
labs/jbossrules/trunk/drools-jbrms/src/test/java/org/drools/brms/client/modeldriven/RuleModelTest.java
Log:
pretty much all working now.
Modified: labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/SuggestionCompletionEngine.java
===================================================================
--- labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/SuggestionCompletionEngine.java 2006-12-08 20:35:37 UTC (rev 8151)
+++ labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/SuggestionCompletionEngine.java 2006-12-08 21:15:15 UTC (rev 8152)
@@ -9,6 +9,11 @@
* An suggestion completion processor. This should be usable in both GWT/Web and the IDE.
* The data for this can be loaded into this from simple string lists.
*
+ * TODO: make this i18n friendly, either at this level, or the data
+ * being fed into it.
+ * TODO: also make this include type info for the fields (for display, but may be needed
+ * for rendering DRL).
+ *
* @author Michael Neale
*/
public class SuggestionCompletionEngine {
@@ -123,4 +128,11 @@
return toStringArray( this.globals.keySet() );
}
+ /**
+ * Returns a list of First order logic prefixes
+ */
+ public String[] getListOfCEs() {
+ return new String[] {"There is no", "There exists", "Any one of"};
+ }
+
}
Modified: labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/model/ActionFieldList.java
===================================================================
--- labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/model/ActionFieldList.java 2006-12-08 20:35:37 UTC (rev 8151)
+++ labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/model/ActionFieldList.java 2006-12-08 21:15:15 UTC (rev 8152)
@@ -12,7 +12,7 @@
implements
IAction {
- public ActionFieldValue[] fieldValues;
+ public ActionFieldValue[] fieldValues = new ActionFieldValue[0];
public void removeField(int idx) {
//Unfortunately, this is kinda duplicate code with other methods,
Modified: labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/model/ActionSetField.java
===================================================================
--- labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/model/ActionSetField.java 2006-12-08 20:35:37 UTC (rev 8151)
+++ labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/model/ActionSetField.java 2006-12-08 21:15:15 UTC (rev 8152)
@@ -7,6 +7,11 @@
*/
public class ActionSetField extends ActionFieldList {
+ public ActionSetField(String var) {
+ this.variable = var;
+ }
+
+ public ActionSetField() {}
public String variable;
public boolean modify;
Modified: labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/model/CompositeFactPattern.java
===================================================================
--- labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/model/CompositeFactPattern.java 2006-12-08 20:35:37 UTC (rev 8151)
+++ labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/model/CompositeFactPattern.java 2006-12-08 21:15:15 UTC (rev 8152)
@@ -14,6 +14,14 @@
public String type;
public FactPattern[] patterns;
+
+ public CompositeFactPattern(String type) {
+ this.type = type;
+ }
+
+ public CompositeFactPattern() {}
+
+
public void addFactPattern(FactPattern pat) {
if (this.patterns == null) this.patterns = new FactPattern[0];
Modified: labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/model/ConnectiveConstraint.java
===================================================================
--- labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/model/ConnectiveConstraint.java 2006-12-08 20:35:37 UTC (rev 8151)
+++ labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/model/ConnectiveConstraint.java 2006-12-08 21:15:15 UTC (rev 8152)
@@ -2,10 +2,16 @@
import com.google.gwt.user.client.rpc.IsSerializable;
+/**
+ * This is for a connective constraint that adds more options to a field constraint.
+ * @author Michael Neale
+ */
public class ConnectiveConstraint
implements
IsSerializable {
+ public ConnectiveConstraint() {}
+
public ConnectiveConstraint(String opr,
String val) {
this.operator = opr;
Modified: labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/model/Constraint.java
===================================================================
--- labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/model/Constraint.java 2006-12-08 20:35:37 UTC (rev 8151)
+++ labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/model/Constraint.java 2006-12-08 21:15:15 UTC (rev 8152)
@@ -16,5 +16,22 @@
public Constraint() {}
+ /**
+ * This adds a new connective.
+ *
+ */
+ public void addNewConnective() {
+ if (connectives == null) {
+ connectives = new ConnectiveConstraint[] {new ConnectiveConstraint()};
+ } else {
+ ConnectiveConstraint[] newList = new ConnectiveConstraint[connectives.length + 1];
+ for ( int i = 0; i < connectives.length; i++ ) {
+ newList[i] = connectives[i];
+ }
+ newList[connectives.length] = new ConnectiveConstraint();
+ connectives = newList;
+ }
+ }
+
}
Modified: labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/model/RuleModel.java
===================================================================
--- labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/model/RuleModel.java 2006-12-08 20:35:37 UTC (rev 8151)
+++ labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/model/RuleModel.java 2006-12-08 21:15:15 UTC (rev 8152)
@@ -112,6 +112,20 @@
this.lhs = newList;
}
+ public void addRhsItem(IAction action) {
+ if (this.rhs == null) this.rhs = new IAction[0];
+
+ IAction[] list = this.rhs;
+ IAction[] newList = new IAction[list.length + 1];
+
+ for ( int i = 0; i < list.length; i++ ) {
+ newList[i] = list[i];
+ }
+ newList[list.length] = action;
+
+ this.rhs = newList;
+ }
+
public void removeRhsItem(int idx) {
IAction[] newList = new IAction[rhs.length - 1];
int newIdx = 0;
Modified: labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/ui/ActionSetFieldWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/ui/ActionSetFieldWidget.java 2006-12-08 20:35:37 UTC (rev 8151)
+++ labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/ui/ActionSetFieldWidget.java 2006-12-08 21:15:15 UTC (rev 8152)
@@ -62,6 +62,7 @@
FlexTable inner = new FlexTable();
+
for ( int i = 0; i < model.fieldValues.length; i++ ) {
ActionFieldValue val = model.fieldValues[i];
Modified: labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/ui/CompositeFactPatternWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/ui/CompositeFactPatternWidget.java 2006-12-08 20:35:37 UTC (rev 8151)
+++ labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/ui/CompositeFactPatternWidget.java 2006-12-08 21:15:15 UTC (rev 8152)
@@ -26,83 +26,91 @@
public class CompositeFactPatternWidget extends Composite {
private final SuggestionCompletionEngine completions;
- private CompositeFactPattern pattern;
- private Grid layout;
- private RuleModeller modeller;
+ private CompositeFactPattern pattern;
+ private Grid layout;
+ private RuleModeller modeller;
- public CompositeFactPatternWidget(RuleModeller modeller, CompositeFactPattern pattern,
+ public CompositeFactPatternWidget(RuleModeller modeller,
+ CompositeFactPattern pattern,
SuggestionCompletionEngine completions) {
this.completions = completions;
this.pattern = pattern;
this.modeller = modeller;
-
-
- this.layout = new Grid(1, 2);
+
+ this.layout = new Grid( 1, 2 );
this.layout.setStyleName( "model-builderInner-Background" );
-
- doLayout( );
-
-
- initWidget( layout );
- }
+ doLayout();
+ initWidget( layout );
+ }
+
private void doLayout() {
- VerticalPanel vert = new VerticalPanel();
-
- FactPattern[] facts = pattern.patterns;
- for ( int i = 0; i < facts.length; i++ ) {
- vert.add( new FactPatternWidget(modeller, facts[i], this.completions, false) );
+ this.layout.setWidget( 0,
+ 0,
+ getCompositeLabel() );
+
+ if ( pattern.patterns != null ) {
+ VerticalPanel vert = new VerticalPanel();
+ FactPattern[] facts = pattern.patterns;
+ for ( int i = 0; i < facts.length; i++ ) {
+ vert.add( new FactPatternWidget( modeller,
+ facts[i],
+ this.completions,
+ false ) );
+ }
+ this.layout.setWidget( 0,
+ 1,
+ vert );
}
-
- this.layout.setWidget( 0, 0, getCompositeLabel() );
- this.layout.setWidget( 0, 1, vert );
}
private Widget getCompositeLabel() {
-
+
HorizontalPanel horiz = new HorizontalPanel();
- Image edit = new Image("images/edit.gif");
+ Image edit = new Image( "images/edit.gif" );
edit.addClickListener( new ClickListener() {
public void onClick(Widget w) {
showFactTypeSelector( w );
}
} );
-
+
horiz.add( edit );
- horiz.add( new Label(pattern.type));
+ horiz.add( new Label( pattern.type ) );
return horiz;
}
-
+
/**
* Pops up the fact selector.
*/
protected void showFactTypeSelector(final Widget w) {
final ListBox box = new ListBox();
String[] facts = completions.getFactTypes();
-
+
for ( int i = 0; i < facts.length; i++ ) {
box.addItem( facts[i] );
}
- final FormStylePopup popup = new FormStylePopup("images/new_fact.gif", "New fact pattern...");
- popup.addAttribute( "choose type", box );
- Button ok = new Button("OK");
- popup.addAttribute( "", ok );
-
+ final FormStylePopup popup = new FormStylePopup( "images/new_fact.gif",
+ "New fact pattern..." );
+ popup.addAttribute( "choose type",
+ box );
+ Button ok = new Button( "OK" );
+ popup.addAttribute( "",
+ ok );
+
ok.addClickListener( new ClickListener() {
public void onClick(Widget w) {
- pattern.addFactPattern( new FactPattern(box.getItemText( box.getSelectedIndex() )));
+ pattern.addFactPattern( new FactPattern( box.getItemText( box.getSelectedIndex() ) ) );
modeller.refreshWidget();
- popup.hide();
+ popup.hide();
}
- });
+ } );
popup.setStyleName( "ks-popups-Popup" );
-
- popup.setPopupPosition( w.getAbsoluteLeft() - 400, w.getAbsoluteTop() );
+
+ popup.setPopupPosition( w.getAbsoluteLeft() - 400,
+ w.getAbsoluteTop() );
popup.show();
- }
+ }
-
-
}
Modified: labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/ui/FactPatternWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/ui/FactPatternWidget.java 2006-12-08 20:35:37 UTC (rev 8151)
+++ labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/ui/FactPatternWidget.java 2006-12-08 21:15:15 UTC (rev 8152)
@@ -62,23 +62,32 @@
inner.setWidget( row, 3, connectives(c) );
Image clear = new Image("images/clear_item.gif");
+ clear.setTitle( "Remove this field constraint" );
+
clear.addClickListener( new ClickListener() {
public void onClick(Widget w) {
YesNoDialog d = new YesNoDialog("Remove this item?", new Command() {
-
public void execute() {
pattern.removeConstraint( currentRow );
modeller.refreshWidget();
- }
-
+ }
});
d.setPopupPosition( w.getAbsoluteLeft(), w.getAbsoluteTop());
d.show();
}
} );
-
- inner.setWidget( row, 4, clear );
+ Image addConnective = new Image("images/add_connective.gif");
+ addConnective.addClickListener( new ClickListener() {
+ public void onClick(Widget w) {
+ c.addNewConnective();
+ modeller.refreshWidget();
+ }
+ });
+
+ inner.setWidget( row, 4, addConnective );
+ inner.setWidget( row, 5, clear );
+
}
if (bindable) {
layout.setStyleName( "model-builderInner-Background" );
@@ -259,38 +268,7 @@
private Widget fieldDropDown(final Constraint con) {//, final Command onChange) {
-//MN: don't really need drop downs here. No idea why I did it initially.
-// HorizontalPanel horiz = new HorizontalPanel();
-//
-// final ListBox box = new ListBox();
-//
-// String[] com = completions.getFieldCompletions( this.pattern.factType );
-// for ( int i = 0; i < com.length; i++ ) {
-// box.addItem( com[i] );
-// if (com[i].equals( con.fieldName )) {
-// box.setSelectedIndex( i );
-// }
-// }
-//
-// box.addChangeListener( new ChangeListener() {
-//
-// public void onChange(Widget w) {
-// con.fieldName = box.getItemText( box.getSelectedIndex() );
-// onChange.execute();
-// }
-//
-// });
-// horiz.add( box );
-//
-// if (con.fieldBinding != null) {
-// horiz.add( new Label( "[" + con.fieldBinding + "]") );
-// }
-//
-// return horiz;
-//
-
return new Label(con.fieldName);
-
}
}
Modified: labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/ui/RuleModeller.java
===================================================================
--- labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/ui/RuleModeller.java 2006-12-08 20:35:37 UTC (rev 8151)
+++ labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/modeldriven/ui/RuleModeller.java 2006-12-08 21:15:15 UTC (rev 8152)
@@ -1,5 +1,8 @@
package org.drools.brms.client.modeldriven.ui;
+import java.util.Iterator;
+import java.util.List;
+
import org.drools.brms.client.common.ErrorPopup;
import org.drools.brms.client.common.FormStylePopup;
import org.drools.brms.client.common.YesNoDialog;
@@ -14,7 +17,7 @@
import org.drools.brms.client.modeldriven.model.RuleModel;
import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.ChangeListener;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
@@ -58,7 +61,7 @@
Image addPattern = new Image( "images/new_item.gif" );
addPattern.addClickListener( new ClickListener() {
public void onClick(Widget w) {
- showFactTypeSelector(w);
+ showPatternSelector(w);
}
});
@@ -67,9 +70,19 @@
layout.setWidget( 1, 1, renderLhs(this.model) );
layout.setWidget( 2, 0, new Label("THEN") );
+
+ Image addAction = new Image("images/new_item.gif");
+ addAction.addClickListener( new ClickListener() {
+ public void onClick(Widget w) {
+ showActionSelector(w);
+ }
+ });
+ layout.setWidget( 2, 2, addAction );
+
layout.setWidget( 3, 1, renderRhs(this.model) );
}
+
/**
* Do the widgets for the RHS.
*/
@@ -90,7 +103,8 @@
HorizontalPanel horiz = new HorizontalPanel();
- Image remove = new Image("images/delete_obj.gif");
+ Image remove = new Image("images/delete_item_small.gif");
+ remove.setTitle( "Remove this action." );
final int idx = i;
remove.addClickListener( new ClickListener() {
public void onClick(Widget w) {
@@ -111,40 +125,126 @@
}
-
-
return vert;
}
/**
* Pops up the fact selector.
*/
- protected void showFactTypeSelector(final Widget w) {
- final ListBox box = new ListBox();
+ protected void showPatternSelector(final Widget w) {
+ final FormStylePopup popup = new FormStylePopup("images/new_fact.gif", "New fact pattern...");
+
+
+
+ //
+ // The list of facts
+ //
String[] facts = completions.getFactTypes();
-
+ final ListBox factTypeBox = new ListBox();
+ factTypeBox.addItem( "Choose fact type...", "IGNORE" );
for ( int i = 0; i < facts.length; i++ ) {
- box.addItem( facts[i] );
+ factTypeBox.addItem( facts[i] );
}
+ factTypeBox.setSelectedIndex( 0 );
+ popup.addAttribute( "Fact", factTypeBox );
+ factTypeBox.addChangeListener( new ChangeListener() {
+ public void onChange(Widget w) {
+ String s = factTypeBox.getItemText( factTypeBox.getSelectedIndex() );
+ if (!s.equals( "IGNORE" )) {
+ addNewFact(s);
+ popup.hide();
+ }
+ }
+ });
+ popup.setStyleName( "ks-popups-Popup" );
+
+ //
+ // The list of top level CEs
+ //
+ String ces[] = completions.getListOfCEs();
+ final ListBox ceBox = new ListBox();
+ ceBox.addItem( "Choose condition type...", "IGNORE" );
+ for ( int i = 0; i < ces.length; i++ ) {
+ ceBox.addItem( ces[i] );
+ }
+ ceBox.setSelectedIndex( 0 );
+
+ popup.addAttribute( "Condition type", ceBox );
+ ceBox.addChangeListener( new ChangeListener() {
+ public void onChange(Widget w) {
+ String s = ceBox.getItemText( ceBox.getSelectedIndex() );
+ if (!s.equals( "IGNORE" )) {
+ addNewCE(s);
+ popup.hide();
+ }
+ }
+ });
+
+ popup.setPopupPosition( w.getAbsoluteLeft() - 400, w.getAbsoluteTop() );
+ popup.show();
- final FormStylePopup popup = new FormStylePopup("images/new_fact.gif", "New fact pattern...");
- popup.addAttribute( "choose type", box );
- Button ok = new Button("OK");
- popup.addAttribute( "", ok );
+ }
+
+ protected void showActionSelector(Widget w) {
+ final FormStylePopup popup = new FormStylePopup("images/new_fact.gif", "Add a new action...");
- ok.addClickListener( new ClickListener() {
- public void onClick(Widget w) {
- addNewFact(box.getItemText( box.getSelectedIndex() ));
- popup.hide();
+ popup.setStyleName( "ks-popups-Popup" );
+
+ List vars = model.getBoundFacts();
+
+ final ListBox varBox = new ListBox();
+ final ListBox retractBox = new ListBox();
+ varBox.addItem( "Choose ..." );
+ retractBox.addItem( "Choose..." );
+ for ( Iterator iter = vars.iterator(); iter.hasNext(); ) {
+ String v = (String) iter.next();
+ varBox.addItem( v );
+ retractBox.addItem( v );
+ }
+ String[] globals = this.completions.getGlobalVariables();
+ for ( int i = 0; i < globals.length; i++ ) {
+ varBox.addItem( globals[i] );
+ }
+
+ varBox.setSelectedIndex( 0 );
+ varBox.addChangeListener( new ChangeListener() {
+ public void onChange(Widget w) {
+ addModifyVar(varBox.getItemText( varBox.getSelectedIndex() ));
+ popup.hide();
}
});
- popup.setStyleName( "ks-popups-Popup" );
+ retractBox.addChangeListener( new ChangeListener() {
+ public void onChange(Widget w) {
+ addRetract(retractBox.getItemText( retractBox.getItemCount() ));
+ popup.hide();
+ }
+ });
+
+ popup.addAttribute( "Modify a field on", varBox );
+ popup.addAttribute( "Retract a fact", retractBox );
+
popup.setPopupPosition( w.getAbsoluteLeft() - 400, w.getAbsoluteTop() );
popup.show();
+ }
+
+
+ protected void addRetract(String var) {
+ this.model.addRhsItem( new ActionRetractFact(var) );
+ refreshWidget();
}
+ protected void addModifyVar(String itemText) {
+ this.model.addRhsItem(new ActionSetField(itemText));
+ refreshWidget();
+ }
+
+ protected void addNewCE(String s) {
+ this.model.addLhsItem( new CompositeFactPattern(s) );
+ refreshWidget();
+ }
+
/**
* Adds a fact to the model, and then refreshes the display.
*/
@@ -169,21 +269,19 @@
HorizontalPanel horiz = new HorizontalPanel();
- Image remove = new Image("images/delete_obj.gif");
+ Image remove = new Image("images/delete_item_small.gif");
+ remove.setTitle( "Remove this condition, and all the field constraints that belong to it." );
final int idx = i;
remove.addClickListener( new ClickListener() {
public void onClick(Widget w) {
YesNoDialog diag = new YesNoDialog("Remove this item?", new Command() {
-
public void execute() {
if (model.removeLhsItem(idx)) {
refreshWidget();
} else {
ErrorPopup.showMessage( "Can't remove that item as it is used in the action part of the rule." );
- }
-
- }
-
+ }
+ }
});
diag.setPopupPosition( w.getAbsoluteLeft(), w.getAbsoluteTop() );
diag.show();
Added: labs/jbossrules/trunk/drools-jbrms/src/test/java/org/drools/brms/client/modeldriven/ConstraintTest.java
===================================================================
--- labs/jbossrules/trunk/drools-jbrms/src/test/java/org/drools/brms/client/modeldriven/ConstraintTest.java 2006-12-08 20:35:37 UTC (rev 8151)
+++ labs/jbossrules/trunk/drools-jbrms/src/test/java/org/drools/brms/client/modeldriven/ConstraintTest.java 2006-12-08 21:15:15 UTC (rev 8152)
@@ -0,0 +1,24 @@
+package org.drools.brms.client.modeldriven;
+
+import junit.framework.TestCase;
+
+import org.drools.brms.client.modeldriven.model.Constraint;
+
+public class ConstraintTest extends TestCase {
+
+ public void testAdd() {
+ Constraint con = new Constraint();
+ con.addNewConnective();
+
+ assertEquals(1, con.connectives.length);
+ assertNotNull(con.connectives[0]);
+
+ con.addNewConnective();
+
+ assertEquals(2, con.connectives.length);
+ assertNotNull(con.connectives[1]);
+
+
+ }
+
+}
Modified: labs/jbossrules/trunk/drools-jbrms/src/test/java/org/drools/brms/client/modeldriven/RuleModelTest.java
===================================================================
--- labs/jbossrules/trunk/drools-jbrms/src/test/java/org/drools/brms/client/modeldriven/RuleModelTest.java 2006-12-08 20:35:37 UTC (rev 8151)
+++ labs/jbossrules/trunk/drools-jbrms/src/test/java/org/drools/brms/client/modeldriven/RuleModelTest.java 2006-12-08 21:15:15 UTC (rev 8152)
@@ -137,7 +137,21 @@
}
+ public void testAddItemRhs() {
+ RuleModel model = new RuleModel();
+ IAction a0 = new ActionSetField();
+ IAction a1 = new ActionSetField();
+
+ model.addRhsItem( a0 );
+
+ assertEquals(1, model.rhs.length);
+ model.addRhsItem( a1 );
+
+ assertEquals(2, model.rhs.length);
+
+ assertEquals(a0, model.rhs[0]);
+ assertEquals(a1, model.rhs[1]);
+ }
-
}
More information about the jboss-svn-commits
mailing list