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