use of org.drools.workbench.screens.guided.rule.client.widget.RuleModellerWidget in project drools-wb by kiegroup.
the class RuleModeller method renderRhs.
/**
* Do all the widgets for the RHS.
*/
private void renderRhs(final RuleModel model) {
for (int i = 0; i < model.rhs.length; i++) {
DirtyableVerticalPane widget = new DirtyableVerticalPane();
widget.setWidth("100%");
IAction action = model.rhs[i];
// if lockRHS() set the widget RO, otherwise let them decide.
Boolean readOnly = this.lockRHS() ? true : null;
RuleModellerWidget w = getWidgetFactory().getWidget(this, eventBus, action, readOnly);
w.addOnModifiedCommand(this.onWidgetModifiedCommand);
widget.add(wrapRHSWidget(model, i, w));
widget.add(spacerWidget());
layout.setWidget(currentLayoutRow, 0, new DirtyableHorizontalPane());
layout.setWidget(currentLayoutRow, 1, new DirtyableHorizontalPane());
layout.setWidget(currentLayoutRow, 2, this.wrapLineNumber(i + 1, false));
layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 2, HasHorizontalAlignment.ALIGN_CENTER);
layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 2, HasVerticalAlignment.ALIGN_MIDDLE);
layout.setWidget(currentLayoutRow, 3, widget);
layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 3, HasHorizontalAlignment.ALIGN_LEFT);
layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 3, HasVerticalAlignment.ALIGN_TOP);
layout.getFlexCellFormatter().setWidth(currentLayoutRow, 3, "100%");
layout.getRowFormatter().addStyleName(currentLayoutRow, (i % 2 == 0 ? GuidedRuleEditorResources.INSTANCE.css().evenRow() : GuidedRuleEditorResources.INSTANCE.css().oddRow()));
if (!w.isFactTypeKnown()) {
addInvalidPatternIcon();
addFactTypeKnownValueChangeHandler(w, currentLayoutRow);
}
final int index = i;
if (!(this.lockRHS() || w.isReadOnly())) {
this.addActionsButtonsToLayout(GuidedRuleEditorResources.CONSTANTS.AddAnActionBelow(), new ClickHandler() {
public void onClick(ClickEvent event) {
showActionSelector(index + 1);
}
}, new ClickHandler() {
public void onClick(ClickEvent event) {
model.moveRhsItemDown(index);
refreshWidget();
}
}, new ClickHandler() {
public void onClick(ClickEvent event) {
model.moveRhsItemUp(index);
refreshWidget();
}
});
}
this.rhsWidgets.add(w);
currentLayoutRow++;
}
}
use of org.drools.workbench.screens.guided.rule.client.widget.RuleModellerWidget in project drools-wb by kiegroup.
the class RuleModellerWidgetFactory method getWidget.
public RuleModellerWidget getWidget(RuleModeller ruleModeller, EventBus eventBus, IAction action, Boolean readOnly) {
if (action instanceof ActionCallMethod) {
return new ActionCallMethodWidget(ruleModeller, eventBus, (ActionCallMethod) action, readOnly);
}
if (action instanceof ActionSetField) {
return new ActionSetFieldWidget(ruleModeller, eventBus, (ActionSetField) action, readOnly);
}
if (action instanceof ActionInsertFact) {
return new ActionInsertFactWidget(ruleModeller, eventBus, (ActionInsertFact) action, readOnly);
}
if (action instanceof ActionRetractFact) {
return new ActionRetractFactWidget(ruleModeller, eventBus, (ActionRetractFact) action, readOnly);
}
if (action instanceof DSLSentence) {
RuleModellerWidget w = new DSLSentenceWidget(ruleModeller, eventBus, (DSLSentence) action, readOnly);
return w;
}
if (action instanceof FreeFormLine) {
return new FreeFormLineWidget(ruleModeller, eventBus, (FreeFormLine) action, readOnly);
}
if (action instanceof ActionGlobalCollectionAdd) {
return new GlobalCollectionAddWidget(ruleModeller, eventBus, (ActionGlobalCollectionAdd) action, readOnly);
}
// All hardcoded action widgets have been checked, perform a plugin lookup
List<RuleModellerActionPlugin> matchingActionPlugins = actionPlugins.stream().filter(p -> p.accept(action)).collect(Collectors.toList());
if (matchingActionPlugins.size() > 1) {
throw new IllegalStateException("Ambigious " + RuleModellerActionPlugin.class.getName() + " implementations for action " + action);
}
if (matchingActionPlugins.size() == 1) {
RuleModellerActionPlugin actionPlugin = matchingActionPlugins.get(0);
RuleModellerWidget ruleModellerWidget = actionPlugin.createWidget(ruleModeller, eventBus, action, readOnly);
return ruleModellerWidget;
}
// NON-NLS
throw new RuntimeException("I don't know what type of action is: " + action);
}
use of org.drools.workbench.screens.guided.rule.client.widget.RuleModellerWidget in project drools-wb by kiegroup.
the class RuleModeller method renderLhs.
/**
* Builds all the condition widgets.
*/
private void renderLhs(final RuleModel model) {
for (int i = 0; i < model.lhs.length; i++) {
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];
final RuleModellerWidget widget = getWidgetFactory().getWidget(this, eventBus, pattern, readOnly);
widget.addOnModifiedCommand(this.onWidgetModifiedCommand);
vert.add(wrapLHSWidget(model, i, widget));
vert.add(spacerWidget());
layout.setWidget(currentLayoutRow, 0, new DirtyableHorizontalPane());
layout.setWidget(currentLayoutRow, 1, new DirtyableHorizontalPane());
layout.setWidget(currentLayoutRow, 2, this.wrapLineNumber(i + 1, true));
layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 2, HasHorizontalAlignment.ALIGN_CENTER);
layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 2, HasVerticalAlignment.ALIGN_MIDDLE);
layout.setWidget(currentLayoutRow, 3, vert);
layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 3, HasHorizontalAlignment.ALIGN_LEFT);
layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 3, HasVerticalAlignment.ALIGN_TOP);
layout.getFlexCellFormatter().setWidth(currentLayoutRow, 3, "100%");
layout.getRowFormatter().addStyleName(currentLayoutRow, (i % 2 == 0 ? GuidedRuleEditorResources.INSTANCE.css().evenRow() : GuidedRuleEditorResources.INSTANCE.css().oddRow()));
if (!widget.isFactTypeKnown()) {
addInvalidPatternIcon();
addFactTypeKnownValueChangeHandler(widget, currentLayoutRow);
}
final int index = i;
if (!(this.lockLHS() || widget.isReadOnly())) {
this.addActionsButtonsToLayout(GuidedRuleEditorResources.CONSTANTS.AddAConditionBelow(), new ClickHandler() {
public void onClick(ClickEvent event) {
showConditionSelector(index + 1);
}
}, new ClickHandler() {
public void onClick(ClickEvent event) {
model.moveLhsItemDown(index);
refreshWidget();
}
}, new ClickHandler() {
public void onClick(ClickEvent event) {
model.moveLhsItemUp(index);
refreshWidget();
}
});
}
this.lhsWidgets.add(widget);
currentLayoutRow++;
}
}
Aggregations