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();
}
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);
}
}
}
}
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);
}
}
}
}
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();
}
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;
}
Aggregations