Search in sources :

Example 16 with RowNumberCol52

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

the class GuidedDecisionTablePresenter method onDeleteSelectedCells.

@Override
public void onDeleteSelectedCells() {
    if (isReadOnly()) {
        return;
    }
    final List<GridData.SelectedCell> selections = uiModel.getSelectedCells();
    if (selections == null || selections.isEmpty()) {
        return;
    }
    for (GridData.SelectedCell sc : selections) {
        final int rowIndex = sc.getRowIndex();
        final int columnIndex = findUiColumnIndex(sc.getColumnIndex());
        final BaseColumn column = model.getExpandedColumns().get(columnIndex);
        final GridColumn<?> uiColumn = uiModel.getColumns().get(columnIndex);
        if (column instanceof RowNumberCol52) {
            continue;
        }
        if (uiColumn instanceof BooleanUiColumn) {
            uiModel.setCellValue(rowIndex, columnIndex, new GuidedDecisionTableUiCell<>(false));
        } else {
            uiModel.deleteCell(rowIndex, columnIndex);
        }
    }
    view.getLayer().draw();
}
Also used : GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) BooleanUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BooleanUiColumn) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)

Example 17 with RowNumberCol52

use of org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52 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 18 with RowNumberCol52

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

the class GuidedDecisionTablePresenter method onDeleteSelectedColumns.

@Override
public void onDeleteSelectedColumns() {
    if (isReadOnly()) {
        return;
    }
    final Set<Integer> selectedColumnIndexes = getSelectedColumnIndexes();
    final Set<BaseColumn> columnsToDelete = new HashSet<>();
    for (int selectedColumnIndex : selectedColumnIndexes) {
        final int columnIndex = findUiColumnIndex(selectedColumnIndex);
        final BaseColumn column = model.getExpandedColumns().get(columnIndex);
        if (!(column instanceof RowNumberCol52 || column instanceof DescriptionCol52)) {
            columnsToDelete.add(column);
        }
    }
    for (BaseColumn columnToDelete : columnsToDelete) {
        if (columnToDelete instanceof AttributeCol52) {
            try {
                deleteColumn((AttributeCol52) columnToDelete);
            } catch (VetoException veto) {
                getModellerPresenter().getView().showGenericVetoMessage();
            }
        } else if (columnToDelete instanceof MetadataCol52) {
            try {
                deleteColumn((MetadataCol52) columnToDelete);
            } catch (VetoException veto) {
                getModellerPresenter().getView().showGenericVetoMessage();
            }
        } else if (columnToDelete instanceof ConditionCol52) {
            try {
                deleteColumn((ConditionCol52) columnToDelete);
            } catch (VetoException veto) {
                getModellerPresenter().getView().showUnableToDeleteColumnMessage((ConditionCol52) columnsToDelete);
            }
        } else if (columnToDelete instanceof ActionCol52) {
            try {
                deleteColumn((ActionCol52) columnToDelete);
            } catch (VetoException veto) {
                getModellerPresenter().getView().showUnableToDeleteColumnMessage((ActionCol52) columnsToDelete);
            }
        }
    }
}
Also used : ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) VetoException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException) MetadataCol52(org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) HashSet(java.util.HashSet) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)

Example 19 with RowNumberCol52

use of org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52 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 20 with RowNumberCol52

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

the class EditMenuBuilder method isOnlyMandatoryColumnSelected.

// Check whether column selection is only RowNumberColumn or DescriptionColumn. These cannot be deleted.
private boolean isOnlyMandatoryColumnSelected(final List<GridData.SelectedCell> selections) {
    boolean isOnlyMandatoryColumnSelected = true;
    for (GridData.SelectedCell sc : selections) {
        final int columnIndex = findUiColumnIndex(sc.getColumnIndex());
        final BaseColumn column = activeDecisionTable.getModel().getExpandedColumns().get(columnIndex);
        if (!((column instanceof RowNumberCol52) || (column instanceof DescriptionCol52))) {
            isOnlyMandatoryColumnSelected = false;
        }
    }
    return isOnlyMandatoryColumnSelected;
}
Also used : DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)

Aggregations

RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)82 Test (org.junit.Test)70 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)66 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)57 ArrayList (java.util.ArrayList)47 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)33 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)24 BRLConditionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)23 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)23 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)23 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)22 BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)22 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)21 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)21 GuidedDTTemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider)19 TemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.TemplateDataProvider)19 BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)19 BRLActionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)18 IOException (java.io.IOException)17 InputStream (java.io.InputStream)17