Search in sources :

Example 41 with GridColumn

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

the class DeleteRuleAnnotationClauseCommandTest method testNewGraphCommandUndo.

@Test
public void testNewGraphCommandUndo() {
    final int uiColumnIndex = 3;
    final int annotationClauseIndex = 2;
    final AbstractCanvasHandler handler = mock(AbstractCanvasHandler.class);
    final DeleteRuleAnnotationClauseCommand command = mock(DeleteRuleAnnotationClauseCommand.class);
    final DecisionRule rule1 = mock(DecisionRule.class);
    final DecisionRule rule2 = mock(DecisionRule.class);
    final List<DecisionRule> rules = Arrays.asList(rule1, rule2);
    final List rule1AnnotationEntries = mock(List.class);
    final List rule2AnnotationEntries = mock(List.class);
    final List annotations = mock(List.class);
    final List widths = mock(List.class);
    final GraphCommandExecutionContext context = mock(GraphCommandExecutionContext.class);
    final RuleAnnotationClause oldRuleClause = mock(RuleAnnotationClause.class);
    final GridColumn oldUiModelColumn = mock(GridColumn.class);
    final double oldUiModelColumnWidth = 123.4D;
    final RuleAnnotationClauseText deleted1 = mock(RuleAnnotationClauseText.class);
    final RuleAnnotationClauseText deleted2 = mock(RuleAnnotationClauseText.class);
    final List<RuleAnnotationClauseText> oldCommandData = Arrays.asList(deleted1, deleted2);
    doCallRealMethod().when(command).newGraphCommand(handler);
    when(command.getOldColumnData()).thenReturn(oldCommandData);
    when(command.getOldRuleClause()).thenReturn(oldRuleClause);
    when(oldUiModelColumn.getWidth()).thenReturn(oldUiModelColumnWidth);
    when(command.getOldUiModelColumn()).thenReturn(oldUiModelColumn);
    when(command.getDecisionTable()).thenReturn(decisionTable);
    when(command.getRuleAnnotationClauseIndex()).thenReturn(annotationClauseIndex);
    when(command.getUiColumnIndex()).thenReturn(uiColumnIndex);
    when(rule1.getAnnotationEntry()).thenReturn(rule1AnnotationEntries);
    when(rule2.getAnnotationEntry()).thenReturn(rule2AnnotationEntries);
    when(decisionTable.getRule()).thenReturn(rules);
    when(decisionTable.getAnnotations()).thenReturn(annotations);
    when(decisionTable.getComponentWidths()).thenReturn(widths);
    final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(handler);
    final CommandResult<RuleViolation> result = graphCommand.undo(context);
    assertEquals(GraphCommandResultBuilder.SUCCESS, result);
    verify(annotations).add(annotationClauseIndex, oldRuleClause);
    verify(rule1AnnotationEntries).add(annotationClauseIndex, deleted1);
    verify(rule2AnnotationEntries).add(annotationClauseIndex, deleted2);
}
Also used : RuleAnnotationClauseText(org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClauseText) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) RuleAnnotationClause(org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) List(java.util.List) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) Test(org.junit.Test)

Example 42 with GridColumn

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

the class EditableHeaderGridWidgetEditCellMouseEventHandlerTest method setupAdditionalColumn.

private void setupAdditionalColumn() {
    final GridColumn additionalGridColumn = mock(GridColumn.class);
    uiModel.appendColumn(additionalGridColumn);
    when(gridColumn.getHeaderMetaData()).thenReturn(Collections.singletonList(editableHeaderMetaData));
    when(gridColumn.getIndex()).thenReturn(0);
    when(additionalGridColumn.getHeaderMetaData()).thenReturn(Collections.singletonList(editableHeaderMetaData));
    when(additionalGridColumn.getIndex()).thenReturn(1);
    uiModel.selectHeaderCell(0, 0);
    uiModel.selectHeaderCell(0, 1);
}
Also used : GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn)

Example 43 with GridColumn

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

the class BaseExpressionGridThemeTest method testGetHeaderBackgroundFillColour.

@Test
public void testGetHeaderBackgroundFillColour() {
    tests.stream().forEach(test -> {
        final GridColumn column = mock(test.getK1());
        final Rectangle rectangle = theme.getHeaderBackground(column);
        assertEquals("Column '" + column.getClass().getSimpleName() + "' has wrong colour.", test.getK2(), rectangle.getFillColor());
    });
}
Also used : Rectangle(com.ait.lienzo.client.core.shape.Rectangle) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) Test(org.junit.Test)

Example 44 with GridColumn

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

the class DMNGridPanelCellSelectionHandlerTest method mockGridWidget.

private BaseExpressionGrid mockGridWidget() {
    final BaseExpressionGrid gridWidget = mock(BaseExpressionGrid.class);
    final GridData gridData = new DMNGridData();
    when(gridWidget.getModel()).thenReturn(gridData);
    gridData.appendColumn(new RowNumberColumn());
    IntStream.range(0, 3).forEach(i -> {
        final GridColumn gridColumn = mock(GridColumn.class);
        final List<GridColumn.HeaderMetaData> headerMetaData = Collections.singletonList(mock(GridColumn.HeaderMetaData.class));
        when(gridColumn.getIndex()).thenReturn(i);
        when(gridColumn.getHeaderMetaData()).thenReturn(headerMetaData);
        gridData.appendColumn(gridColumn);
    });
    gridData.appendRow(new BaseGridRow());
    gridData.appendRow(new BaseGridRow());
    gridData.appendRow(new BaseGridRow());
    return gridWidget;
}
Also used : RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)

Example 45 with GridColumn

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

the class BaseExpressionGrid method getMinimumWidth.

public double getMinimumWidth() {
    double minimumWidth = 0;
    final int columnCount = model.getColumnCount();
    final List<GridColumn<?>> uiColumns = model.getColumns();
    for (int columnIndex = 0; columnIndex < columnCount - 1; columnIndex++) {
        final GridColumn editorColumn = uiColumns.get(columnIndex);
        minimumWidth = minimumWidth + editorColumn.getWidth();
    }
    if (columnCount > 0) {
        minimumWidth = minimumWidth + uiColumns.get(columnCount - 1).getMinimumWidth();
    }
    return minimumWidth;
}
Also used : GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn)

Aggregations

GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)62 Test (org.junit.Test)42 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)15 BaseGridColumn (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridColumn)12 ArrayList (java.util.ArrayList)11 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)10 ContextMenuHandler (com.google.gwt.event.dom.client.ContextMenuHandler)8 DMNGridColumn (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridColumn)8 IntegerUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn)7 StringUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn)7 GridBodyCellRenderContext (org.uberfire.ext.wires.core.grids.client.widget.context.GridBodyCellRenderContext)7 RowNumberColumn (org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn)6 List (java.util.List)5 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)5 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)5 GridRow (org.uberfire.ext.wires.core.grids.client.model.GridRow)5 Optional (java.util.Optional)4 ScenarioHeaderMetaData (org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData)4 ScenarioGridColumn (org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGridColumn)4 GridCell (org.uberfire.ext.wires.core.grids.client.model.GridCell)4