Search in sources :

Example 21 with BaseColumn

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

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

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

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

the class EditMenuBuilder method isOtherwiseEnabled.

// Check whether the "otherwise" menu item can be enabled
private boolean isOtherwiseEnabled(final List<GridData.SelectedCell> selections) {
    if (selections.size() != 1) {
        return false;
    }
    boolean isOtherwiseEnabled = true;
    final GridData.SelectedCell selection = selections.get(0);
    final int columnIndex = findUiColumnIndex(selection.getColumnIndex());
    final BaseColumn column = activeDecisionTable.getModel().getExpandedColumns().get(columnIndex);
    isOtherwiseEnabled = isOtherwiseEnabled && ColumnUtilities.canAcceptOtherwiseValues(column);
    return isOtherwiseEnabled;
}
Also used : GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)

Example 25 with BaseColumn

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

BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)118 Test (org.junit.Test)69 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)57 ArrayList (java.util.ArrayList)53 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)43 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)30 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)30 ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)27 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)25 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)23 List (java.util.List)22 GuidedDTTemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider)20 TemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.TemplateDataProvider)20 CompositeColumn (org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn)20 BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)19 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)19 IOException (java.io.IOException)17 InputStream (java.io.InputStream)17 ExcelParser (org.drools.decisiontable.parser.xls.ExcelParser)17 DataListener (org.drools.template.parser.DataListener)17