class SpoonStepsDelegate extends SpoonDelegate {

  public void delSteps( TransMeta transformation, StepMeta[] steps ) {
    try {
      ExtensionPointHandler.callExtensionPoint( log, KettleExtensionPoint.TransBeforeDeleteSteps.id, steps );
    } catch ( KettleException e ) {
      return;
    }

    // Hops belonging to the deleting steps are placed in a single transaction and removed.
    List<TransHopMeta> transHops = new ArrayList<>();
    int[] hopIndexes = new int[transformation.nrTransHops()];
    int hopIndex = 0;
    for ( int i = transformation.nrTransHops() - 1; i >= 0; i-- ) {
      TransHopMeta hi = transformation.getTransHop( i );
      for ( int j = 0; j < steps.length && hopIndex < hopIndexes.length; j++ ) {
        if ( hi.getFromStep().equals( steps[j] ) || hi.getToStep().equals( steps[j] ) ) {
          int idx = transformation.indexOfTransHop( hi );
          transHops.add( (TransHopMeta) hi.clone() );
          hopIndexes[hopIndex] = idx;
          transformation.removeTransHop( idx );
          spoon.refreshTree();
          hopIndex++;
          break;
        }
      }
    }
    if ( !transHops.isEmpty() ) {
      TransHopMeta[] hops = transHops.toArray( new TransHopMeta[transHops.size()] );
      spoon.addUndoDelete( transformation, hops, hopIndexes );
    }

    // Deleting steps are placed all in a single transaction and removed.
    int[] positions = new int[steps.length];
    for ( int i = 0; i < steps.length; i++ ) {
      int pos = transformation.indexOfStep( steps[i] );
      transformation.removeStep( pos );
      positions[i] = pos;
    }
    spoon.addUndoDelete( transformation, steps, positions );

    spoon.refreshTree();
    spoon.refreshGraph();
  }

  public  SpoonStepsDelegate( Spoon spoon );

}