use of org.eclipse.gef.requests.ChangeBoundsRequest in project tdi-studio-se by Talend.
the class BusinessExtNodeLabelHostLayoutEditPolicy method getCommand.
/**
* @generated
*/
public Command getCommand(Request request) {
if (REQ_MOVE_CHILDREN.equals(request.getType())) {
ChangeBoundsRequest cbRequest = (ChangeBoundsRequest) request;
List extLabels = getExternalLabels(cbRequest);
if (!extLabels.isEmpty()) {
List editParts = cbRequest.getEditParts();
Command cmd = null;
if (realLayoutEditPolicy != null && editParts.size() > extLabels.size()) {
List other = new ArrayList(editParts);
other.removeAll(extLabels);
cbRequest.setEditParts(other);
cmd = realLayoutEditPolicy.getCommand(request);
}
cbRequest.setEditParts(extLabels);
Command extLabelsCmd = getMoveChildrenCommand(request);
cbRequest.setEditParts(editParts);
return cmd == null ? extLabelsCmd : cmd.chain(extLabelsCmd);
}
}
if (request instanceof GroupRequest) {
List extLabels = getExternalLabels((GroupRequest) request);
if (!extLabels.isEmpty()) {
return null;
}
}
return realLayoutEditPolicy == null ? null : realLayoutEditPolicy.getCommand(request);
}
use of org.eclipse.gef.requests.ChangeBoundsRequest in project archi by archimatetool.
the class ConstrainedResizableEditPolicy method getResizeTracker.
@Override
protected ResizeTracker getResizeTracker(int direction) {
return new ResizeTracker((GraphicalEditPart) getHost(), direction) {
@Override
protected Request createSourceRequest() {
ChangeBoundsRequest request = new ChangeBoundsRequest(REQ_RESIZE) {
@Override
public boolean isConstrainedResize() {
return super.isConstrainedResize();
// return getCurrentInput().isModKeyDown(SWT.SHIFT) ? false : true;
}
@Override
public boolean isCenteredResize() {
return super.isCenteredResize();
// return false;
}
@Override
public boolean isSnapToEnabled() {
return super.isSnapToEnabled();
// int direction = getResizeDirection();
// if(direction == PositionConstants.EAST) {
// return super.isSnapToEnabled();
// }
// return false;
}
};
request.setResizeDirection(getResizeDirection());
return request;
}
@Override
protected Dimension getMinimumSizeFor(ChangeBoundsRequest request) {
return MIN_DIMENSION;
}
};
}
use of org.eclipse.gef.requests.ChangeBoundsRequest in project knime-core by knime.
the class SnapIconToGrid method snapRectangle.
/**
* {@inheritDoc}
*/
@Override
public int snapRectangle(final Request request, final int snapLocations, final PrecisionRectangle rect, final PrecisionRectangle result) {
PrecisionRectangle r = rect;
if (request instanceof ChangeBoundsRequest) {
EditPart refPart = getReferencePart(((ChangeBoundsRequest) request).getEditParts(), ((ChangeBoundsRequest) request).getLocation(), ((ChangeBoundsRequest) request).getMoveDelta());
if (refPart instanceof NodeContainerEditPart) {
// adjust the rectangle to snap the center of the icon of the node
NodeContainerEditPart contPart = (NodeContainerEditPart) refPart;
NodeContainerFigure fig = (NodeContainerFigure) contPart.getFigure();
Point iconOffset = getIconOffset(fig);
r = rect.getPreciseCopy();
r.translate(iconOffset);
} else if (refPart instanceof NodeAnnotationEditPart) {
// the rect is the annotation outline - adjust it to snap the center of the corresponding node icon
NodeAnnotationEditPart annoPart = (NodeAnnotationEditPart) refPart;
WorkflowRootEditPart parent = (WorkflowRootEditPart) annoPart.getParent();
IFigure annoFig = annoPart.getFigure();
NodeAnnotation anno = (NodeAnnotation) annoPart.getModel();
NodeContainerEditPart nodePart = (NodeContainerEditPart) m_container.getViewer().getEditPartRegistry().get(parent.getWorkflowManager().getNodeContainer(anno.getNodeID()));
NodeContainerFigure nodeFig = (NodeContainerFigure) nodePart.getFigure();
Point iconOffset = getIconOffset(nodeFig);
int xOff = nodeFig.getBounds().x - annoFig.getBounds().x;
xOff += iconOffset.x;
int yOff = iconOffset.y - nodeFig.getBounds().height;
r = rect.getPreciseCopy();
r.translate(new Point(xOff, yOff));
}
}
return super.snapRectangle(request, snapLocations, r, result);
}
use of org.eclipse.gef.requests.ChangeBoundsRequest in project knime-core by knime.
the class ConnectionContainerEditPart method getBendpointAdaptionCommand.
/**
* Creates a GEF command to shift the connections bendpoints.
*
* @param request the underlying request holding information about the shift
* @return the command to change the bendpoint locations
*/
public Command getBendpointAdaptionCommand(final Request request) {
assert (request instanceof ChangeBoundsRequest) : "Unexpected request type: " + request.getClass();
ZoomManager zoomManager = (ZoomManager) (getRoot().getViewer().getProperty(ZoomManager.class.toString()));
Point moveDelta = ((ChangeBoundsRequest) request).getMoveDelta();
return new ChangeBendPointLocationCommand(this, moveDelta, zoomManager);
}
use of org.eclipse.gef.requests.ChangeBoundsRequest in project yamcs-studio by yamcs.
the class WidgetTreeEditPolicy method getMoveCommand.
protected Command getMoveCommand(ChangeBoundsRequest req) {
EditPart parent = getHost().getParent();
if (parent != null) {
ChangeBoundsRequest request = new ChangeBoundsRequest(REQ_MOVE_CHILDREN);
// request.setEditParts(getHost());
request.setEditParts(req.getEditParts());
request.setLocation(req.getLocation());
// $NON-NLS-1$
req.setType("");
return parent.getCommand(request);
}
return UnexecutableCommand.INSTANCE;
}
Aggregations