Search in sources :

Example 16 with GridRow

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

the class MoveColumnsCommandTest method addUiModelRow.

@Override
protected void addUiModelRow(final int rowIndex) {
    final GridRow uiRow = new BaseGridRow();
    uiModel.appendRow(uiRow);
    uiModel.setCellValue(rowIndex, 0, new BaseGridCellValue<>(rowIndex + 1));
    uiModel.setCellValue(rowIndex, 1, new BaseGridCellValue<>("value0"));
    uiModel.setCellValue(rowIndex, 2, new BaseGridCellValue<>("value1"));
}
Also used : BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow)

Example 17 with GridRow

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

the class ExpressionEditorColumn method getMinimumWidth.

@Override
public Double getMinimumWidth() {
    double minimumWidth = super.getMinimumWidth();
    final GridData model = gridWidget.getModel();
    final int columnIndex = getLogicalColumnIndex(model);
    if (columnIndex != -1) {
        for (GridRow row : model.getRows()) {
            final GridCell<?> cell = row.getCells().get(columnIndex);
            if (cell != null) {
                final GridCellValue<?> value = cell.getValue();
                if (value instanceof ExpressionCellValue) {
                    final ExpressionCellValue ecv = (ExpressionCellValue) value;
                    final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> editor = ecv.getValue();
                    final double padding = editor.map(BaseExpressionGrid::getPadding).orElse(0.0);
                    minimumWidth = Math.max(minimumWidth, ecv.getMinimumWidth().orElse(0.0) + padding * 2);
                }
            }
        }
    }
    return minimumWidth;
}
Also used : BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) BaseUIModelMapper(org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow)

Example 18 with GridRow

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

the class ExpressionEditorColumn method updateWidthOfChildren.

protected void updateWidthOfChildren() {
    final double columnWidth = getWidth();
    final GridData model = gridWidget.getModel();
    final int columnIndex = getLogicalColumnIndex(model);
    if (columnIndex != -1) {
        for (GridRow row : model.getRows()) {
            final GridCell<?> cell = row.getCells().get(columnIndex);
            if (cell != null) {
                final GridCellValue<?> value = cell.getValue();
                if (value instanceof ExpressionCellValue) {
                    final ExpressionCellValue ecv = (ExpressionCellValue) value;
                    final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> editor = ecv.getValue();
                    if (editor.isPresent()) {
                        final BaseExpressionGrid beg = editor.get();
                        updateWidthOfLastColumn(beg, columnWidth);
                    }
                }
            }
        }
    }
}
Also used : BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) BaseUIModelMapper(org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow)

Example 19 with GridRow

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

the class DecisionTableGrid method addDecisionRule.

void addDecisionRule(final int index) {
    getExpression().get().ifPresent(dtable -> {
        final GridRow decisionTableRow = new LiteralExpressionGridRow();
        final DecisionRule decisionRule = DecisionRuleFactory.makeDecisionRule(dtable);
        sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new AddDecisionRuleCommand(dtable, decisionRule, model, decisionTableRow, index, uiModelMapper, () -> resize(BaseExpressionGrid.RESIZE_EXISTING)));
    });
}
Also used : AddDecisionRuleCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.dtable.AddDecisionRuleCommand) LiteralExpressionGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.LiteralExpressionGridRow) LiteralExpressionGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.LiteralExpressionGridRow) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule)

Example 20 with GridRow

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

the class ContextGrid method isRowDragPermitted.

@Override
public boolean isRowDragPermitted(final GridWidgetDnDHandlersState state) {
    final GridWidgetHandlersOperation operation = state.getOperation();
    if (operation == GridWidgetHandlersOperation.ROW_MOVE_PENDING) {
        final int lastRowIndex = model.getRowCount() - 1;
        final List<GridRow> rows = state.getActiveGridRows();
        return !rows.contains(model.getRow(lastRowIndex));
    }
    return true;
}
Also used : GridWidgetHandlersOperation(org.uberfire.ext.wires.core.grids.client.widget.dnd.GridWidgetDnDHandlersState.GridWidgetHandlersOperation) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) ExpressionEditorGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.ExpressionEditorGridRow)

Aggregations

GridRow (org.uberfire.ext.wires.core.grids.client.model.GridRow)54 Test (org.junit.Test)31 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)22 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)10 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)10 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)10 ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)8 GridCell (org.uberfire.ext.wires.core.grids.client.model.GridCell)6 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)6 BaseGridCell (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCell)6 ArrayList (java.util.ArrayList)4 DecisionRule (org.kie.workbench.common.dmn.api.definition.model.DecisionRule)4 BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)4 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)3 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)3 HashMap (java.util.HashMap)2 Maps (org.kie.soup.commons.util.Maps)2 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)2 List (org.kie.workbench.common.dmn.api.definition.model.List)2 BaseUIModelMapper (org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper)2