@Override protected boolean handleButtonUp(int button) { try { if (internalResizeCommand != null) internalResizeCommand.undo(null, null); } catch (ExecutionException e) { } return super.handleButtonUp(button); }
@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; }