Search in sources :

Example 46 with DTCellValue52

use of org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52 in project drools-wb by kiegroup.

the class GuidedDecisionTablePresenter method initialiseRow.

private void initialiseRow(final List<BaseColumn> columns, final List<DTCellValue52> row) {
    final GridRow uiModelRow = new BaseGridRow(GuidedDecisionTableView.ROW_HEIGHT);
    final int rowIndex = uiModel.getRowCount();
    uiModel.appendRow(uiModelRow);
    for (int iModelColumn = 0; iModelColumn < row.size(); iModelColumn++) {
        final DTCellValue52 modelCell = row.get(iModelColumn);
        final BaseColumn modelColumn = columns.get(iModelColumn);
        // We cannot rely upon the values in the existing data as legacy tables aren't guaranteed to be sorted
        if (modelColumn instanceof RowNumberCol52) {
            modelCell.setNumericValue(uiModel.getRowCount());
        }
        // BaseGridData is sparsely populated; only add values if needed.
        if (modelCell.hasValue()) {
            uiModel.setCellValueInternal(rowIndex, iModelColumn, gridWidgetCellFactory.convertCell(modelCell, modelColumn, cellUtilities, columnUtilities));
            // Set-up SelectionManager for Row Number column, to select entire row.
            if (modelColumn instanceof RowNumberCol52) {
                uiModel.getCell(rowIndex, iModelColumn).setSelectionStrategy(RowSelectionStrategy.INSTANCE);
            }
        }
    }
}
Also used : BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)

Example 47 with DTCellValue52

use of org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52 in project drools-wb by kiegroup.

the class GuidedDecisionTablePresenter method onPaste.

@Override
public void onPaste() {
    if (!clipboard.hasData()) {
        return;
    }
    if (isSelectionEmpty()) {
        return;
    }
    if (isReadOnly()) {
        return;
    }
    final Set<Clipboard.ClipboardData> data = clipboard.getData();
    final int currentOriginRowIndex = uiModel.getSelectedCellsOrigin().getRowIndex();
    final int currentOriginColumnIndex = findUiColumnIndex(uiModel.getSelectedCellsOrigin().getColumnIndex());
    boolean updateSystemControlledValues = false;
    for (Clipboard.ClipboardData cd : data) {
        final int targetRowIndex = currentOriginRowIndex + cd.getRowIndex();
        final int targetColumnIndex = currentOriginColumnIndex + cd.getColumnIndex();
        if (targetRowIndex < 0 || targetRowIndex > uiModel.getRowCount() - 1) {
            continue;
        }
        if (targetColumnIndex < 0 || targetColumnIndex > uiModel.getColumns().size() - 1) {
            continue;
        }
        final DTCellValue52 modelCell = cd.getValue();
        final BaseColumn modelColumn = model.getExpandedColumns().get(targetColumnIndex);
        if (modelCell.hasValue()) {
            uiModel.setCellValue(targetRowIndex, targetColumnIndex, gridWidgetCellFactory.convertCell(modelCell, modelColumn, cellUtilities, columnUtilities));
        } else {
            uiModel.deleteCell(targetRowIndex, targetColumnIndex);
        }
        if (modelColumn instanceof RowNumberCol52) {
            updateSystemControlledValues = true;
        }
    }
    if (updateSystemControlledValues) {
        synchronizer.updateSystemControlledColumnValues();
    }
    view.batch();
}
Also used : BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) Clipboard(org.drools.workbench.screens.guided.dtable.client.editor.clipboard.Clipboard) DefaultClipboard(org.drools.workbench.screens.guided.dtable.client.editor.clipboard.impl.DefaultClipboard) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)

Example 48 with DTCellValue52

use of org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52 in project drools-wb by kiegroup.

the class BaseColumnSynchronizer method synchroniseAppendColumn.

protected void synchroniseAppendColumn(final BaseColumn modelColumn, final List<DTCellValue52> originalColumnData) {
    final int columnIndex = model.getExpandedColumns().indexOf(modelColumn);
    final GridColumn<?> uiModelColumn = gridWidgetColumnFactory.convertColumn(modelColumn, access, view);
    uiModel.insertColumn(columnIndex, uiModelColumn);
    for (int rowIndex = 0; rowIndex < model.getData().size(); rowIndex++) {
        final DTCellValue52 modelCell = originalColumnData.get(rowIndex);
        final List<DTCellValue52> modelRow = model.getData().get(rowIndex);
        modelRow.add(columnIndex, modelCell);
        if (modelCell.hasValue()) {
            uiModel.setCellValueInternal(rowIndex, columnIndex, gridWidgetCellFactory.convertCell(modelCell, modelColumn, cellUtilities, columnUtilities));
        }
    }
    uiModel.indexColumn(columnIndex);
}
Also used : DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)

Example 49 with DTCellValue52

use of org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52 in project drools-wb by kiegroup.

the class BaseColumnSynchronizer method synchroniseAppendColumn.

protected void synchroniseAppendColumn(final BaseColumn modelColumn) {
    final int columnIndex = model.getExpandedColumns().indexOf(modelColumn);
    final GridColumn<?> uiModelColumn = gridWidgetColumnFactory.convertColumn(modelColumn, access, view);
    uiModel.insertColumn(columnIndex, uiModelColumn);
    for (int rowIndex = 0; rowIndex < model.getData().size(); rowIndex++) {
        final DTCellValue52 modelCell = makeModelCellValue(modelColumn);
        final List<DTCellValue52> modelRow = model.getData().get(rowIndex);
        modelRow.add(columnIndex, modelCell);
        // BaseGridData is sparsely populated; only add values if needed.
        if (modelCell.hasValue()) {
            uiModel.setCellValueInternal(rowIndex, columnIndex, gridWidgetCellFactory.convertCell(modelCell, modelColumn, cellUtilities, columnUtilities));
        }
    }
    uiModel.indexColumn(columnIndex);
}
Also used : DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)

Example 50 with DTCellValue52

use of org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52 in project drools-wb by kiegroup.

the class BaseColumnSynchronizer method clearColumnData.

// Clear the values in a column
protected void clearColumnData(final BaseColumn column) {
    final int columnIndex = this.model.getExpandedColumns().indexOf(column);
    for (List<DTCellValue52> row : this.model.getData()) {
        final DTCellValue52 dcv = row.get(columnIndex);
        dcv.clearValues();
    }
}
Also used : DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)

Aggregations

DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)244 Test (org.junit.Test)121 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)53 ArrayList (java.util.ArrayList)51 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)46 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)46 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)39 LimitedEntryConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)39 AttributeCol52 (org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52)30 List (java.util.List)29 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)28 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)27 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)25 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)24 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)23 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)21 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)20 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)20 GuidedDTTemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider)20 TemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.TemplateDataProvider)20