//Add pattern to model, if applicable
if ( ! existPattern ) {
model.getConditions().add( editPattern );
//Signal patterns changed event
BoundFactsChangedEvent pce = new BoundFactsChangedEvent( rm.getLHSBoundFacts() );
eventBus.fireEvent( pce );
} else {
// Calculate the diffs between original and edit pattern
patternDiff = origPattern.diff(editPattern);
// Update the original pattern properties with new values.
origPattern.update(editPattern);
}
boolean bUpdateColumnData = false;
boolean bUpdateColumnDefinition = false;
// Change in bound name requires column to be repositioned
if ( !isEqualOrNull( origPattern.getBoundName(),
editPattern.getBoundName() ) ) {
editPattern.getChildColumns().add( editColumn );
List<DTCellValue52> columnData = cellValueFactory.makeColumnData( editColumn );
int origColumnIndex = model.getExpandedColumns().indexOf( origColumn );
// If the FactType, FieldType and ConstraintValueType are unchanged
// we can copy cell values from the old column into the new
if ( isEqualOrNull( origPattern.getFactType(),
editPattern.getFactType() )
&& isEqualOrNull( origColumn.getFactField(),
editColumn.getFactField() )
&& origColumn.getConstraintValueType() == editColumn.getConstraintValueType() ) {
columnData.clear();
for ( int iRow = 0; iRow < model.getData().size(); iRow++ ) {
List<DTCellValue52> row = model.getData().get( iRow );
columnData.add( row.get( origColumnIndex ) );
}
}
addColumn( editColumn,
columnData,
true );
// Delete old column
origPattern.getChildColumns().remove( origColumn );
if ( origPattern.getChildColumns().size() == 0 ) {
model.getConditions().remove( origPattern );
//Signal patterns changed event to Decision Table Widget
BRLRuleModel rm = new BRLRuleModel( model );
BoundFactsChangedEvent pce = new BoundFactsChangedEvent( rm.getLHSBoundFacts() );
eventBus.fireEvent( pce );
}
deleteColumn( origColumnIndex,
true );