use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLActionColumn in project drools-wb by kiegroup.
the class LimitedEntryBRLActionColumnSynchronizerTest method testUpdate.
@Test
public void testUpdate() throws VetoException {
final LimitedEntryBRLActionColumn column = new LimitedEntryBRLActionColumn();
column.setHeader("col1");
modelSynchronizer.appendColumn(column);
final LimitedEntryBRLActionColumn edited = new LimitedEntryBRLActionColumn();
edited.setHideColumn(true);
edited.setHeader("updated");
modelSynchronizer.updateColumn(column, edited);
assertEquals(1, model.getActionCols().size());
assertEquals(3, uiModel.getColumns().size());
assertTrue(uiModel.getColumns().get(2) instanceof BooleanUiColumn);
assertEquals("updated", uiModel.getColumns().get(2).getHeaderMetaData().get(0).getTitle());
assertEquals(false, uiModel.getColumns().get(2).isVisible());
}
use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLActionColumn in project drools-wb by kiegroup.
the class LimitedEntryBRLActionColumnSynchronizerTest method testMoveColumnTo_MoveLeft.
@Test
public void testMoveColumnTo_MoveLeft() throws VetoException {
final LimitedEntryBRLActionColumn column1 = new LimitedEntryBRLActionColumn();
column1.setHeader("age");
final LimitedEntryBRLActionColumn column2 = new LimitedEntryBRLActionColumn();
column2.setHeader("name");
modelSynchronizer.appendColumn(column1);
modelSynchronizer.appendColumn(column2);
modelSynchronizer.appendRow();
uiModel.setCellValue(0, 2, new BaseGridCellValue<Boolean>(true));
uiModel.setCellValue(0, 3, new BaseGridCellValue<Boolean>(false));
assertEquals(2, model.getActionCols().size());
assertEquals(column1, model.getActionCols().get(0));
assertEquals(column2, model.getActionCols().get(1));
assertEquals(true, model.getData().get(0).get(2).getBooleanValue());
assertEquals(false, model.getData().get(0).get(3).getBooleanValue());
assertEquals(4, uiModel.getColumns().size());
final GridColumn<?> uiModelColumn1_1 = uiModel.getColumns().get(2);
final GridColumn<?> uiModelColumn2_1 = uiModel.getColumns().get(3);
assertEquals("age", uiModelColumn1_1.getHeaderMetaData().get(0).getTitle());
assertEquals("name", uiModelColumn2_1.getHeaderMetaData().get(0).getTitle());
assertTrue(uiModelColumn1_1 instanceof BooleanUiColumn);
assertTrue(uiModelColumn2_1 instanceof BooleanUiColumn);
assertEquals(2, uiModelColumn1_1.getIndex());
assertEquals(3, 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(2, uiModelColumn2_1);
assertEquals(2, model.getActionCols().size());
assertEquals(column2, model.getActionCols().get(0));
assertEquals(column1, model.getActionCols().get(1));
assertEquals(false, model.getData().get(0).get(2).getBooleanValue());
assertEquals(true, model.getData().get(0).get(3).getBooleanValue());
assertEquals(4, uiModel.getColumns().size());
final GridColumn<?> uiModelColumn1_2 = uiModel.getColumns().get(2);
final GridColumn<?> uiModelColumn2_2 = uiModel.getColumns().get(3);
assertEquals("name", uiModelColumn1_2.getHeaderMetaData().get(0).getTitle());
assertEquals("age", uiModelColumn2_2.getHeaderMetaData().get(0).getTitle());
assertTrue(uiModelColumn1_2 instanceof BooleanUiColumn);
assertTrue(uiModelColumn2_2 instanceof BooleanUiColumn);
assertEquals(3, uiModelColumn1_2.getIndex());
assertEquals(2, uiModelColumn2_2.getIndex());
assertEquals(false, uiModel.getRow(0).getCells().get(uiModelColumn1_2.getIndex()).getValue().getValue());
assertEquals(true, uiModel.getRow(0).getCells().get(uiModelColumn2_2.getIndex()).getValue().getValue());
}
use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLActionColumn in project drools-wb by kiegroup.
the class LimitedEntryBRLActionColumnSynchronizerTest method testMoveColumnTo_OutOfBounds.
@Test
public void testMoveColumnTo_OutOfBounds() throws VetoException {
final LimitedEntryBRLActionColumn column1 = new LimitedEntryBRLActionColumn();
column1.setHeader("age");
final LimitedEntryBRLActionColumn column2 = new LimitedEntryBRLActionColumn();
column2.setHeader("name");
modelSynchronizer.appendColumn(column1);
modelSynchronizer.appendColumn(column2);
modelSynchronizer.appendRow();
uiModel.setCellValue(0, 2, new BaseGridCellValue<Boolean>(true));
uiModel.setCellValue(0, 3, new BaseGridCellValue<Boolean>(false));
assertEquals(2, model.getActionCols().size());
assertEquals(column1, model.getActionCols().get(0));
assertEquals(column2, model.getActionCols().get(1));
assertEquals(true, model.getData().get(0).get(2).getBooleanValue());
assertEquals(false, model.getData().get(0).get(3).getBooleanValue());
assertEquals(4, uiModel.getColumns().size());
final GridColumn<?> uiModelColumn1_1 = uiModel.getColumns().get(2);
final GridColumn<?> uiModelColumn2_1 = uiModel.getColumns().get(3);
assertEquals("age", uiModelColumn1_1.getHeaderMetaData().get(0).getTitle());
assertEquals("name", uiModelColumn2_1.getHeaderMetaData().get(0).getTitle());
assertTrue(uiModelColumn1_1 instanceof BooleanUiColumn);
assertTrue(uiModelColumn2_1 instanceof BooleanUiColumn);
assertEquals(2, uiModelColumn1_1.getIndex());
assertEquals(3, 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(0, uiModelColumn1_1);
assertEquals(2, model.getActionCols().size());
assertEquals(column1, model.getActionCols().get(0));
assertEquals(column2, model.getActionCols().get(1));
assertEquals(true, model.getData().get(0).get(2).getBooleanValue());
assertEquals(false, model.getData().get(0).get(3).getBooleanValue());
assertEquals(4, uiModel.getColumns().size());
final GridColumn<?> uiModelColumn1_2 = uiModel.getColumns().get(2);
final GridColumn<?> uiModelColumn2_2 = uiModel.getColumns().get(3);
assertEquals("age", uiModelColumn1_2.getHeaderMetaData().get(0).getTitle());
assertEquals("name", uiModelColumn2_2.getHeaderMetaData().get(0).getTitle());
assertTrue(uiModelColumn1_2 instanceof BooleanUiColumn);
assertTrue(uiModelColumn2_2 instanceof BooleanUiColumn);
assertEquals(2, uiModelColumn1_2.getIndex());
assertEquals(3, 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());
}
use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLActionColumn in project drools-wb by kiegroup.
the class LimitedEntryBRLActionColumnSynchronizer method append.
@Override
public void append(final ColumnMetaData metaData) throws VetoException {
// Check operation is supported
if (!handlesAppend(metaData)) {
return;
}
final LimitedEntryBRLActionColumn column = (LimitedEntryBRLActionColumn) metaData.getColumn();
model.getActionCols().add(column);
synchroniseAppendColumn(column);
}
use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLActionColumn in project drools-wb by kiegroup.
the class LimitedEntryBRLActionColumnSynchronizer 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 LimitedEntryBRLActionColumn originalColumn = (LimitedEntryBRLActionColumn) originalMetaData.getColumn();
final LimitedEntryBRLActionColumn editedColumn = (LimitedEntryBRLActionColumn) editedMetaData.getColumn();
final List<BaseColumnFieldDiff> diffs = originalColumn.diff(editedColumn);
update(originalColumn, editedColumn);
// LimitedEntry columns are always represented with a BooleanUiColumn
final boolean isHideUpdated = BaseColumnFieldDiffImpl.hasChanged(ConditionCol52.FIELD_HIDE_COLUMN, diffs);
final boolean isHeaderUpdated = BaseColumnFieldDiffImpl.hasChanged(ConditionCol52.FIELD_HIDE_COLUMN, diffs);
if (isHideUpdated) {
setColumnVisibility(originalColumn, originalColumn.isHideColumn());
}
if (isHeaderUpdated) {
setColumnHeader(originalColumn, originalColumn.getHeader());
}
return diffs;
}
Aggregations