public void activate() {
    super.activate();
    getEditor().startUndo("Reorder Parameters");

    DecorationMgr.addDecorator(getEditor(), BasicFigure.DECO_OVERLAY, targetDecorator);

    getView().redraw();
  }
  public void deactivate() {
    DecorationMgr.removeDecorator(getEditor(), BasicFigure.DECO_OVERLAY, targetDecorator);

    paramFigure = null;
    socketFigure = null;
    oldIndex = 0;
    regions = null;
    socketDisplayBox = null;

    super.deactivate();
  }
  public void setAffectedObject(Object affectedObject) {
    super.setAffectedObject(affectedObject);

    if (affectedObject != null) {
      this.paramFigure = (ParamFigure) affectedObject;
      this.socketFigure = (SocketFigure) paramFigure.getParent();

      // Rebuild the parameter list, displaying all parameters
      socketFigure.reinitParams(true);

      socketDisplayBox = socketFigure.displayBox();

      // We retrieve the old index of the parameter.
      oldIndex = socketFigure.getNodeSocket().getParamList().indexOf(paramFigure.getNodeParam());

      regions = socketFigure.getParamRegions();
    } else {
      socketFigure = null;
      regions = null;
    }
  }
  public void mouseUp(MouseEvent e, int x, int y) {
    if (socketDisplayBox.contains(x, y)) {
      // Strategy: We determine the region over which we are right now
      for (int i = 0; i < regions.length; i++) {
        if (regions[i].contains(x, y)) {
          socketFigure.moveParameter(oldIndex, i);

          getView().setCursor(null);

          break;
        }
      }
    }

    // Rebuild the parmeter list, displaying the visible parameters only
    socketFigure.reinitParams(false);

    getView().singleSelect(paramFigure);

    getEditor().endUndo();

    super.mouseUp(e, x, y);
  }