Search in sources :

Example 11 with BaseHeaderMetaData

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseHeaderMetaData in project kie-wb-common by kiegroup.

the class InvocationGridTest method testExpressionColumnMetaData.

@Test
public void testExpressionColumnMetaData() {
    setupGrid(0);
    final GridColumn<?> column = grid.getModel().getColumns().get(InvocationUIModelMapper.BINDING_EXPRESSION_COLUMN_INDEX);
    final List<GridColumn.HeaderMetaData> header = column.getHeaderMetaData();
    assertEquals(2, header.size());
    assertTrue(header.get(0) instanceof BaseHeaderMetaData);
    assertTrue(header.get(1) instanceof InvocationColumnExpressionHeaderMetaData);
    final BaseHeaderMetaData md1 = (BaseHeaderMetaData) header.get(0);
    final InvocationColumnExpressionHeaderMetaData md2 = (InvocationColumnExpressionHeaderMetaData) header.get(1);
    assertEquals("", md1.getTitle());
    assertEquals("invocation-expression", md2.getTitle());
}
Also used : BaseHeaderMetaData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseHeaderMetaData) NameColumnHeaderMetaData(org.kie.workbench.common.dmn.client.editors.expressions.types.context.NameColumnHeaderMetaData) BaseHeaderMetaData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseHeaderMetaData) Test(org.junit.Test)

Example 12 with BaseHeaderMetaData

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseHeaderMetaData in project kie-wb-common by kiegroup.

the class CommandUtilsTest method testUpdateParentInformation_WithMultipleColumns.

@Test
@SuppressWarnings("unchecked")
public void testUpdateParentInformation_WithMultipleColumns() {
    setupUiModel(Pair.newPair(new ExpressionEditorColumn(gridLayer, new BaseHeaderMetaData("column"), ExpressionEditorColumn.DEFAULT_WIDTH, gridWidget), (rowIndex) -> {
        final BaseExpressionGrid grid = mock(BaseExpressionGrid.class);
        final GridCellTuple gct = new GridCellTuple(rowIndex, 0, mock(GridWidget.class));
        when(grid.getParentInformation()).thenReturn(gct);
        return new ExpressionCellValue(Optional.of(grid));
    }), Pair.newPair(new RowNumberColumn(), (rowIndex) -> new BaseGridCellValue<>(rowIndex + 1)));
    assertParentInformationValues(0);
    gridData.moveColumnTo(0, gridData.getColumns().get(1));
    CommandUtils.updateParentInformation(gridData);
    assertParentInformationValues(1);
}
Also used : IntStream(java.util.stream.IntStream) CellEditorControlsView(org.kie.workbench.common.dmn.client.widgets.grid.controls.container.CellEditorControlsView) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) Arrays(java.util.Arrays) BaseGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseGrid) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) DMNGridLayer(org.kie.workbench.common.dmn.client.widgets.layer.DMNGridLayer) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) GridRenderer(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.GridRenderer) Function(java.util.function.Function) BaseHeaderMetaData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseHeaderMetaData) ArrayList(java.util.ArrayList) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) RefreshFormPropertiesEvent(org.kie.workbench.common.stunner.forms.client.event.RefreshFormPropertiesEvent) LienzoMockitoTestRunner(com.ait.lienzo.test.LienzoMockitoTestRunner) RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) Assertions(org.assertj.core.api.Assertions) Assert.fail(org.junit.Assert.fail) SessionManager(org.kie.workbench.common.stunner.core.client.api.SessionManager) Pair(org.uberfire.commons.data.Pair) Mockito.doReturn(org.mockito.Mockito.doReturn) Before(org.junit.Before) TranslationService(org.jboss.errai.ui.client.local.spi.TranslationService) GridCell(org.uberfire.ext.wires.core.grids.client.model.GridCell) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule) Test(org.junit.Test) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) Mockito.when(org.mockito.Mockito.when) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) SessionCommandManager(org.kie.workbench.common.stunner.core.client.command.SessionCommandManager) GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) List(java.util.List) DomainObjectSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.DomainObjectSelectionEvent) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue) DefaultCanvasCommandFactory(org.kie.workbench.common.dmn.client.commands.factory.DefaultCanvasCommandFactory) GridCellValue(org.uberfire.ext.wires.core.grids.client.model.GridCellValue) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) Optional(java.util.Optional) ExpressionEditorColumn(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionEditorColumn) EventSourceMock(org.uberfire.mocks.EventSourceMock) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) Mockito.mock(org.mockito.Mockito.mock) RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) ExpressionEditorColumn(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionEditorColumn) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) BaseHeaderMetaData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseHeaderMetaData) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue) Test(org.junit.Test)

Example 13 with BaseHeaderMetaData

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseHeaderMetaData in project drools-wb by kiegroup.

the class ActionWorkItemExecuteColumnConverter method makeHeaderMetaData.

@Override
public List<GridColumn.HeaderMetaData> makeHeaderMetaData(final BaseColumn column) {
    final PortableWorkDefinition pwd = ((ActionWorkItemCol52) column).getWorkItemDefinition();
    final String workItemName = pwd == null ? column.getHeader() : pwd.getName();
    return new ArrayList<GridColumn.HeaderMetaData>() {

        {
            add(new BaseHeaderMetaData(workItemName, ActionCol52.class.getName()));
            add(new BaseHeaderMetaData(column.getHeader(), workItemName + "-exec"));
        }
    };
}
Also used : ActionWorkItemCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52) PortableWorkDefinition(org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition) ArrayList(java.util.ArrayList) BaseHeaderMetaData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseHeaderMetaData) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn)

Example 14 with BaseHeaderMetaData

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseHeaderMetaData in project drools-wb by kiegroup.

the class ActionInsertFactColumnConverter method makeHeaderMetaData.

@Override
public List<GridColumn.HeaderMetaData> makeHeaderMetaData(final BaseColumn column) {
    return new ArrayList<GridColumn.HeaderMetaData>() {

        {
            if (column instanceof ActionInsertFactCol52) {
                ActionInsertFactCol52 actionInsertFactColumn = (ActionInsertFactCol52) column;
                StringBuilder headerFirstRow = new StringBuilder();
                if (actionInsertFactColumn.getBoundName() != null && !actionInsertFactColumn.getBoundName().isEmpty()) {
                    headerFirstRow.append(actionInsertFactColumn.getBoundName()).append(" : ");
                }
                headerFirstRow.append(actionInsertFactColumn.getFactType());
                add(new BaseHeaderMetaData(headerFirstRow.toString(), ActionCol52.class.getName()));
                add(new BaseHeaderMetaData(column.getHeader(), headerFirstRow.toString()));
            } else {
                add(new BaseHeaderMetaData(column.getHeader(), ActionCol52.class.getName()));
            }
        }
    };
}
Also used : ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) ArrayList(java.util.ArrayList) BaseHeaderMetaData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseHeaderMetaData) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn)

Example 15 with BaseHeaderMetaData

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseHeaderMetaData in project drools-wb by kiegroup.

the class ActionSetFieldColumnConverter method makeHeaderMetaData.

@Override
public List<GridColumn.HeaderMetaData> makeHeaderMetaData(final BaseColumn column) {
    return new ArrayList<GridColumn.HeaderMetaData>() {

        {
            if (column instanceof ActionSetFieldCol52) {
                ActionSetFieldCol52 actionSetFieldColumn = (ActionSetFieldCol52) column;
                if (actionSetFieldColumn.getBoundName() != null && !actionSetFieldColumn.getBoundName().isEmpty()) {
                    add(new BaseHeaderMetaData(actionSetFieldColumn.getBoundName(), ActionCol52.class.getName()));
                    add(new BaseHeaderMetaData(column.getHeader(), actionSetFieldColumn.getBoundName()));
                }
            } else {
                add(new BaseHeaderMetaData(column.getHeader(), ActionCol52.class.getName()));
            }
        }
    };
}
Also used : ArrayList(java.util.ArrayList) BaseHeaderMetaData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseHeaderMetaData) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)

Aggregations

BaseHeaderMetaData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseHeaderMetaData)15 ArrayList (java.util.ArrayList)10 GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)8 Test (org.junit.Test)6 Before (org.junit.Before)4 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)3 LienzoMockitoTestRunner (com.ait.lienzo.test.LienzoMockitoTestRunner)2 Arrays (java.util.Arrays)2 Collections (java.util.Collections)2 List (java.util.List)2 Optional (java.util.Optional)2 Function (java.util.function.Function)2 IntStream (java.util.stream.IntStream)2 Assertions (org.assertj.core.api.Assertions)2 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)2 TranslationService (org.jboss.errai.ui.client.local.spi.TranslationService)2 Assert.assertEquals (org.junit.Assert.assertEquals)2 Assert.fail (org.junit.Assert.fail)2 RunWith (org.junit.runner.RunWith)2 DecisionRule (org.kie.workbench.common.dmn.api.definition.model.DecisionRule)2