/**
  * Creates a new Command that can bar line shift a melody part.
  *
  * @param source the Part to paste
  * @param startSlot the slot to start pasting over in the dest
  * @param stopSlot the slot to end pasting over in the dest
  * @param direction the direction ("up" or "down") to transpose the second half
  * @param distance the number of half steps to transpose the melody
  * @param keySig the key signature that the solo is being played in
  * @param cm the command manager used
  */
 public SideSlipCommand(
     MelodyPart source, String direction, int distance, int keySig, CommandManager cm) {
   this.source = source;
   this.dest = source.copy();
   this.original = source.copy();
   this.direction = direction;
   this.distance = distance;
   this.keySig = keySig;
   this.cm = cm;
 }
  /** applies the transformation to the source MelodyPart */
  public void execute() {
    Trace.log(2, "executing SideSlipCommand");

    int start = original.getSize();

    if (direction.equals("up")) { // slide up
      cm.execute(new ShiftPitchesCommand(distance, dest, 0, start, 0, 128, keySig));
    } else if (direction.equals("down")) { // slide down
      cm.execute(new ShiftPitchesCommand(-1 * distance, dest, 0, start, 0, 128, keySig));
    }

    // add two of the same melodies with one transposed
    source.setSize(dest.getSize() * 2);
    source.pasteOver(dest, start);
  }
 /** Redoes the side slip. */
 public void redo() {
   if (source != null && dest != null) {
     dest.pasteOver(source, source.getSize());
   }
 }