Search in sources :

Example 1 with MoveUpButton

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("&nbsp;&nbsp;&nbsp;&nbsp;"));
    return t;
}
Also used : CompositeFieldConstraint(org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint) DataType(org.kie.soup.project.datamodel.oracle.DataType) FlexTable(com.google.gwt.user.client.ui.FlexTable) Image(com.google.gwt.user.client.ui.Image) SingleFieldConstraintOperatorSelector(org.drools.workbench.screens.guided.rule.client.widget.operator.SingleFieldConstraintOperatorSelector) HumanReadable(org.kie.workbench.common.widgets.client.resources.HumanReadable) HTML(com.google.gwt.user.client.ui.HTML) Label(com.google.gwt.user.client.ui.Label) Map(java.util.Map) RuleModeller(org.drools.workbench.screens.guided.rule.client.editor.RuleModeller) ToStringExpressionVisitor(org.drools.workbench.models.datamodel.rule.visitors.ToStringExpressionVisitor) EventBus(com.google.gwt.event.shared.EventBus) DOM(com.google.gwt.user.client.DOM) ConstraintValueEditor(org.drools.workbench.screens.guided.rule.client.editor.ConstraintValueEditor) TextBox(org.gwtbootstrap3.client.ui.TextBox) FieldConstraint(org.drools.workbench.models.datamodel.rule.FieldConstraint) MoveUpButton(org.drools.workbench.screens.guided.rule.client.editor.MoveUpButton) ClickableLabel(org.uberfire.ext.widgets.common.client.common.ClickableLabel) List(java.util.List) Widget(com.google.gwt.user.client.ui.Widget) GuidedRuleEditorImages508(org.drools.workbench.screens.guided.rule.client.resources.images.GuidedRuleEditorImages508) DRLConstraintValueBuilder(org.drools.workbench.models.datamodel.rule.builder.DRLConstraintValueBuilder) HumanReadableConstants(org.kie.workbench.common.widgets.client.resources.i18n.HumanReadableConstants) CEPWindowOperatorsDropdown(org.drools.workbench.screens.guided.rule.client.editor.CEPWindowOperatorsDropdown) OperatorSelection(org.drools.workbench.screens.guided.rule.client.editor.OperatorSelection) RefreshUtil(org.drools.workbench.screens.guided.rule.client.util.RefreshUtil) SingleFieldConstraintEBLeftSide(org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide) HasCEPWindow(org.drools.workbench.models.datamodel.rule.HasCEPWindow) MoveDownButton(org.drools.workbench.screens.guided.rule.client.editor.MoveDownButton) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) GuidedRuleEditorResources(org.drools.workbench.screens.guided.rule.client.resources.GuidedRuleEditorResources) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) HashMap(java.util.HashMap) GWT(com.google.gwt.core.client.GWT) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ArrayList(java.util.ArrayList) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) Window(com.google.gwt.user.client.Window) RuleAttribute(org.drools.workbench.models.datamodel.rule.RuleAttribute) IPattern(org.drools.workbench.models.datamodel.rule.IPattern) SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) Connectives(org.drools.workbench.screens.guided.rule.client.editor.factPattern.Connectives) HasHorizontalAlignment(com.google.gwt.user.client.ui.HasHorizontalAlignment) HasConstraints(org.drools.workbench.models.datamodel.rule.HasConstraints) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) HasVerticalAlignment(com.google.gwt.user.client.ui.HasVerticalAlignment) PopupCreator(org.drools.workbench.screens.guided.rule.client.editor.factPattern.PopupCreator) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) MoveDownButton(org.drools.workbench.screens.guided.rule.client.editor.MoveDownButton) FlexTable(com.google.gwt.user.client.ui.FlexTable) ClickableLabel(org.uberfire.ext.widgets.common.client.common.ClickableLabel) MoveUpButton(org.drools.workbench.screens.guided.rule.client.editor.MoveUpButton) HTML(com.google.gwt.user.client.ui.HTML) Image(com.google.gwt.user.client.ui.Image) CompositeFieldConstraint(org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint) FieldConstraint(org.drools.workbench.models.datamodel.rule.FieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) CompositeFieldConstraint(org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint) FieldConstraint(org.drools.workbench.models.datamodel.rule.FieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)

Example 2 with MoveUpButton

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();
            }));
        }
    }
}
Also used : CompositeFieldConstraint(org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint) DataType(org.kie.soup.project.datamodel.oracle.DataType) FlexTable(com.google.gwt.user.client.ui.FlexTable) Image(com.google.gwt.user.client.ui.Image) SingleFieldConstraintOperatorSelector(org.drools.workbench.screens.guided.rule.client.widget.operator.SingleFieldConstraintOperatorSelector) HumanReadable(org.kie.workbench.common.widgets.client.resources.HumanReadable) HTML(com.google.gwt.user.client.ui.HTML) Label(com.google.gwt.user.client.ui.Label) Map(java.util.Map) RuleModeller(org.drools.workbench.screens.guided.rule.client.editor.RuleModeller) ToStringExpressionVisitor(org.drools.workbench.models.datamodel.rule.visitors.ToStringExpressionVisitor) EventBus(com.google.gwt.event.shared.EventBus) DOM(com.google.gwt.user.client.DOM) ConstraintValueEditor(org.drools.workbench.screens.guided.rule.client.editor.ConstraintValueEditor) TextBox(org.gwtbootstrap3.client.ui.TextBox) FieldConstraint(org.drools.workbench.models.datamodel.rule.FieldConstraint) MoveUpButton(org.drools.workbench.screens.guided.rule.client.editor.MoveUpButton) ClickableLabel(org.uberfire.ext.widgets.common.client.common.ClickableLabel) List(java.util.List) Widget(com.google.gwt.user.client.ui.Widget) GuidedRuleEditorImages508(org.drools.workbench.screens.guided.rule.client.resources.images.GuidedRuleEditorImages508) DRLConstraintValueBuilder(org.drools.workbench.models.datamodel.rule.builder.DRLConstraintValueBuilder) HumanReadableConstants(org.kie.workbench.common.widgets.client.resources.i18n.HumanReadableConstants) CEPWindowOperatorsDropdown(org.drools.workbench.screens.guided.rule.client.editor.CEPWindowOperatorsDropdown) OperatorSelection(org.drools.workbench.screens.guided.rule.client.editor.OperatorSelection) RefreshUtil(org.drools.workbench.screens.guided.rule.client.util.RefreshUtil) SingleFieldConstraintEBLeftSide(org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide) HasCEPWindow(org.drools.workbench.models.datamodel.rule.HasCEPWindow) MoveDownButton(org.drools.workbench.screens.guided.rule.client.editor.MoveDownButton) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) GuidedRuleEditorResources(org.drools.workbench.screens.guided.rule.client.resources.GuidedRuleEditorResources) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) HashMap(java.util.HashMap) GWT(com.google.gwt.core.client.GWT) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ArrayList(java.util.ArrayList) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) Window(com.google.gwt.user.client.Window) RuleAttribute(org.drools.workbench.models.datamodel.rule.RuleAttribute) IPattern(org.drools.workbench.models.datamodel.rule.IPattern) SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) Connectives(org.drools.workbench.screens.guided.rule.client.editor.factPattern.Connectives) HasHorizontalAlignment(com.google.gwt.user.client.ui.HasHorizontalAlignment) HasConstraints(org.drools.workbench.models.datamodel.rule.HasConstraints) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) HasVerticalAlignment(com.google.gwt.user.client.ui.HasVerticalAlignment) PopupCreator(org.drools.workbench.screens.guided.rule.client.editor.factPattern.PopupCreator) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) MoveDownButton(org.drools.workbench.screens.guided.rule.client.editor.MoveDownButton) FlexTable(com.google.gwt.user.client.ui.FlexTable) ArrayList(java.util.ArrayList) MoveUpButton(org.drools.workbench.screens.guided.rule.client.editor.MoveUpButton) Image(com.google.gwt.user.client.ui.Image) CompositeFieldConstraint(org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint) FieldConstraint(org.drools.workbench.models.datamodel.rule.FieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) CompositeFieldConstraint(org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint) FieldConstraint(org.drools.workbench.models.datamodel.rule.FieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)

Aggregations

GWT (com.google.gwt.core.client.GWT)2 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)2 EventBus (com.google.gwt.event.shared.EventBus)2 DOM (com.google.gwt.user.client.DOM)2 Window (com.google.gwt.user.client.Window)2 FlexTable (com.google.gwt.user.client.ui.FlexTable)2 FlexCellFormatter (com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter)2 HTML (com.google.gwt.user.client.ui.HTML)2 HasHorizontalAlignment (com.google.gwt.user.client.ui.HasHorizontalAlignment)2 HasVerticalAlignment (com.google.gwt.user.client.ui.HasVerticalAlignment)2 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)2 Image (com.google.gwt.user.client.ui.Image)2 Label (com.google.gwt.user.client.ui.Label)2 Widget (com.google.gwt.user.client.ui.Widget)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)2 CompositeFieldConstraint (org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint)2