Search in sources :

Example 1 with Synchronizer

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

the class ModelSynchronizerImpl method moveRowsTo.

@Override
@SuppressWarnings("unchecked")
public void moveRowsTo(final int targetRowIndex, final List<GridRow> rows) throws VetoException {
    // Generate meta-data to handle moves
    final List<MoveRowToMetaData> metaData = new ArrayList<MoveRowToMetaData>();
    for (int index = 0; index < rows.size(); index++) {
        final GridRow row = rows.get(index);
        final int sourceRowIndex = uiModel.getRows().indexOf(row);
        if (sourceRowIndex == targetRowIndex) {
            throw new MoveVetoException();
        }
        final List<DTCellValue52> modelRow = model.getData().get(sourceRowIndex);
        metaData.add(new MoveRowToMetaDataImpl(sourceRowIndex, targetRowIndex + index, modelRow));
    }
    final List<Synchronizer> handlers = new ArrayList<Synchronizer>();
    for (Synchronizer synchronizer : synchronizers) {
        if (synchronizer.handlesMoveRowsTo(metaData)) {
            handlers.add(synchronizer);
        }
    }
    if (handlers.isEmpty()) {
        throw new MoveVetoException();
    }
    for (Synchronizer synchronizer : handlers) {
        synchronizer.moveRowsTo(metaData);
    }
}
Also used : Synchronizer(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.Synchronizer) ModelSynchronizer(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer) MoveRowToMetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.MoveRowToMetaData) ArrayList(java.util.ArrayList) MoveRowToMetaDataImpl(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.MoveRowToMetaDataImpl) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow)

Example 2 with Synchronizer

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

the class ModelSynchronizerImpl method insertRow.

@Override
public void insertRow(final int rowIndex) throws VetoException {
    final MetaData metaData = new RowSynchronizer.RowMetaDataImpl(rowIndex);
    for (Synchronizer synchronizer : synchronizers) {
        if (synchronizer.handlesInsert(metaData)) {
            synchronizer.insert(metaData);
            break;
        }
    }
    fireInsertRowEvent(rowIndex);
    systemControlledColumnValuesSynchronizer.insertRow(rowIndex);
    fireUpdateColumnDataEvent();
}
Also used : Synchronizer(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.Synchronizer) ModelSynchronizer(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer) PatternConditionMetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.PatternConditionMetaData) MoveRowToMetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.MoveRowToMetaData) MetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.BaseColumnSynchronizer.MetaData) MoveColumnToMetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.MoveColumnToMetaData)

Example 3 with Synchronizer

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

the class ModelSynchronizerImpl method appendRow.

@Override
@SuppressWarnings("unchecked")
public void appendRow() throws VetoException {
    final MetaData metaData = new RowSynchronizer.RowMetaDataImpl();
    for (Synchronizer synchronizer : synchronizers) {
        if (synchronizer.handlesAppend(metaData)) {
            synchronizer.append(metaData);
            break;
        }
    }
    fireAppendRowEvent();
    systemControlledColumnValuesSynchronizer.appendRow();
    fireUpdateColumnDataEvent();
}
Also used : Synchronizer(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.Synchronizer) ModelSynchronizer(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer) PatternConditionMetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.PatternConditionMetaData) MoveRowToMetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.MoveRowToMetaData) MetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.BaseColumnSynchronizer.MetaData) MoveColumnToMetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.MoveColumnToMetaData)

Example 4 with Synchronizer

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

the class ModelSynchronizerImpl method appendColumn.

@Override
@SuppressWarnings("unchecked")
public void appendColumn(final BaseColumn column) throws VetoException {
    final MetaData metaData = new BaseColumnSynchronizer.ColumnMetaDataImpl(column);
    for (Synchronizer synchronizer : synchronizers) {
        if (synchronizer.handlesAppend(metaData)) {
            synchronizer.append(metaData);
            break;
        }
    }
    fireAfterColumnInsertedEvent(column);
}
Also used : Synchronizer(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.Synchronizer) ModelSynchronizer(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer) PatternConditionMetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.PatternConditionMetaData) MoveRowToMetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.MoveRowToMetaData) MetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.BaseColumnSynchronizer.MetaData) MoveColumnToMetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.MoveColumnToMetaData)

Example 5 with Synchronizer

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

the class ModelSynchronizerImpl method updateColumn.

@Override
@SuppressWarnings("unchecked")
public List<BaseColumnFieldDiff> updateColumn(final Pattern52 originalPattern, final ConditionCol52 originalColumn, final Pattern52 editedPattern, final ConditionCol52 editedColumn) throws VetoException {
    final PatternConditionMetaData originalMetaData = new PatternConditionMetaData(originalPattern, originalColumn);
    final PatternConditionMetaData editedMetaData = new PatternConditionMetaData(editedPattern, editedColumn);
    for (Synchronizer synchronizer : synchronizers) {
        if (synchronizer.handlesUpdate(originalMetaData)) {
            return synchronizer.update(originalMetaData, editedMetaData);
        }
    }
    return Collections.emptyList();
}
Also used : Synchronizer(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.Synchronizer) ModelSynchronizer(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer) PatternConditionMetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.PatternConditionMetaData)

Aggregations

Synchronizer (org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.Synchronizer)13 ModelSynchronizer (org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer)12 MoveColumnToMetaData (org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.MoveColumnToMetaData)8 PatternConditionMetaData (org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.PatternConditionMetaData)8 MoveRowToMetaData (org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.MoveRowToMetaData)7 MetaData (org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.BaseColumnSynchronizer.MetaData)6 ArrayList (java.util.ArrayList)4 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)2 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)2 BaseColumnConverter (org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.column.BaseColumnConverter)2 MoveColumnToMetaDataImpl (org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.MoveColumnToMetaDataImpl)2 EventBus (com.google.gwt.event.shared.EventBus)1 AbsolutePanel (com.google.gwt.user.client.ui.AbsolutePanel)1 Iterator (java.util.Iterator)1 Set (java.util.Set)1 PortableWorkDefinition (org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition)1 BRLRuleModel (org.drools.workbench.models.guided.dtable.shared.model.BRLRuleModel)1 BaseColumnFieldDiff (org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)1 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)1 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)1