Search in sources :

Example 51 with ListBox

use of org.gwtbootstrap3.client.ui.ListBox in project drools-wb by kiegroup.

the class FromCollectCompositeFactPatternWidget method showFactTypeSelector.

@Override
protected void showFactTypeSelector() {
    final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorResources.CONSTANTS.NewFactPattern());
    popup.setTitle(GuidedRuleEditorResources.CONSTANTS.NewFactPattern());
    final ListBox box = GWT.create(ListBox.class);
    box.addItem(GuidedRuleEditorResources.CONSTANTS.Choose());
    for (Map.Entry<String, String> entry : this.getExtraLeftSidePatternFactTypes().entrySet()) {
        box.addItem(entry.getKey(), entry.getValue());
    }
    box.setSelectedIndex(0);
    box.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            pattern.setFactPattern(new FactPattern(box.getValue(box.getSelectedIndex())));
            setModified(true);
            getModeller().refreshWidget();
            popup.hide();
        }
    });
    popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.chooseFactType(), box);
    popup.show();
}
Also used : 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) HashMap(java.util.HashMap) Map(java.util.Map)

Example 52 with ListBox

use of org.gwtbootstrap3.client.ui.ListBox in project drools-wb by kiegroup.

the class FromCollectCompositeFactPatternWidget method showRightPatternSelector.

/**
 * Pops up the fact selector.
 */
protected void showRightPatternSelector(final Widget w) {
    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) {
            getFromCollectPattern().setRightPattern(new FactPattern(box.getItemText(box.getSelectedIndex())));
            setModified(true);
            getModeller().refreshWidget();
            popup.hide();
        }
    });
    final Button freeFormDRLBtn = new Button(GuidedRuleEditorResources.CONSTANTS.FreeFormDrl());
    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) {
                getFromCollectPattern().setRightPattern(new FromCompositeFactPattern());
            } else if (sender == fromAccumulateBtn) {
                getFromCollectPattern().setRightPattern(new FromAccumulateCompositeFactPattern());
            } else if (sender == fromCollectBtn) {
                getFromCollectPattern().setRightPattern(new FromCollectCompositeFactPattern());
            } else if (sender == freeFormDRLBtn) {
                getFromCollectPattern().setRightPattern(new FreeFormLine());
            } else if (sender == fromEntryPointBtn) {
                getFromCollectPattern().setRightPattern(new FromEntryPointFactPattern());
            } else {
                throw new IllegalArgumentException("Unknown sender: " + sender);
            }
            setModified(true);
            getModeller().refreshWidget();
            popup.hide();
        }
    };
    freeFormDRLBtn.addClickHandler(btnsClickHandler);
    fromBtn.addClickHandler(btnsClickHandler);
    fromAccumulateBtn.addClickHandler(btnsClickHandler);
    fromCollectBtn.addClickHandler(btnsClickHandler);
    fromEntryPointBtn.addClickHandler(btnsClickHandler);
    popup.addAttribute("", freeFormDRLBtn);
    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) FreeFormLine(org.drools.workbench.models.datamodel.rule.FreeFormLine) 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 53 with ListBox

use of org.gwtbootstrap3.client.ui.ListBox in project drools-wb by kiegroup.

the class RuleModellerActionSelectorPopup method makeChoicesListBox.

private ListBox makeChoicesListBox(final String filter) {
    choices = GWT.create(ListBox.class);
    choices.setMultipleSelect(true);
    choices.setPixelSize(getChoicesWidth(), getChoicesHeight());
    choices.addKeyUpHandler(new KeyUpHandler() {

        public void onKeyUp(com.google.gwt.event.dom.client.KeyUpEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                selectSomething();
            }
        }
    });
    final Predicate<String> predicate = (item) -> item.toLowerCase().contains(Objects.isNull(filter) ? "" : filter.toLowerCase());
    boolean itemsAdded = addDSLSentences(predicate);
    if (!onlyShowDSLStatements) {
        itemsAdded = addUpdateNotModify(itemsAdded) || itemsAdded;
        itemsAdded = addGlobals(itemsAdded) || itemsAdded;
        itemsAdded = addRetractions(itemsAdded) || itemsAdded;
        itemsAdded = addModifies(itemsAdded) || itemsAdded;
        itemsAdded = addInsertions(predicate, itemsAdded) || itemsAdded;
        itemsAdded = addLogicalInsertions(predicate, itemsAdded) || itemsAdded;
        itemsAdded = addGlobalCollections(itemsAdded) || itemsAdded;
        itemsAdded = addFreeFormDRL(itemsAdded) || itemsAdded;
        itemsAdded = addCallMethodOn(itemsAdded) || itemsAdded;
        addCustomActionPlugins(itemsAdded);
    }
    return choices;
}
Also used : ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) GuidedRuleEditorResources(org.drools.workbench.screens.guided.rule.client.resources.GuidedRuleEditorResources) RuleModellerActionPlugin(org.drools.workbench.screens.guided.rule.client.editor.plugin.RuleModellerActionPlugin) ListBox(org.gwtbootstrap3.client.ui.ListBox) GWT(com.google.gwt.core.client.GWT) HTML(com.google.gwt.user.client.ui.HTML) Command(com.google.gwt.user.client.Command) ModalFooterOKCancelButtons(org.uberfire.ext.widgets.common.client.common.popups.footers.ModalFooterOKCancelButtons) ModalBody(org.gwtbootstrap3.client.ui.ModalBody) CheckBox(org.gwtbootstrap3.client.ui.CheckBox) InfoPopup(org.uberfire.ext.widgets.common.client.common.InfoPopup) FreeFormLine(org.drools.workbench.models.datamodel.rule.FreeFormLine) DSLSentence(org.drools.workbench.models.datamodel.rule.DSLSentence) IAction(org.drools.workbench.models.datamodel.rule.IAction) Iterator(java.util.Iterator) Predicate(java.util.function.Predicate) ActionInsertFact(org.drools.workbench.models.datamodel.rule.ActionInsertFact) Collection(java.util.Collection) KeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler) AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) ActionInsertLogicalFact(org.drools.workbench.models.datamodel.rule.ActionInsertLogicalFact) ActionUpdateField(org.drools.workbench.models.datamodel.rule.ActionUpdateField) Objects(java.util.Objects) List(java.util.List) Widget(com.google.gwt.user.client.ui.Widget) ActionSetField(org.drools.workbench.models.datamodel.rule.ActionSetField) KeyCodes(com.google.gwt.event.dom.client.KeyCodes) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) ActionRetractFact(org.drools.workbench.models.datamodel.rule.ActionRetractFact) ActionGlobalCollectionAdd(org.drools.workbench.models.datamodel.rule.ActionGlobalCollectionAdd) ActionCallMethod(org.drools.workbench.models.datamodel.rule.ActionCallMethod) KeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Example 54 with ListBox

use of org.gwtbootstrap3.client.ui.ListBox in project drools-wb by kiegroup.

the class ActionValueEditor method boundVariable.

private Widget boundVariable() {
    // If there is a bound variable that is the same type of the current variable type, then display a list
    ListBox listVariable = new ListBox();
    listVariable.addItem(GuidedRuleEditorResources.CONSTANTS.Choose());
    List<String> bindings = getApplicableBindings();
    for (String v : bindings) {
        listVariable.addItem(v);
    }
    // Pre-select applicable item
    if (value.getValue().equals("=")) {
        listVariable.setSelectedIndex(0);
    } else {
        for (int i = 0; i < listVariable.getItemCount(); i++) {
            if (listVariable.getItemText(i).equals(value.getValue().substring(1))) {
                listVariable.setSelectedIndex(i);
            }
        }
    }
    // Add event handler
    if (listVariable.getItemCount() > 0) {
        listVariable.addChangeHandler(new ChangeHandler() {

            public void onChange(ChangeEvent event) {
                ListBox w = (ListBox) event.getSource();
                value.setValue("=" + w.getValue(w.getSelectedIndex()));
                executeOnChangeCommand();
                refresh();
            }
        });
    }
    if (this.readOnly) {
        return new SmallLabel(listVariable.getItemText(listVariable.getSelectedIndex()));
    }
    return listVariable;
}
Also used : SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) ListBox(org.gwtbootstrap3.client.ui.ListBox) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) FieldConstraint(org.drools.workbench.models.datamodel.rule.FieldConstraint)

Example 55 with ListBox

use of org.gwtbootstrap3.client.ui.ListBox in project drools-wb by kiegroup.

the class CEPOperatorsDropdown method getDropDown.

// Actual drop-down
private Widget getDropDown() {
    String selected = "";
    String selectedText = "";
    box = new ListBox();
    for (int i = 0; i < operators.length; i++) {
        String op = operators[i];
        box.addItem(HumanReadable.getOperatorDisplayName(op), op);
        if (op.equals(hop.getOperator())) {
            selected = op;
            selectedText = HumanReadable.getOperatorDisplayName(op);
            box.setSelectedIndex(i);
        }
    }
    // Fire event to ensure parent Widgets correct their state depending on selection
    final HasValueChangeHandlers<OperatorSelection> source = this;
    final OperatorSelection selection = new OperatorSelection(selected, selectedText);
    Scheduler.get().scheduleFinally(new Command() {

        public void execute() {
            operatorChanged(selection);
            ValueChangeEvent.fire(source, selection);
        }
    });
    // Signal parent Widget whenever a change happens
    box.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            String selected = box.getValue(box.getSelectedIndex());
            String selectedText = box.getItemText(box.getSelectedIndex());
            OperatorSelection selection = new OperatorSelection(selected, selectedText);
            operatorChanged(selection);
            ValueChangeEvent.fire(source, selection);
        }
    });
    return box;
}
Also used : ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) Command(com.google.gwt.user.client.Command) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Aggregations

ListBox (org.gwtbootstrap3.client.ui.ListBox)61 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)31 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)30 ValueChangeEvent (com.google.gwt.event.logical.shared.ValueChangeEvent)15 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)15 FormStylePopup (org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup)12 Widget (com.google.gwt.user.client.ui.Widget)11 Test (org.junit.Test)11 Button (org.gwtbootstrap3.client.ui.Button)10 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)10 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)9 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)9 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)7 FromCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern)7 TextBox (org.gwtbootstrap3.client.ui.TextBox)7 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)6 IsWidget (com.google.gwt.user.client.ui.IsWidget)6 FromAccumulateCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern)6 FromCollectCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern)6 DropDownData (org.kie.soup.project.datamodel.oracle.DropDownData)6