Search in sources :

Example 11 with FormStylePopup

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

the class FromCompositeFactPatternWidget method showFactTypeSelector.

/**
 * Pops up the fact selector.
 */
protected void showFactTypeSelector() {
    AsyncPackageDataModelOracle oracle = this.getModeller().getDataModelOracle();
    final ListBox box = new ListBox();
    String[] facts = oracle.getFactTypes();
    box.addItem(GuidedRuleEditorResources.CONSTANTS.Choose());
    for (int i = 0; i < facts.length; i++) {
        box.addItem(facts[i]);
    }
    box.setSelectedIndex(0);
    final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorResources.CONSTANTS.NewFactPattern());
    popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.chooseFactType(), box);
    box.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            pattern.setFactPattern(new FactPattern(box.getItemText(box.getSelectedIndex())));
            setModified(true);
            getModeller().refreshWidget();
            popup.hide();
        }
    });
    popup.show();
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup) FromCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Example 12 with FormStylePopup

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

the class PopupCreatorTest method testOnExpressionEditorButtonClick.

@Test
public void testOnExpressionEditorButtonClick() {
    final String factType = "factType";
    final FactPattern factPattern = mock(FactPattern.class);
    final HasConstraints hasConstraints = mock(HasConstraints.class);
    final FormStylePopup popup = mock(FormStylePopup.class);
    final SingleFieldConstraintEBLeftSide constraint = mock(SingleFieldConstraintEBLeftSide.class);
    final RuleModeller ruleModeller = mock(RuleModeller.class);
    final ClickEvent clickEvent = mock(ClickEvent.class);
    doReturn(factType).when(factPattern).getFactType();
    doReturn(constraint).when(popupCreator).makeSingleFieldConstraintEBLeftSide(factType);
    doReturn(ruleModeller).when(popupCreator).getModeller();
    doReturn(factPattern).when(popupCreator).getPattern();
    final ClickHandler clickHandler = popupCreator.onExpressionEditorButtonClick(hasConstraints, popup);
    clickHandler.onClick(clickEvent);
    verify(hasConstraints).addConstraint(constraint);
    verify(ruleModeller).refreshWidget();
    verify(popup).hide();
}
Also used : SingleFieldConstraintEBLeftSide(org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide) RuleModeller(org.drools.workbench.screens.guided.rule.client.editor.RuleModeller) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) HasConstraints(org.drools.workbench.models.datamodel.rule.HasConstraints) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup) Test(org.junit.Test)

Example 13 with FormStylePopup

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

the class FromAccumulateCompositeFactPatternWidget method showSourcePatternSelector.

/**
 * Pops up the fact selector.
 */
protected void showSourcePatternSelector() {
    final ListBox box = new ListBox();
    AsyncPackageDataModelOracle oracle = this.getModeller().getDataModelOracle();
    String[] facts = oracle.getFactTypes();
    box.addItem(GuidedRuleEditorResources.CONSTANTS.Choose());
    for (int i = 0; i < facts.length; i++) {
        box.addItem(facts[i]);
    }
    box.setSelectedIndex(0);
    final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorResources.CONSTANTS.NewFactPattern());
    popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.chooseFactType(), box);
    box.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            getFromAccumulatePattern().setSourcePattern(new FactPattern(box.getItemText(box.getSelectedIndex())));
            setModified(true);
            getModeller().refreshWidget();
            popup.hide();
        }
    });
    final Button fromBtn = new Button(HumanReadableConstants.INSTANCE.From());
    final Button fromAccumulateBtn = new Button(HumanReadableConstants.INSTANCE.FromAccumulate());
    final Button fromCollectBtn = new Button(HumanReadableConstants.INSTANCE.FromCollect());
    final Button fromEntryPointBtn = new Button(HumanReadableConstants.INSTANCE.FromEntryPoint());
    ClickHandler btnsClickHandler = new ClickHandler() {

        public void onClick(ClickEvent event) {
            Widget sender = (Widget) event.getSource();
            if (sender == fromBtn) {
                getFromAccumulatePattern().setSourcePattern(new FromCompositeFactPattern());
            } else if (sender == fromAccumulateBtn) {
                getFromAccumulatePattern().setSourcePattern(new FromAccumulateCompositeFactPattern());
            } else if (sender == fromCollectBtn) {
                getFromAccumulatePattern().setSourcePattern(new FromCollectCompositeFactPattern());
            } else if (sender == fromEntryPointBtn) {
                getFromAccumulatePattern().setSourcePattern(new FromEntryPointFactPattern());
            } else {
                throw new IllegalArgumentException("Unknown sender: " + sender);
            }
            setModified(true);
            getModeller().refreshWidget();
            popup.hide();
        }
    };
    fromBtn.addClickHandler(btnsClickHandler);
    fromAccumulateBtn.addClickHandler(btnsClickHandler);
    fromCollectBtn.addClickHandler(btnsClickHandler);
    fromEntryPointBtn.addClickHandler(btnsClickHandler);
    popup.addAttribute("", fromBtn);
    popup.addAttribute("", fromAccumulateBtn);
    popup.addAttribute("", fromCollectBtn);
    popup.addAttribute("", fromEntryPointBtn);
    popup.show();
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FromEntryPointFactPattern(org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern) Widget(com.google.gwt.user.client.ui.Widget) 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) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) FromCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) Button(org.gwtbootstrap3.client.ui.Button) FromAccumulateCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Example 14 with FormStylePopup

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

the class FromAccumulateCompositeFactPatternWidget method showFactTypeSelector.

/**
 * Pops up the fact selector.
 */
@Override
protected void showFactTypeSelector() {
    final ListBox box = GWT.create(ListBox.class);
    AsyncPackageDataModelOracle oracle = this.getModeller().getDataModelOracle();
    String[] facts = oracle.getFactTypes();
    box.addItem(GuidedRuleEditorResources.CONSTANTS.Choose());
    for (int i = 0; i < facts.length; i++) {
        box.addItem(facts[i]);
    }
    box.setSelectedIndex(0);
    final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorResources.CONSTANTS.NewFactPattern());
    popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.chooseFactType(), box);
    box.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            pattern.setFactPattern(new FactPattern(box.getItemText(box.getSelectedIndex())));
            setModified(true);
            getModeller().refreshWidget();
            popup.hide();
        }
    });
    popup.show();
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup) 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) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Example 15 with FormStylePopup

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

the class ActionValueEditor method showTypeChoice.

protected void showTypeChoice() {
    final FormStylePopup form = new FormStylePopup(GuidedRuleEditorImages508.INSTANCE.Wizard(), GuidedRuleEditorResources.CONSTANTS.FieldValue());
    Button lit = new Button(GuidedRuleEditorResources.CONSTANTS.LiteralValue());
    lit.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            value.setNature(FieldNatureType.TYPE_LITERAL);
            value.setValue("");
            doTypeChosen(form);
        }
    });
    form.addAttributeWithHelp(GuidedRuleEditorResources.CONSTANTS.LiteralValue(), GuidedRuleEditorResources.CONSTANTS.Literal(), GuidedRuleEditorResources.CONSTANTS.ALiteralValueMeansTheValueAsTypedInIeItsNotACalculation(), lit);
    if (modeller.isTemplate()) {
        Button templateButton = new Button(GuidedRuleEditorResources.CONSTANTS.TemplateKey());
        templateButton.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                value.setNature(FieldNatureType.TYPE_TEMPLATE);
                value.setValue("");
                doTypeChosen(form);
            }
        });
        form.addAttributeWithHelp(GuidedRuleEditorResources.CONSTANTS.TemplateKey(), GuidedRuleEditorResources.CONSTANTS.TemplateKey(), GuidedRuleEditorResources.CONSTANTS.TemplateKeyTip(), templateButton);
    }
    form.addRow(new HTML("<hr/>"));
    form.addRow(new SmallLabel(GuidedRuleEditorResources.CONSTANTS.AdvancedSection()));
    Button formula = new Button(GuidedRuleEditorResources.CONSTANTS.Formula());
    formula.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            value.setNature(FieldNatureType.TYPE_FORMULA);
            doTypeChosen(form);
        }
    });
    // If there is a bound Facts or Fields that are of the same type as the current variable type, then show a button
    List<String> bindings = getApplicableBindings();
    if (bindings.size() > 0) {
        Button variable = new Button(GuidedRuleEditorResources.CONSTANTS.BoundVariable());
        form.addAttribute(GuidedRuleEditorResources.CONSTANTS.BoundVariable() + ":", variable);
        variable.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                value.setNature(FieldNatureType.TYPE_VARIABLE);
                value.setValue("=");
                doTypeChosen(form);
            }
        });
    }
    form.addAttributeWithHelp(GuidedRuleEditorResources.CONSTANTS.Formula(), GuidedRuleEditorResources.CONSTANTS.Formula(), GuidedRuleEditorResources.CONSTANTS.FormulaTip(), formula);
    form.show();
}
Also used : SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) Button(org.gwtbootstrap3.client.ui.Button) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup) HTML(com.google.gwt.user.client.ui.HTML)

Aggregations

FormStylePopup (org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup)23 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)15 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)14 Button (org.gwtbootstrap3.client.ui.Button)14 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)12 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)12 ListBox (org.gwtbootstrap3.client.ui.ListBox)12 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)8 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)7 SmallLabel (org.uberfire.ext.widgets.common.client.common.SmallLabel)7 FromCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern)6 HTML (com.google.gwt.user.client.ui.HTML)5 FromAccumulateCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern)5 FromCollectCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern)5 InfoPopup (org.uberfire.ext.widgets.common.client.common.InfoPopup)5 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)4 Widget (com.google.gwt.user.client.ui.Widget)4 FromEntryPointFactPattern (org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern)4 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)4 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)4