[jboss-svn-commits] JBL Code SVN: r32102 - 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
Mon Mar 15 17:50:02 EDT 2010
Author: eaa
Date: 2010-03-15 17:50:01 -0400 (Mon, 15 Mar 2010)
New Revision: 32102
Added:
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/ReadOnlyWidget.java
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/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/FromAccumulateCompositeFactPatternWidget.java
labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FromCollectCompositeFactPatternWidget.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:
Created new FreeFormLineWidget for Free Form DRL.
All LHS widgets now inherit from ReadOnlyWidget (the name is horrible...)
Widgets are set as Read-Only by RuleModeller according to isLockLHS().
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-15 20:24:28 UTC (rev 32101)
+++ labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/CompositeFactPatternWidget.java 2010-03-15 21:50:01 UTC (rev 32102)
@@ -18,11 +18,9 @@
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.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.CompositeFactPattern;
@@ -39,7 +37,7 @@
* @author Michael Neale
*
*/
-public class CompositeFactPatternWidget extends DirtyableComposite {
+public class CompositeFactPatternWidget extends ReadOnlyWidget {
protected final SuggestionCompletionEngine completions;
protected CompositeFactPattern pattern;
@@ -50,6 +48,12 @@
public CompositeFactPatternWidget(RuleModeller modeller,
CompositeFactPattern pattern) {
+ this(modeller, pattern, null);
+ }
+
+ public CompositeFactPatternWidget(RuleModeller modeller,
+ CompositeFactPattern pattern,
+ Boolean readOnly) {
this.completions = modeller.getSuggestionCompletions();
this.pattern = pattern;
this.modeller = modeller;
@@ -57,13 +61,17 @@
this.layout = new DirtyableFlexTable();
this.layout.setStyleName( "model-builderInner-Background" );
- this.readOnly = false;
- if (this.pattern != null && this.pattern.patterns != null){
- for (int i = 0; i < this.pattern.patterns.length; i++) {
- FactPattern factPattern = this.pattern.patterns[i];
- if (!completions.containsFactType(factPattern.factType)){
- this.readOnly = true;
- break;
+ if (readOnly != null){
+ this.readOnly = readOnly;
+ }else{
+ this.readOnly = false;
+ if (this.pattern != null && this.pattern.patterns != null){
+ for (int i = 0; i < this.pattern.patterns.length; i++) {
+ FactPattern factPattern = this.pattern.patterns[i];
+ if (!completions.containsFactType(factPattern.factType)){
+ this.readOnly = true;
+ break;
+ }
}
}
}
@@ -113,7 +121,7 @@
lbl += " <font color='red'>" + constants.clickToAddPatterns() + "</font>";
}
- return new ClickableLabel( lbl + ":", click, !(this.modeller.lockLHS() || this.readOnly) ) ;
+ return new ClickableLabel( lbl + ":", click, !this.readOnly ) ;
}
/**
@@ -149,4 +157,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/DSLSentenceWidget.java
===================================================================
--- labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/DSLSentenceWidget.java 2010-03-15 20:24:28 UTC (rev 32101)
+++ labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/DSLSentenceWidget.java 2010-03-15 21:50:01 UTC (rev 32102)
@@ -46,7 +46,7 @@
*
* @author Michael Neale
*/
-public class DSLSentenceWidget extends Composite {
+public class DSLSentenceWidget extends ReadOnlyWidget {
private static final String ENUM_TAG = "ENUM";
private static final String DATE_TAG = "DATE";
@@ -56,17 +56,34 @@
private final VerticalPanel layout;
private HorizontalPanel currentRow;
private RuleModeller modeller;
+ private boolean readOnly;
public DSLSentenceWidget(RuleModeller modeller, DSLSentence sentence) {
+ this(modeller, sentence, null);
+ }
+
+ public DSLSentenceWidget(RuleModeller modeller, DSLSentence sentence, Boolean readOnly) {
widgets = new ArrayList();
this.modeller = modeller;
this.sentence = sentence;
+
+ if (readOnly == null){
+ this.readOnly = false;
+ }else{
+ this.readOnly = readOnly;
+ }
+
this.layout = new VerticalPanel();
this.currentRow = new HorizontalPanel();
this.layout.add( currentRow );
this.layout.setCellWidth( currentRow,
"100%" );
this.layout.setWidth( "100%" );
+
+ if (this.readOnly) {
+ this.layout.addStyleName("editor-disabled-widget");
+ }
+
init();
}
@@ -494,4 +511,9 @@
return DATE_TAG;
}
}
+
+ @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/ExpressionBuilder.java
===================================================================
--- labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ExpressionBuilder.java 2010-03-15 20:24:28 UTC (rev 32101)
+++ labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ExpressionBuilder.java 2010-03-15 21:50:01 UTC (rev 32102)
@@ -5,7 +5,6 @@
import java.util.List;
import java.util.Map;
-import org.drools.guvnor.client.common.DirtyableComposite;
import org.drools.guvnor.client.messages.Constants;
import org.drools.guvnor.client.modeldriven.MethodInfo;
import org.drools.guvnor.client.modeldriven.SuggestionCompletionEngine;
@@ -29,7 +28,7 @@
import com.gwtext.client.widgets.form.Label;
import org.drools.guvnor.client.common.SmallLabel;
-public class ExpressionBuilder extends DirtyableComposite {
+public class ExpressionBuilder extends ReadOnlyWidget {
private static final String DELETE_VALUE = "_delete_";
private static final String FIElD_VALUE_PREFIX = "fl";
@@ -50,9 +49,15 @@
}
public ExpressionBuilder(RuleModeller modeller,
- ExpressionFormLine expression, boolean readOnly) {
+ ExpressionFormLine expression, Boolean readOnly) {
super();
- this.readOnly = readOnly;
+
+ if (readOnly == null){
+ this.readOnly = !modeller.getSuggestionCompletions().containsFactType(modeller.getSuggestionCompletions().getFactNameFromType(this.expression.getRootExpression().getClassType()));
+ }else{
+ this.readOnly = readOnly;
+ }
+
this.expression = expression;
this.modeller = modeller;
if (expression == null || expression.getText().length() == 0) {
@@ -340,4 +345,9 @@
private ExpressionPart getRootExpression() {
return expression.getRootExpression();
}
+
+ @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/FactPatternWidget.java
===================================================================
--- labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FactPatternWidget.java 2010-03-15 20:24:28 UTC (rev 32101)
+++ labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FactPatternWidget.java 2010-03-15 21:50:01 UTC (rev 32102)
@@ -46,7 +46,7 @@
* @author Michael Neale
*
*/
-public class FactPatternWidget extends DirtyableComposite {
+public class FactPatternWidget extends ReadOnlyWidget {
private FactPattern pattern;
private SuggestionCompletionEngine completions;
@@ -188,7 +188,7 @@
}
});
- if (!(this.modeller.lockLHS() || this.readOnly)) {
+ if (!this.readOnly) {
table.setWidget(currentRow, 5, clear);
}
@@ -270,7 +270,7 @@
desc = constants.AnyOf() + ":";
}
- t.setWidget(0, 0, new ClickableLabel(desc, click, !(modeller.lockLHS() || this.readOnly)));
+ t.setWidget(0, 0, new ClickableLabel(desc, click, !this.readOnly));
t.getFlexCellFormatter().setColSpan(0, 0, 2);
//t.getFlexCellFormatter().setWidth(0, 0, "15%");
@@ -294,7 +294,7 @@
}
}
});
- if (!(modeller.lockLHS() || this.readOnly)) {
+ if (!this.readOnly) {
inner.setWidget(i, 5, clear);
}
}
@@ -334,7 +334,7 @@
}
});
- if (!(modeller.lockLHS() || this.readOnly)) {
+ if (!this.readOnly) {
inner.setWidget(row, 4 + col, addConnective);
}
} else if (constraint.constraintValueType == SingleFieldConstraint.TYPE_PREDICATE) {
@@ -361,7 +361,7 @@
final TextBox box = new TextBox();
box.setText(c.value);
- if (!(this.modeller.lockLHS() || this.readOnly)) {
+ if (!this.readOnly) {
box.addChangeListener(new ChangeListener() {
public void onChange(Widget w) {
@@ -406,7 +406,7 @@
desc = Format.format(desc, patternName);
}
- return new ClickableLabel(desc, click, !(modeller.lockLHS() || this.readOnly));
+ return new ClickableLabel(desc, click, !this.readOnly);
}
/** Change to an/a depending on context - only for english */
@@ -429,7 +429,7 @@
}
private Widget operatorDropDown(final SingleFieldConstraint c) {
- if (!(this.modeller.lockLHS() || this.readOnly)) {
+ if (!this.readOnly) {
String[] ops = completions.getOperatorCompletions(pattern.factType, c.fieldName);
final ListBox box = new ListBox();
box.addItem(constants.pleaseChoose(), "");
@@ -471,7 +471,7 @@
ab.setStyleName("modeller-field-Label");
if (!con.isBound()) {
- if (bindable && showBinding && !(this.modeller.lockLHS() || this.readOnly)) {
+ if (bindable && showBinding && !this.readOnly) {
ClickListener click = new ClickListener() {
@@ -484,7 +484,7 @@
Image bind = new ImageButton("images/edit_tiny.gif", constants.GiveFieldVarName()); //NON-NLS
bind.addClickListener(click);
- ClickableLabel cl = new ClickableLabel(con.fieldName, click, !(this.modeller.lockLHS() || this.readOnly));
+ ClickableLabel cl = new ClickableLabel(con.fieldName, click, !this.readOnly);
DOM.setStyleAttribute(cl.getElement(), "marginLeft", "" + padding + "pt"); //NON-NLS
ab.add(cl);
//ab.add( bind );
@@ -513,4 +513,9 @@
return layout.hasDirty();
}
+ @Override
+ public boolean isReadOnly() {
+ return this.readOnly;
+ }
+
}
Added: 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 (rev 0)
+++ labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FreeFormLineWidget.java 2010-03-15 21:50:01 UTC (rev 32102)
@@ -0,0 +1,101 @@
+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.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;
+import org.drools.guvnor.client.modeldriven.brl.FreeFormLine;
+
+/**
+ * This is the new smart widget that works off the model.
+ * @author Michael Neale
+ *
+ */
+public class FreeFormLineWidget extends ReadOnlyWidget {
+
+ private FreeFormLine pattern;
+ private RuleModeller modeller;
+ private DirtyableFlexTable layout = new DirtyableFlexTable();
+ private Constants constants = ((Constants) GWT.create(Constants.class));
+ private boolean readOnly;
+
+ public FreeFormLineWidget(RuleModeller mod, FreeFormLine p) {
+ this(mod, p, 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 FreeFormLineWidget(RuleModeller mod, FreeFormLine p,
+ Boolean readOnly) {
+ this.pattern = p;
+ this.modeller = mod;
+
+ if (readOnly == null){
+ this.readOnly = false;
+ }else{
+ this.readOnly = readOnly;
+ }
+
+ layout.setWidget(0, 0, createTextBox());
+ FlexCellFormatter formatter = layout.getFlexCellFormatter();
+ formatter.setAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_BOTTOM);
+
+ if (this.readOnly) {
+ this.layout.addStyleName("editor-disabled-widget");
+ }
+
+ initWidget(layout);
+
+ }
+
+ private Widget createTextBox() {
+ final TextBox tb = new TextBox();
+ tb.setText(this.pattern.text);
+ tb.setTitle(constants.ThisIsADrlExpressionFreeForm());
+
+ if (!this.readOnly){
+ tb.addChangeListener(new ChangeListener() {
+
+ public void onChange(Widget arg0) {
+ pattern.text = tb.getText();
+ }
+ });
+ } else{
+ tb.setEnabled(false);
+ }
+ return tb;
+ }
+
+ @Override
+ public boolean isDirty() {
+ return layout.hasDirty();
+ }
+
+ @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/FromAccumulateCompositeFactPatternWidget.java
===================================================================
--- labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FromAccumulateCompositeFactPatternWidget.java 2010-03-15 20:24:28 UTC (rev 32101)
+++ labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FromAccumulateCompositeFactPatternWidget.java 2010-03-15 21:50:01 UTC (rev 32102)
@@ -63,14 +63,14 @@
int r = 0;
if (pattern.getFactPattern() == null) {
- panel.setWidget(r++, 0, new ClickableLabel("<br> <font color='red'>" + constants.clickToAddPattern() + "</font>", leftPatternclick, !(this.modeller.lockLHS() || this.readOnly)));
+ panel.setWidget(r++, 0, new ClickableLabel("<br> <font color='red'>" + constants.clickToAddPattern() + "</font>", leftPatternclick, !this.readOnly));
}
panel.setWidget(r++, 0, new HTML(lbl));
if (this.getFromAccumulatePattern().getSourcePattern() == null) {
- panel.setWidget(r++, 0, new ClickableLabel("<br> <font color='red'>" + constants.clickToAddPattern() + "</font>", sourcePatternClick, !(this.modeller.lockLHS() || this.readOnly)));
+ panel.setWidget(r++, 0, new ClickableLabel("<br> <font color='red'>" + constants.clickToAddPattern() + "</font>", sourcePatternClick, !this.readOnly));
} else {
IPattern rPattern = this.getFromAccumulatePattern().getSourcePattern();
Modified: labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FromCollectCompositeFactPatternWidget.java
===================================================================
--- labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FromCollectCompositeFactPatternWidget.java 2010-03-15 20:24:28 UTC (rev 32101)
+++ labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FromCollectCompositeFactPatternWidget.java 2010-03-15 21:50:01 UTC (rev 32102)
@@ -59,14 +59,14 @@
int r = 0;
if (pattern.getFactPattern() == null) {
- panel.setWidget(r++, 0, new ClickableLabel("<br> <font color='red'>" + constants.clickToAddPatterns() + "</font>", leftPatternclick, !(this.modeller.lockLHS() || this.readOnly)));
+ panel.setWidget(r++, 0, new ClickableLabel("<br> <font color='red'>" + constants.clickToAddPatterns() + "</font>", leftPatternclick, !this.readOnly));
}
panel.setWidget(r++, 0, new HTML(lbl));
if (this.getFromCollectPattern().getRightPattern() == null) {
- panel.setWidget(r++, 0, new ClickableLabel("<br> <font color='red'>" + constants.clickToAddPatterns() + "</font>", rightPatternclick, !(this.modeller.lockLHS() || this.readOnly)));
+ panel.setWidget(r++, 0, new ClickableLabel("<br> <font color='red'>" + constants.clickToAddPatterns() + "</font>", rightPatternclick, !this.readOnly));
} else {
IPattern rPattern = this.getFromCollectPattern().getRightPattern();
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-15 20:24:28 UTC (rev 32101)
+++ labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FromCompositeFactPatternWidget.java 2010-03-15 21:50:01 UTC (rev 32102)
@@ -9,7 +9,6 @@
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.DirtyableHorizontalPane;
import org.drools.guvnor.client.common.FormStylePopup;
@@ -24,7 +23,7 @@
*
* @author esteban
*/
-public class FromCompositeFactPatternWidget extends DirtyableComposite {
+public class FromCompositeFactPatternWidget extends ReadOnlyWidget {
protected FromCompositeFactPattern pattern;
protected DirtyableFlexTable layout;
@@ -113,7 +112,7 @@
int r = 0;
if (pattern.getFactPattern() == null) {
- panel.setWidget(r, 0, new ClickableLabel("<br> <font color='red'>" + constants.clickToAddPatterns() + "</font>", click, !(this.modeller.lockLHS() || this.readOnly)));
+ panel.setWidget(r, 0, new ClickableLabel("<br> <font color='red'>" + constants.clickToAddPatterns() + "</font>", click, !this.readOnly));
r++;
}
@@ -169,7 +168,7 @@
w.setWidth("100%");
horiz.add(w);
- if (!(modeller.lockLHS() || this.readOnly)) {
+ if (!this.readOnly) {
horiz.add(remove);
}
return horiz;
@@ -184,4 +183,9 @@
this.readOnly = !modeller.getSuggestionCompletions().containsFactType(this.pattern.factPattern.factType);
}
}
+
+ @Override
+ public boolean isReadOnly() {
+ return this.readOnly;
+ }
}
Added: 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 (rev 0)
+++ labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ReadOnlyWidget.java 2010-03-15 21:50:01 UTC (rev 32102)
@@ -0,0 +1,11 @@
+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-15 20:24:28 UTC (rev 32101)
+++ labs/jbossrules/branches/factsConstraints_baunax_esteban/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java 2010-03-15 21:50:01 UTC (rev 32102)
@@ -922,37 +922,29 @@
DirtyableVerticalPane vert = new DirtyableVerticalPane();
vert.setWidth("100%");
+ //if lockLHS() set the widget RO, otherwise let them decide.
+ Boolean readOnly = this.lockLHS()?true:null;
+
IPattern pattern = model.lhs[i];
- Widget w = null;
+ ReadOnlyWidget w = null;
if (pattern instanceof FactPattern) {
- w = new FactPatternWidget(this, pattern, true);
+ w = new FactPatternWidget(this, pattern, true, readOnly);
} else if (pattern instanceof CompositeFactPattern) {
- w = new CompositeFactPatternWidget(this, (CompositeFactPattern) pattern);
+ w = new CompositeFactPatternWidget(this, (CompositeFactPattern) pattern, readOnly);
} else if (pattern instanceof FromAccumulateCompositeFactPattern) {
- w = new FromAccumulateCompositeFactPatternWidget(this, (FromAccumulateCompositeFactPattern) pattern);
+ w = new FromAccumulateCompositeFactPatternWidget(this, (FromAccumulateCompositeFactPattern) pattern, readOnly);
} else if (pattern instanceof FromCollectCompositeFactPattern) {
- w = new FromCollectCompositeFactPatternWidget(this, (FromCollectCompositeFactPattern) pattern);
+ w = new FromCollectCompositeFactPatternWidget(this, (FromCollectCompositeFactPattern) pattern, readOnly);
} else if (pattern instanceof FromCompositeFactPattern) {
- w = new FromCompositeFactPatternWidget(this, (FromCompositeFactPattern) pattern);
+ w = new FromCompositeFactPatternWidget(this, (FromCompositeFactPattern) pattern, readOnly);
} else if (pattern instanceof DSLSentence) {
- w = new DSLSentenceWidget(this,(DSLSentence) pattern);
+ w = new DSLSentenceWidget(this,(DSLSentence) pattern, readOnly);
} 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;
+ w = new FreeFormLineWidget(this, (FreeFormLine)pattern, readOnly);
} else if (pattern instanceof ExpressionFormLine) {
- ExpressionFormLine efl = (ExpressionFormLine) pattern;
- w = new ExpressionBuilder(this, efl);
+ w = new ExpressionBuilder(this, (ExpressionFormLine) pattern, readOnly);
} else {
- throw new RuntimeException("I don't know what type of pattern that is.");
+ throw new RuntimeException("I don't know what type of pattern it is: "+pattern);
}
vert.add(wrapLHSWidget(model, i, w));
@@ -969,7 +961,7 @@
layout.getFlexCellFormatter().setWidth(currentLayoutRow, 1, "100%");
final int index = i;
- if (!lockLHS()) {
+ if (!(this.lockLHS() || w.isReadOnly())) {
this.addActionsButtonsToLayout(constants.AddAConditionBelow(), new ClickListener() {
public void onClick(Widget w) {
@@ -1008,7 +1000,7 @@
*/
private Widget wrapLHSWidget(final RuleModel model,
int i,
- Widget w) {
+ ReadOnlyWidget w) {
DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();
final Image remove = new ImageButton("images/delete_faded.gif"); //NON-NLS
@@ -1032,7 +1024,7 @@
w.setWidth("100%");
horiz.add(w);
- if (!lockLHS()) {
+ if (!(this.lockLHS() || w.isReadOnly())) {
horiz.add(remove);
}
@@ -1104,6 +1096,7 @@
return model.isVariableNameUsed(name) || completions.isGlobalVariable(name);
}
+ @Override
public boolean isDirty() {
return (layout.hasDirty() || dirtyflag);
}
More information about the jboss-svn-commits
mailing list