Search in sources :

Example 11 with SmallLabel

use of org.uberfire.ext.widgets.common.client.common.SmallLabel in project drools-wb by kiegroup.

the class RuleModeller method addExtendedRuleDropdown.

private void addExtendedRuleDropdown() {
    layout.setWidget(currentLayoutRow, 0, new SmallLabel("<b>" + GuidedRuleEditorResources.CONSTANTS.EXTENDS() + "</b>"));
    ruleSelector.setRuleName(model.parentName);
    ruleSelector.addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            model.parentName = event.getValue();
        }
    });
    layout.setWidget(currentLayoutRow, 3, ruleSelector);
    currentLayoutRow++;
}
Also used : SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel)

Example 12 with SmallLabel

use of org.uberfire.ext.widgets.common.client.common.SmallLabel in project drools-wb by kiegroup.

the class RuleModeller method initWidget.

/**
 * This updates the widget to reflect the state of the model.
 */
public void initWidget() {
    layout.removeAllRows();
    currentLayoutRow = 0;
    Image addPattern = GuidedRuleEditorImages508.INSTANCE.NewItem();
    addPattern.setTitle(GuidedRuleEditorResources.CONSTANTS.AddAConditionToThisRule());
    addPattern.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            showConditionSelector(null);
        }
    });
    layout.getColumnFormatter().setWidth(0, "20px");
    layout.getColumnFormatter().setWidth(1, "20px");
    layout.getColumnFormatter().setWidth(2, "48px");
    layout.getColumnFormatter().setWidth(4, "64px");
    if (this.showExtendedRuleDropdown()) {
        addExtendedRuleDropdown();
    }
    if (this.showLHS()) {
        layout.setWidget(currentLayoutRow, 0, new SmallLabel("<b>" + GuidedRuleEditorResources.CONSTANTS.WHEN() + "</b>"));
        layout.getFlexCellFormatter().setColSpan(currentLayoutRow, 0, 4);
        if (!lockLHS()) {
            layout.setWidget(currentLayoutRow, 1, addPattern);
        }
        currentLayoutRow++;
        renderLhs(this.model);
    }
    if (this.showRHS()) {
        layout.setWidget(currentLayoutRow, 0, new SmallLabel("<b>" + GuidedRuleEditorResources.CONSTANTS.THEN() + "</b>"));
        layout.getFlexCellFormatter().setColSpan(currentLayoutRow, 0, 4);
        Image addAction = GuidedRuleEditorImages508.INSTANCE.NewItem();
        addAction.setTitle(GuidedRuleEditorResources.CONSTANTS.AddAnActionToThisRule());
        addAction.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                showActionSelector(null);
            }
        });
        if (!lockRHS()) {
            layout.setWidget(currentLayoutRow, 1, addAction);
        }
        currentLayoutRow++;
        renderRhs(this.model);
    }
    if (showAttributes()) {
        final int optionsRowIndex = currentLayoutRow;
        if (!this.showingOptions) {
            ClickableLabel showMoreOptions = new ClickableLabel(GuidedRuleEditorResources.CONSTANTS.ShowOptions(), new ClickHandler() {

                public void onClick(ClickEvent event) {
                    showingOptions = true;
                    renderOptions(optionsRowIndex);
                }
            });
            layout.setWidget(optionsRowIndex, 2, showMoreOptions);
        } else {
            renderOptions(optionsRowIndex);
        }
    }
    currentLayoutRow++;
    layout.setWidget(currentLayoutRow + 1, 3, spacerWidget());
    layout.getCellFormatter().setHeight(currentLayoutRow + 1, 3, "100%");
}
Also used : SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ClickableLabel(org.uberfire.ext.widgets.common.client.common.ClickableLabel) Image(com.google.gwt.user.client.ui.Image)

Example 13 with SmallLabel

use of org.uberfire.ext.widgets.common.client.common.SmallLabel in project drools-wb by kiegroup.

the class PopupCreator method showPatternPopup.

/**
 * This shows a popup allowing you to add field constraints to a pattern
 * (its a popup).
 */
public void showPatternPopup(final FactPattern fp, final SingleFieldConstraint con, final boolean isNested) {
    final String factType = getFactType(fp, con);
    String title = (con == null) ? GuidedRuleEditorResources.CONSTANTS.ModifyConstraintsFor0(fp.getFactType()) : GuidedRuleEditorResources.CONSTANTS.AddSubFieldConstraint();
    final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorImages508.INSTANCE.Wizard(), title);
    final ListBox box = new ListBox();
    box.addItem("...");
    this.oracle.getFieldCompletions(factType, FieldAccessorsAndMutators.ACCESSOR, new Callback<ModelField[]>() {

        @Override
        public void callback(final ModelField[] fields) {
            for (int i = 0; i < fields.length; i++) {
                // You can't use "this" in a nested accessor
                final String fieldName = fields[i].getName();
                if (!isNested || !fieldName.equals(DataType.TYPE_THIS)) {
                    box.addItem(fieldName);
                }
            }
        }
    });
    box.setSelectedIndex(0);
    box.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            String fieldName = box.getItemText(box.getSelectedIndex());
            if ("...".equals(fieldName)) {
                return;
            }
            String fieldType = oracle.getFieldType(factType, fieldName);
            fp.addConstraint(new SingleFieldConstraint(factType, fieldName, fieldType, con));
            modeller.refreshWidget();
            popup.hide();
        }
    });
    popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.AddARestrictionOnAField(), box);
    final ListBox composites = new ListBox();
    composites.addItem("...");
    composites.addItem(GuidedRuleEditorResources.CONSTANTS.AllOfAnd(), CompositeFieldConstraint.COMPOSITE_TYPE_AND);
    composites.addItem(GuidedRuleEditorResources.CONSTANTS.AnyOfOr(), CompositeFieldConstraint.COMPOSITE_TYPE_OR);
    composites.setSelectedIndex(0);
    composites.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            CompositeFieldConstraint comp = new CompositeFieldConstraint();
            comp.setCompositeJunctionType(composites.getValue(composites.getSelectedIndex()));
            fp.addConstraint(comp);
            modeller.refreshWidget();
            popup.hide();
        }
    });
    InfoPopup infoComp = new InfoPopup(GuidedRuleEditorResources.CONSTANTS.MultipleFieldConstraints(), GuidedRuleEditorResources.CONSTANTS.MultipleConstraintsTip1());
    HorizontalPanel horiz = new HorizontalPanel();
    horiz.add(composites);
    horiz.add(infoComp);
    if (con == null) {
        popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.MultipleFieldConstraint(), horiz);
    }
    if (con == null) {
        // NON-NLS
        popup.addRow(new SmallLabel("<i>" + GuidedRuleEditorResources.CONSTANTS.AdvancedOptionsColon() + "</i>"));
        Button predicate = new Button(GuidedRuleEditorResources.CONSTANTS.NewFormula());
        predicate.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                SingleFieldConstraint con = new SingleFieldConstraint();
                con.setConstraintValueType(SingleFieldConstraint.TYPE_PREDICATE);
                fp.addConstraint(con);
                modeller.refreshWidget();
                popup.hide();
            }
        });
        popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.AddANewFormulaStyleExpression(), predicate);
        final Button expressionEditorButton = makeExpressionEditorButton(fp, popup);
        popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.ExpressionEditor(), expressionEditorButton);
        doBindingEditor(popup);
    }
    popup.show();
}
Also used : SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) CompositeFieldConstraint(org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ModelField(org.kie.soup.project.datamodel.oracle.ModelField) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) Button(org.gwtbootstrap3.client.ui.Button) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup) InfoPopup(org.uberfire.ext.widgets.common.client.common.InfoPopup) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Example 14 with SmallLabel

use of org.uberfire.ext.widgets.common.client.common.SmallLabel in project drools-wb by kiegroup.

the class PopupCreator method showPatternPopupForComposite.

/**
 * This shows a popup for adding fields to a composite
 */
public void showPatternPopupForComposite(final HasConstraints hasConstraints) {
    final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorImages508.INSTANCE.Wizard(), GuidedRuleEditorResources.CONSTANTS.AddFieldsToThisConstraint());
    final ListBox box = new ListBox();
    box.addItem("...");
    this.oracle.getFieldCompletions(this.pattern.getFactType(), new Callback<ModelField[]>() {

        @Override
        public void callback(final ModelField[] fields) {
            for (int i = 0; i < fields.length; i++) {
                final String fieldName = fields[i].getName();
                box.addItem(fieldName);
            }
        }
    });
    box.setSelectedIndex(0);
    box.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            String factType = pattern.getFactType();
            String fieldName = box.getItemText(box.getSelectedIndex());
            String fieldType = getDataModelOracle().getFieldType(factType, fieldName);
            hasConstraints.addConstraint(new SingleFieldConstraint(factType, fieldName, fieldType, null));
            modeller.refreshWidget();
            popup.hide();
        }
    });
    popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.AddARestrictionOnAField(), box);
    final ListBox composites = new ListBox();
    // NON-NLS
    composites.addItem("...");
    composites.addItem(GuidedRuleEditorResources.CONSTANTS.AllOfAnd(), CompositeFieldConstraint.COMPOSITE_TYPE_AND);
    composites.addItem(GuidedRuleEditorResources.CONSTANTS.AnyOfOr(), CompositeFieldConstraint.COMPOSITE_TYPE_OR);
    composites.setSelectedIndex(0);
    composites.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            CompositeFieldConstraint comp = new CompositeFieldConstraint();
            comp.setCompositeJunctionType(composites.getValue(composites.getSelectedIndex()));
            hasConstraints.addConstraint(comp);
            modeller.refreshWidget();
            popup.hide();
        }
    });
    InfoPopup infoComp = new InfoPopup(GuidedRuleEditorResources.CONSTANTS.MultipleFieldConstraints(), GuidedRuleEditorResources.CONSTANTS.MultipleConstraintsTip());
    HorizontalPanel horiz = new HorizontalPanel();
    horiz.add(composites);
    horiz.add(infoComp);
    popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.MultipleFieldConstraint(), horiz);
    // Include Expression Editor
    popup.addRow(new SmallLabel("<i>" + GuidedRuleEditorResources.CONSTANTS.AdvancedOptionsColon() + "</i>"));
    Button predicate = new Button(GuidedRuleEditorResources.CONSTANTS.NewFormula());
    predicate.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            SingleFieldConstraint con = new SingleFieldConstraint();
            con.setConstraintValueType(SingleFieldConstraint.TYPE_PREDICATE);
            hasConstraints.addConstraint(con);
            modeller.refreshWidget();
            popup.hide();
        }
    });
    popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.AddANewFormulaStyleExpression(), predicate);
    final Button expressionEditorButton = makeExpressionEditorButton(hasConstraints, popup);
    popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.ExpressionEditor(), expressionEditorButton);
    popup.show();
}
Also used : SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) CompositeFieldConstraint(org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ModelField(org.kie.soup.project.datamodel.oracle.ModelField) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) Button(org.gwtbootstrap3.client.ui.Button) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup) InfoPopup(org.uberfire.ext.widgets.common.client.common.InfoPopup) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Example 15 with SmallLabel

use of org.uberfire.ext.widgets.common.client.common.SmallLabel in project drools-wb by kiegroup.

the class FactPatternWidget method operatorDropDown.

private Widget operatorDropDown(final SingleFieldConstraint constraint, final FlexTable inner, final int rowIndex, final int colIndex) {
    final HorizontalPanel dropdownContainer = new HorizontalPanel();
    if (!this.readOnly) {
        final SingleFieldConstraintOperatorSelector operatorSelectorBuilder = GWT.create(SingleFieldConstraintOperatorSelector.class);
        operatorSelectorBuilder.configure(constraint, () -> constraintValueEditor, this::createValueEditor, this, dropdownContainer, inner, rowIndex, colIndex, getConnectives().getDataModelOracle());
    } else {
        final SmallLabel sl = new SmallLabel("<b>" + (constraint.getOperator() == null ? GuidedRuleEditorResources.CONSTANTS.pleaseChoose() : HumanReadable.getOperatorDisplayName(constraint.getOperator())) + "</b>");
        dropdownContainer.add(sl);
    }
    return dropdownContainer;
}
Also used : SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) SingleFieldConstraintOperatorSelector(org.drools.workbench.screens.guided.rule.client.widget.operator.SingleFieldConstraintOperatorSelector)

Aggregations

SmallLabel (org.uberfire.ext.widgets.common.client.common.SmallLabel)32 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)13 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)13 Button (org.gwtbootstrap3.client.ui.Button)12 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)9 HTML (com.google.gwt.user.client.ui.HTML)8 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)7 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)7 Image (com.google.gwt.user.client.ui.Image)7 FormStylePopup (org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup)7 ListBox (org.gwtbootstrap3.client.ui.ListBox)6 ValueChangeEvent (com.google.gwt.event.logical.shared.ValueChangeEvent)5 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)5 TextBox (org.gwtbootstrap3.client.ui.TextBox)5 InfoPopup (org.uberfire.ext.widgets.common.client.common.InfoPopup)5 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)4 Widget (com.google.gwt.user.client.ui.Widget)3 CompositeFieldConstraint (org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint)3 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)3 ClickableLabel (org.uberfire.ext.widgets.common.client.common.ClickableLabel)3