Search in sources :

Example 1 with ListSelectorTextItem

use of org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl.ListSelectorTextItem in project kie-wb-common by kiegroup.

the class ListSelectorViewImpl method makeListSelectorItemView.

private Optional<IsElement> makeListSelectorItemView(final ListSelectorItem item) {
    Optional<IsElement> listSelectorItemView = Optional.empty();
    if (item instanceof ListSelectorTextItem) {
        final ListSelectorTextItem ti = (ListSelectorTextItem) item;
        final ListSelectorTextItemView selector = listSelectorTextItemViews.get();
        selector.setText(ti.getText());
        selector.setEnabled(ti.isEnabled());
        selector.addClickHandler(() -> {
            if (ti.isEnabled()) {
                presenter.onItemSelected(item);
            }
        });
        listSelectorItemView = Optional.of(selector);
    } else if (item instanceof ListSelectorDividerItem) {
        listSelectorItemView = Optional.of(listSelectorDividerItemViews.get());
    }
    return listSelectorItemView;
}
Also used : ListSelectorDividerItem(org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl.ListSelectorDividerItem) IsElement(org.jboss.errai.common.client.api.IsElement) ListSelectorTextItem(org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl.ListSelectorTextItem)

Example 2 with ListSelectorTextItem

use of org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl.ListSelectorTextItem in project kie-wb-common by kiegroup.

the class UndefinedExpressionColumnTest method testGetItems.

@Test
public void testGetItems() {
    final List<ListSelectorItem> items = column.getItems(0, 0);
    assertThat(items).isNotNull();
    assertThat(items.size()).isEqualTo(1);
    final ListSelectorItem item = items.get(0);
    assertThat(item).isInstanceOf(ListSelectorTextItem.class);
    final ListSelectorTextItem textItem = (ListSelectorTextItem) item;
    assertThat(textItem.getText()).isEqualTo(LiteralExpression.class.getSimpleName());
    textItem.getCommand().execute();
    verify(gridWidget).onExpressionTypeChanged(eq(ExpressionType.LITERAL_EXPRESSION));
}
Also used : ListSelectorItem(org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl.ListSelectorItem) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) ListSelectorTextItem(org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl.ListSelectorTextItem) Test(org.junit.Test)

Example 3 with ListSelectorTextItem

use of org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl.ListSelectorTextItem in project kie-wb-common by kiegroup.

the class UndefinedExpressionGridTest method testOnItemSelected.

@Test
public void testOnItemSelected() {
    setupGrid(0);
    final Command command = mock(Command.class);
    final ListSelectorTextItem listSelectorItem = mock(ListSelectorTextItem.class);
    when(listSelectorItem.getCommand()).thenReturn(command);
    grid.onItemSelected(listSelectorItem);
    verify(command).execute();
}
Also used : SetCellValueCommand(org.kie.workbench.common.dmn.client.commands.general.SetCellValueCommand) Command(org.uberfire.mvp.Command) ListSelectorTextItem(org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl.ListSelectorTextItem) Test(org.junit.Test)

Example 4 with ListSelectorTextItem

use of org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl.ListSelectorTextItem in project kie-wb-common by kiegroup.

the class HasListSelectorControlTest method testBuild.

@Test
public void testBuild() {
    final ListSelectorTextItem item = ListSelectorTextItem.build(TEXT, ENABLED, command);
    assertThat(item.getText()).isEqualTo(TEXT);
    assertThat(item.isEnabled()).isEqualTo(ENABLED);
    assertThat(item.getCommand()).isEqualTo(command);
}
Also used : ListSelectorTextItem(org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl.ListSelectorTextItem) Test(org.junit.Test)

Example 5 with ListSelectorTextItem

use of org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl.ListSelectorTextItem in project kie-wb-common by kiegroup.

the class UndefinedExpressionColumnTest method testOnItemSelectedWithExpressionTypeSelected.

@Test
public void testOnItemSelectedWithExpressionTypeSelected() {
    final List<ListSelectorItem> items = column.getItems(0, 0);
    final ListSelectorTextItem ti = (ListSelectorTextItem) items.get(0);
    column.onItemSelected(ti);
    verify(gridWidget).onExpressionTypeChanged(eq(ExpressionType.LITERAL_EXPRESSION));
}
Also used : ListSelectorItem(org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl.ListSelectorItem) ListSelectorTextItem(org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl.ListSelectorTextItem) Test(org.junit.Test)

Aggregations

ListSelectorTextItem (org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl.ListSelectorTextItem)5 Test (org.junit.Test)4 ListSelectorItem (org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl.ListSelectorItem)2 IsElement (org.jboss.errai.common.client.api.IsElement)1 LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)1 SetCellValueCommand (org.kie.workbench.common.dmn.client.commands.general.SetCellValueCommand)1 ListSelectorDividerItem (org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl.ListSelectorDividerItem)1 Command (org.uberfire.mvp.Command)1