use of org.eclipse.gef.requests.ChangeBoundsRequest in project yamcs-studio by yamcs.
the class PolyPointDragTracker method updateSourceRequest.
/**
* {@inheritDoc}
*/
@Override
@SuppressWarnings("unchecked")
protected void updateSourceRequest() {
super.updateSourceRequest();
ChangeBoundsRequest request = (ChangeBoundsRequest) getSourceRequest();
PrecisionPoint location = new PrecisionPoint(getLocation().x, getLocation().y);
if (_snapToHelper != null) {
_snapToHelper.snapPoint(request, PositionConstants.NORTH_WEST, new PrecisionPoint(getLocation().x, getLocation().y), location);
}
_owner.getFigure().translateToRelative(location);
PointList oldPoints = ((PointList) request.getExtendedData().get(EXT_DATA_POINTS)).getCopy();
PointList newPoints = oldPoints.getCopy();
newPoints.setPoint(location.getCopy(), _pointIndex);
// calculate difference
Rectangle oldBounds = _oldPoints.getBounds();
Rectangle newBounds = newPoints.getBounds();
request.setLocation(getLocation());
Dimension locationDiff = newBounds.getLocation().getDifference(oldBounds.getLocation());
_owner.getFigure().translateToAbsolute(locationDiff);
Dimension sizeDiff = newBounds.getSize().getDifference(oldBounds.getSize());
_owner.getFigure().translateToAbsolute(sizeDiff);
request.setMoveDelta(new Point(locationDiff.width, locationDiff.height));
request.setSizeDelta(sizeDiff);
request.getExtendedData().put(EXT_DATA_POINTS, newPoints);
request.getExtendedData().put(EXT_DATA_POINT_INDEX, _pointIndex);
}
use of org.eclipse.gef.requests.ChangeBoundsRequest in project yamcs-studio by yamcs.
the class PolyPointDragTracker method createSourceRequest.
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
protected Request createSourceRequest() {
ChangeBoundsRequest request = new ChangeBoundsRequest();
// TODO: swende: ugly
request.setEditParts(getTargetEditPart());
PointList points = ((AbstractPolyModel) _owner.getModel()).getPoints();
request.getExtendedData().put(AbstractPolyFeedbackFactory.PROP_POINTS, points.getCopy());
request.setType(RequestConstants.REQ_RESIZE);
_oldPoints = points.getCopy();
return request;
}
use of org.eclipse.gef.requests.ChangeBoundsRequest in project whole by wholeplatform.
the class EditPartTransferDropTargetListener method updateTargetRequest.
@Override
protected void updateTargetRequest() {
DropTargetEvent event = getCurrentEvent();
ChangeBoundsRequest request = (ChangeBoundsRequest) getTargetRequest();
request.setType(REQ_CLONE);
request.setEditParts(event.data == null ? Collections.emptyList() : (List<?>) event.data);
request.getExtendedData().clear();
request.setLocation(getDropLocation());
}
use of org.eclipse.gef.requests.ChangeBoundsRequest in project whole by wholeplatform.
the class EditPartTransferDropTargetListener method isMoving.
@SuppressWarnings("unchecked")
protected boolean isMoving() {
DropTargetEvent event = getCurrentEvent();
EditPart targetEditPart = getTargetEditPart();
if (event.detail != DND.DROP_MOVE || targetEditPart == null)
return false;
ChangeBoundsRequest request = (ChangeBoundsRequest) getTargetRequest();
for (EditPart editPart : ((List<EditPart>) request.getEditParts())) if (!targetEditPart.equals(editPart.getParent()))
return false;
return true;
}
use of org.eclipse.gef.requests.ChangeBoundsRequest in project whole by wholeplatform.
the class EditPartTransferDropTargetListener method getCommand.
@SuppressWarnings("unchecked")
protected Command getCommand() {
EditPart targetEditPart = getTargetEditPart();
if (targetEditPart == null)
return UnexecutableCommand.INSTANCE;
ChangeBoundsRequest request = (ChangeBoundsRequest) getTargetRequest();
DnDCompoundCommand command = new DnDCompoundCommand();
boolean cloning = isCloning();
boolean moving = isMoving();
if (cloning)
request.setType(REQ_CLONE);
else if (moving)
request.setType(REQ_MOVE);
else
request.setType(REQ_ORPHAN);
// create REQ_MOVE and REQ_ORPHAN requests
if (!cloning)
for (EditPart editPart : ((List<EditPart>) request.getEditParts())) command.addSourceCommand(editPart, editPart.getCommand(request));
// create REQ_CLONE request
if (!moving) {
request.setType(REQ_CLONE);
command.addTargetCommand(targetEditPart, targetEditPart.getCommand(request));
}
return command;
}
Aggregations