use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumn in project drools-wb by kiegroup.
the class RuleBuilder method resolveColumns.
private void resolveColumns() throws BuildException {
int columnIndex = 0;
for (final BaseColumn baseColumn : model.getExpandedColumns()) {
if (baseColumn instanceof ConditionCol52) {
final Condition condition = builderFactory.getConditionBuilder().with((ConditionCol52) baseColumn).with(rule).with(row).with(columnIndex).build();
rule.getConditions().add(condition);
} else if (baseColumn instanceof ActionCol52) {
final Action action = builderFactory.getActionBuilder().with(rule).with((ActionCol52) baseColumn).with(row).with(columnIndex).build();
rule.getActions().add(action);
}
columnIndex++;
}
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumn in project drools-wb by kiegroup.
the class ModelMetaDataEnhancerTest method conditionCol52Column.
@Test
public void conditionCol52Column() throws Exception {
final ArrayList<BaseColumn> columns = new ArrayList<>();
final ConditionCol52 conditionCol52 = new ConditionCol52();
final Pattern52 pattern52 = new Pattern52();
columns.add(conditionCol52);
when(model.getExpandedColumns()).thenReturn(columns);
when(model.getPattern(conditionCol52)).thenReturn(pattern52);
final Map<Integer, ModelMetaData> metaData = new ModelMetaDataEnhancer(model).getHeaderMetaData().getPatternsByColumnNumber();
assertEquals(1, metaData.size());
assertEquals(pattern52, metaData.get(0).getPattern());
assertEquals(PatternType.LHS, metaData.get(0).getPatternType());
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumn in project drools-wb by kiegroup.
the class DecisionTableAnalyzer method getColumnIndex.
private int getColumnIndex(final BaseColumn baseColumn) {
List<BaseColumn> cols = model.getExpandedColumns();
final int indexOf = cols.indexOf(baseColumn);
if (indexOf < 0) {
if (baseColumn instanceof BRLConditionColumn) {
for (final BaseColumn column : model.getExpandedColumns()) {
if (column instanceof BRLConditionVariableColumn) {
if (((BRLConditionColumn) baseColumn).getChildColumns().contains(column)) {
return model.getExpandedColumns().indexOf(column);
}
}
}
throw new IllegalArgumentException("Could not find BRLConditionColumn: " + baseColumn.toString());
}
if (baseColumn instanceof BRLActionColumn) {
for (final BaseColumn column : model.getExpandedColumns()) {
if (column instanceof BRLActionVariableColumn) {
if (((BRLActionColumn) baseColumn).getChildColumns().contains(column)) {
return model.getExpandedColumns().indexOf(column);
}
}
}
throw new IllegalArgumentException("Could not find BRLActionColumn: " + baseColumn.toString());
} else if (baseColumn instanceof BRLVariableColumn) {
return model.getExpandedColumns().indexOf(model.getBRLColumn((BRLVariableColumn) baseColumn));
} else {
throw new IllegalArgumentException("Could not find baseColumn: " + baseColumn.toString());
}
} else {
return indexOf;
}
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumn in project drools-wb by kiegroup.
the class GuidedDecisionTablePresenter method initialiseModels.
// Copy Model data to UiModel.
void initialiseModels() {
initialiseLegacyColumnDataTypes();
final List<BaseColumn> modelColumns = model.getExpandedColumns();
for (BaseColumn column : modelColumns) {
initialiseColumn(column);
}
for (List<DTCellValue52> row : model.getData()) {
initialiseRow(modelColumns, row);
}
setOriginalHashCode(model.hashCode());
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumn 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();
}
Aggregations