int targetColumnIndex = -1;
int numberOfColumns = -1;
if ( action instanceof BRLActionColumn ) {
BRLActionColumn brlColumn = (BRLActionColumn) action;
BRLActionVariableColumn variable = brlColumn.getChildColumns().get( 0 );
sourceColumnIndex = model.getExpandedColumns().indexOf( variable );
numberOfColumns = brlColumn.getChildColumns().size();
} else {
sourceColumnIndex = model.getExpandedColumns().indexOf( action );
numberOfColumns = 1;
}
if ( actionBeingMovedAfter instanceof BRLActionColumn ) {
BRLActionColumn brlColumn = (BRLActionColumn) actionBeingMovedAfter;
BRLActionVariableColumn variable = brlColumn.getChildColumns().get( brlColumn.getChildColumns().size() - 1 );
targetColumnIndex = model.getExpandedColumns().indexOf( variable );
} else {
targetColumnIndex = model.getExpandedColumns().indexOf( actionBeingMovedAfter );
}
//Update model
model.getActionCols().remove( action );
model.getActionCols().add( actionTargetIndex,
action );
//Update data and UI
MoveColumnsEvent mce = new MoveColumnsEvent( sourceColumnIndex,
targetColumnIndex,
numberOfColumns );
eventBus.fireEvent( mce );
} else {
//Move up (before)
ActionCol52 actionBeingMovedBefore = model.getActionCols().get( actionTargetIndex );
int sourceColumnIndex = -1;
int targetColumnIndex = -1;
int numberOfColumns = -1;
if ( action instanceof BRLActionColumn ) {
BRLActionColumn brlColumn = (BRLActionColumn) action;
BRLActionVariableColumn variable = brlColumn.getChildColumns().get( 0 );
sourceColumnIndex = model.getExpandedColumns().indexOf( variable );
numberOfColumns = brlColumn.getChildColumns().size();
} else {
sourceColumnIndex = model.getExpandedColumns().indexOf( action );
numberOfColumns = 1;
}
if ( actionBeingMovedBefore instanceof BRLActionColumn ) {
BRLActionColumn brlColumn = (BRLActionColumn) actionBeingMovedBefore;
BRLActionVariableColumn variable = brlColumn.getChildColumns().get( 0 );
targetColumnIndex = model.getExpandedColumns().indexOf( variable );
} else {
targetColumnIndex = model.getExpandedColumns().indexOf( actionBeingMovedBefore );
}