* (non-Javadoc)
*
* @see org.eclipse.gef.editpolicies.ResizableEditPolicy#getResizeCommand(org.eclipse.gef.requests.ChangeBoundsRequest)
*/
protected Command getResizeCommand(ChangeBoundsRequest request) {
ElementEditPart part = (ElementEditPart) this.getHost();
Rectangle rect = part.getFigure().getBounds();
rect = request.getTransformedRectangle(rect);
int width = rect.width;
int height = rect.height;
// since the user dragged rectangle included border/padding of the
// element. And if the element's
// width/height style setting don't include border padding, then we need
// to set the element's width/height
// style property a little smaller.
if (part.getFigure() instanceof CSSFigure) {
CSSFigure cssfigure = (CSSFigure) part.getFigure();
ICSSStyle style = cssfigure.getCSSStyle();
if (style != null && !style.isSizeIncludeBorderPadding()) {
width -= (style.getBorderInsets().getWidth() + style
.getPaddingInsets().getWidth());
height -= (style.getBorderInsets().getHeight() + style
.getPaddingInsets().getHeight());
}
}
//make sure to only change the dimensions for the direction of the resize request.
int resizeDirection = request.getResizeDirection();
switch (resizeDirection) {
case PositionConstants.EAST:
case PositionConstants.WEST:
//resizing, only the width, so set the height to -1;
height = -1;
break;
case PositionConstants.NORTH:
case PositionConstants.SOUTH:
//resizing only the height, so set the width to -1
width = -1;
break;
default:
//all others are changing both directions...
}
return getResizeCommand((IDOMElement) part.getIDOMNode(), width, height);
}