Search in sources :

Example 6 with ClickableLabel

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

the class FromCompositeFactPatternWidget method getCompositeLabel.

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

        public void onClick(ClickEvent event) {
            showFactTypeSelector();
        }
    };
    String lbl = "<div class='form-field'>" + HumanReadable.getCEDisplayName("from") + "&nbsp;</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));
    ExpressionBuilder expressionBuilder = new ExpressionBuilder(this.getModeller(), this.getEventBus(), this.pattern.getExpression(), this.readOnly);
    expressionBuilder.addOnModifiedCommand(new Command() {

        public void execute() {
            setModified(true);
        }
    });
    panel.setWidget(r, 1, expressionBuilder);
    return panel;
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) Command(com.google.gwt.user.client.Command) 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)

Example 7 with ClickableLabel

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

the class FactPatternWidget method fieldLabel.

/**
 * get the field widget. This may be a simple label, or it may be bound (and
 * show the var name) or a icon to create a binding. It will only show the
 * binding option of showBinding is true.
 */
private Widget fieldLabel(final SingleFieldConstraint con, final HasConstraints hasConstraints, final boolean showBinding, final int padding) {
    HorizontalPanel ab = new HorizontalPanel();
    ab.setStyleName("modeller-field-Label");
    StringBuilder bindingLabel = new StringBuilder();
    if (con.isBound()) {
        bindingLabel.append("<b>[");
        bindingLabel.append(con.getFieldBinding());
        bindingLabel.append("]</b>&nbsp;");
    }
    String fieldName = con.getFieldName();
    bindingLabel.append(fieldName);
    if (bindable && showBinding && !this.readOnly) {
        ClickHandler click = new ClickHandler() {

            public void onClick(final ClickEvent event) {
                // If field name is "this" use parent FactPattern type otherwise we can use the Constraint's field type
                String fieldName = con.getFieldName();
                if (DataType.TYPE_THIS.equals(fieldName)) {
                    getConnectives().getDataModelOracle().getFieldCompletions(pattern.getFactType(), new Callback<ModelField[]>() {

                        @Override
                        public void callback(final ModelField[] fields) {
                            popupCreator.showBindFieldPopup(pattern, con, fields, popupCreator);
                        }
                    });
                } else {
                    getConnectives().getDataModelOracle().getFieldCompletions(con.getFieldType(), new Callback<ModelField[]>() {

                        @Override
                        public void callback(final ModelField[] fields) {
                            popupCreator.showBindFieldPopup(pattern, con, fields, popupCreator);
                        }
                    });
                }
            }
        };
        ClickableLabel cl = new ClickableLabel(bindingLabel.toString(), click, !this.readOnly);
        DOM.setStyleAttribute(cl.getElement(), "marginLeft", "" + padding + "pt");
        ab.add(cl);
    } else {
        ab.add(new SmallLabel(bindingLabel.toString()));
    }
    return ab;
}
Also used : SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ModelField(org.kie.soup.project.datamodel.oracle.ModelField) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) ClickableLabel(org.uberfire.ext.widgets.common.client.common.ClickableLabel)

Example 8 with ClickableLabel

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

the class FromCollectCompositeFactPatternWidget method getCompositeLabel.

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

        public void onClick(ClickEvent event) {
            showFactTypeSelector();
        }
    };
    ClickHandler rightPatternclick = new ClickHandler() {

        public void onClick(ClickEvent event) {
            Widget w = (Widget) event.getSource();
            showRightPatternSelector(w);
        }
    };
    String lbl = "<div class='form-field'>" + HumanReadable.getCEDisplayName("from collect") + "</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>", leftPatternclick, !this.readOnly));
    }
    panel.setWidget(r++, 0, new HTML(lbl));
    if (this.getFromCollectPattern().getRightPattern() == null) {
        panel.setWidget(r++, 0, new ClickableLabel("<br> <font color='red'>" + GuidedRuleEditorResources.CONSTANTS.clickToAddPatterns() + "</font>", rightPatternclick, !this.readOnly));
    } else {
        IPattern rPattern = this.getFromCollectPattern().getRightPattern();
        RuleModellerWidget patternWidget = null;
        if (rPattern instanceof FactPattern) {
            patternWidget = new FactPatternWidget(this.getModeller(), this.getEventBus(), rPattern, true, true, this.readOnly);
        } else if (rPattern instanceof FromAccumulateCompositeFactPattern) {
            patternWidget = new FromAccumulateCompositeFactPatternWidget(this.getModeller(), this.getEventBus(), (FromAccumulateCompositeFactPattern) rPattern, this.readOnly);
        } else if (rPattern instanceof FromCollectCompositeFactPattern) {
            patternWidget = new FromCollectCompositeFactPatternWidget(this.getModeller(), this.getEventBus(), (FromCollectCompositeFactPattern) rPattern, this.readOnly);
        } else if (rPattern instanceof FromEntryPointFactPattern) {
            patternWidget = new FromEntryPointFactPatternWidget(this.getModeller(), this.getEventBus(), (FromEntryPointFactPattern) rPattern, this.readOnly);
        } else if (rPattern instanceof FromCompositeFactPattern) {
            patternWidget = new FromCompositeFactPatternWidget(this.getModeller(), this.getEventBus(), (FromCompositeFactPattern) rPattern, this.readOnly);
        } else if (rPattern instanceof FreeFormLine) {
            patternWidget = new FreeFormLineWidget(this.getModeller(), this.getEventBus(), (FreeFormLine) rPattern, this.readOnly);
        } else {
            throw new IllegalArgumentException("Unsupported pattern " + rPattern + " for right side of FROM COLLECT");
        }
        patternWidget.addOnModifiedCommand(new Command() {

            public void execute() {
                setModified(true);
            }
        });
        panel.setWidget(r++, 0, addRemoveButton(patternWidget, new ClickHandler() {

            public void onClick(ClickEvent event) {
                if (Window.confirm(GuidedRuleEditorResources.CONSTANTS.RemoveThisBlockOfData())) {
                    setModified(true);
                    getFromCollectPattern().setRightPattern(null);
                    getModeller().refreshWidget();
                }
            }
        }));
    }
    return panel;
}
Also used : IPattern(org.drools.workbench.models.datamodel.rule.IPattern) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FromEntryPointFactPattern(org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern) Widget(com.google.gwt.user.client.ui.Widget) FlexTable(com.google.gwt.user.client.ui.FlexTable) FromEntryPointFactPattern(org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) FromAccumulateCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern) FromCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) HTML(com.google.gwt.user.client.ui.HTML) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) FreeFormLine(org.drools.workbench.models.datamodel.rule.FreeFormLine) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) FromCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern) Command(com.google.gwt.user.client.Command) FromAccumulateCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern) ClickableLabel(org.uberfire.ext.widgets.common.client.common.ClickableLabel)

Example 9 with ClickableLabel

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

the class CompositeFactPatternWidget method getCompositeLabel.

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

        public void onClick(ClickEvent event) {
            Widget w = (Widget) event.getSource();
            showFactTypeSelector(w);
        }
    };
    String lbl = HumanReadable.getCEDisplayName(pattern.getType());
    if (pattern.getPatterns() == null || pattern.getPatterns().length == 0) {
        lbl += " <font color='red'>" + GuidedRuleEditorResources.CONSTANTS.clickToAddPatterns() + "</font>";
    }
    return new ClickableLabel(lbl + ":", click, !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)

Example 10 with ClickableLabel

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

the class FactPatternWidget method getPatternLabel.

/**
 * This returns the pattern label.
 */
private Widget getPatternLabel(final FactPattern fp) {
    ClickHandler click = new ClickHandler() {

        public void onClick(ClickEvent event) {
            popupCreator.showPatternPopup(fp, null, false);
        }
    };
    String patternName = (pattern.isBound()) ? pattern.getFactType() + " <b>[" + pattern.getBoundName() + "]</b>" : pattern.getFactType();
    String desc;
    if (isAll0WithLabel) {
        desc = GuidedRuleEditorResources.CONSTANTS.All0with(patternName);
    } else {
        if (pattern.getNumberOfConstraints() > 0) {
            desc = GuidedRuleEditorResources.CONSTANTS.ThereIsAAn0With(patternName);
        } else {
            desc = GuidedRuleEditorResources.CONSTANTS.ThereIsAAn0(patternName);
        }
        desc = anA(desc, patternName);
    }
    return new ClickableLabel(desc, click, !this.readOnly);
}
Also used : 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)

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