Search in sources :

Example 1 with ChangeBoundsRequest

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);
}
Also used : ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest) Command(org.eclipse.gef.commands.Command) GroupRequest(org.eclipse.gef.requests.GroupRequest) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with ChangeBoundsRequest

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;
        }
    };
}
Also used : ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest) ResizeTracker(org.eclipse.gef.tools.ResizeTracker)

Example 3 with ChangeBoundsRequest

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);
}
Also used : ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) PrecisionRectangle(org.eclipse.draw2d.geometry.PrecisionRectangle) NodeAnnotation(org.knime.core.node.workflow.NodeAnnotation) WorkflowRootEditPart(org.knime.workbench.editor2.editparts.WorkflowRootEditPart) WorkflowRootEditPart(org.knime.workbench.editor2.editparts.WorkflowRootEditPart) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) NodeAnnotationEditPart(org.knime.workbench.editor2.editparts.NodeAnnotationEditPart) EditPart(org.eclipse.gef.EditPart) Point(org.eclipse.draw2d.geometry.Point) NodeAnnotationEditPart(org.knime.workbench.editor2.editparts.NodeAnnotationEditPart) NodeContainerFigure(org.knime.workbench.editor2.figures.NodeContainerFigure) IFigure(org.eclipse.draw2d.IFigure)

Example 4 with ChangeBoundsRequest

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);
}
Also used : ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest) ZoomManager(org.eclipse.gef.editparts.ZoomManager) Point(org.eclipse.draw2d.geometry.Point) ChangeBendPointLocationCommand(org.knime.workbench.editor2.commands.ChangeBendPointLocationCommand)

Example 5 with ChangeBoundsRequest

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;
}
Also used : ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest) EditPart(org.eclipse.gef.EditPart)

Aggregations

ChangeBoundsRequest (org.eclipse.gef.requests.ChangeBoundsRequest)24 Point (org.eclipse.draw2d.geometry.Point)8 EditPart (org.eclipse.gef.EditPart)7 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)7 List (java.util.List)6 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)6 ArrayList (java.util.ArrayList)5 Command (org.eclipse.gef.commands.Command)4 PointList (org.eclipse.draw2d.geometry.PointList)3 PrecisionRectangle (org.eclipse.draw2d.geometry.PrecisionRectangle)3 IFigure (org.eclipse.draw2d.IFigure)2 Rectangle (org.eclipse.draw2d.geometry.Rectangle)2 ICommandProxy (org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy)2 IGraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)2 DropTargetEvent (org.eclipse.swt.dnd.DropTargetEvent)2 Shell (org.eclipse.swt.widgets.Shell)2 IPersistenceKit (org.whole.lang.codebase.IPersistenceKit)2 IEntity (org.whole.lang.model.IEntity)2 IImportAsModelDialog (org.whole.lang.ui.dialogs.IImportAsModelDialog)2 CreateNestedArchimateConnectionsWithDialogCommand (com.archimatetool.editor.diagram.commands.CreateNestedArchimateConnectionsWithDialogCommand)1