use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLConditionColumn in project drools-wb by kiegroup.
the class LimitedEntryBRLConditionColumnSynchronizer method moveColumnsTo.
@Override
public void moveColumnsTo(final List<MoveColumnToMetaData> metaData) throws VetoException {
// Check operation is supported
if (!handlesMoveColumnsTo(metaData)) {
return;
}
final MoveColumnToMetaData md = metaData.get(0);
final LimitedEntryBRLConditionColumn modelColumn = (LimitedEntryBRLConditionColumn) md.getColumn();
final List<CompositeColumn<? extends BaseColumn>> modelConditionColumns = model.getConditions();
final int modelConditionColumnCount = modelConditionColumns.size();
if (modelConditionColumnCount == 0) {
throw new ModelSynchronizer.MoveVetoException();
}
final List<BaseColumn> allModelColumns = model.getExpandedColumns();
final int minColumnIndex = allModelColumns.indexOf(modelConditionColumns.get(0));
final int maxColumnIndex = allModelColumns.indexOf(modelConditionColumns.get(modelConditionColumnCount - 1));
final int targetColumnIndex = md.getTargetColumnIndex();
final int sourceColumnIndex = md.getSourceColumnIndex();
if (targetColumnIndex < minColumnIndex || targetColumnIndex > maxColumnIndex) {
throw new ModelSynchronizer.MoveVetoException();
}
moveModelData(targetColumnIndex, sourceColumnIndex, sourceColumnIndex);
modelConditionColumns.remove(modelColumn);
modelConditionColumns.add(targetColumnIndex - minColumnIndex, modelColumn);
}
use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLConditionColumn in project drools-wb by kiegroup.
the class LimitedEntryBRLConditionColumnSynchronizer method append.
@Override
public void append(final ColumnMetaData metaData) throws VetoException {
// Check operation is supported
if (!handlesAppend(metaData)) {
return;
}
final LimitedEntryBRLConditionColumn column = (LimitedEntryBRLConditionColumn) metaData.getColumn();
model.getConditions().add(column);
synchroniseAppendColumn(column);
}
use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLConditionColumn in project drools-wb by kiegroup.
the class LimitedEntryBRLConditionColumnSynchronizer 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 LimitedEntryBRLConditionColumn originalColumn = (LimitedEntryBRLConditionColumn) originalMetaData.getColumn();
final LimitedEntryBRLConditionColumn editedColumn = (LimitedEntryBRLConditionColumn) 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;
}
use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLConditionColumn in project drools-wb by kiegroup.
the class BRLConditionColumnPluginTest method testCloneWhenColumnIsALimitedEntryBRLConditionColumn.
@Test
public void testCloneWhenColumnIsALimitedEntryBRLConditionColumn() throws Exception {
final List<IPattern> definition = new ArrayList<>();
final boolean hideColumn = false;
final LimitedEntryBRLConditionColumn column = makeLimitedEntryBRLConditionColumn("header", hideColumn, definition);
final BRLConditionColumn clone = plugin.clone(column);
assertEquals(column.getHeader(), clone.getHeader());
assertEquals(column.isHideColumn(), clone.isHideColumn());
assertEquals(column.getDefinition(), clone.getDefinition());
assertNotSame(column, clone);
assertTrue(clone.getChildColumns().isEmpty());
}
use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLConditionColumn in project drools-wb by kiegroup.
the class BRLConditionColumnPluginTest method makeLimitedEntryBRLConditionColumn.
private LimitedEntryBRLConditionColumn makeLimitedEntryBRLConditionColumn(final String header, final boolean hideColumn, final List<IPattern> definition) {
final LimitedEntryBRLConditionColumn column = new LimitedEntryBRLConditionColumn();
column.setHeader(header);
column.setHideColumn(hideColumn);
column.setDefinition(definition);
return column;
}
Aggregations