Search in sources :

Example 1 with OperatorSelection

use of org.drools.workbench.screens.guided.rule.client.editor.OperatorSelection in project drools-wb by kiegroup.

the class FactPatternWidget method createCEPWindowWidget.

// Widget for CEP 'windows'
private Widget createCEPWindowWidget(final RuleModeller modeller, final HasCEPWindow c) {
    final HorizontalPanel hp = new HorizontalPanel();
    modeller.getDataModelOracle().isFactTypeAnEvent(pattern.getFactType(), new Callback<Boolean>() {

        @Override
        public void callback(final Boolean result) {
            if (Boolean.TRUE.equals(result)) {
                final Label lbl = new Label(HumanReadableConstants.INSTANCE.OverCEPWindow());
                lbl.setStyleName("paddedLabel");
                hp.add(lbl);
                final CEPWindowOperatorsDropdown cwo = new CEPWindowOperatorsDropdown(c, readOnly);
                if (!isReadOnly()) {
                    cwo.addValueChangeHandler(new ValueChangeHandler<OperatorSelection>() {

                        public void onValueChange(ValueChangeEvent<OperatorSelection> event) {
                            setModified(true);
                            OperatorSelection selection = event.getValue();
                            String selected = selection.getValue();
                            c.getWindow().setOperator(selected);
                        }
                    });
                }
                hp.add(cwo);
            }
        }
    });
    return hp;
}
Also used : CEPWindowOperatorsDropdown(org.drools.workbench.screens.guided.rule.client.editor.CEPWindowOperatorsDropdown) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) OperatorSelection(org.drools.workbench.screens.guided.rule.client.editor.OperatorSelection) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) Label(com.google.gwt.user.client.ui.Label) ClickableLabel(org.uberfire.ext.widgets.common.client.common.ClickableLabel) SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler)

Example 2 with OperatorSelection

use of org.drools.workbench.screens.guided.rule.client.editor.OperatorSelection in project drools-wb by kiegroup.

the class Connectives method connectiveOperatorDropDown.

private void connectiveOperatorDropDown(final ConnectiveConstraint cc, final Callback<Widget> callback) {
    if (!isReadOnly) {
        final String factType = cc.getFactType();
        final String fieldName = cc.getFieldName();
        this.getDataModelOracle().getConnectiveOperatorCompletions(factType, fieldName, new Callback<String[]>() {

            @Override
            public void callback(final String[] operators) {
                final CEPOperatorsDropdown dropdown = getDropdown(operators, cc);
                dropdown.addPlaceholder(GuidedRuleEditorResources.CONSTANTS.pleaseChoose(), "");
                dropdown.addValueChangeHandler(new ValueChangeHandler<OperatorSelection>() {

                    public void onValueChange(ValueChangeEvent<OperatorSelection> event) {
                        OperatorSelection selection = event.getValue();
                        String selected = selection.getValue();
                        cc.setOperator(selected);
                    }
                });
                callback.callback(dropdown);
            }
        });
    } else {
        final SmallLabel w = new SmallLabel("<b>" + (cc.getOperator() == null ? GuidedRuleEditorResources.CONSTANTS.pleaseChoose() : HumanReadable.getOperatorDisplayName(cc.getOperator())) + "</b>");
        callback.callback(w);
    }
}
Also used : SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) OperatorSelection(org.drools.workbench.screens.guided.rule.client.editor.OperatorSelection) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) CEPOperatorsDropdown(org.drools.workbench.screens.guided.rule.client.editor.CEPOperatorsDropdown)

Aggregations

ValueChangeEvent (com.google.gwt.event.logical.shared.ValueChangeEvent)2 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)2 OperatorSelection (org.drools.workbench.screens.guided.rule.client.editor.OperatorSelection)2 SmallLabel (org.uberfire.ext.widgets.common.client.common.SmallLabel)2 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)1 Label (com.google.gwt.user.client.ui.Label)1 CEPOperatorsDropdown (org.drools.workbench.screens.guided.rule.client.editor.CEPOperatorsDropdown)1 CEPWindowOperatorsDropdown (org.drools.workbench.screens.guided.rule.client.editor.CEPWindowOperatorsDropdown)1 ClickableLabel (org.uberfire.ext.widgets.common.client.common.ClickableLabel)1