use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumn in project drools-wb by kiegroup.
the class DTableUpdateManager method newColumn.
public void newColumn(final GuidedDecisionTable52 model, final HeaderMetaData headerMetaData, final FactTypes factTypes, final int columnIndex) throws BuildException {
PortablePreconditions.checkNotNull("model", model);
PortablePreconditions.checkNotNull("headerMetaData", headerMetaData);
PortablePreconditions.checkNotNull("fieldTypes", factTypes);
PortablePreconditions.checkNotNull("columnIndex", columnIndex);
final BuilderFactory builderFactory = new BuilderFactory(new VerifierColumnUtilities(model, headerMetaData, factTypes), index, model, headerMetaData, configuration);
final Column column = builderFactory.getColumnBuilder().with(columnIndex).build();
analyzer.newColumn(column);
int rowIndex = 0;
for (final List<DTCellValue52> row : model.getData()) {
final BaseColumn baseColumn = model.getExpandedColumns().get(columnIndex);
final Rule rule = index.getRules().where(Rule.index().is(rowIndex)).select().first();
builderFactory.getCellBuilder().with(columnIndex).with(baseColumn).with(rule).with(row).build();
rowIndex++;
}
analyzer.resetChecks();
analyzer.analyze();
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumn in project drools-wb by kiegroup.
the class ActionSetFieldColumnSynchronizer method isActionSetFieldFragment.
private boolean isActionSetFieldFragment(final List<? extends MetaData> metaData) {
if (!metaData.stream().allMatch((c) -> (c instanceof MoveColumnToMetaData))) {
return false;
}
if (!metaData.stream().map(c -> (MoveColumnToMetaData) c).allMatch(c -> c.getColumn() instanceof ActionSetFieldCol52)) {
return false;
}
final BaseColumn firstColumnInFragment = ((MoveColumnToMetaData) metaData.get(0)).getColumn();
final BaseColumn lastColumnInFragment = ((MoveColumnToMetaData) metaData.get(metaData.size() - 1)).getColumn();
final int firstColumnIndex = model.getExpandedColumns().indexOf(firstColumnInFragment);
final int lastColumnIndex = model.getExpandedColumns().indexOf(lastColumnInFragment);
return lastColumnIndex - firstColumnIndex == metaData.size() - 1;
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumn in project drools-wb by kiegroup.
the class ModelSynchronizerImpl method moveColumnsTo.
@Override
@SuppressWarnings("unchecked")
public void moveColumnsTo(final int targetColumnIndex, final List<GridColumn<?>> columns) throws VetoException {
// Generate meta-data to handle moves
final List<MoveColumnToMetaData> metaData = new ArrayList<MoveColumnToMetaData>();
for (int index = 0; index < columns.size(); index++) {
final GridColumn<?> column = columns.get(index);
final int sourceColumnIndex = uiModel.getColumns().indexOf(column);
if (sourceColumnIndex == targetColumnIndex) {
throw new MoveVetoException();
}
final BaseColumn modelColumn = model.getExpandedColumns().get(sourceColumnIndex);
metaData.add(new MoveColumnToMetaDataImpl(sourceColumnIndex, targetColumnIndex + index, modelColumn));
}
Synchronizer handler = null;
for (Synchronizer synchronizer : synchronizers) {
if (synchronizer.handlesMoveColumnsTo(metaData)) {
handler = synchronizer;
break;
}
}
if (handler == null) {
throw new MoveVetoException();
}
handler.moveColumnsTo(metaData);
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumn in project drools-wb by kiegroup.
the class ModelSynchronizerImpl method moveColumnTo.
@Override
@SuppressWarnings("unchecked")
public void moveColumnTo(final int targetColumnIndex, final GridColumn<?> column) throws VetoException {
final int sourceColumnIndex = uiModel.getColumns().indexOf(column);
if (sourceColumnIndex == targetColumnIndex) {
throw new MoveVetoException();
}
final BaseColumn modelColumn = model.getExpandedColumns().get(sourceColumnIndex);
final List<MoveColumnToMetaData> metaData = new ArrayList<MoveColumnToMetaData>() {
{
add(new MoveColumnToMetaDataImpl(sourceColumnIndex, targetColumnIndex, modelColumn));
}
};
final List<Synchronizer> handlers = new ArrayList<Synchronizer>();
for (Synchronizer synchronizer : synchronizers) {
if (synchronizer.handlesMoveColumnsTo(metaData)) {
handlers.add(synchronizer);
}
}
if (handlers.isEmpty()) {
throw new MoveVetoException();
}
for (Synchronizer synchronizer : handlers) {
synchronizer.moveColumnsTo(metaData);
}
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumn in project drools-wb by kiegroup.
the class RowSynchronizer method initialiseRowData.
private void initialiseRowData(final int rowIndex) {
final List<BaseColumn> modelColumns = model.getExpandedColumns();
final List<DTCellValue52> modelRow = model.getData().get(rowIndex);
for (int columnIndex = 0; columnIndex < modelColumns.size(); columnIndex++) {
final BaseColumn modelColumn = modelColumns.get(columnIndex);
final DTCellValue52 modelCell = makeModelCellValue(modelColumn);
modelRow.add(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);
// Set-up SelectionManager for Row Number column, to select entire row.
if (modelColumn instanceof RowNumberCol52) {
uiModel.getCell(rowIndex, columnIndex).setSelectionStrategy(RowSelectionStrategy.INSTANCE);
}
}
}
Aggregations