Search in sources :

Example 16 with ActionWorkItemInsertFactCol52

use of org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemInsertFactCol52 in project drools-wb by kiegroup.

the class ActionWorkItemInsertFactColumnConverterTest method getColumn.

@Override
protected BaseColumn getColumn() {
    final ActionWorkItemInsertFactCol52 column = new ActionWorkItemInsertFactCol52();
    column.setWorkItemName(WID_NAME);
    column.setHeader(HEADER);
    column.setWidth(WIDTH);
    return column;
}
Also used : ActionWorkItemInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemInsertFactCol52)

Example 17 with ActionWorkItemInsertFactCol52

use of org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemInsertFactCol52 in project drools-wb by kiegroup.

the class ActionWorkItemInsertFactColumnSynchronizer method update.

@Override
public List<BaseColumnFieldDiff> update(final ColumnMetaData originalMetaData, final ColumnMetaData editedMetaData) throws VetoException {
    // Check operation is supported
    if (!(handlesUpdate(originalMetaData) && handlesUpdate(editedMetaData))) {
        return Collections.emptyList();
    }
    // Get differences between original and edited column
    final ActionWorkItemInsertFactCol52 originalColumn = (ActionWorkItemInsertFactCol52) originalMetaData.getColumn();
    final ActionWorkItemInsertFactCol52 editedColumn = (ActionWorkItemInsertFactCol52) editedMetaData.getColumn();
    final List<BaseColumnFieldDiff> diffs = originalColumn.diff(editedColumn);
    update(originalColumn, editedColumn);
    // ActionWorkItem columns are always represented with a BooleanUiColumn
    final boolean isHideUpdated = BaseColumnFieldDiffImpl.hasChanged(ActionWorkItemInsertFactCol52.FIELD_HIDE_COLUMN, diffs);
    final boolean isHeaderUpdated = BaseColumnFieldDiffImpl.hasChanged(ActionWorkItemInsertFactCol52.FIELD_HEADER, diffs);
    if (isHideUpdated) {
        setColumnVisibility(originalColumn, originalColumn.isHideColumn());
    }
    if (isHeaderUpdated) {
        setColumnHeader(originalColumn, originalColumn.getHeader());
    }
    return diffs;
}
Also used : ActionWorkItemInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemInsertFactCol52) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)

Example 18 with ActionWorkItemInsertFactCol52

use of org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemInsertFactCol52 in project drools-wb by kiegroup.

the class ActionWorkItemInsertFactColumnSynchronizerTest method testMoveColumnTo_OutOfBounds.

@Test
public void testMoveColumnTo_OutOfBounds() throws VetoException {
    final ActionWorkItemInsertFactCol52 column1 = new ActionWorkItemInsertFactCol52();
    column1.setWorkItemName(WORK_ITEM_NAME);
    column1.setBoundName("$a");
    column1.setFactType("Applicant");
    column1.setFactField("age");
    column1.setHeader("wid1");
    final ActionWorkItemInsertFactCol52 column2 = new ActionWorkItemInsertFactCol52();
    column2.setWorkItemName(WORK_ITEM_NAME);
    column2.setBoundName("$a");
    column2.setFactType("Applicant");
    column2.setFactField("name");
    column2.setHeader("wid2");
    modelSynchronizer.appendColumn(column1);
    modelSynchronizer.appendColumn(column2);
    modelSynchronizer.appendRow();
    uiModel.setCellValue(0, 3, new BaseGridCellValue<Boolean>(true));
    uiModel.setCellValue(0, 4, new BaseGridCellValue<Boolean>(false));
    assertEquals(3, model.getActionCols().size());
    assertEquals(column1, model.getActionCols().get(1));
    assertEquals(column2, model.getActionCols().get(2));
    assertEquals(true, model.getData().get(0).get(3).getBooleanValue());
    assertEquals(false, model.getData().get(0).get(4).getBooleanValue());
    assertEquals(5, uiModel.getColumns().size());
    final GridColumn<?> uiModelColumn1_1 = uiModel.getColumns().get(3);
    final GridColumn<?> uiModelColumn2_1 = uiModel.getColumns().get(4);
    assertEquals("wid1", uiModelColumn1_1.getHeaderMetaData().get(1).getTitle());
    assertEquals("wid2", uiModelColumn2_1.getHeaderMetaData().get(1).getTitle());
    assertTrue(uiModelColumn1_1 instanceof BooleanUiColumn);
    assertTrue(uiModelColumn2_1 instanceof BooleanUiColumn);
    assertEquals(3, uiModelColumn1_1.getIndex());
    assertEquals(4, uiModelColumn2_1.getIndex());
    assertEquals(true, uiModel.getRow(0).getCells().get(uiModelColumn1_1.getIndex()).getValue().getValue());
    assertEquals(false, uiModel.getRow(0).getCells().get(uiModelColumn2_1.getIndex()).getValue().getValue());
    uiModel.moveColumnTo(1, uiModelColumn1_1);
    assertEquals(3, model.getActionCols().size());
    assertEquals(column1, model.getActionCols().get(1));
    assertEquals(column2, model.getActionCols().get(2));
    assertEquals(true, model.getData().get(0).get(3).getBooleanValue());
    assertEquals(false, model.getData().get(0).get(4).getBooleanValue());
    assertEquals(5, uiModel.getColumns().size());
    final GridColumn<?> uiModelColumn1_2 = uiModel.getColumns().get(3);
    final GridColumn<?> uiModelColumn2_2 = uiModel.getColumns().get(4);
    assertEquals("wid1", uiModelColumn1_2.getHeaderMetaData().get(1).getTitle());
    assertEquals("wid2", uiModelColumn2_2.getHeaderMetaData().get(1).getTitle());
    assertTrue(uiModelColumn1_2 instanceof BooleanUiColumn);
    assertTrue(uiModelColumn2_2 instanceof BooleanUiColumn);
    assertEquals(3, uiModelColumn1_2.getIndex());
    assertEquals(4, uiModelColumn2_2.getIndex());
    assertEquals(true, uiModel.getRow(0).getCells().get(uiModelColumn1_2.getIndex()).getValue().getValue());
    assertEquals(false, uiModel.getRow(0).getCells().get(uiModelColumn2_2.getIndex()).getValue().getValue());
}
Also used : ActionWorkItemInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemInsertFactCol52) BooleanUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BooleanUiColumn) Test(org.junit.Test)

Example 19 with ActionWorkItemInsertFactCol52

use of org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemInsertFactCol52 in project drools-wb by kiegroup.

the class ActionWorkItemInsertFactColumnSynchronizerTest method testMoveColumnTo_MoveWorkItemInsertFactColRight_WithFollowingInsertFactCol.

@Test
@SuppressWarnings("unchecked")
public void testMoveColumnTo_MoveWorkItemInsertFactColRight_WithFollowingInsertFactCol() throws VetoException {
    final ActionWorkItemInsertFactCol52 column1 = new ActionWorkItemInsertFactCol52();
    column1.setWorkItemName(WORK_ITEM_NAME);
    column1.setBoundName("$a");
    column1.setFactType("Applicant");
    column1.setFactField("age");
    column1.setHeader("wid1");
    final ActionInsertFactCol52 column2 = new ActionInsertFactCol52();
    column2.setBoundName("$a");
    column2.setFactType("Applicant");
    column2.setFactField("name");
    column2.setHeader("name");
    modelSynchronizer.appendColumn(column1);
    modelSynchronizer.appendColumn(column2);
    modelSynchronizer.appendRow();
    uiModel.setCellValue(0, 3, new BaseGridCellValue<>(true));
    uiModel.setCellValue(0, 4, new BaseGridCellValue<>("Fred"));
    assertGridDefinitionMovingWorkItemInsertFactColAndInsertFactCol(column1, column2);
    final GridColumn<?> uiModelColumn1 = uiModel.getColumns().get(2);
    final GridColumn<?> uiModelColumn2 = uiModel.getColumns().get(3);
    uiModel.moveColumnsTo(4, new ArrayList<GridColumn<?>>() {

        {
            add(uiModelColumn1);
            add(uiModelColumn2);
        }
    });
    // Move should be aborted and the definition unchanged
    assertGridDefinitionMovingWorkItemInsertFactColAndInsertFactCol(column1, column2);
}
Also used : ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) ActionWorkItemInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemInsertFactCol52) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) Test(org.junit.Test)

Example 20 with ActionWorkItemInsertFactCol52

use of org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemInsertFactCol52 in project drools-wb by kiegroup.

the class ActionWorkItemInsertFactColumnSynchronizerTest method testAppendMultipleColumns.

@Test
public void testAppendMultipleColumns() throws VetoException {
    final ActionWorkItemInsertFactCol52 column1 = new ActionWorkItemInsertFactCol52();
    column1.setWorkItemName(WORK_ITEM_NAME);
    column1.setHeader("col1");
    final ActionWorkItemInsertFactCol52 column2 = new ActionWorkItemInsertFactCol52();
    column2.setWorkItemName(WORK_ITEM_NAME);
    column2.setHeader("col2");
    modelSynchronizer.appendColumn(column1);
    modelSynchronizer.appendColumn(column2);
    assertEquals(3, model.getActionCols().size());
    assertEquals(5, uiModel.getColumns().size());
    assertTrue(uiModel.getColumns().get(3) instanceof BooleanUiColumn);
    assertTrue(uiModel.getColumns().get(4) instanceof BooleanUiColumn);
    assertEquals(true, ((BaseMultipleDOMElementUiColumn) uiModel.getColumns().get(3)).isEditable());
    assertEquals(true, ((BaseMultipleDOMElementUiColumn) uiModel.getColumns().get(4)).isEditable());
    assertEquals(column1.getHeader(), uiModel.getColumns().get(3).getHeaderMetaData().get(1).getTitle());
    assertEquals(column2.getHeader(), uiModel.getColumns().get(4).getHeaderMetaData().get(1).getTitle());
}
Also used : ActionWorkItemInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemInsertFactCol52) BooleanUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BooleanUiColumn) Test(org.junit.Test)

Aggregations

ActionWorkItemInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemInsertFactCol52)25 Test (org.junit.Test)17 ActionWorkItemCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52)6 BooleanUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BooleanUiColumn)6 ArrayList (java.util.ArrayList)5 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)5 BaseColumnFieldDiff (org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)5 ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)4 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)4 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)4 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)3 ActionWorkItemSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemSetFieldCol52)3 Collections (java.util.Collections)2 List (java.util.List)2 Dependent (javax.enterprise.context.Dependent)2 ActionExecuteWorkItem (org.drools.workbench.models.datamodel.rule.ActionExecuteWorkItem)2 ActionFieldValue (org.drools.workbench.models.datamodel.rule.ActionFieldValue)2 ActionInsertFact (org.drools.workbench.models.datamodel.rule.ActionInsertFact)2 ActionWorkItemFieldValue (org.drools.workbench.models.datamodel.rule.ActionWorkItemFieldValue)2 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)2