Search in sources :

Example 1 with GuidedDecisionTableUiCell

use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.GuidedDecisionTableUiCell in project drools-wb by kiegroup.

the class PrioritySynchronizer method update.

public void update(final int rowNumberColumnIndex, final RowNumberChanges rowNumberChanges) {
    if (!GuidedDecisionTable52.HitPolicy.RESOLVED_HIT.equals(model.getHitPolicy())) {
        return;
    }
    final Optional<BaseColumnInfo> optional = getPriorityColumnInfo();
    if (optional.isPresent()) {
        final BaseColumnInfo baseColumnInfo = optional.get();
        for (final List<DTCellValue52> row : model.getData()) {
            final DTCellValue52 dtCellValue52 = row.get(baseColumnInfo.getColumnIndex());
            final int oldValue = getNumber(dtCellValue52);
            final int rowNumber = row.get(rowNumberColumnIndex).getNumericValue().intValue() - 1;
            if (oldValue != 0) {
                GuidedDecisionTableUiCell newUiCell;
                if (oldValue > rowNumber || rowNumberChanges.get(oldValue) > rowNumber) {
                    newUiCell = new GuidedDecisionTableUiCell<>("");
                } else {
                    dtCellValue52.setStringValue(Integer.toString(rowNumberChanges.get(oldValue)));
                    newUiCell = gridWidgetCellFactory.convertCell(dtCellValue52, baseColumnInfo.getBaseColumn(), cellUtilities, columnUtilities);
                }
                uiModel.setCellValueInternal(rowNumber, baseColumnInfo.getColumnIndex(), newUiCell);
            }
        }
    }
}
Also used : DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) GuidedDecisionTableUiCell(org.drools.workbench.screens.guided.dtable.client.widget.table.model.GuidedDecisionTableUiCell)

Example 2 with GuidedDecisionTableUiCell

use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.GuidedDecisionTableUiCell in project drools-wb by kiegroup.

the class ConditionColumnSynchronizerTest method testOtherwise.

@Test
public void testOtherwise() throws VetoException {
    // Single Pattern, single Condition
    final Pattern52 pattern = boundApplicantPattern("$a");
    final ConditionCol52 condition = nameEqualsCondition();
    modelSynchronizer.appendColumn(pattern, condition);
    modelSynchronizer.appendRow();
    uiModel.setCellValue(0, 2, new GuidedDecisionTableUiCell("John"));
    modelSynchronizer.appendRow();
    uiModel.setCellValue(1, 2, new GuidedDecisionTableUiCell("George"));
    modelSynchronizer.setCellOtherwiseState(1, 2);
    assertFalse(((GuidedDecisionTableUiCell) uiModel.getCell(0, 2).getValue()).isOtherwise());
    assertTrue(((GuidedDecisionTableUiCell) uiModel.getCell(1, 2).getValue()).isOtherwise());
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) GuidedDecisionTableUiCell(org.drools.workbench.screens.guided.dtable.client.widget.table.model.GuidedDecisionTableUiCell) Test(org.junit.Test)

Aggregations

GuidedDecisionTableUiCell (org.drools.workbench.screens.guided.dtable.client.widget.table.model.GuidedDecisionTableUiCell)2 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)1 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)1 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)1 Test (org.junit.Test)1