use of org.drools.workbench.screens.guided.rule.client.editor.MoveUpButton in project drools-wb by kiegroup.
the class FactPatternWidget method compositeFieldConstraintEditor.
/**
* This will show the constraint editor - allowing field constraints to be
* nested etc.
*/
private Widget compositeFieldConstraintEditor(final CompositeFieldConstraint constraint) {
FlexTable t = new FlexTable();
String desc;
ClickHandler click = event -> popupCreator.showPatternPopupForComposite(constraint);
if (constraint.getCompositeJunctionType().equals(CompositeFieldConstraint.COMPOSITE_TYPE_AND)) {
desc = GuidedRuleEditorResources.CONSTANTS.AllOf() + ":";
} else {
desc = GuidedRuleEditorResources.CONSTANTS.AnyOf() + ":";
}
t.setWidget(0, 0, new ClickableLabel(desc, click, !this.readOnly));
t.getFlexCellFormatter().setColSpan(0, 0, 2);
FieldConstraint[] nested = constraint.getConstraints();
FlexTable inner = new FlexTable();
if (nested != null) {
for (int i = 0; i < nested.length; i++) {
this.renderFieldConstraint(inner, i, nested[i], constraint, true, 0);
// add in remove icon here...
final int currentRow = i;
Image clear = GuidedRuleEditorImages508.INSTANCE.DeleteItemSmall();
clear.setTitle(GuidedRuleEditorResources.CONSTANTS.RemoveThisNestedRestriction());
clear.addClickHandler(event -> {
if (Window.confirm(GuidedRuleEditorResources.CONSTANTS.RemoveThisItemFromNestedConstraint())) {
setModified(true);
constraint.removeConstraint(currentRow);
getModeller().refreshWidget();
}
});
if (!this.readOnly) {
// This used to be 5 and Connectives were not rendered
inner.setWidget(i, 6, clear);
inner.setWidget(i, 7, new MoveDownButton(event -> {
constraint.moveDown(currentRow);
getModeller().refreshWidget();
}));
inner.setWidget(i, 8, new MoveUpButton(event -> {
constraint.moveUp(currentRow);
getModeller().refreshWidget();
}));
}
}
}
t.setWidget(1, 1, inner);
t.setWidget(1, 0, new HTML(" "));
return t;
}
use of org.drools.workbench.screens.guided.rule.client.editor.MoveUpButton in project drools-wb by kiegroup.
the class FactPatternWidget method drawConstraints.
/**
* Render a hierarchy of constraints, hierarchy here means constraints that
* may themselves depend on members of constraint objects. With this code,
* the GUI enables clicking rules of the form: $result = RoutingResult(
* NerOption.types contains "arzt" )
* @param sortedConst a sorted list of constraints to display.
*/
protected void drawConstraints(List<FieldConstraint> sortedConst, HasConstraints hasConstraints) {
final FlexTable table = new FlexTable();
layout.setWidget(1, 0, table);
List<FieldConstraint> parents = new ArrayList<>();
for (int i = 0; i < sortedConst.size(); i++) {
traverseSingleFieldConstraints(sortedConst, table, parents, hasConstraints, i);
// now the clear icon
final int currentRow = i;
Image clear = GuidedRuleEditorImages508.INSTANCE.DeleteItemSmall();
clear.setTitle(GuidedRuleEditorResources.CONSTANTS.RemoveThisWholeRestriction());
clear.addClickHandler(createClickHandlerForClearImageButton(currentRow));
if (!this.readOnly) {
// This used to be 5 and Connectives were not rendered
table.setWidget(currentRow, 6, clear);
table.setWidget(currentRow, 7, new MoveUpButton(event -> {
hasConstraints.moveUp(currentRow);
getModeller().refreshWidget();
}));
table.setWidget(currentRow, 8, new MoveDownButton(event -> {
hasConstraints.moveDown(currentRow);
getModeller().refreshWidget();
}));
}
}
}
Aggregations