[jboss-svn-commits] JBL Code SVN: r31307 - in labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor: client/modeldriven/ui and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Jan 29 11:31:11 EST 2010
Author: eaa
Date: 2010-01-29 11:31:10 -0500 (Fri, 29 Jan 2010)
New Revision: 31307
Added:
labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/public/images/new_item_below.png
Modified:
labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.java
labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.properties
labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants_es_ES.properties
labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FromCollectCompositeFactPatternWidget.java
labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FromCompositeFactPatternWidget.java
labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java
Log:
Guided Editor:
IPattern/Actions can be added in any order now: an icon is added near each row.
Pattern/Actions rows are now numbered.
Right & Left Patterns of FROM/COLLECT/ACCUMULATE can be removed now.
Modified: labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.java 2010-01-29 16:03:56 UTC (rev 31306)
+++ labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.java 2010-01-29 16:31:10 UTC (rev 31307)
@@ -2030,4 +2030,9 @@
String ConditionPositionExplanation();
String ActionPositionExplanation();
+
+ String AddAConditionBelow();
+
+ String AddAnActionBelow();
+
}
Modified: labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.properties
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.properties 2010-01-29 16:03:56 UTC (rev 31306)
+++ labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.properties 2010-01-29 16:31:10 UTC (rev 31307)
@@ -967,4 +967,6 @@
Line0=Line {0}
PositionColon=Position:
ConditionPositionExplanation=Select the position where the Condition will be added.
-ActionPositionExplanation=Select the position where the Action will be added.
\ No newline at end of file
+ActionPositionExplanation=Select the position where the Action will be added.
+AddAConditionBelow=Add a condition below.
+AddAnActionBelow=Add an action below.
\ No newline at end of file
Modified: labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants_es_ES.properties
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants_es_ES.properties 2010-01-29 16:03:56 UTC (rev 31306)
+++ labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants_es_ES.properties 2010-01-29 16:31:10 UTC (rev 31307)
@@ -897,4 +897,6 @@
Line0=L\u00EDnea {0}
PositionColon=Posici\u00F3n:
ConditionPositionExplanation=Seleccione la posici\u00F3n donde la Condici\u00F3n ser\u00E1 agregada.
-ActionPositionExplanation=Seleccione la posici\u00F3n donde la Acci\u00F3n ser\u00E1 agregada.
\ No newline at end of file
+ActionPositionExplanation=Seleccione la posici\u00F3n donde la Acci\u00F3n ser\u00E1 agregada.
+AddAConditionBelow=Agregar una condici\u00F3n debajo.
+AddAnActionBelow=Agregar una acci\u00F3n debajo.
\ No newline at end of file
Modified: labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FromCollectCompositeFactPatternWidget.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FromCollectCompositeFactPatternWidget.java 2010-01-29 16:03:56 UTC (rev 31306)
+++ labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FromCollectCompositeFactPatternWidget.java 2010-01-29 16:31:10 UTC (rev 31307)
@@ -1,5 +1,6 @@
package org.drools.guvnor.client.modeldriven.ui;
+import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ChangeListener;
import com.google.gwt.user.client.ui.ClickListener;
@@ -8,7 +9,6 @@
import com.google.gwt.user.client.ui.Widget;
import org.drools.guvnor.client.common.ClickableLabel;
import org.drools.guvnor.client.common.DirtyableFlexTable;
-import org.drools.guvnor.client.common.DirtyableVerticalPane;
import org.drools.guvnor.client.common.FormStylePopup;
import org.drools.guvnor.client.modeldriven.HumanReadable;
import org.drools.guvnor.client.modeldriven.brl.FactPattern;
@@ -61,28 +61,34 @@
if (this.getFromCollectPattern().getRightPattern() == null) {
panel.setWidget(r++, 0, new ClickableLabel("<br> <font color='red'>" + constants.clickToAddPatterns() + "</font>", rightPatternclick, !this.modeller.lockLHS()));
} else {
- DirtyableVerticalPane vert = new DirtyableVerticalPane();
IPattern rPattern = this.getFromCollectPattern().getRightPattern();
Widget patternWidget = null;
- if (rPattern instanceof FactPattern){
- patternWidget = new FactPatternWidget(modeller, rPattern,constants.All0with(), false);
- }else if (rPattern instanceof FromCompositeFactPattern){
- patternWidget = new FromCompositeFactPatternWidget(modeller, (FromCompositeFactPattern)rPattern);
- }else{
- throw new IllegalArgumentException("Unsuported pattern "+rPattern+" for right side of FROM COLLECT");
+ if (rPattern instanceof FactPattern) {
+ patternWidget = new FactPatternWidget(modeller, rPattern, constants.All0with(), false);
+ } else if (rPattern instanceof FromCompositeFactPattern) {
+ patternWidget = new FromCompositeFactPatternWidget(modeller, (FromCompositeFactPattern) rPattern);
+ } else {
+ throw new IllegalArgumentException("Unsuported pattern " + rPattern + " for right side of FROM COLLECT");
}
- vert.add(patternWidget);
+
panel.setWidget(r++,
0,
- vert);
+ addRemoveButton(patternWidget, new ClickListener() {
+
+ public void onClick(Widget sender) {
+ if (Window.confirm(constants.RemoveThisEntireConditionQ())) {
+ getFromCollectPattern().setRightPattern(null);
+ modeller.refreshWidget();
+ }
+ }
+ }));
}
return panel;
}
-
@Override
protected void showFactTypeSelector(final Widget w) {
@@ -93,26 +99,27 @@
box.addItem(constants.Choose());
- box.addItem("java.util.ArrayList","java.util.ArrayList");
- box.addItem("java.util.LinkedList","java.util.LinkedArrayList");
- box.addItem("java.util.HashSet","java.util.HashSet");
- box.addItem("java.util.LinkedHashSet","java.util.LinkedHashSet");
+ box.addItem("java.util.ArrayList", "java.util.ArrayList");
+ box.addItem("java.util.LinkedList", "java.util.LinkedArrayList");
+ box.addItem("java.util.HashSet", "java.util.HashSet");
+ box.addItem("java.util.LinkedHashSet", "java.util.LinkedHashSet");
box.addItem("...");
box.addItem("TODO: Add Facts that extedns Collection");
- box.setSelectedIndex( 0 );
+ box.setSelectedIndex(0);
- box.addChangeListener( new ChangeListener() {
+ box.addChangeListener(new ChangeListener() {
+
public void onChange(Widget w) {
- pattern.setFactPattern( new FactPattern( box.getItemText( box.getSelectedIndex() ) ) );
+ pattern.setFactPattern(new FactPattern(box.getItemText(box.getSelectedIndex())));
modeller.refreshWidget();
popup.hide();
}
- } );
+ });
popup.addAttribute(constants.chooseFactType(),
- box );
+ box);
popup.show();
}
@@ -153,7 +160,7 @@
}
});
- popup.addAttribute("",fromBtn );
+ popup.addAttribute("", fromBtn);
popup.show();
Modified: labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FromCompositeFactPatternWidget.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FromCompositeFactPatternWidget.java 2010-01-29 16:03:56 UTC (rev 31306)
+++ labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FromCompositeFactPatternWidget.java 2010-01-29 16:31:10 UTC (rev 31307)
@@ -1,16 +1,19 @@
package org.drools.guvnor.client.modeldriven.ui;
import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.ChangeListener;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.Widget;
import org.drools.guvnor.client.common.ClickableLabel;
import org.drools.guvnor.client.common.DirtyableComposite;
import org.drools.guvnor.client.common.DirtyableFlexTable;
-import org.drools.guvnor.client.common.DirtyableVerticalPane;
+import org.drools.guvnor.client.common.DirtyableHorizontalPane;
import org.drools.guvnor.client.common.FormStylePopup;
+import org.drools.guvnor.client.common.ImageButton;
import org.drools.guvnor.client.modeldriven.HumanReadable;
import org.drools.guvnor.client.modeldriven.SuggestionCompletionEngine;
import org.drools.guvnor.client.modeldriven.brl.FactPattern;
@@ -47,15 +50,21 @@
int r = 0;
if (pattern.getFactPattern() != null) {
- DirtyableVerticalPane vert = new DirtyableVerticalPane();
FactPattern fact = pattern.getFactPattern();
if (fact != null) {
- vert.add(new FactPatternWidget(modeller,
- fact,
- true));
this.layout.setWidget(r,
0,
- vert);
+ addRemoveButton(new FactPatternWidget(modeller,
+ fact,
+ true), new ClickListener() {
+
+ public void onClick(Widget w) {
+ if (Window.confirm(constants.RemoveThisEntireConditionQ())) {
+ pattern.setFactPattern(null);
+ modeller.refreshWidget();
+ }
+ }
+ }));
r++;
}
}
@@ -102,27 +111,47 @@
box.addItem(constants.Choose());
- for ( int i = 0; i < facts.length; i++ ) {
- box.addItem( facts[i] );
+ for (int i = 0; i < facts.length; i++) {
+ box.addItem(facts[i]);
}
- box.setSelectedIndex( 0 );
+ box.setSelectedIndex(0);
final FormStylePopup popup = new FormStylePopup();
popup.setTitle(constants.NewFactPattern());
popup.addAttribute(constants.chooseFactType(),
- box );
+ box);
- box.addChangeListener( new ChangeListener() {
+ box.addChangeListener(new ChangeListener() {
+
public void onChange(Widget w) {
- pattern.setFactPattern( new FactPattern( box.getItemText( box.getSelectedIndex() ) ) );
+ pattern.setFactPattern(new FactPattern(box.getItemText(box.getSelectedIndex())));
modeller.refreshWidget();
popup.hide();
}
- } );
+ });
popup.show();
}
+ protected Widget addRemoveButton(Widget w, ClickListener listener) {
+ DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();
+
+ final Image remove = new ImageButton("images/delete_faded.gif"); //NON-NLS
+ remove.setTitle(constants.RemoveThisBlockOfData());
+ remove.addClickListener(listener);
+
+
+ horiz.setWidth("100%");
+ w.setWidth("100%");
+
+ horiz.add(w);
+ if (!modeller.lockLHS()) {
+ horiz.add(remove);
+ }
+
+ return horiz;
+ }
+
public boolean isDirty() {
return layout.hasDirty();
}
Modified: labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java 2010-01-29 16:03:56 UTC (rev 31306)
+++ labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java 2010-01-29 16:31:10 UTC (rev 31307)
@@ -15,8 +15,6 @@
* limitations under the License.
*/
-
-
import java.util.*;
import org.drools.guvnor.client.common.*;
@@ -49,6 +47,7 @@
private RuleModel model;
private Constants constants = ((Constants) GWT.create(Constants.class));
private boolean showingOptions = false;
+ private int currentLayoutRow = 0;
public RuleModeller(RuleAsset asset, RuleViewer viewer) {
this(asset);
@@ -57,19 +56,18 @@
public RuleModeller(RuleAsset asset) {
this.model = (RuleModel) asset.content;
- this.completions = SuggestionCompletionCache.getInstance().getEngineFromCache( asset.metaData.packageName );
+ this.completions = SuggestionCompletionCache.getInstance().getEngineFromCache(asset.metaData.packageName);
layout = new DirtyableFlexTable();
initWidget();
- layout.setStyleName( "model-builder-Background" );
- initWidget( layout );
- setWidth( "100%" );
- setHeight( "100%" );
+ layout.setStyleName("model-builder-Background");
+ initWidget(layout);
+ setWidth("100%");
+ setHeight("100%");
}
-
private boolean isLock(String attr) {
//UNCOMMENT THIS WHEN READY !
@@ -79,8 +77,10 @@
if (this.model.metadataList.length == 0) {
return false;
} else {
- for(RuleMetadata at : this.model.metadataList) {
- if (at.attributeName.equals(attr)) return true;
+ for (RuleMetadata at : this.model.metadataList) {
+ if (at.attributeName.equals(attr)) {
+ return true;
+ }
}
return false;
}
@@ -96,18 +96,19 @@
return isLock(RuleAttributeWidget.LOCK_LHS); //NON-NLS
}
-
/**
* This updates the widget to reflect the state of the model.
*/
public void initWidget() {
layout.clear();
+ this.currentLayoutRow = 0;
- Image addPattern = new ImageButton( "images/new_item.gif" );
+ Image addPattern = new ImageButton("images/new_item.gif");
addPattern.setTitle(constants.AddAConditionToThisRule());
- addPattern.addClickListener( new ClickListener() {
+ addPattern.addClickListener(new ClickListener() {
+
public void onClick(Widget w) {
- showConditionSelector(w);
+ showConditionSelector(w, null);
}
});
@@ -115,56 +116,67 @@
layout.getColumnFormatter().setWidth(1, "87%");
layout.getColumnFormatter().setWidth(2, "5%");
- layout.setWidget( 0, 0, new SmallLabel(constants.WHEN()) );
+ //layout.setBorderWidth(2);
+ layout.setWidget(currentLayoutRow, 0, new SmallLabel("<b>"+constants.WHEN()+"</b>"));
+
if (!lockLHS()) {
- layout.setWidget( 0, 2, addPattern );
+ layout.setWidget(currentLayoutRow, 2, addPattern);
}
+ currentLayoutRow++;
- layout.setWidget( 1, 1, renderLhs(this.model) );
- layout.getFlexCellFormatter().setHorizontalAlignment(1, 1, HasHorizontalAlignment.ALIGN_LEFT);
- layout.getFlexCellFormatter().setVerticalAlignment(1, 1, HasVerticalAlignment.ALIGN_TOP);
- layout.setWidget( 2, 0, new SmallLabel(constants.THEN()) );
+ renderLhs(this.model);
+
+ layout.setWidget(currentLayoutRow, 0, new SmallLabel("<b>"+constants.THEN()+"</b>"));
+
Image addAction = new ImageButton("images/new_item.gif"); //NON-NLS
addAction.setTitle(constants.AddAnActionToThisRule());
- addAction.addClickListener( new ClickListener() {
+ addAction.addClickListener(new ClickListener() {
+
public void onClick(Widget w) {
- showActionSelector(w);
+ showActionSelector(w, null);
}
});
if (!lockRHS()) {
- layout.setWidget( 2, 2, addAction );
+ layout.setWidget(currentLayoutRow, 2, addAction);
}
+ currentLayoutRow++;
- layout.setWidget( 3, 1, renderRhs(this.model) );
- layout.getFlexCellFormatter().setHorizontalAlignment(3, 1, HasHorizontalAlignment.ALIGN_LEFT);
- layout.getFlexCellFormatter().setVerticalAlignment(3, 1, HasVerticalAlignment.ALIGN_TOP);
+ renderRhs(this.model);
-
if (showAttributes()) {
+ final int tmp1 = currentLayoutRow;
+ final int tmp2 = currentLayoutRow + 1;
+
final RuleModeller self = this;
if (!this.showingOptions) {
ClickableLabel showMoreOptions = new ClickableLabel("(show options...)", new ClickListener() {
+
public void onClick(Widget sender) {
showingOptions = true;
- layout.setWidget( 4, 0, new SmallLabel(constants.optionsRuleModeller()) );
- layout.setWidget( 4, 2, getAddAttribute() );
- layout.setWidget( 5, 1, new RuleAttributeWidget(self, self.model) );
+ layout.setWidget(tmp1, 0, new SmallLabel(constants.optionsRuleModeller()));
+ layout.setWidget(tmp1, 2, getAddAttribute());
+ layout.setWidget(tmp2, 1, new RuleAttributeWidget(self, self.model));
}
});
- layout.setWidget( 4, 0, showMoreOptions );
+ layout.setWidget(tmp1, 0, showMoreOptions);
} else {
- layout.setWidget( 4, 0, new SmallLabel(constants.optionsRuleModeller()) );
- layout.setWidget( 4, 2, getAddAttribute() );
- layout.setWidget( 5, 1, new RuleAttributeWidget(self, self.model) );
-
+ layout.setWidget(tmp1, 0, new SmallLabel(constants.optionsRuleModeller()));
+ layout.setWidget(tmp1, 2, getAddAttribute());
+ layout.setWidget(tmp2, 1, new RuleAttributeWidget(self, self.model));
+
}
}
+ currentLayoutRow++;
+ layout.setWidget(currentLayoutRow, 1, spacerWidget());
+ layout.getCellFormatter().setHeight(currentLayoutRow, 1, "100%");
+
+
}
private boolean showAttributes() {
@@ -181,7 +193,8 @@
Image add = new ImageButton("images/new_item.gif"); //NON-NLS
add.setTitle(constants.AddAnOptionToTheRuleToModifyItsBehaviorWhenEvaluatedOrExecuted());
- add.addClickListener( new ClickListener() {
+ add.addClickListener(new ClickListener() {
+
public void onClick(Widget w) {
showAttributeSelector(w);
}
@@ -189,7 +202,6 @@
return add;
}
-
protected void showAttributeSelector(Widget w) {
final FormStylePopup pop = new FormStylePopup("images/config.png", constants.AddAnOptionToTheRule()); //NON-NLS
final ListBox list = RuleAttributeWidget.getAttributeList();
@@ -198,55 +210,59 @@
final TextBox box = new TextBox();
- list.setSelectedIndex( 0 );
+ list.setSelectedIndex(0);
- list.addChangeListener( new ChangeListener() {
+ list.addChangeListener(new ChangeListener() {
+
public void onChange(Widget w) {
- String attr = list.getItemText( list.getSelectedIndex() );
- if (attr.equals(RuleAttributeWidget.LOCK_LHS) ||attr.equals(RuleAttributeWidget.LOCK_RHS)) {
- model.addMetadata(new RuleMetadata(attr, "true") );
- } else {
- model.addAttribute( new RuleAttribute(attr, "") );
- }
- refreshWidget();
- pop.hide();
+ String attr = list.getItemText(list.getSelectedIndex());
+ if (attr.equals(RuleAttributeWidget.LOCK_LHS) || attr.equals(RuleAttributeWidget.LOCK_RHS)) {
+ model.addMetadata(new RuleMetadata(attr, "true"));
+ } else {
+ model.addAttribute(new RuleAttribute(attr, ""));
+ }
+ refreshWidget();
+ pop.hide();
}
});
- box.setVisibleLength( 15 );
+ box.setVisibleLength(15);
addbutton.setTitle(constants.AddMetadataToTheRule());
- addbutton.addClickListener( new ClickListener() {
+ addbutton.addClickListener(new ClickListener() {
+
public void onClick(Widget w) {
- model.addMetadata( new RuleMetadata(box.getText(), "") );
- refreshWidget();
+ model.addMetadata(new RuleMetadata(box.getText(), ""));
+ refreshWidget();
pop.hide();
}
});
DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();
- horiz.add( box );
- horiz.add( addbutton );
+ horiz.add(box);
+ horiz.add(addbutton);
- pop.addAttribute(constants.Metadata3(), horiz );
- pop.addAttribute(constants.Attribute1(), list );
+ pop.addAttribute(constants.Metadata3(), horiz);
+ pop.addAttribute(constants.Attribute1(), list);
Button freezeConditions = new Button(constants.Conditions());
freezeConditions.addClickListener(new ClickListener() {
+
public void onClick(Widget sender) {
- model.addMetadata(new RuleMetadata(RuleAttributeWidget.LOCK_LHS, "true") );
+ model.addMetadata(new RuleMetadata(RuleAttributeWidget.LOCK_LHS, "true"));
refreshWidget();
pop.hide();
}
});
Button freezeActions = new Button(constants.Actions());
freezeActions.addClickListener(new ClickListener() {
+
public void onClick(Widget sender) {
- model.addMetadata(new RuleMetadata(RuleAttributeWidget.LOCK_RHS, "true") );
+ model.addMetadata(new RuleMetadata(RuleAttributeWidget.LOCK_RHS, "true"));
refreshWidget();
pop.hide();
}
@@ -261,7 +277,7 @@
hz.add(new InfoPopup(constants.FrozenAreas(), constants.FrozenExplanation()));
if (hz.getWidgetCount() > 1) {
- pop.addAttribute(constants.FreezeAreasForEditing(), hz);
+ pop.addAttribute(constants.FreezeAreasForEditing(), hz);
}
@@ -273,34 +289,35 @@
/**
* Do all the widgets for the RHS.
*/
- private Widget renderRhs(final RuleModel model) {
- DirtyableVerticalPane widget = new DirtyableVerticalPane();
+ private void renderRhs(final RuleModel model) {
- for ( int i = 0; i < model.rhs.length; i++ ) {
+ for (int i = 0; i < model.rhs.length; i++) {
+ DirtyableVerticalPane widget = new DirtyableVerticalPane();
IAction action = model.rhs[i];
Widget w = null;
if (action instanceof ActionCallMethod) {
w = new ActionCallMethodWidget(this, (ActionCallMethod) action, completions);
} else if (action instanceof ActionSetField) {
- w = new ActionSetFieldWidget(this, (ActionSetField) action, completions ) ;
+ w = new ActionSetFieldWidget(this, (ActionSetField) action, completions);
} else if (action instanceof ActionInsertFact) {
- w = new ActionInsertFactWidget(this, (ActionInsertFact) action, completions );
+ w = new ActionInsertFactWidget(this, (ActionInsertFact) action, completions);
} else if (action instanceof ActionRetractFact) {
- w = new ActionRetractFactWidget(this.completions, (ActionRetractFact) action , this.getModel());
+ w = new ActionRetractFactWidget(this.completions, (ActionRetractFact) action, this.getModel());
} else if (action instanceof DSLSentence) {
- w = new DSLSentenceWidget((DSLSentence) action,this.completions);
- w.setStyleName( "model-builderInner-Background" ); //NON-NLS
+ w = new DSLSentenceWidget((DSLSentence) action, this.completions);
+ w.setStyleName("model-builderInner-Background"); //NON-NLS
} else if (action instanceof FreeFormLine) {
- final TextBox tb = new TextBox();
- final FreeFormLine ffl = (FreeFormLine) action;
- tb.setText(ffl.text);
- tb.addChangeListener(new ChangeListener() {
- public void onChange(Widget arg0) {
- ffl.text = tb.getText();
- }
- });
- w = tb;
+ final TextBox tb = new TextBox();
+ final FreeFormLine ffl = (FreeFormLine) action;
+ tb.setText(ffl.text);
+ tb.addChangeListener(new ChangeListener() {
+
+ public void onChange(Widget arg0) {
+ ffl.text = tb.getText();
+ }
+ });
+ w = tb;
} else if (action instanceof ActionGlobalCollectionAdd) {
ActionGlobalCollectionAdd gca = (ActionGlobalCollectionAdd) action;
SimplePanel sp = new SimplePanel();
@@ -310,45 +327,74 @@
}
//w.setWidth( "100%" );
- widget.add( spacerWidget() );
- //vert.setWidth( "100%" );
+ widget.add(spacerWidget());
DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();
+ //horiz.setBorderWidth(2);
Image remove = new ImageButton("images/delete_faded.gif"); //NON-NLS
remove.setTitle(constants.RemoveThisAction());
final int idx = i;
- remove.addClickListener( new ClickListener() {
+ remove.addClickListener(new ClickListener() {
+
public void onClick(Widget w) {
- if (Window.confirm(constants.RemoveThisItem())) {
- model.removeRhsItem(idx);
- refreshWidget();
+ if (Window.confirm(constants.RemoveThisItem())) {
+ model.removeRhsItem(idx);
+ refreshWidget();
}
}
- } );
- horiz.add( w );
+ });
+ horiz.add(w);
if (!(w instanceof ActionRetractFactWidget)) {
- w.setWidth( "100%" ); //NON-NLS
- horiz.setWidth( "100%" );
+ w.setWidth("100%"); //NON-NLS
+ horiz.setWidth("100%");
}
if (!lockRHS()) {
- horiz.add( remove );
+ horiz.add(remove);
}
- widget.add( horiz );
+
+ widget.add(horiz);
+
+
+ layout.setHTML(currentLayoutRow, 0,"<div class='x-form-field'>"+(i+1)+".</div>");
+ layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 0, HasHorizontalAlignment.ALIGN_CENTER);
+ layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 0, HasVerticalAlignment.ALIGN_MIDDLE);
+
+
+ final int index = i;
+ if (!lockLHS()) {
+ Image addPattern = new ImageButton("images/new_item_below.png");
+ addPattern.setTitle(constants.AddAnActionBelow());
+ addPattern.addClickListener(new ClickListener() {
+
+ public void onClick(Widget w) {
+ showActionSelector(w, index + 1);
+ }
+ });
+
+ layout.setWidget(currentLayoutRow, 2, addPattern);
+ layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 2, HasHorizontalAlignment.ALIGN_CENTER);
+ layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 2, HasVerticalAlignment.ALIGN_MIDDLE);
+ }
+
+ layout.setWidget(currentLayoutRow, 1, widget);
+ layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 1, HasHorizontalAlignment.ALIGN_LEFT);
+ layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 1, HasVerticalAlignment.ALIGN_TOP);
+
+ currentLayoutRow++;
+
+
}
- return widget;
}
-
-
/**
* Pops up the fact selector.
*/
- protected void showConditionSelector(final Widget w) {
- //XXX {bauna} add actions for LHS
+ protected void showConditionSelector(final Widget w, Integer position) {
+ //XXX {bauna} add actions for LHS
final FormStylePopup popup = new FormStylePopup();
popup.setWidth(-1);
popup.setTitle(constants.AddAConditionToTheRule());
@@ -356,27 +402,36 @@
final Map<String, Command> cmds = new HashMap<String, Command>();
final ListBox positionCbo = new ListBox();
- positionCbo.addItem(constants.Bottom(),String.valueOf(this.model.lhs.length));
- positionCbo.addItem(constants.Top(),"0");
- for (int i = 1; i < model.lhs.length; i++) {
- positionCbo.addItem(Format.format(constants.Line0(), i),String.valueOf(i));
+
+ if (position == null) {
+ positionCbo.addItem(constants.Bottom(), String.valueOf(this.model.lhs.length));
+ positionCbo.addItem(constants.Top(), "0");
+ for (int i = 1; i < model.lhs.length; i++) {
+ positionCbo.addItem(Format.format(constants.Line0(), i), String.valueOf(i));
+ }
+ } else {
+ //if position is fixed, we just add one element to the drop down.
+ positionCbo.addItem(String.valueOf(position));
+ positionCbo.setSelectedIndex(0);
}
+
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++ ) {
+ for (int i = 0; i < completions.getDSLConditions().length; i++) {
final DSLSentence sen = completions.getDSLConditions()[i];
String key = "DSL" + i;
choices.addItem(sen.toString(), key);
cmds.put(key, new Command() {
+
public void execute() {
- addNewDSLLhs(sen,Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
- popup.hide();
+ addNewDSLLhs(sen, Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
+ popup.hide();
}
});
}
@@ -388,15 +443,16 @@
final String[] facts = completions.getFactTypes();
if (facts != null && facts.length > 0) {
choices.addItem("..................");
-
- for ( int i = 0; i < facts.length; i++ ) {
+
+ for (int i = 0; i < facts.length; i++) {
final String f = facts[i];
String key = "NF" + f;
- choices.addItem(f + " ...", key);
+ choices.addItem(f + " ...", key);
cmds.put(key, new Command() {
+
public void execute() {
- addNewFact(f,Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
+ addNewFact(f, Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
popup.hide();
}
});
@@ -406,31 +462,33 @@
//
// The list of top level CEs
//
- String ces[] = HumanReadable.CONDITIONAL_ELEMENTS;
+ String ces[] = HumanReadable.CONDITIONAL_ELEMENTS;
choices.addItem("..................");
- for ( int i = 0; i < ces.length; i++ ) {
+ for (int i = 0; i < ces.length; i++) {
final String ce = ces[i];
String key = "CE" + ce;
- choices.addItem( HumanReadable.getCEDisplayName( ce ) + " ...", key );
+ choices.addItem(HumanReadable.getCEDisplayName(ce) + " ...", key);
cmds.put(key, new Command() {
+
public void execute() {
- addNewCE(ce,Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
+ addNewCE(ce, Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
popup.hide();
}
});
}
- String fces[] = HumanReadable.FROM_CONDITIONAL_ELEMENTS;
+ String fces[] = HumanReadable.FROM_CONDITIONAL_ELEMENTS;
choices.addItem("..................");
- for ( int i = 0; i < fces.length; i++ ) {
+ for (int i = 0; i < fces.length; i++) {
final String ce = fces[i];
String key = "FCE" + ce;
- choices.addItem( HumanReadable.getCEDisplayName( ce ) + " ...", key );
+ choices.addItem(HumanReadable.getCEDisplayName(ce) + " ...", key);
cmds.put(key, new Command() {
+
public void execute() {
- addNewFCE(ce,Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
+ addNewFCE(ce, Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
popup.hide();
}
});
@@ -440,40 +498,46 @@
choices.addItem("..................");
choices.addItem(constants.FreeFormDrl(), "FF");
cmds.put("FF", new Command() {
+
public void execute() {
- model.addLhsItem(new FreeFormLine(),Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
+ model.addLhsItem(new FreeFormLine(), Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
refreshWidget();
popup.hide();
}
});
-
+
choices.addItem("..................");
choices.addItem(constants.ExpressionEditor(), "EE");
cmds.put("EE", new Command() {
+
public void execute() {
- model.addLhsItem(new ExpressionFormLine(),Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
+ model.addLhsItem(new ExpressionFormLine(), Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
refreshWidget();
popup.hide();
}
});
}
-
+
if (completions.getDSLConditions().length == 0 && facts.length == 0) {
- popup.addRow(new HTML("<div class='highlight'>" + constants.NoModelTip() + "</div>")); //NON-NLS
+ popup.addRow(new HTML("<div class='highlight'>" + constants.NoModelTip() + "</div>")); //NON-NLS
}
final ChangeListener cl = new ChangeListener() {
+
public void onChange(Widget sender) {
int sel = choices.getSelectedIndex();
if (sel != -1) {
Command cmd = cmds.get(choices.getValue(choices.getSelectedIndex()));
- if (cmd != null) cmd.execute();
+ if (cmd != null) {
+ cmd.execute();
+ }
}
}
};
//choices.addChangeListener(cl);
choices.addKeyboardListener(new KeyboardListenerAdapter() {
+
@Override
public void onKeyUp(final Widget sender, char keyCode, int modifiers) {
if (keyCode == KeyboardListener.KEY_ENTER) {
@@ -482,17 +546,21 @@
}
});
- HorizontalPanel hp0 = new HorizontalPanel();
- hp0.add(new HTML(constants.PositionColon()));
- hp0.add(positionCbo);
- hp0.add(new InfoPopup(constants.PositionColon(), constants.ConditionPositionExplanation()));
- popup.addRow(hp0);
+ //only show the drop down if we are not using fixed position.
+ if (position == null) {
+ HorizontalPanel hp0 = new HorizontalPanel();
+ hp0.add(new HTML(constants.PositionColon()));
+ hp0.add(positionCbo);
+ hp0.add(new InfoPopup(constants.PositionColon(), constants.ConditionPositionExplanation()));
+ popup.addRow(hp0);
+ }
HorizontalPanel hp = new HorizontalPanel();
hp.add(choices);
Button b = new Button(constants.OK());
hp.add(b);
b.addClickListener(new ClickListener() {
+
public void onClick(final Widget sender) {
cl.onChange(sender);
}
@@ -503,31 +571,42 @@
choices.setFocus(true);
popup.setAfterShow(new Command() {
+
public void execute() {
choices.setFocus(true);
}
});
}
- protected void addNewDSLLhs(DSLSentence sentence,int position) {
- model.addLhsItem( sentence.copy(),position );
+ protected void addNewDSLLhs(DSLSentence sentence, int position) {
+ model.addLhsItem(sentence.copy(), position);
refreshWidget();
}
- protected void showActionSelector(Widget w) {
- //XXX {Bauna} add RHS Actions
+ protected void showActionSelector(Widget w, Integer position) {
+ //XXX {Bauna} add RHS Actions
final FormStylePopup popup = new FormStylePopup();
popup.setWidth(-1);
popup.setTitle(constants.AddANewAction());
+
final ListBox positionCbo = new ListBox();
- positionCbo.addItem(constants.Bottom(),String.valueOf(this.model.rhs.length));
- positionCbo.addItem(constants.Top(),"0");
- for (int i = 1; i < model.rhs.length; i++) {
- positionCbo.addItem(Format.format(constants.Line0(), i),String.valueOf(i));
+ if (position == null) {
+ positionCbo.addItem(constants.Bottom(), String.valueOf(this.model.rhs.length));
+ positionCbo.addItem(constants.Top(), "0");
+ for (int i = 1; i < model.rhs.length; i++) {
+ positionCbo.addItem(Format.format(constants.Line0(), i), String.valueOf(i));
+ }
+ } else {
+ //if position is fixed, we just add one element to the drop down.
+ positionCbo.addItem(String.valueOf(position));
+ positionCbo.setSelectedIndex(0);
}
+
+
+
final ListBox choices = new ListBox(true);
final Map<String, Command> cmds = new HashMap<String, Command>();
@@ -544,15 +623,16 @@
//
if (completions.getDSLActions().length > 0) {
- for(int i = 0; i < completions.getDSLActions().length; i++ ) {
- final DSLSentence sen = completions.getDSLActions()[ i ];
- if(sen!=null) {
+ for (int i = 0; i < completions.getDSLActions().length; i++) {
+ final DSLSentence sen = completions.getDSLActions()[i];
+ if (sen != null) {
String sentence = sen.toString();
choices.addItem(sentence, "DSL" + sentence); //NON-NLS
cmds.put("DSL" + sentence, new Command() { //NON-NLS
+
public void execute() {
- addNewDSLRhs(sen,Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
- popup.hide();
+ addNewDSLRhs(sen, Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
+ popup.hide();
}
});
}
@@ -564,14 +644,15 @@
//Do Set field (NOT modify)
- for ( Iterator<String> iter = vars.iterator(); iter.hasNext(); ) {
+ 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
cmds.put("VAR" + v, new Command() { //NON-NLS
+
public void execute() {
- addActionSetField(v,Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
+ addActionSetField(v, Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
popup.hide();
}
});
@@ -579,12 +660,13 @@
}
- for ( int i = 0; i < globals.length; i++ ) { //we also do globals here...
+ for (int i = 0; i < globals.length; i++) { //we also do globals here...
final String v = globals[i];
choices.addItem(Format.format(constants.ChangeFieldValuesOf0(), v), "GLOBVAR" + v); //NON-NLS
cmds.put("GLOBVAR" + v, new Command() { //NON-NLS
+
public void execute() {
- addActionSetField(v,Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
+ addActionSetField(v, Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
popup.hide();
}
});
@@ -592,27 +674,29 @@
//RETRACT
- for ( Iterator<String> iter = vars.iterator(); iter.hasNext(); ) {
+ 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
+
public void execute() {
- addRetract(v,Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
- popup.hide();
+ addRetract(v, Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
+ popup.hide();
}
});
}
//MODIFY
- for ( Iterator<String> iter = vars.iterator(); iter.hasNext(); ) {
+ 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
cmds.put("MOD" + v, new Command() { //NON-NLS
+
public void execute() {
- addModify(v,Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
+ addModify(v, Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
popup.hide();
}
});
@@ -622,26 +706,28 @@
//Now inserts:
- for ( int i = 0; i < completions.getFactTypes().length; i++ ) {
+ for (int i = 0; i < completions.getFactTypes().length; i++) {
final String item = completions.getFactTypes()[i];
choices.addItem(Format.format(constants.InsertFact0(), item), "INS" + item); //NON-NLS
cmds.put("INS" + item, new Command() { //NON-NLS
+
public void execute() {
- model.addRhsItem( new ActionInsertFact(item),Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())) );
+ model.addRhsItem(new ActionInsertFact(item), Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
refreshWidget();
popup.hide();
}
});
}
- for ( int i = 0; i < completions.getFactTypes().length; i++ ) {
+ for (int i = 0; i < completions.getFactTypes().length; i++) {
final String item = completions.getFactTypes()[i];
choices.addItem(Format.format(constants.LogicallyInsertFact0(), item), "LINS" + item); //NON-NLS
cmds.put("LINS" + item, new Command() { //NON-NLS
+
public void execute() {
- model.addRhsItem( new ActionInsertLogicalFact(item),Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())) );
- refreshWidget();
- popup.hide();
+ model.addRhsItem(new ActionInsertLogicalFact(item), Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
+ refreshWidget();
+ popup.hide();
}
});
}
@@ -650,16 +736,17 @@
//now global collections
if (completions.getGlobalCollections().length > 0 && vars.size() > 0) {
for (String bf : vars) {
- for(int i = 0; i < completions.getGlobalCollections().length; i++) {
+ for (int i = 0; i < completions.getGlobalCollections().length; i++) {
final String glob = completions.getGlobalCollections()[i];
final String var = bf;
choices.addItem(Format.format(constants.Append0ToList1(), var, glob), "GLOBCOL" + glob + var); //NON-NLS
cmds.put("GLOBCOL" + glob + var, new Command() { //NON-NLS
+
public void execute() {
ActionGlobalCollectionAdd gca = new ActionGlobalCollectionAdd();
gca.globalName = glob;
gca.factName = var;
- model.addRhsItem(gca,Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
+ model.addRhsItem(gca, Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
refreshWidget();
popup.hide();
}
@@ -671,18 +758,20 @@
if (ExplorerLayoutManager.shouldShow(Capabilities.SHOW_PACKAGE_VIEW)) {
choices.addItem(constants.AddFreeFormDrl(), "FF"); //NON-NLS
cmds.put("FF", new Command() { //NON-NLS
+
public void execute() {
- model.addRhsItem(new FreeFormLine(),Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
+ model.addRhsItem(new FreeFormLine(), Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
refreshWidget();
popup.hide();
}
});
- for ( int i = 0; i < globals.length; i++ ) { //we also do globals here...
+ for (int i = 0; i < globals.length; i++) { //we also do globals here...
final String v = globals[i];
- choices.addItem(Format.format(constants.CallMethodOn0(), v ), "GLOBCALL" + v); //NON-NLS
+ choices.addItem(Format.format(constants.CallMethodOn0(), v), "GLOBCALL" + v); //NON-NLS
cmds.put("GLOBCALL" + v, new Command() { //NON-NLS
+
public void execute() {
- addCallMethod(v,Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
+ addCallMethod(v, Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
popup.hide();
}
});
@@ -690,25 +779,27 @@
}
//CALL methods
- for ( Iterator<String> iter = vars.iterator(); iter.hasNext(); ) {
+ for (Iterator<String> iter = vars.iterator(); iter.hasNext();) {
final String v = iter.next();
- choices.addItem(Format.format(constants.CallMethodOn0(), v ), "CALL" + v); //NON-NLS
+ choices.addItem(Format.format(constants.CallMethodOn0(), v), "CALL" + v); //NON-NLS
cmds.put("CALL" + v, new Command() { //NON-NLS
+
public void execute() {
- addCallMethod(v,Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
+ addCallMethod(v, Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
popup.hide();
}
});
}
//Do Set field (NOT modify)
- for ( Iterator<String> iter = vars2.iterator(); iter.hasNext(); ) {
+ 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
+
public void execute() {
- addCallMethod(v,Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
+ addCallMethod(v, Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
popup.hide();
}
});
@@ -716,14 +807,18 @@
}
- HorizontalPanel hp0 = new HorizontalPanel();
- hp0.add(new HTML(constants.PositionColon()));
- hp0.add(positionCbo);
- hp0.add(new InfoPopup(constants.PositionColon(), constants.ActionPositionExplanation()));
- popup.addRow(hp0);
+ //only show the drop down if we are not using fixed position.
+ if (position == null) {
+ HorizontalPanel hp0 = new HorizontalPanel();
+ hp0.add(new HTML(constants.PositionColon()));
+ hp0.add(positionCbo);
+ hp0.add(new InfoPopup(constants.PositionColon(), constants.ActionPositionExplanation()));
+ popup.addRow(hp0);
+ }
HorizontalPanel hp = new HorizontalPanel();
final ClickListener cl = new ClickListener() {
+
public void onClick(Widget sender) {
int sel = choices.getSelectedIndex();
if (sel != -1) {
@@ -733,6 +828,7 @@
};
choices.addKeyboardListener(new KeyboardListenerAdapter() {
+
@Override
public void onKeyUp(Widget sender, char keyCode, int modifiers) {
if (keyCode == KeyboardListener.KEY_ENTER) {
@@ -751,134 +847,136 @@
choices.setFocus(true);
}
- protected void addModify(String itemText,int position) {
- this.model.addRhsItem(new ActionUpdateField(itemText),position);
+ protected void addModify(String itemText, int position) {
+ this.model.addRhsItem(new ActionUpdateField(itemText), position);
refreshWidget();
}
- protected void addNewDSLRhs(DSLSentence sentence,int position) {
- this.model.addRhsItem( sentence.copy(),position );
+ protected void addNewDSLRhs(DSLSentence sentence, int position) {
+ this.model.addRhsItem(sentence.copy(), position);
refreshWidget();
}
- protected void addRetract(String var,int position) {
- this.model.addRhsItem( new ActionRetractFact(var),position );
+ protected void addRetract(String var, int position) {
+ this.model.addRhsItem(new ActionRetractFact(var), position);
refreshWidget();
}
- protected void addActionSetField(String itemText,int position) {
- this.model.addRhsItem(new ActionSetField(itemText),position);
+ protected void addActionSetField(String itemText, int position) {
+ this.model.addRhsItem(new ActionSetField(itemText), position);
refreshWidget();
}
- protected void addCallMethod(String itemText,int position) {
- this.model.addRhsItem(new ActionCallMethod(itemText),position);
+ protected void addCallMethod(String itemText, int position) {
+ this.model.addRhsItem(new ActionCallMethod(itemText), position);
refreshWidget();
}
- protected void addNewCE(String s,int position) {
- this.model.addLhsItem( new CompositeFactPattern(s),position );
+ protected void addNewCE(String s, int position) {
+ this.model.addLhsItem(new CompositeFactPattern(s), position);
refreshWidget();
}
- protected void addNewFCE(String type,int position) {
+ protected void addNewFCE(String type, int position) {
FromCompositeFactPattern p = null;
- if (type.equals("from")){
+ if (type.equals("from")) {
p = new FromCompositeFactPattern();
- }else if (type.equals("from accumulate")){
+ } else if (type.equals("from accumulate")) {
p = new FromAccumulateCompositeFactPattern();
- }else if (type.equals("from collect")){
+ } else if (type.equals("from collect")) {
p = new FromCollectCompositeFactPattern();
}
- this.model.addLhsItem(p,position);
+ this.model.addLhsItem(p, position);
refreshWidget();
}
/**
* Adds a fact to the model, and then refreshes the display.
*/
- protected void addNewFact(String itemText,int position) {
- this.model.addLhsItem( new FactPattern(itemText),position );
+ protected void addNewFact(String itemText, int position) {
+ this.model.addLhsItem(new FactPattern(itemText), position);
refreshWidget();
}
/**
* Builds all the condition widgets.
*/
- private Widget renderLhs(final RuleModel model) {
- DirtyableVerticalPane vert = new DirtyableVerticalPane();
+ private void renderLhs(final RuleModel model) {
- for ( int i = 0; i < model.lhs.length; i++ ) {
+
+ for (int i = 0; i < model.lhs.length; i++) {
+ DirtyableVerticalPane vert = new DirtyableVerticalPane();
IPattern pattern = model.lhs[i];
Widget w = null;
if (pattern instanceof FactPattern) {
- w = new FactPatternWidget(this, pattern, true) ;
- vert.add( wrapLHSWidget( model,
- i,
- w ) );
- vert.add( spacerWidget() );
+ w = new FactPatternWidget(this, pattern, true);
} else if (pattern instanceof CompositeFactPattern) {
- w = new CompositeFactPatternWidget(this, (CompositeFactPattern) pattern) ;
- vert.add( wrapLHSWidget( model, i, w ));
- vert.add( spacerWidget() );
- }else if(pattern instanceof FromAccumulateCompositeFactPattern){
- w = new FromAccumulateCompositeFactPatternWidget(this, (FromAccumulateCompositeFactPattern) pattern) ;
- vert.add( wrapLHSWidget( model, i, w ));
- vert.add( spacerWidget() );
- }else if(pattern instanceof FromCollectCompositeFactPattern){
- w = new FromCollectCompositeFactPatternWidget(this, (FromCollectCompositeFactPattern) pattern) ;
- vert.add( wrapLHSWidget( model, i, w ));
- vert.add( spacerWidget() );
- }else if(pattern instanceof FromCompositeFactPattern){
- w = new FromCompositeFactPatternWidget(this, (FromCompositeFactPattern) pattern) ;
- vert.add( wrapLHSWidget( model, i, w ));
- vert.add( spacerWidget() );
- }else if (pattern instanceof DSLSentence) {
- //ignore this time
- } else if (pattern instanceof FreeFormLine){
- final FreeFormLine ffl = (FreeFormLine) pattern;
- final TextBox tb = new TextBox();
- tb.setText(ffl.text);
- tb.setTitle(constants.ThisIsADrlExpressionFreeForm());
- tb.addChangeListener(new ChangeListener() {
- public void onChange(Widget arg0) {
- ffl.text = tb.getText();
- }
- });
- vert.add(wrapLHSWidget(model, i, tb));
- vert.add( spacerWidget() );
+ w = new CompositeFactPatternWidget(this, (CompositeFactPattern) pattern);
+ } else if (pattern instanceof FromAccumulateCompositeFactPattern) {
+ w = new FromAccumulateCompositeFactPatternWidget(this, (FromAccumulateCompositeFactPattern) pattern);
+ } else if (pattern instanceof FromCollectCompositeFactPattern) {
+ w = new FromCollectCompositeFactPatternWidget(this, (FromCollectCompositeFactPattern) pattern);
+ } else if (pattern instanceof FromCompositeFactPattern) {
+ w = new FromCompositeFactPatternWidget(this, (FromCompositeFactPattern) pattern);
+ } else if (pattern instanceof DSLSentence) {
+ w = new DSLSentenceWidget((DSLSentence) pattern, completions);
+ } else if (pattern instanceof FreeFormLine) {
+ final FreeFormLine ffl = (FreeFormLine) pattern;
+ final TextBox tb = new TextBox();
+ tb.setText(ffl.text);
+ tb.setTitle(constants.ThisIsADrlExpressionFreeForm());
+ tb.addChangeListener(new ChangeListener() {
+
+ public void onChange(Widget arg0) {
+ ffl.text = tb.getText();
+ }
+ });
+ w = tb;
} else if (pattern instanceof ExpressionFormLine) {
- ExpressionFormLine efl = (ExpressionFormLine) pattern;
- ExpressionBuilder eb = new ExpressionBuilder(this, efl);
- vert.add(wrapLHSWidget(model, i, eb));
- vert.add( spacerWidget() );
+ ExpressionFormLine efl = (ExpressionFormLine) pattern;
+ w = new ExpressionBuilder(this, efl);
} else {
throw new RuntimeException("I don't know what type of pattern that is.");
}
- }
+ vert.add(wrapLHSWidget(model, i, w));
+ vert.add(spacerWidget());
+ //vert.setBorderWidth(1);
- DirtyableVerticalPane dsls = new DirtyableVerticalPane();
- for ( int i = 0; i < model.lhs.length; i++ ) {
- IPattern pattern = model.lhs[i];
- Widget w = null;
- if (pattern instanceof DSLSentence) {
- w = new DSLSentenceWidget((DSLSentence) pattern,completions);
+ layout.setHTML(currentLayoutRow, 0,"<div class='x-form-field'>"+(i+1)+".</div>");
+ layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 0, HasHorizontalAlignment.ALIGN_CENTER);
+ layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 0, HasVerticalAlignment.ALIGN_MIDDLE);
- dsls.add( wrapLHSWidget( model, i, w ) );
- dsls.setStyleName( "model-builderInner-Background" ); //NON-NLS
+ final int index = i;
+ if (!lockLHS()) {
+ Image addPattern = new ImageButton("images/new_item_below.png");
+ addPattern.setTitle(constants.AddAConditionBelow());
+ addPattern.addClickListener(new ClickListener() {
+
+ public void onClick(Widget w) {
+ showConditionSelector(w, index + 1);
+ }
+ });
+
+ layout.setWidget(currentLayoutRow, 2, addPattern);
+ layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 2, HasHorizontalAlignment.ALIGN_CENTER);
+ layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 2, HasVerticalAlignment.ALIGN_MIDDLE);
}
+
+ layout.setWidget(currentLayoutRow, 1, vert);
+ layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 1, HasHorizontalAlignment.ALIGN_LEFT);
+ layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 1, HasVerticalAlignment.ALIGN_TOP);
+
+ currentLayoutRow++;
}
- vert.add( dsls );
- return vert;
}
private HTML spacerWidget() {
HTML h = new HTML(" "); //NON-NLS
- h.setHeight( "2px" ); //NON-NLS
+ h.setHeight("2px"); //NON-NLS
return h;
}
@@ -886,37 +984,38 @@
* This adds the widget to the UI, also adding the remove icon.
*/
private Widget wrapLHSWidget(final RuleModel model,
- int i,
- Widget w) {
+ int i,
+ Widget w) {
DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();
final Image remove = new ImageButton("images/delete_faded.gif"); //NON-NLS
remove.setTitle(constants.RemoveThisENTIREConditionAndAllTheFieldConstraintsThatBelongToIt());
final int idx = i;
- remove.addClickListener( new ClickListener() {
+ remove.addClickListener(new ClickListener() {
+
public void onClick(Widget w) {
- if (Window.confirm(constants.RemoveThisEntireConditionQ())) {
- if (model.removeLhsItem(idx)) {
- refreshWidget();
- } else {
- ErrorPopup.showMessage(constants.CanTRemoveThatItemAsItIsUsedInTheActionPartOfTheRule());
- }
+ if (Window.confirm(constants.RemoveThisEntireConditionQ())) {
+ if (model.removeLhsItem(idx)) {
+ refreshWidget();
+ } else {
+ ErrorPopup.showMessage(constants.CanTRemoveThatItemAsItIsUsedInTheActionPartOfTheRule());
+ }
}
}
- } );
+ });
- horiz.setWidth( "100%" );
- w.setWidth( "100%" );
+ horiz.setWidth("100%");
+ w.setWidth("100%");
- horiz.add( w );
- if (!lockLHS()) horiz.add( remove );
+ horiz.add(w);
+ if (!lockLHS()) {
+ horiz.add(remove);
+ }
return horiz;
}
-
-
public RuleModel getModel() {
return model;
}
@@ -925,17 +1024,16 @@
* Returns true is a var name has already been used
* either by the rule, or as a global.
*/
-
public boolean isVariableNameUsed(String name) {
- return model.isVariableNameUsed( name ) || completions.isGlobalVariable( name );
+ return model.isVariableNameUsed(name) || completions.isGlobalVariable(name);
}
public boolean isDirty() {
- return ( layout.hasDirty() || dirtyflag) ;
+ return (layout.hasDirty() || dirtyflag);
}
public SuggestionCompletionEngine getSuggestionCompletions() {
return this.completions;
}
-}
\ No newline at end of file
+}
Added: labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/public/images/new_item_below.png
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/guvnor_expressionEditor3_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/public/images/new_item_below.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
More information about the jboss-svn-commits
mailing list