[jboss-svn-commits] JBL Code SVN: r32127 - labs/jbossrules/branches/factsConstraints_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 Mar 17 17:05:33 EDT 2010
Author: eaa
Date: 2010-03-17 17:05:31 -0400 (Wed, 17 Mar 2010)
New Revision: 32127
Added:
labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/GlobalCollectionAddWidget.java
labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModellerWidget.java
Removed:
labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ReadOnlyWidget.java
Modified:
labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionCallMethodWidget.java
labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionInsertFactWidget.java
labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionRetractFactWidget.java
labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionSetFieldWidget.java
labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionValueEditor.java
labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/CompositeFactPatternWidget.java
labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/DSLSentenceWidget.java
labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ExpressionBuilder.java
labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FactPatternWidget.java
labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FreeFormLineWidget.java
labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FromCompositeFactPatternWidget.java
labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java
Log:
ReadOnlyWidget renamed as RuleModellerWidget (much better name)
Created new GlobalCollectionAddWidget.
All RHS widgets now inherit from RuleModellerWidget
Widgets are set as Read-Only by RuleModeller according to isLockRHS().
Modified: labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionCallMethodWidget.java
===================================================================
--- labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionCallMethodWidget.java 2010-03-17 15:47:19 UTC (rev 32126)
+++ labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionCallMethodWidget.java 2010-03-17 21:05:31 UTC (rev 32127)
@@ -37,7 +37,7 @@
* @author isabel
*
*/
-public class ActionCallMethodWidget extends DirtyableComposite {
+public class ActionCallMethodWidget extends RuleModellerWidget {
final private ActionCallMethod model;
final private DirtyableFlexTable layout;
@@ -49,8 +49,15 @@
private String variableClass;
private Constants constants = GWT.create( Constants.class );
+ private boolean readOnly;
+
public ActionCallMethodWidget(RuleModeller mod,
ActionCallMethod set) {
+ this(mod, set, null);
+ }
+
+ public ActionCallMethodWidget(RuleModeller mod,
+ ActionCallMethod set, Boolean readOnly) {
this.model = set;
this.layout = new DirtyableFlexTable();
this.modeller = mod;
@@ -105,6 +112,18 @@
}
}
}
+
+ if (readOnly == null){
+ this.readOnly = !completions.containsFactType(this.variableClass);
+ }else{
+ this.readOnly = readOnly;
+ }
+
+ if (this.readOnly){
+ layout.addStyleName("editor-disabled-widget");
+ }
+
+
doLayout();
initWidget( this.layout );
}
@@ -154,7 +173,9 @@
}
} );
horiz.add( new SmallLabel( HumanReadable.getActionDisplayName( "call" ) + " [" + model.variable + "]" ) ); // NON-NLS
- horiz.add( edit );
+ if (!this.readOnly){
+ horiz.add( edit );
+ }
} else {
horiz.add( new SmallLabel( HumanReadable.getActionDisplayName( "call" ) + " [" + model.variable + "." + model.methodName + "]" ) ); // NON-NLS
}
@@ -308,4 +329,9 @@
return layout.hasDirty();
}
+ @Override
+ public boolean isReadOnly() {
+ return this.readOnly;
+ }
+
}
\ No newline at end of file
Modified: labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionInsertFactWidget.java
===================================================================
--- labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionInsertFactWidget.java 2010-03-17 15:47:19 UTC (rev 32126)
+++ labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionInsertFactWidget.java 2010-03-17 21:05:31 UTC (rev 32127)
@@ -39,7 +39,7 @@
* @author Michael Neale
*
*/
-public class ActionInsertFactWidget extends DirtyableComposite {
+public class ActionInsertFactWidget extends RuleModellerWidget {
private final DirtyableFlexTable layout;
private final ActionInsertFact model;
@@ -47,8 +47,13 @@
private final RuleModeller modeller;
private final String factType;
private Constants constants = GWT.create(Constants.class);
+ private boolean readOnly;
public ActionInsertFactWidget(RuleModeller mod, ActionInsertFact set) {
+ this(mod, set, null);
+ }
+
+ public ActionInsertFactWidget(RuleModeller mod, ActionInsertFact set,Boolean readOnly) {
this.model = set;
this.layout = new DirtyableFlexTable();
this.modeller = mod;
@@ -60,6 +65,16 @@
layout.setStyleName( "model-builderInner-Background" ); //NON-NLS
+ if (readOnly == null) {
+ this.readOnly = !completions.containsFactType(set.factType);
+ } else {
+ this.readOnly = readOnly;
+ }
+
+ if (this.readOnly) {
+ layout.addStyleName("editor-disabled-widget");
+ }
+
doLayout();
initWidget(this.layout);
@@ -89,7 +104,7 @@
};
}
});
- if (!this.modeller.lockRHS()) {
+ if (!this.readOnly) {
inner.setWidget( i, 2 + col, remove );
}
@@ -103,7 +118,7 @@
private Widget valueEditor(final ActionFieldValue val) {
SuggestionCompletionEngine completions = modeller.getSuggestionCompletions();
DropDownData enums = completions.getEnums(this.factType, this.model.fieldValues, val.field);
- return new ActionValueEditor(val, enums,modeller,val.type);
+ return new ActionValueEditor(val, enums,modeller,val.type,this.readOnly);
}
private Widget fieldSelector(final ActionFieldValue val) {
@@ -129,7 +144,7 @@
if (this.model.fieldValues != null && model.fieldValues.length > 0 ) {
lbl = lbl + ":";
}
- return new ClickableLabel( lbl, cl, !this.modeller.lockRHS() );
+ return new ClickableLabel( lbl, cl, !this.readOnly );
}
@@ -192,4 +207,11 @@
}
+ @Override
+ public boolean isReadOnly() {
+ return this.readOnly;
+ }
+
+
+
}
\ No newline at end of file
Modified: labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionRetractFactWidget.java
===================================================================
--- labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionRetractFactWidget.java 2010-03-17 15:47:19 UTC (rev 32126)
+++ labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionRetractFactWidget.java 2010-03-17 21:05:31 UTC (rev 32127)
@@ -21,31 +21,51 @@
import org.drools.guvnor.client.modeldriven.HumanReadable;
import org.drools.guvnor.client.modeldriven.brl.ActionRetractFact;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.FlexTable;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HorizontalPanel;
/**
* This is used when you want to retract a fact. It will provide a list of
* bound facts for you to retract.
* @author Michael Neale
*/
-public class ActionRetractFactWidget extends Composite {
+public class ActionRetractFactWidget extends RuleModellerWidget {
- private FlexTable layout;
+ private HorizontalPanel layout;
+ private boolean readOnly;
-
public ActionRetractFactWidget(RuleModeller modeller, ActionRetractFact model) {
- layout = new FlexTable();
+ this(modeller, model, null);
+ }
+ public ActionRetractFactWidget(RuleModeller modeller, ActionRetractFact model, Boolean readOnly) {
+
+ layout = new HorizontalPanel();
+ layout.setWidth("100%");
layout.setStyleName( "model-builderInner-Background" );
- layout.setWidget( 0, 0, new SmallLabel(HumanReadable.getActionDisplayName( "retract" )) );
+ if (readOnly == null) {
+ this.readOnly = !modeller.getSuggestionCompletions().containsFactType(modeller.getModel().getBoundFact(model.variableName).factType);
+ } else {
+ this.readOnly = readOnly;
+ }
+ if (this.readOnly) {
+ layout.addStyleName("editor-disabled-widget");
+ }
+
String desc = modeller.getModel().getBoundFact(model.variableName).factType + " [" + model.variableName + "]";
- layout.setWidget( 0, 1, new SmallLabel("<b>" + desc + "</b>") );
+ layout.add(new SmallLabel(HumanReadable.getActionDisplayName( "retract" )+" <b>" + desc + "</b>"));
initWidget( layout );
}
+ @Override
+ public boolean isReadOnly() {
+ return this.readOnly;
+ }
+
+
+
}
\ No newline at end of file
Modified: labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionSetFieldWidget.java
===================================================================
--- labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionSetFieldWidget.java 2010-03-17 15:47:19 UTC (rev 32126)
+++ labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionSetFieldWidget.java 2010-03-17 21:05:31 UTC (rev 32127)
@@ -15,8 +15,6 @@
* limitations under the License.
*/
-
-
import org.drools.guvnor.client.common.*;
import org.drools.guvnor.client.modeldriven.DropDownData;
import org.drools.guvnor.client.modeldriven.FieldAccessorsAndMutators;
@@ -40,60 +38,71 @@
import com.google.gwt.core.client.GWT;
import com.gwtext.client.util.Format;
-
/**
* This widget is for setting fields on a bound fact or global variable.
*
* @author Michael Neale
*/
-public class ActionSetFieldWidget extends DirtyableComposite {
+public class ActionSetFieldWidget extends RuleModellerWidget {
final private ActionSetField model;
final private DirtyableFlexTable layout;
private boolean isBoundFact = false;
-
private String[] fieldCompletions;
final private RuleModeller modeller;
private String variableClass;
private Constants constants = GWT.create(Constants.class);
+ private boolean readOnly;
+ public ActionSetFieldWidget(RuleModeller mod, ActionSetField set) {
+ this(mod, set, null);
+ }
- public ActionSetFieldWidget(RuleModeller mod, ActionSetField set) {
+ public ActionSetFieldWidget(RuleModeller mod, ActionSetField set, Boolean readOnly) {
this.model = set;
this.layout = new DirtyableFlexTable();
this.modeller = mod;
- layout.setStyleName( "model-builderInner-Background" );
+ layout.setStyleName("model-builderInner-Background");
SuggestionCompletionEngine completions = modeller.getSuggestionCompletions();
- if (completions.isGlobalVariable( set.variable )) {
- this.fieldCompletions = completions.getFieldCompletionsForGlobalVariable( set.variable );
- this.variableClass = (String) completions.getGlobalVariable( set.variable );
+ if (completions.isGlobalVariable(set.variable)) {
+ this.fieldCompletions = completions.getFieldCompletionsForGlobalVariable(set.variable);
+ this.variableClass = (String) completions.getGlobalVariable(set.variable);
} else {
- FactPattern pattern = mod.getModel().getBoundFact( set.variable );
- if ( pattern != null ) {
- this.fieldCompletions = completions.getFieldCompletions( FieldAccessorsAndMutators.MUTATOR,
- pattern.factType );
+ FactPattern pattern = mod.getModel().getBoundFact(set.variable);
+ if (pattern != null) {
+ this.fieldCompletions = completions.getFieldCompletions(FieldAccessorsAndMutators.MUTATOR,
+ pattern.factType);
this.variableClass = pattern.factType;
this.isBoundFact = true;
} else {
- ActionInsertFact patternRhs = mod.getModel().getRhsBoundFact( set.variable );
- if ( patternRhs != null ) {
- this.fieldCompletions = completions.getFieldCompletions( FieldAccessorsAndMutators.MUTATOR,
- patternRhs.factType );
+ ActionInsertFact patternRhs = mod.getModel().getRhsBoundFact(set.variable);
+ if (patternRhs != null) {
+ this.fieldCompletions = completions.getFieldCompletions(FieldAccessorsAndMutators.MUTATOR,
+ patternRhs.factType);
this.variableClass = patternRhs.factType;
this.isBoundFact = true;
}
}
}
+ if (readOnly == null) {
+ this.readOnly = !completions.containsFactType(this.variableClass);
+ } else {
+ this.readOnly = readOnly;
+ }
+
+ if (this.readOnly) {
+ layout.addStyleName("editor-disabled-widget");
+ }
+
doLayout();
- initWidget( this.layout );
+ initWidget(this.layout);
}
-
private void doLayout() {
layout.clear();
@@ -101,25 +110,29 @@
//DirtyableFlexTable inner = new DirtyableFlexTable();
- for ( int i = 0; i < model.fieldValues.length; i++ ) {
+ for (int i = 0; i < model.fieldValues.length; i++) {
ActionFieldValue val = model.fieldValues[i];
layout.setWidget(i, 0, getSetterLabel());
- layout.setWidget( i, 1, fieldSelector(val) );
- layout.setWidget( i, 2, valueEditor(val) );
+ layout.setWidget(i, 1, fieldSelector(val));
+ layout.setWidget(i, 2, valueEditor(val));
final int idx = i;
Image remove = new ImageButton("images/delete_faded.gif"); //NON-NLS
//Image remove = new ImageButton("images/delete_item_fade.gif"); //NON-NLS
- remove.addClickListener( new ClickListener() {
+ remove.addClickListener(new ClickListener() {
+
public void onClick(Widget w) {
- if (Window.confirm(constants.RemoveThisItem())) {
- model.removeField( idx );
- modeller.refreshWidget();
- }
+ if (Window.confirm(constants.RemoveThisItem())) {
+ model.removeField(idx);
+ modeller.refreshWidget();
+ }
}
});
- if (!modeller.lockRHS()) layout.setWidget( i, 3, remove );
+ if (!this.readOnly) {
+ layout.setWidget(i, 3, remove);
+ }
remove.addMouseListener(new MouseListenerAdapter() {
+
@Override
public void onMouseEnter(Widget sender) {
super.onMouseEnter(sender); //To change body of overridden methods use File | Settings | File Templates.
@@ -135,11 +148,14 @@
if (model.fieldValues.length == 0) {
HorizontalPanel h = new HorizontalPanel();
h.add(getSetterLabel());
- h.add(new ImageButton("images/edit_tiny.gif", constants.AddFirstNewField(), new ClickListener() {
- public void onClick(Widget sender) {
- showAddFieldPopup(sender);
- }
- }));
+ if (!this.readOnly) {
+ h.add(new ImageButton("images/edit_tiny.gif", constants.AddFirstNewField(), new ClickListener() {
+
+ public void onClick(Widget sender) {
+ showAddFieldPopup(sender);
+ }
+ }));
+ }
layout.setWidget(0, 0, h);
}
@@ -148,12 +164,12 @@
}
-
private Widget getSetterLabel() {
- ClickListener clk = new ClickListener() {
+ ClickListener clk = new ClickListener() {
+
public void onClick(Widget w) {
showAddFieldPopup(w);
}
@@ -167,33 +183,33 @@
FactPattern fp = this.modeller.getModel().getBoundFact(model.variable);
- String descFact = (fp != null)? this.modeller.getModel().getBoundFact(model.variable).factType + " <b>[" + model.variable + "]</b>" : model.variable;
+ String descFact = (fp != null) ? this.modeller.getModel().getBoundFact(model.variable).factType + " <b>[" + model.variable + "]</b>" : model.variable;
- String sl = Format.format(constants.setterLabel(), new String[] {HumanReadable.getActionDisplayName(modifyType), descFact});
- return new ClickableLabel(sl, clk, !modeller.lockRHS());//HumanReadable.getActionDisplayName(modifyType) + " value of <b>[" + model.variable + "]</b>", clk);
+ String sl = Format.format(constants.setterLabel(), new String[]{HumanReadable.getActionDisplayName(modifyType), descFact});
+ return new ClickableLabel(sl, clk, !this.readOnly);//HumanReadable.getActionDisplayName(modifyType) + " value of <b>[" + model.variable + "]</b>", clk);
}
-
protected void showAddFieldPopup(Widget w) {
final SuggestionCompletionEngine completions = modeller.getSuggestionCompletions();
final FormStylePopup popup = new FormStylePopup("images/newex_wiz.gif", constants.AddAField());
final ListBox box = new ListBox();
- box.addItem( "..." );
+ box.addItem("...");
- for ( int i = 0; i < fieldCompletions.length; i++ ) {
- box.addItem( fieldCompletions[i] );
+ for (int i = 0; i < fieldCompletions.length; i++) {
+ box.addItem(fieldCompletions[i]);
}
- box.setSelectedIndex( 0 );
+ box.setSelectedIndex(0);
- popup.addAttribute(constants.AddField(), box );
- box.addChangeListener( new ChangeListener() {
+ popup.addAttribute(constants.AddField(), box);
+ box.addChangeListener(new ChangeListener() {
+
public void onChange(Widget w) {
- String fieldName = box.getItemText( box.getSelectedIndex() );
+ String fieldName = box.getItemText(box.getSelectedIndex());
- String fieldType = completions.getFieldType( variableClass, fieldName );
- model.addFieldValue( new ActionFieldValue( fieldName, "", fieldType ) );
+ String fieldType = completions.getFieldType(variableClass, fieldName);
+ model.addFieldValue(new ActionFieldValue(fieldName, "", fieldType));
modeller.refreshWidget();
popup.hide();
}
@@ -204,30 +220,25 @@
}
-
private Widget valueEditor(final ActionFieldValue val) {
SuggestionCompletionEngine completions = modeller.getSuggestionCompletions();
- String type = "";
- if (completions.isGlobalVariable(this.model.variable)) {
- type = (String) completions.getGlobalVariable(this.model.variable);
- } else {
- type = this.modeller.getModel().getBoundFact(this.model.variable).factType;
- /*
- * to take in account if the using a rhs bound variable
- */
- if (type==null){
- type = this.modeller.getModel().getRhsBoundFact(this.model.variable).factType;
- }
- }
+ String type = "";
+ if (completions.isGlobalVariable(this.model.variable)) {
+ type = (String) completions.getGlobalVariable(this.model.variable);
+ } else {
+ type = this.modeller.getModel().getBoundFact(this.model.variable).factType;
+ /*
+ * to take in account if the using a rhs bound variable
+ */
+ if (type == null) {
+ type = this.modeller.getModel().getRhsBoundFact(this.model.variable).factType;
+ }
+ }
- DropDownData enums = completions.getEnums(type, this.model.fieldValues, val.field);
- return new ActionValueEditor(val, enums,modeller,val.type);
+ DropDownData enums = completions.getEnums(type, this.model.fieldValues, val.field);
+ return new ActionValueEditor(val, enums, modeller, val.type, this.readOnly);
}
-
-
-
-
private Widget fieldSelector(final ActionFieldValue val) {
return new SmallLabel(val.field);
}
@@ -243,4 +254,8 @@
return layout.hasDirty();
}
-}
\ No newline at end of file
+ @Override
+ public boolean isReadOnly() {
+ return this.readOnly;
+ }
+}
Modified: labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionValueEditor.java
===================================================================
--- labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionValueEditor.java 2010-03-17 15:47:19 UTC (rev 32126)
+++ labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionValueEditor.java 2010-03-17 21:05:31 UTC (rev 32127)
@@ -22,16 +22,18 @@
public class ActionValueEditor extends DirtyableComposite {
private ActionFieldValue value;
- private DropDownData enums;
- private SimplePanel root;
- private Constants constants = GWT.create( Constants.class );
- private RuleModeller model = null;
- private String variableType = null;
+ private DropDownData enums;
+ private SimplePanel root;
+ private Constants constants = GWT.create(Constants.class);
+ private RuleModeller model = null;
+ private String variableType = null;
+ private boolean readOnly;
public ActionValueEditor(final ActionFieldValue val,
- final DropDownData enums) {
- if ( val.type.equals( SuggestionCompletionEngine.TYPE_BOOLEAN ) ) {
- this.enums = DropDownData.create( new String[]{"true", "false"} );
+ final DropDownData enums, boolean readOnly) {
+ this.readOnly = readOnly;
+ if (val.type.equals(SuggestionCompletionEngine.TYPE_BOOLEAN)) {
+ this.enums = DropDownData.create(new String[]{"true", "false"});
} else {
this.enums = enums;
}
@@ -39,15 +41,30 @@
this.value = val;
refresh();
- initWidget( root );
+ initWidget(root);
}
public ActionValueEditor(final ActionFieldValue val,
- final DropDownData enums,
- RuleModeller model,
- String variableType) {
- if ( val.type.equals( SuggestionCompletionEngine.TYPE_BOOLEAN ) ) {
- this.enums = DropDownData.create( new String[]{"true", "false"} );
+ final DropDownData enums) {
+ this(val, enums, false);
+ }
+
+ public ActionValueEditor(final ActionFieldValue val,
+ final DropDownData enums,
+ RuleModeller model,
+ String variableType) {
+ this(val, enums, model, variableType, false);
+ }
+
+ public ActionValueEditor(final ActionFieldValue val,
+ final DropDownData enums,
+ RuleModeller model,
+ String variableType, boolean readOnly) {
+
+ this.readOnly = readOnly;
+
+ if (val.type.equals(SuggestionCompletionEngine.TYPE_BOOLEAN)) {
+ this.enums = DropDownData.create(new String[]{"true", "false"});
} else {
this.enums = enums;
}
@@ -56,45 +73,40 @@
this.model = model;
this.variableType = variableType;
refresh();
- initWidget( root );
+ initWidget(root);
}
private void refresh() {
root.clear();
- if ( enums != null && (enums.fixedList != null || enums.queryExpression != null) ) {
- root.add( new EnumDropDown( value.value,
- new DropDownValueChanged() {
- public void valueChanged(String newText,
- String newValue) {
- value.value = newValue;
- makeDirty();
- }
- },
- enums ) );
+ if (enums != null && (enums.fixedList != null || enums.queryExpression != null)) {
+ //enum
+ Widget list = boundEnum(value);
+ root.add(list);
} else {
// FIX nheron il faut ajouter les autres choix pour appeller les
// bons editeurs suivant le type
// si la valeur vaut 0 il faut mettre un stylo (
- if ( value.value != null && value.value.length() > 0 && value.nature == ActionFieldValue.TYPE_UNDEFINED ) {
+ if (value.value != null && value.value.length() > 0 && value.nature == ActionFieldValue.TYPE_UNDEFINED) {
///JBDS-894
- if ( value.value.charAt( 0 ) == '=' ) {
+ if (value.value.charAt(0) == '=') {
value.nature = ActionFieldValue.TYPE_VARIABLE;
} else {
value.nature = ActionFieldValue.TYPE_LITERAL;
}
}
- if ( value.nature == ActionFieldValue.TYPE_UNDEFINED ) {
+ if (value.nature == ActionFieldValue.TYPE_UNDEFINED) {
// we have a blank slate..
// have to give them a choice
- root.add( choice() );
+ root.add(choice());
} else {
- if ( value.nature == ActionFieldValue.TYPE_VARIABLE ) {
- ListBox list = boundVariable( value );
- root.add( list );
+ if (value.nature == ActionFieldValue.TYPE_VARIABLE) {
+ Widget list = boundVariable(value);
+ root.add(list);
} else {
- TextBox box = boundTextBox( this.value );
- root.add( box );
+ //formula and literal
+ Widget box = boundTextBox(this.value);
+ root.add(box);
}
}
@@ -102,101 +114,127 @@
}
}
- private ListBox boundVariable(final ActionFieldValue c) {
+ private Widget boundVariable(final ActionFieldValue c) {
/*
* If there is a bound variable that is the same type of the current
* variable type, then propose a list
*/
ListBox listVariable = new ListBox();
List<String> vars = model.getModel().getBoundFacts();
- for ( String v : vars ) {
- FactPattern factPattern = model.getModel().getBoundFact( v );
- String fv = model.getModel().getFieldConstraint( v );
+ for (String v : vars) {
+ FactPattern factPattern = model.getModel().getBoundFact(v);
+ String fv = model.getModel().getFieldConstraint(v);
- if ( (factPattern != null && factPattern.factType.equals( this.variableType )) || (fv != null) ) {
+ if ((factPattern != null && factPattern.factType.equals(this.variableType)) || (fv != null)) {
// First selection is empty
- if ( listVariable.getItemCount() == 0 ) {
- listVariable.addItem( "..." );
+ if (listVariable.getItemCount() == 0) {
+ listVariable.addItem("...");
}
- listVariable.addItem( v );
+ listVariable.addItem(v);
}
}
/*
* add the bound variable of the rhs
*/
List<String> vars2 = model.getModel().getRhsBoundFacts();
- for ( String v : vars2 ) {
- ActionInsertFact factPattern = model.getModel().getRhsBoundFact( v );
- if ( factPattern.factType.equals( this.variableType ) ) {
+ for (String v : vars2) {
+ ActionInsertFact factPattern = model.getModel().getRhsBoundFact(v);
+ if (factPattern.factType.equals(this.variableType)) {
// First selection is empty
- if ( listVariable.getItemCount() == 0 ) {
- listVariable.addItem( "..." );
+ if (listVariable.getItemCount() == 0) {
+ listVariable.addItem("...");
}
- listVariable.addItem( v );
+ listVariable.addItem(v);
}
}
- if ( value.value.equals( "=" ) ) {
- listVariable.setSelectedIndex( 0 );
+ if (value.value.equals("=")) {
+ listVariable.setSelectedIndex(0);
} else {
- for ( int i = 0; i < listVariable.getItemCount(); i++ ) {
- if ( listVariable.getItemText( i ).equals( value.value.substring( 1 ) ) ) {
- listVariable.setSelectedIndex( i );
+ for (int i = 0; i < listVariable.getItemCount(); i++) {
+ if (listVariable.getItemText(i).equals(value.value.substring(1))) {
+ listVariable.setSelectedIndex(i);
}
}
}
- if ( listVariable.getItemCount() > 0 ) {
+ if (listVariable.getItemCount() > 0) {
- listVariable.addChangeListener( new ChangeListener() {
+ listVariable.addChangeListener(new ChangeListener() {
+
public void onChange(Widget arg0) {
ListBox w = (ListBox) arg0;
- value.value = "=" + w.getValue( w.getSelectedIndex() );
+ value.value = "=" + w.getValue(w.getSelectedIndex());
makeDirty();
refresh();
}
+ });
+ }
- } );
+ if (this.readOnly) {
+ return new SmallLabel(listVariable.getItemText(listVariable.getSelectedIndex()));
}
+
return listVariable;
}
- private TextBox boundTextBox(final ActionFieldValue c) {
+ private Widget boundEnum(final ActionFieldValue c) {
+ EnumDropDown enumDropDown = new EnumDropDown(value.value, new DropDownValueChanged() {
+
+ public void valueChanged(String newText, String newValue) {
+ value.value = newValue;
+ makeDirty();
+ }
+ }, enums);
+
+ if (this.readOnly) {
+ return new SmallLabel(enumDropDown.getItemText(enumDropDown.getSelectedIndex()));
+ } else {
+ return enumDropDown;
+ }
+ }
+
+ private Widget boundTextBox(final ActionFieldValue c) {
final TextBox box = new TextBox();
- box.setStyleName( "constraint-value-Editor" );
- if ( c.value == null ) {
- box.setText( "" );
+ box.setStyleName("constraint-value-Editor");
+ if (c.value == null) {
+ box.setText("");
} else {
- if ( c.value.trim().equals( "" ) ) {
+ if (c.value.trim().equals("")) {
c.value = "";
}
- box.setText( c.value );
+ box.setText(c.value);
}
- if ( c.value == null || c.value.length() < 5 ) {
- box.setVisibleLength( 6 );
+ if (c.value == null || c.value.length() < 5) {
+ box.setVisibleLength(6);
} else {
- box.setVisibleLength( c.value.length() - 1 );
+ box.setVisibleLength(c.value.length() - 1);
}
- box.addChangeListener( new ChangeListener() {
+ box.addChangeListener(new ChangeListener() {
+
public void onChange(Widget w) {
c.value = box.getText();
makeDirty();
}
+ });
- } );
+ box.addKeyboardListener(new FieldEditListener(new Command() {
- box.addKeyboardListener( new FieldEditListener( new Command() {
public void execute() {
- box.setVisibleLength( box.getText().length() );
+ box.setVisibleLength(box.getText().length());
}
- } ) );
+ }));
- if ( value.type.equals( SuggestionCompletionEngine.TYPE_NUMERIC ) ) {
- box.addKeyboardListener( getNumericFilter( box ) );
+ if (value.type.equals(SuggestionCompletionEngine.TYPE_NUMERIC)) {
+ box.addKeyboardListener(getNumericFilter(box));
}
+ if (this.readOnly) {
+ return new SmallLabel(box.getText());
+ }
+
return box;
}
@@ -210,42 +248,46 @@
return new KeyboardListener() {
public void onKeyDown(Widget arg0,
- char arg1,
- int arg2) {
-
+ char arg1,
+ int arg2) {
}
public void onKeyPress(Widget w,
- char c,
- int i) {
- if ( Character.isLetter( c ) && c != '=' && !(box.getText().startsWith( "=" )) ) {
+ char c,
+ int i) {
+ if (Character.isLetter(c) && c != '=' && !(box.getText().startsWith("="))) {
((TextBox) w).cancelKey();
}
}
public void onKeyUp(Widget arg0,
- char arg1,
- int arg2) {
+ char arg1,
+ int arg2) {
}
-
};
}
private Widget choice() {
- Image clickme = new Image( "images/edit.gif" );
- clickme.addClickListener( new ClickListener() {
- public void onClick(Widget w) {
- showTypeChoice( w );
- }
- } );
- return clickme;
+ if (this.readOnly) {
+ return new HTML();
+ } else {
+ Image clickme = new Image("images/edit.gif");
+ clickme.addClickListener(new ClickListener() {
+
+ public void onClick(Widget w) {
+ showTypeChoice(w);
+ }
+ });
+ return clickme;
+ }
}
protected void showTypeChoice(Widget w) {
- final FormStylePopup form = new FormStylePopup( "images/newex_wiz.gif",
- constants.FieldValue() );
- Button lit = new Button( constants.LiteralValue() );
- lit.addClickListener( new ClickListener() {
+ final FormStylePopup form = new FormStylePopup("images/newex_wiz.gif",
+ constants.FieldValue());
+ Button lit = new Button(constants.LiteralValue());
+ lit.addClickListener(new ClickListener() {
+
public void onClick(Widget w) {
value.nature = ActionFieldValue.TYPE_LITERAL;
value.value = " ";
@@ -253,19 +295,18 @@
refresh();
form.hide();
}
+ });
- } );
+ form.addAttribute(constants.LiteralValue() + ":",
+ widgets(lit,
+ new InfoPopup(constants.Literal(),
+ constants.ALiteralValueMeansTheValueAsTypedInIeItsNotACalculation())));
+ form.addRow(new HTML("<hr/>"));
+ form.addRow(new SmallLabel(constants.AdvancedSection()));
- form.addAttribute( constants.LiteralValue() + ":",
- widgets( lit,
- new InfoPopup( constants.Literal(),
- constants.ALiteralValueMeansTheValueAsTypedInIeItsNotACalculation() ) ) );
- form.addRow( new HTML( "<hr/>" ) );
- form.addRow( new SmallLabel( constants.AdvancedSection() ) );
+ Button formula = new Button(constants.Formula());
+ formula.addClickListener(new ClickListener() {
- Button formula = new Button( constants.Formula() );
- formula.addClickListener( new ClickListener() {
-
public void onClick(Widget w) {
value.nature = ActionFieldValue.TYPE_FORMULA;
value.value = "=";
@@ -273,36 +314,35 @@
refresh();
form.hide();
}
+ });
- } );
-
/*
* If there is a bound variable that is the same type of the current
* variable type, then show abutton
*/
List<String> vars = model.getModel().getBoundFacts();
List<String> vars2 = model.getModel().getRhsBoundFacts();
- for ( String i : vars2 ) {
- vars.add( i );
+ for (String i : vars2) {
+ vars.add(i);
}
- for ( String v : vars ) {
+ for (String v : vars) {
boolean createButton = false;
- Button variable = new Button( constants.BoundVariable() );
- if ( vars2.contains( v ) == false ) {
- FactPattern factPattern = model.getModel().getBoundFact( v );
- if ( factPattern.factType.equals( this.variableType ) ) {
+ Button variable = new Button(constants.BoundVariable());
+ if (vars2.contains(v) == false) {
+ FactPattern factPattern = model.getModel().getBoundFact(v);
+ if (factPattern.factType.equals(this.variableType)) {
createButton = true;
}
} else {
- ActionInsertFact factPattern = model.getModel().getRhsBoundFact( v );
- if ( factPattern.factType.equals( this.variableType ) ) {
+ ActionInsertFact factPattern = model.getModel().getRhsBoundFact(v);
+ if (factPattern.factType.equals(this.variableType)) {
createButton = true;
}
}
- if ( createButton == true ) {
- form.addAttribute( constants.BoundVariable() + ":",
- variable );
- variable.addClickListener( new ClickListener() {
+ if (createButton == true) {
+ form.addAttribute(constants.BoundVariable() + ":",
+ variable);
+ variable.addClickListener(new ClickListener() {
public void onClick(Widget w) {
value.nature = ActionFieldValue.TYPE_VARIABLE;
@@ -311,16 +351,15 @@
refresh();
form.hide();
}
-
- } );
+ });
break;
}
}
- form.addAttribute( constants.Formula() + ":",
- widgets( formula,
- new InfoPopup( constants.Formula(),
- constants.FormulaTip() ) ) );
+ form.addAttribute(constants.Formula() + ":",
+ widgets(formula,
+ new InfoPopup(constants.Formula(),
+ constants.FormulaTip())));
// if (model != null){
// for (int i=0;i< model.lhs.length;i++){
@@ -335,11 +374,10 @@
}
private Widget widgets(Button lit,
- InfoPopup popup) {
+ InfoPopup popup) {
HorizontalPanel h = new HorizontalPanel();
- h.add( lit );
- h.add( popup );
+ h.add(lit);
+ h.add(popup);
return h;
}
-
}
Modified: labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/CompositeFactPatternWidget.java
===================================================================
--- labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/CompositeFactPatternWidget.java 2010-03-17 15:47:19 UTC (rev 32126)
+++ labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/CompositeFactPatternWidget.java 2010-03-17 21:05:31 UTC (rev 32127)
@@ -37,7 +37,7 @@
* @author Michael Neale
*
*/
-public class CompositeFactPatternWidget extends ReadOnlyWidget {
+public class CompositeFactPatternWidget extends RuleModellerWidget {
protected final SuggestionCompletionEngine completions;
protected CompositeFactPattern pattern;
Modified: labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/DSLSentenceWidget.java
===================================================================
--- labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/DSLSentenceWidget.java 2010-03-17 15:47:19 UTC (rev 32126)
+++ labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/DSLSentenceWidget.java 2010-03-17 21:05:31 UTC (rev 32127)
@@ -46,7 +46,7 @@
*
* @author Michael Neale
*/
-public class DSLSentenceWidget extends ReadOnlyWidget {
+public class DSLSentenceWidget extends RuleModellerWidget {
private static final String ENUM_TAG = "ENUM";
private static final String DATE_TAG = "DATE";
Modified: labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ExpressionBuilder.java
===================================================================
--- labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ExpressionBuilder.java 2010-03-17 15:47:19 UTC (rev 32126)
+++ labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ExpressionBuilder.java 2010-03-17 21:05:31 UTC (rev 32127)
@@ -28,7 +28,7 @@
import com.gwtext.client.widgets.form.Label;
import org.drools.guvnor.client.common.SmallLabel;
-public class ExpressionBuilder extends ReadOnlyWidget {
+public class ExpressionBuilder extends RuleModellerWidget {
private static final String DELETE_VALUE = "_delete_";
private static final String FIElD_VALUE_PREFIX = "fl";
Modified: labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FactPatternWidget.java
===================================================================
--- labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FactPatternWidget.java 2010-03-17 15:47:19 UTC (rev 32126)
+++ labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FactPatternWidget.java 2010-03-17 21:05:31 UTC (rev 32127)
@@ -46,7 +46,7 @@
* @author Michael Neale
*
*/
-public class FactPatternWidget extends ReadOnlyWidget {
+public class FactPatternWidget extends RuleModellerWidget {
private FactPattern pattern;
private SuggestionCompletionEngine completions;
Modified: labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FreeFormLineWidget.java
===================================================================
--- labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FreeFormLineWidget.java 2010-03-17 15:47:19 UTC (rev 32126)
+++ labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FreeFormLineWidget.java 2010-03-17 21:05:31 UTC (rev 32127)
@@ -25,14 +25,13 @@
import org.drools.guvnor.client.modeldriven.brl.FreeFormLine;
/**
- * This is the new smart widget that works off the model.
- * @author Michael Neale
+ * Free form DRL line widget
+ * @author esteban.aliverti at gmail.com
*
*/
-public class FreeFormLineWidget extends ReadOnlyWidget {
+public class FreeFormLineWidget extends RuleModellerWidget {
- private FreeFormLine pattern;
- private RuleModeller modeller;
+ private FreeFormLine action;
private DirtyableFlexTable layout = new DirtyableFlexTable();
private Constants constants = ((Constants) GWT.create(Constants.class));
private boolean readOnly;
@@ -50,8 +49,7 @@
*/
public FreeFormLineWidget(RuleModeller mod, FreeFormLine p,
Boolean readOnly) {
- this.pattern = p;
- this.modeller = mod;
+ this.action = p;
if (readOnly == null){
this.readOnly = false;
@@ -73,14 +71,14 @@
private Widget createTextBox() {
final TextBox tb = new TextBox();
- tb.setText(this.pattern.text);
+ tb.setText(this.action.text);
tb.setTitle(constants.ThisIsADrlExpressionFreeForm());
if (!this.readOnly){
tb.addChangeListener(new ChangeListener() {
public void onChange(Widget arg0) {
- pattern.text = tb.getText();
+ action.text = tb.getText();
}
});
} else{
Modified: labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FromCompositeFactPatternWidget.java
===================================================================
--- labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FromCompositeFactPatternWidget.java 2010-03-17 15:47:19 UTC (rev 32126)
+++ labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FromCompositeFactPatternWidget.java 2010-03-17 21:05:31 UTC (rev 32127)
@@ -23,7 +23,7 @@
*
* @author esteban
*/
-public class FromCompositeFactPatternWidget extends ReadOnlyWidget {
+public class FromCompositeFactPatternWidget extends RuleModellerWidget {
protected FromCompositeFactPattern pattern;
protected DirtyableFlexTable layout;
Added: labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/GlobalCollectionAddWidget.java
===================================================================
--- labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/GlobalCollectionAddWidget.java (rev 0)
+++ labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/GlobalCollectionAddWidget.java 2010-03-17 21:05:31 UTC (rev 32127)
@@ -0,0 +1,82 @@
+package org.drools.guvnor.client.modeldriven.ui;
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.guvnor.client.common.DirtyableFlexTable;
+import org.drools.guvnor.client.messages.Constants;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.ui.*;
+import com.gwtext.client.util.Format;
+import org.drools.guvnor.client.common.SmallLabel;
+import org.drools.guvnor.client.modeldriven.brl.ActionGlobalCollectionAdd;
+
+/**
+ * Add Variable to global collection Widget
+ * @author esteban.aliverti at gmail.com
+ *
+ */
+public class GlobalCollectionAddWidget extends RuleModellerWidget {
+
+ private DirtyableFlexTable layout = new DirtyableFlexTable();
+ private Constants constants = ((Constants) GWT.create(Constants.class));
+ private boolean readOnly;
+
+ public GlobalCollectionAddWidget(RuleModeller mod, ActionGlobalCollectionAdd action) {
+ this(mod, action, null);
+ }
+
+ /**
+ * Creates a new FactPatternWidget
+ * @param mod
+ * @param p
+ * @param readOnly if the widget should be in RO mode. If this parameter
+ * is null, the readOnly attribute is calculated.
+ */
+ public GlobalCollectionAddWidget(RuleModeller modeller, ActionGlobalCollectionAdd action,
+ Boolean readOnly) {
+
+ if (readOnly == null) {
+ this.readOnly = !modeller.getSuggestionCompletions().containsFactType(modeller.getModel().getBoundFact(action.factName).factType);
+ } else {
+ this.readOnly = readOnly;
+ }
+
+ ActionGlobalCollectionAdd gca = (ActionGlobalCollectionAdd) action;
+ SimplePanel sp = new SimplePanel();
+ sp.setStyleName("model-builderInner-Background"); //NON-NLS
+ sp.add(new SmallLabel(" " + Format.format(constants.AddXToListY(), gca.factName, gca.globalName)));
+
+ if (this.readOnly) {
+ this.layout.addStyleName("editor-disabled-widget");
+ sp.addStyleName("editor-disabled-widget");
+ }
+
+ layout.setWidget(0, 0, sp);
+ initWidget(layout);
+
+ }
+
+ @Override
+ public boolean isDirty() {
+ return layout.hasDirty();
+ }
+
+ @Override
+ public boolean isReadOnly() {
+ return this.readOnly;
+ }
+}
Deleted: labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ReadOnlyWidget.java
===================================================================
--- labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ReadOnlyWidget.java 2010-03-17 15:47:19 UTC (rev 32126)
+++ labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ReadOnlyWidget.java 2010-03-17 21:05:31 UTC (rev 32127)
@@ -1,11 +0,0 @@
-package org.drools.guvnor.client.modeldriven.ui;
-
-import org.drools.guvnor.client.common.DirtyableComposite;
-
-/**
- *
- * @author esteban.aliverti at gmail.com
- */
-public abstract class ReadOnlyWidget extends DirtyableComposite {
- public abstract boolean isReadOnly();
-}
Modified: labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java
===================================================================
--- labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java 2010-03-17 15:47:19 UTC (rev 32126)
+++ labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java 2010-03-17 21:05:31 UTC (rev 32127)
@@ -296,41 +296,32 @@
widget.setWidth("100%");
IAction action = model.rhs[i];
- Widget w = null;
+ //if lockRHS() set the widget RO, otherwise let them decide.
+ Boolean readOnly = this.lockRHS()?true:null;
+
+ RuleModellerWidget w = null;
if (action instanceof ActionCallMethod) {
- w = new ActionCallMethodWidget(this, (ActionCallMethod) action);
+ w = new ActionCallMethodWidget(this, (ActionCallMethod) action,readOnly);
} else if (action instanceof ActionSetField) {
- w = new ActionSetFieldWidget(this, (ActionSetField) action);
+ w = new ActionSetFieldWidget(this, (ActionSetField) action,readOnly);
} else if (action instanceof ActionInsertFact) {
- w = new ActionInsertFactWidget(this, (ActionInsertFact) action);
+ w = new ActionInsertFactWidget(this, (ActionInsertFact) action, readOnly);
} else if (action instanceof ActionRetractFact) {
- w = new ActionRetractFactWidget(this, (ActionRetractFact) action);
+ w = new ActionRetractFactWidget(this, (ActionRetractFact) action, readOnly);
} else if (action instanceof DSLSentence) {
- w = new DSLSentenceWidget(this,(DSLSentence) action);
- w.setStyleName("model-builderInner-Background"); //NON-NLS
+ w = new DSLSentenceWidget(this,(DSLSentence) action, readOnly);
+ w.addStyleName("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;
+ w = new FreeFormLineWidget(this, (FreeFormLine) action, readOnly);
} else if (action instanceof ActionGlobalCollectionAdd) {
- ActionGlobalCollectionAdd gca = (ActionGlobalCollectionAdd) action;
- SimplePanel sp = new SimplePanel();
- sp.setStyleName("model-builderInner-Background"); //NON-NLS
- w = sp;
- sp.add(new SmallLabel(" " + Format.format(constants.AddXToListY(), gca.factName, gca.globalName)));
+ w = new GlobalCollectionAddWidget(this, (ActionGlobalCollectionAdd) action, readOnly);
}
- //w.setWidth( "100%" );
+ w.setWidth( "100%" );
widget.add(spacerWidget());
DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();
+ horiz.setWidth("100%");
//horiz.setBorderWidth(2);
Image remove = new ImageButton("images/delete_faded.gif"); //NON-NLS
@@ -368,9 +359,10 @@
layout.setWidget(currentLayoutRow, 1, widget);
layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 1, HasHorizontalAlignment.ALIGN_LEFT);
layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 1, HasVerticalAlignment.ALIGN_TOP);
+ layout.getFlexCellFormatter().setWidth(currentLayoutRow, 1, "100%");
final int index = i;
- if (!lockRHS()) {
+ if (!(this.lockRHS() || w.isReadOnly())) {
this.addActionsButtonsToLayout(constants.AddAnActionBelow(), new ClickListener() {
public void onClick(Widget w) {
@@ -926,7 +918,7 @@
Boolean readOnly = this.lockLHS()?true:null;
IPattern pattern = model.lhs[i];
- ReadOnlyWidget w = null;
+ RuleModellerWidget w = null;
if (pattern instanceof FactPattern) {
w = new FactPatternWidget(this, pattern, true, readOnly);
} else if (pattern instanceof CompositeFactPattern) {
@@ -1000,7 +992,7 @@
*/
private Widget wrapLHSWidget(final RuleModel model,
int i,
- ReadOnlyWidget w) {
+ RuleModellerWidget w) {
DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();
final Image remove = new ImageButton("images/delete_faded.gif"); //NON-NLS
Copied: labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModellerWidget.java (from rev 32102, labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ReadOnlyWidget.java)
===================================================================
--- labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModellerWidget.java (rev 0)
+++ labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModellerWidget.java 2010-03-17 21:05:31 UTC (rev 32127)
@@ -0,0 +1,18 @@
+package org.drools.guvnor.client.modeldriven.ui;
+
+import org.drools.guvnor.client.common.DirtyableComposite;
+
+/**
+ * A superclass for the widgets present in RuleModeller.
+ * @author esteban.aliverti at gmail.com
+ */
+public abstract class RuleModellerWidget extends DirtyableComposite {
+
+ /**
+ * Dictates if the widget's state is RO or not. Sometimes RuleModeller will
+ * force this state (i.e. when lockLHS() or lockRHS()), but some other times,
+ * the widget itself is responsible to autodetect its state.
+ * @return
+ */
+ public abstract boolean isReadOnly();
+}
More information about the jboss-svn-commits
mailing list