Search in sources :

Example 11 with Callback

use of org.uberfire.client.callbacks.Callback in project drools-wb by kiegroup.

the class CallbackFactoryTest method makeOnCreationCallbackListBoxSingleSelect.

@Test
@SuppressWarnings("unchecked")
public void makeOnCreationCallbackListBoxSingleSelect() {
    setupMultipleSelectTest(CallbackFactory.MAX_VISIBLE_ROWS, false);
    final Callback callback = CallbackFactory.makeOnCreationCallback(factory, cell, enumLookups);
    callback.callback(multiValueDOMElement);
    verifyMultipleSelectTest(CallbackFactory.MAX_VISIBLE_ROWS);
    verify(multiValueWidget, never()).setVisibleItemCount(anyInt());
}
Also used : Callback(org.uberfire.client.callbacks.Callback) Test(org.junit.Test)

Example 12 with Callback

use of org.uberfire.client.callbacks.Callback in project drools-wb by kiegroup.

the class CallbackFactoryTest method makeOnCreationCallbackListBoxMultipleSelect.

@Test
@SuppressWarnings("unchecked")
public void makeOnCreationCallbackListBoxMultipleSelect() {
    setupMultipleSelectTest(CallbackFactory.MAX_VISIBLE_ROWS, true);
    final Callback callback = CallbackFactory.makeOnCreationCallback(factory, cell, enumLookups);
    callback.callback(multiValueDOMElement);
    verifyMultipleSelectTest(CallbackFactory.MAX_VISIBLE_ROWS);
    verify(multiValueWidget).setVisibleItemCount(eq(CallbackFactory.MAX_VISIBLE_ROWS));
}
Also used : Callback(org.uberfire.client.callbacks.Callback) Test(org.junit.Test)

Example 13 with Callback

use of org.uberfire.client.callbacks.Callback 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 14 with Callback

use of org.uberfire.client.callbacks.Callback in project drools-wb by kiegroup.

the class ColumnHeaderPopOverImpl method showSource.

private void showSource(final GuidedDecisionTableModellerView modellerView, final GuidedDecisionTableView.Presenter dtPresenter, final int uiColumnIndex) {
    final BaseColumn column = dtPresenter.getModel().getExpandedColumns().get(uiColumnIndex);
    final int screenX = getScreenX(modellerView, dtPresenter, uiColumnIndex);
    final int screenY = getScreenY(modellerView, dtPresenter);
    view.show((Callback<PopOverView.Content> callback) -> columnDefinitionFactory.generateColumnDefinition(dtPresenter, column, (String definition) -> callback.callback(new PopOverView.Content() {

        @Override
        public String getContent() {
            return definition;
        }

        @Override
        public int getX() {
            return screenX;
        }

        @Override
        public int getY() {
            return screenY;
        }
    })));
}
Also used : Callback(org.uberfire.client.callbacks.Callback) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)

Example 15 with Callback

use of org.uberfire.client.callbacks.Callback in project drools-wb by kiegroup.

the class EnumLoaderUtilitiesTest method checkEmptyDefinition.

@Test
public void checkEmptyDefinition() {
    final Callback<Map<String, String>> callback = (result) -> assertTrue(result.isEmpty());
    enumLoaderUtilities.getEnums(new DropDownData(), callback, presenter, onFetchCommand, onFetchCompleteCommand);
    assertNoInteractions();
}
Also used : GuidedDecisionTablePresenter(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter) EnumDropdownService(org.kie.workbench.common.services.shared.enums.EnumDropdownService) CallerMock(org.uberfire.mocks.CallerMock) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) Mockito.when(org.mockito.Mockito.when) Mockito.spy(org.mockito.Mockito.spy) Mockito.verify(org.mockito.Mockito.verify) Mockito.never(org.mockito.Mockito.never) MockitoJUnitRunner(org.mockito.runners.MockitoJUnitRunner) Callback(org.uberfire.client.callbacks.Callback) Assert.assertFalse(org.junit.Assert.assertFalse) Map(java.util.Map) Caller(org.jboss.errai.common.client.api.Caller) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) Mockito.any(org.mockito.Mockito.any) DropDownData(org.kie.soup.project.datamodel.oracle.DropDownData) Path(org.uberfire.backend.vfs.Path) Command(org.uberfire.mvp.Command) Assert.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) DropDownData(org.kie.soup.project.datamodel.oracle.DropDownData) Map(java.util.Map) Test(org.junit.Test)

Aggregations

Callback (org.uberfire.client.callbacks.Callback)18 Test (org.junit.Test)10 Map (java.util.Map)5 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)3 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)3 GuidedDecisionTablePresenter (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter)3 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)3 Caller (org.jboss.errai.common.client.api.Caller)3 Assert.assertEquals (org.junit.Assert.assertEquals)3 Assert.assertFalse (org.junit.Assert.assertFalse)3 Assert.assertTrue (org.junit.Assert.assertTrue)3 Before (org.junit.Before)3 RunWith (org.junit.runner.RunWith)3 DropDownData (org.kie.soup.project.datamodel.oracle.DropDownData)3 EnumDropdownService (org.kie.workbench.common.services.shared.enums.EnumDropdownService)3 Mock (org.mockito.Mock)3 Mockito.any (org.mockito.Mockito.any)3 Mockito.never (org.mockito.Mockito.never)3 Mockito.spy (org.mockito.Mockito.spy)3 Mockito.times (org.mockito.Mockito.times)3