[jboss-svn-commits] JBL Code SVN: r28591 - in labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client: modeldriven/ui and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Jul 30 02:37:32 EDT 2009
Author: michael.neale at jboss.com
Date: 2009-07-30 02:37:31 -0400 (Thu, 30 Jul 2009)
New Revision: 28591
Modified:
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/common/ClickableLabel.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionInsertFactWidget.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionSetFieldWidget.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/CompositeFactPatternWidget.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FactPatternWidget.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleAttributeWidget.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java
Log:
GUVNOR-424 Freezable regions
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/common/ClickableLabel.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/common/ClickableLabel.java 2009-07-30 05:34:18 UTC (rev 28590)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/common/ClickableLabel.java 2009-07-30 06:37:31 UTC (rev 28591)
@@ -5,11 +5,21 @@
public class ClickableLabel extends HTML {
- public ClickableLabel(String text, ClickListener event) {
- //super("<small>" + text + "</small>");
- super("<div class='x-form-field'><span class='selectable-label'>" + text + "</span></div>");
- this.addClickListener(event);
+ public ClickableLabel(String text, ClickListener event, boolean enabled) {
+ super(doText(text, enabled));
+ if (enabled) this.addClickListener(event);
}
+ private static String doText(String text, boolean enabled) {
+ if (enabled)
+ return "<div class='x-form-field'><span class='selectable-label'>" + text + "</span></div>";
+ else
+ return "<div class='x-form-field'>" + text + "</div>";
+ }
+ public ClickableLabel(String text, ClickListener event) {
+ this(text, event, true);
+ }
+
+
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionInsertFactWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionInsertFactWidget.java 2009-07-30 05:34:18 UTC (rev 28590)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionInsertFactWidget.java 2009-07-30 06:37:31 UTC (rev 28591)
@@ -87,7 +87,9 @@
};
}
});
- inner.setWidget( i, 2 + col, remove );
+ if (!this.modeller.lockRHS()) {
+ inner.setWidget( i, 2 + col, remove );
+ }
}
@@ -124,7 +126,7 @@
if (this.model.fieldValues != null && model.fieldValues.length > 0 ) {
lbl = lbl + ":";
}
- return new ClickableLabel( lbl, cl );
+ return new ClickableLabel( lbl, cl, !this.modeller.lockRHS() );
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionSetFieldWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionSetFieldWidget.java 2009-07-30 05:34:18 UTC (rev 28590)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ActionSetFieldWidget.java 2009-07-30 06:37:31 UTC (rev 28591)
@@ -35,6 +35,7 @@
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 com.google.gwt.user.client.ui.MouseListenerAdapter;
import com.google.gwt.core.client.GWT;
import com.gwtext.client.util.Format;
@@ -104,6 +105,7 @@
layout.setWidget( i, 2, valueEditor(val) );
final int idx = i;
Image remove = new ImageButton("images/delete_item_small.gif"); //NON-NLS
+ //Image remove = new ImageButton("images/delete_item_fade.gif"); //NON-NLS
remove.addClickListener( new ClickListener() {
public void onClick(Widget w) {
if (Window.confirm(constants.RemoveThisItem())) {
@@ -112,7 +114,18 @@
}
}
});
- layout.setWidget( i, 3, remove );
+ if (!modeller.lockRHS()) 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.
+ }
+
+ @Override
+ public void onMouseLeave(Widget sender) {
+ super.onMouseLeave(sender); //To change body of overridden methods use File | Settings | File Templates.
+ }
+ });
}
if (model.fieldValues.length == 0) {
@@ -153,7 +166,7 @@
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);//HumanReadable.getActionDisplayName(modifyType) + " value of <b>[" + model.variable + "]</b>", clk);
+ return new ClickableLabel(sl, clk, !modeller.lockRHS());//HumanReadable.getActionDisplayName(modifyType) + " value of <b>[" + model.variable + "]</b>", clk);
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/CompositeFactPatternWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/CompositeFactPatternWidget.java 2009-07-30 05:34:18 UTC (rev 28590)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/CompositeFactPatternWidget.java 2009-07-30 06:37:31 UTC (rev 28591)
@@ -99,7 +99,7 @@
lbl += " <font color='red'>" + constants.clickToAddPatterns() + "</font>";
}
- return new ClickableLabel( lbl + ":", click ) ;
+ return new ClickableLabel( lbl + ":", click, !this.modeller.lockLHS() ) ;
}
/**
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FactPatternWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FactPatternWidget.java 2009-07-30 05:34:18 UTC (rev 28590)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/FactPatternWidget.java 2009-07-30 06:37:31 UTC (rev 28591)
@@ -145,7 +145,9 @@
}
} );
- table.setWidget( currentRow, 5, clear );
+ if (!this.modeller.lockLHS()) {
+ table.setWidget( currentRow, 5, clear );
+ }
}
}
@@ -225,7 +227,7 @@
desc = constants.AnyOf() + ":";
}
- t.setWidget(0, 0, new ClickableLabel(desc, click));
+ t.setWidget(0, 0, new ClickableLabel(desc, click, !modeller.lockLHS()));
t.getFlexCellFormatter().setColSpan(0, 0, 2);
//t.getFlexCellFormatter().setWidth(0, 0, "15%");
@@ -248,7 +250,7 @@
}
}
} );
- inner.setWidget( i, 5, clear );
+ if (!modeller.lockLHS()) inner.setWidget( i, 5, clear );
}
}
@@ -287,7 +289,7 @@
}
} );
- inner.setWidget( row, 4+ col, addConnective );
+ if (!modeller.lockLHS()) inner.setWidget( row, 4+ col, addConnective );
} else if (constraint.constraintValueType == SingleFieldConstraint.TYPE_PREDICATE) {
inner.setWidget( row, 0+ col, predicateEditor(constraint) );
inner.getFlexCellFormatter().setColSpan( row, 0, 5 );
@@ -336,10 +338,10 @@
if (pattern.constraintList != null && pattern.constraintList.constraints.length > 0) {
String desc = Format.format(constants.ThereIsAAn0With(), patternName);
- return new ClickableLabel( anA(desc, patternName) , click) ;
+ return new ClickableLabel( anA(desc, patternName) , click, !modeller.lockLHS()) ;
} else {
String desc = Format.format(constants.ThereIsAAn0(), patternName);
- return new ClickableLabel( anA(desc, patternName) , click );
+ return new ClickableLabel( anA(desc, patternName) , click, !modeller.lockLHS() );
}
}
@@ -408,7 +410,7 @@
Image bind = new ImageButton( "images/edit_tiny.gif", constants.GiveFieldVarName()); //NON-NLS
bind.addClickListener( click);
- ClickableLabel cl = new ClickableLabel(con.fieldName, click);
+ ClickableLabel cl = new ClickableLabel(con.fieldName, click, !modeller.lockLHS());
DOM.setStyleAttribute(cl.getElement(), "marginLeft", "" + padding + "pt"); //NON-NLS
ab.add( cl );
//ab.add( bind );
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleAttributeWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleAttributeWidget.java 2009-07-30 05:34:18 UTC (rev 28590)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleAttributeWidget.java 2009-07-30 06:37:31 UTC (rev 28591)
@@ -31,6 +31,7 @@
import org.drools.guvnor.client.common.DirtyableHorizontalPane;
import org.drools.guvnor.client.common.FormStyleLayout;
import org.drools.guvnor.client.common.SmallLabel;
+import org.drools.guvnor.client.common.InfoPopup;
import org.drools.guvnor.client.messages.Constants;
import org.drools.guvnor.client.modeldriven.brl.RuleAttribute;
import org.drools.guvnor.client.modeldriven.brl.RuleMetadata;
@@ -60,6 +61,8 @@
private static final String LOCK_ON_ACTIVE_ATTR = "lock-on-active";
private static final String RULEFLOW_GROUP_ATTR = "ruleflow-group";
private static final String DIALECT_ATTR = "dialect";
+ public static final String LOCK_LHS = "freeze_conditions";
+ public static final String LOCK_RHS = "freeze_actions";
/**
* If the rule attribute is represented visually by a checkbox, these are the values that will
@@ -68,7 +71,6 @@
private static final String TRUE_VALUE = "true";
private static final String FALSE_VALUE = "false";
- private FormStyleLayout layout;
private RuleModel model;
private RuleModeller parent;
private Constants constants = ((Constants) GWT.create(Constants.class));
@@ -76,7 +78,7 @@
public RuleAttributeWidget(RuleModeller parent, RuleModel model) {
this.parent = parent;
this.model = model;
- layout = new FormStyleLayout();
+ FormStyleLayout layout = new FormStyleLayout();
//Adding metadata here, seems redundant to add a new widget for metadata. Model does handle meta data separate.
RuleMetadata[] meta = model.metadataList;
if (meta.length > 0) {
@@ -129,6 +131,7 @@
list.addItem(RULEFLOW_GROUP_ATTR);
list.addItem(DIALECT_ATTR);
+
return list;
}
@@ -138,7 +141,8 @@
if (at.attributeName.equals(ENABLED_ATTR)
|| at.attributeName.equals(AUTO_FOCUS_ATTR)
|| at.attributeName.equals(LOCK_ON_ACTIVE_ATTR)
- || at.attributeName.equals(NO_LOOP_ATTR)) {
+ || at.attributeName.equals(NO_LOOP_ATTR)
+ ) {
editor = checkBoxEditor(at);
} else {
editor = textBoxEditor(at);
@@ -154,7 +158,12 @@
private Widget getEditorWidget(final RuleMetadata rm, final int idx) {
Widget editor;
- editor = textBoxEditor(rm);
+ if (rm.attributeName.equals(LOCK_LHS)
+ || rm.attributeName.equals(LOCK_RHS)) {
+ editor = new InfoPopup(constants.FrozenAreas(), constants.FrozenExplanation());
+ } else {
+ editor = textBoxEditor(rm);
+ }
DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();
horiz.add(editor);
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java 2009-07-30 05:34:18 UTC (rev 28590)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java 2009-07-30 06:37:31 UTC (rev 28591)
@@ -48,6 +48,7 @@
private SuggestionCompletionEngine completions;
private RuleModel model;
private Constants constants = ((Constants) GWT.create(Constants.class));
+ private boolean showingOptions = false;
public RuleModeller(RuleAsset asset, RuleViewer viewer) {
this(asset);
@@ -68,6 +69,34 @@
setHeight( "100%" );
}
+
+ private boolean isLock(String attr) {
+
+ //UNCOMMENT THIS WHEN READY !
+ //if (ExplorerLayoutManager.shouldShow(Capabilities.SHOW_CREATE_NEW_PACKAGE)) return true;
+
+
+ if (this.model.metadataList.length == 0) {
+ return false;
+ } else {
+ for(RuleMetadata at : this.model.metadataList) {
+ if (at.attributeName.equals(attr)) return true;
+ }
+ return false;
+ }
+ }
+
+ /** return true if we should not allow unfrozen editing of the RHS */
+ public boolean lockRHS() {
+ return isLock(RuleAttributeWidget.LOCK_RHS); //NON-NLS
+ }
+
+ /** return true if we should not allow unfrozen editing of the LHS */
+ public boolean lockLHS() {
+ return isLock(RuleAttributeWidget.LOCK_LHS); //NON-NLS
+ }
+
+
/**
* This updates the widget to reflect the state of the model.
*/
@@ -89,10 +118,13 @@
layout.setWidget( 0, 0, new SmallLabel(constants.WHEN()) );
- layout.setWidget( 0, 2, addPattern );
+ if (!lockLHS()) {
+ layout.setWidget( 0, 2, addPattern );
+ }
+
layout.setWidget( 1, 1, renderLhs(this.model) );
layout.getFlexCellFormatter().setHorizontalAlignment(1, 1, HasHorizontalAlignment.ALIGN_LEFT);
layout.getFlexCellFormatter().setVerticalAlignment(1, 1, HasVerticalAlignment.ALIGN_TOP);
@@ -105,18 +137,45 @@
showActionSelector(w);
}
});
- layout.setWidget( 2, 2, addAction );
+ if (!lockRHS()) {
+ layout.setWidget( 2, 2, addAction );
+ }
layout.setWidget( 3, 1, renderRhs(this.model) );
layout.getFlexCellFormatter().setHorizontalAlignment(3, 1, HasHorizontalAlignment.ALIGN_LEFT);
layout.getFlexCellFormatter().setVerticalAlignment(3, 1, HasVerticalAlignment.ALIGN_TOP);
- layout.setWidget( 4, 0, new SmallLabel(constants.optionsRuleModeller()) );
- layout.setWidget( 4, 2, getAddAttribute() );
- layout.setWidget( 5, 1, new RuleAttributeWidget(this, this.model) );
+ if (showAttributes()) {
+
+ 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( 4, 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) );
+
+ }
+
+
+ }
+
}
+ private boolean showAttributes() {
+ //return false;
+ return ExplorerLayoutManager.shouldShow(Capabilities.SHOW_PACKAGE_VIEW);
+ }
+
public void refreshWidget() {
initWidget();
makeDirty();
@@ -138,6 +197,7 @@
protected void showAttributeSelector(Widget w) {
final FormStylePopup pop = new FormStylePopup("images/config.png", constants.AddAnOptionToTheRule()); //NON-NLS
final ListBox list = RuleAttributeWidget.getAttributeList();
+
final Image addbutton = new ImageButton("images/new_item.gif"); //NON-NLS
final TextBox box = new TextBox();
@@ -146,7 +206,12 @@
list.addChangeListener( new ChangeListener() {
public void onChange(Widget w) {
- model.addAttribute( new RuleAttribute(list.getItemText( list.getSelectedIndex() ), "") );
+ 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();
}
@@ -174,22 +239,38 @@
pop.addAttribute(constants.Metadata3(), horiz );
pop.addAttribute(constants.Attribute1(), list );
- //add text field
- //add button
- //add listener that adds the rule Attribute
-// pop.addAttribute( "Metadata:",
-// editableText( new FieldBinding() {
-// public String getValue() {
-// return data.subject;
-// }
-//
-// public void setValue(String val) {
-// data.subject = val;
-// }
-// },
-// "A short description of the subject matter." ) );
+ Button freezeConditions = new Button(constants.Conditions());
+ freezeConditions.addClickListener(new ClickListener() {
+ public void onClick(Widget sender) {
+ 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") );
+ refreshWidget();
+ pop.hide();
+ }
+ });
+ HorizontalPanel hz = new HorizontalPanel();
+ if (!lockLHS()) {
+ hz.add(freezeConditions);
+ }
+ if (!lockRHS()) {
+ hz.add(freezeActions);
+ }
+ hz.add(new InfoPopup(constants.FrozenAreas(), constants.FrozenExplanation()));
+ if (hz.getWidgetCount() > 1) {
+ pop.addAttribute(constants.FreezeAreasForEditing(), hz);
+ }
+
+
+
pop.show();
}
@@ -255,7 +336,9 @@
horiz.setWidth( "100%" );
}
- horiz.add( remove );
+ if (!lockRHS()) {
+ horiz.add( remove );
+ }
widget.add( horiz );
}
@@ -780,7 +863,7 @@
w.setWidth( "100%" );
horiz.add( w );
- horiz.add( remove );
+ if (!lockLHS()) horiz.add( remove );
return horiz;
}
More information about the jboss-svn-commits
mailing list