Search in sources :

Example 6 with LimitedEntryBRLConditionColumn

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);
}
Also used : LimitedEntryBRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLConditionColumn) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) CompositeColumn(org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn)

Example 7 with LimitedEntryBRLConditionColumn

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);
}
Also used : LimitedEntryBRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLConditionColumn)

Example 8 with LimitedEntryBRLConditionColumn

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;
}
Also used : LimitedEntryBRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLConditionColumn) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)

Example 9 with LimitedEntryBRLConditionColumn

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());
}
Also used : IPattern(org.drools.workbench.models.datamodel.rule.IPattern) BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) LimitedEntryBRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLConditionColumn) LimitedEntryBRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLConditionColumn) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 10 with LimitedEntryBRLConditionColumn

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;
}
Also used : LimitedEntryBRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLConditionColumn)

Aggregations

LimitedEntryBRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLConditionColumn)11 Test (org.junit.Test)5 BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)2 BooleanUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BooleanUiColumn)2 ArrayList (java.util.ArrayList)1 IPattern (org.drools.workbench.models.datamodel.rule.IPattern)1 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)1 BaseColumnFieldDiff (org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)1 CompositeColumn (org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn)1