Search in sources :

Example 1 with ClickableLabel

use of org.uberfire.ext.widgets.common.client.common.ClickableLabel 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 2 with ClickableLabel

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

the class ActionInsertFactWidget method getAssertLabel.

private Widget getAssertLabel() {
    ClickHandler cl = new ClickHandler() {

        public void onClick(ClickEvent event) {
            Widget w = (Widget) event.getSource();
            showAddFieldPopup(w);
        }
    };
    // NON-NLS
    String assertType = "assert";
    if (this.model instanceof ActionInsertLogicalFact) {
        // NON-NLS
        assertType = "assertLogical";
    }
    String lbl = (model.isBound() == false) ? HumanReadable.getActionDisplayName(assertType) + " <b>" + this.model.getFactType() + "</b>" : HumanReadable.getActionDisplayName(assertType) + " <b>" + this.model.getFactType() + "</b>" + " <b>[" + model.getBoundName() + "]</b>";
    if (this.model.getFieldValues() != null && model.getFieldValues().length > 0) {
        lbl = lbl + ":";
    }
    return new ClickableLabel(lbl, cl, !this.readOnly);
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Widget(com.google.gwt.user.client.ui.Widget) ClickableLabel(org.uberfire.ext.widgets.common.client.common.ClickableLabel) ActionInsertLogicalFact(org.drools.workbench.models.datamodel.rule.ActionInsertLogicalFact)

Example 3 with ClickableLabel

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

the class ActionSetFieldWidget method getSetterLabel.

private Widget getSetterLabel() {
    ClickHandler clk = new ClickHandler() {

        public void onClick(ClickEvent event) {
            // Widget w = (Widget)event.getSource();
            showAddFieldPopup(event);
        }
    };
    String modifyType = "set";
    if (this.model instanceof ActionUpdateField) {
        modifyType = "modify";
    }
    String type = this.getModeller().getModel().getLHSBindingType(model.getVariable());
    String descFact = (type != null) ? type + " <b>[" + model.getVariable() + "]</b>" : model.getVariable();
    String sl = GuidedRuleEditorResources.CONSTANTS.setterLabel(HumanReadable.getActionDisplayName(modifyType), descFact);
    return new ClickableLabel(sl, clk, // HumanReadable.getActionDisplayName(modifyType) + " value of <b>[" + model.variable + "]</b>", clk);
    !this.readOnly);
}
Also used : ActionUpdateField(org.drools.workbench.models.datamodel.rule.ActionUpdateField) 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)

Example 4 with ClickableLabel

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

the class FromEntryPointFactPatternWidget method getCompositeLabel.

@Override
protected Widget getCompositeLabel() {
    ClickHandler click = new ClickHandler() {

        public void onClick(ClickEvent event) {
            showFactTypeSelector();
        }
    };
    String lbl = "<div class='form-field'>" + HumanReadable.getCEDisplayName("from entry-point") + "</div>";
    FlexTable panel = new FlexTable();
    int r = 0;
    if (pattern.getFactPattern() == null) {
        panel.setWidget(r, 0, new ClickableLabel("<br> <font color='red'>" + GuidedRuleEditorResources.CONSTANTS.clickToAddPatterns() + "</font>", click, !this.readOnly));
        r++;
    }
    panel.setWidget(r, 0, new HTML(lbl));
    this.txtEntryPoint = new TextBox();
    this.txtEntryPoint.setText(getFromEntryPointPattern().getEntryPointName());
    this.txtEntryPoint.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            getFromEntryPointPattern().setEntryPointName(txtEntryPoint.getText());
            setModified(true);
        }
    });
    panel.setWidget(r, 1, this.txtEntryPoint);
    return panel;
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FlexTable(com.google.gwt.user.client.ui.FlexTable) ClickableLabel(org.uberfire.ext.widgets.common.client.common.ClickableLabel) HTML(com.google.gwt.user.client.ui.HTML) TextBox(org.gwtbootstrap3.client.ui.TextBox)

Example 5 with ClickableLabel

use of org.uberfire.ext.widgets.common.client.common.ClickableLabel 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 = null;
    ClickHandler click = new ClickHandler() {

        public void onClick(ClickEvent 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(new ClickHandler() {

                public void onClick(ClickEvent 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);
            }
        }
    }
    t.setWidget(1, 1, inner);
    t.setWidget(1, 0, new HTML("&nbsp;&nbsp;&nbsp;&nbsp;"));
    return t;
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FlexTable(com.google.gwt.user.client.ui.FlexTable) ClickableLabel(org.uberfire.ext.widgets.common.client.common.ClickableLabel) 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) CompositeFieldConstraint(org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint) FieldConstraint(org.drools.workbench.models.datamodel.rule.FieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)

Aggregations

ClickableLabel (org.uberfire.ext.widgets.common.client.common.ClickableLabel)13 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)11 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)11 FlexTable (com.google.gwt.user.client.ui.FlexTable)5 HTML (com.google.gwt.user.client.ui.HTML)5 Widget (com.google.gwt.user.client.ui.Widget)4 Command (com.google.gwt.user.client.Command)3 SmallLabel (org.uberfire.ext.widgets.common.client.common.SmallLabel)3 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)2 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)2 Image (com.google.gwt.user.client.ui.Image)2 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)2 FromAccumulateCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern)2 FromCollectCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern)2 FromCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern)2 FromEntryPointFactPattern (org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern)2 IPattern (org.drools.workbench.models.datamodel.rule.IPattern)2 FactData (org.drools.workbench.models.testscenarios.shared.FactData)2 TextBox (org.gwtbootstrap3.client.ui.TextBox)2 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)1