@Override
  protected boolean handleDragStarted() {
    // TODO Auto-generated method stub
    boolean b = super.handleDragStarted();

    CustomRegionResizableEditPolicy policy =
        (CustomRegionResizableEditPolicy) regionEP.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);

    regionEP.setSelected(EditPart.SELECTED_NONE);

    View regionView = (View) regionEP.getModel();
    IAdaptable adaptableForRegion = new SemanticAdapter(null, regionView);

    ChangeBoundsRequest internalResizeRequest = new ChangeBoundsRequest();
    int regionWidth = Zone.getWidth(regionView);
    int regionHeight = Zone.getHeight(regionView);

    RegionFigure regionFigure = regionEP.getPrimaryShape();
    regionFigureBounds = regionFigure.getBounds().getCopy();
    // transform the coordinates to absolute
    regionFigure.translateToAbsolute(regionFigureBounds);

    String zone = Zone.getZone(regionView);
    if (Zone.isRight(zone)) {
      internalResizeRequest.setResizeDirection(PositionConstants.WEST);
      internalResizeRequest.setSizeDelta(new Dimension(-regionWidth, 0));
    } else if (Zone.isLeft(zone)) {
      internalResizeRequest.setResizeDirection(PositionConstants.EAST);
      internalResizeRequest.setSizeDelta(new Dimension(-regionWidth, 0));
    } else if (Zone.isTop(zone)) {
      internalResizeRequest.setResizeDirection(PositionConstants.SOUTH);
      internalResizeRequest.setSizeDelta(new Dimension(0, -regionHeight));
    } else if (Zone.isBottom(zone)) {
      internalResizeRequest.setResizeDirection(PositionConstants.NORTH);
      internalResizeRequest.setSizeDelta(new Dimension(0, -regionHeight));
    }

    internalResizeCommand =
        new CustomRegionResizeCommand(
            adaptableForRegion,
            null,
            regionEP.getEditingDomain(),
            null,
            internalResizeRequest,
            null);

    try {
      internalResizeCommand.execute(null, null);
    } catch (ExecutionException e) {
    }

    return b;
  }
  @Override
  protected void refreshVisuals() {
    super.refreshVisuals();

    View view = (View) getModel();
    RegionFigure f = getPrimaryShape();

    // check the region zone
    String zone = Zone.getZone(view);
    if (zone != null) {
      // check the neighbours if any and change the corresponding flags in the
      // figure
      if (Zone.hasRightNeighbours(zone)) f.setDisplayRightBorder(true);
      else f.setDisplayRightBorder(false);
      if (Zone.hasBottomNeighbours(zone)) f.setDisplayBottomBorder(true);
      else f.setDisplayBottomBorder(false);

      CustomRegionResizableEditPolicy policy =
          (CustomRegionResizableEditPolicy) getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
      // test for allowed directions
      int dirs = Zone.getAllowedResizeDirections(zone);
      // constrain the edit policy with these directions
      if (policy != null) policy.setResizeDirections(dirs);
    } else {
      f.setDisplayBottomBorder(false);
      f.setDisplayRightBorder(false);
    }
  }