Search in sources :

Example 31 with ListBox

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

the class EnumMultiSelectUiColumn method doEdit.

@Override
public void doEdit(final GridCell<String> cell, final GridBodyCellRenderContext context, final Callback<GridCellValue<String>> callback) {
    final String value = extractValue(cell);
    // We need to get the list of potential values to lookup the "Display" value from the "Stored" value.
    // Since the content of the list may be different for each cell (dependent enumerations) the list
    // has to be populated "on demand".
    presenter.getEnumLookups(this.factType, this.factField, new DependentEnumsUtilities.Context(context.getRowIndex(), context.getColumnIndex()), new Callback<Map<String, String>>() {

        @Override
        public void callback(final Map<String, String> enumLookups) {
            factory.attachDomElement(context, new Callback<ListBoxDOMElement<String, ListBox>>() {

                @Override
                public void callback(final ListBoxDOMElement<String, ListBox> e) {
                    final ListBox widget = e.getWidget();
                    for (Map.Entry<String, String> lookup : enumLookups.entrySet()) {
                        widget.addItem(lookup.getValue(), lookup.getKey());
                    }
                    final List<String> values = Arrays.asList(value.split(","));
                    for (int i = 0; i < widget.getItemCount(); i++) {
                        widget.setItemSelected(i, values.contains(widget.getValue(i)));
                    }
                    factory.toWidget(cell, widget);
                }
            }, CallbackFactory.makeOnDisplayListBoxCallback());
        }
    });
}
Also used : ListBoxDOMElement(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.dom.listbox.ListBoxDOMElement) Callback(org.uberfire.client.callbacks.Callback) DependentEnumsUtilities(org.drools.workbench.screens.guided.dtable.client.widget.table.utilities.DependentEnumsUtilities) Map(java.util.Map) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Example 32 with ListBox

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

the class RuleModellerActionSelectorPopup method makeChoicesListBox.

private ListBox makeChoicesListBox() {
    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();
            }
        }
    });
    addDSLSentences();
    if (!onlyShowDSLStatements) {
        addUpdateNotModify();
        addGlobals();
        addRetractions();
        addModifies();
        addInsertions();
        addLogicalInsertions();
        addGlobalCollections();
        addFreeFormDRL();
        addCallMethodOn();
        addCustomActionPlugins();
    }
    return choices;
}
Also used : KeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Example 33 with ListBox

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

the class EnumDropDownUtilitiesTest method testCommaSeparatedValuesWithBracketsAndMultiValue.

@Test
public void testCommaSeparatedValuesWithBracketsAndMultiValue() {
    final DropDownData downData = mock(DropDownData.class);
    doReturn(new String[] { "a", "\"b, c\"", "d" }).when(downData).getFixedList();
    final ListBox listBox = mock(ListBox.class);
    new EnumDropDownUtilities().setDropDownData(" ( \"a\",\"\"b, c\"\",\"d\" )", downData, true, mock(Path.class), listBox);
    verify(listBox).clear();
    verify(listBox).addItem("a");
    verify(listBox).addItem("\"b, c\"");
    verify(listBox).addItem("d");
    verify(listBox).setItemSelected(0, true);
    verify(listBox).setItemSelected(1, true);
    verify(listBox).setItemSelected(2, true);
}
Also used : Path(org.uberfire.backend.vfs.Path) DropDownData(org.kie.soup.project.datamodel.oracle.DropDownData) ListBox(org.gwtbootstrap3.client.ui.ListBox) Test(org.junit.Test)

Example 34 with ListBox

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

the class EnumDropDownUtilitiesTest method testCommaSeparatedValuesWithBracketsWhereFirstItemIsMultiValue.

@Test
public void testCommaSeparatedValuesWithBracketsWhereFirstItemIsMultiValue() {
    final DropDownData downData = mock(DropDownData.class);
    doReturn(new String[] { "a", "\"b, c\"", "d" }).when(downData).getFixedList();
    final ListBox listBox = mock(ListBox.class);
    new EnumDropDownUtilities().setDropDownData(" ( \"\"b, c\"\",\"d\" )", downData, true, mock(Path.class), listBox);
    verify(listBox).clear();
    verify(listBox).addItem("a");
    verify(listBox).addItem("\"b, c\"");
    verify(listBox).addItem("d");
    verify(listBox, never()).setItemSelected(0, true);
    verify(listBox).setItemSelected(1, true);
    verify(listBox).setItemSelected(2, true);
}
Also used : Path(org.uberfire.backend.vfs.Path) DropDownData(org.kie.soup.project.datamodel.oracle.DropDownData) ListBox(org.gwtbootstrap3.client.ui.ListBox) Test(org.junit.Test)

Example 35 with ListBox

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

the class EnumDropDownUtilitiesTest method testCommaSeparatedValuesWithBracketsWhereLastItemIsMultiValue.

@Test
public void testCommaSeparatedValuesWithBracketsWhereLastItemIsMultiValue() {
    final DropDownData downData = mock(DropDownData.class);
    doReturn(new String[] { "a", "\"b, c\"", "d" }).when(downData).getFixedList();
    final ListBox listBox = mock(ListBox.class);
    new EnumDropDownUtilities().setDropDownData(" ( \"a\",\"\"b, c\"\" )", downData, true, mock(Path.class), listBox);
    verify(listBox).clear();
    verify(listBox).addItem("a");
    verify(listBox).addItem("\"b, c\"");
    verify(listBox).addItem("d");
    verify(listBox).setItemSelected(0, true);
    verify(listBox).setItemSelected(1, true);
    verify(listBox, never()).setItemSelected(2, true);
}
Also used : Path(org.uberfire.backend.vfs.Path) DropDownData(org.kie.soup.project.datamodel.oracle.DropDownData) ListBox(org.gwtbootstrap3.client.ui.ListBox) Test(org.junit.Test)

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