Search in sources :

Example 11 with ChangeBoundsRequest

use of org.eclipse.gef.requests.ChangeBoundsRequest in project whole by wholeplatform.

the class FileTransferDropTargetListener method updateTargetRequest.

@Override
protected void updateTargetRequest() {
    ChangeBoundsRequest request = (ChangeBoundsRequest) getTargetRequest();
    request.setEditParts(Collections.EMPTY_LIST);
    request.setLocation(getDropLocation());
}
Also used : ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest)

Example 12 with ChangeBoundsRequest

use of org.eclipse.gef.requests.ChangeBoundsRequest in project whole by wholeplatform.

the class TextTransferDropTargetListener method updateTargetRequest.

@Override
protected void updateTargetRequest() {
    ChangeBoundsRequest request = (ChangeBoundsRequest) getTargetRequest();
    request.setEditParts(Collections.EMPTY_LIST);
    request.setLocation(getDropLocation());
}
Also used : ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest)

Example 13 with ChangeBoundsRequest

use of org.eclipse.gef.requests.ChangeBoundsRequest in project webtools.sourceediting by eclipse.

the class DragAndDropEditPolicy method getCommand.

public org.eclipse.gef.commands.Command getCommand(Request request) {
    BaseDragAndDropCommand command = null;
    if (request instanceof ChangeBoundsRequest) {
        ChangeBoundsRequest changeBoundsRequest = (ChangeBoundsRequest) request;
        Point location = changeBoundsRequest.getLocation();
        GraphicalEditPart target = (GraphicalEditPart) viewer.findObjectAt(location);
        location = getPointerLocation(changeBoundsRequest.getLocation());
        ((GraphicalEditPart) viewer.getRootEditPart()).getFigure().translateToRelative(location);
        List list = changeBoundsRequest.getEditParts();
        // allow drag and drop of only one selected object
        if (list.size() == 1) {
            Object itemToDrag = list.get(0);
            if (itemToDrag instanceof XSDBaseFieldEditPart) {
                XSDBaseFieldEditPart selected = (XSDBaseFieldEditPart) itemToDrag;
                if (selected.getModel() instanceof XSDElementDeclarationAdapter) {
                    command = new XSDElementDragAndDropCommand(viewer, (ChangeBoundsRequest) request, target, selected, location);
                    selectionHandlesEditPolicy.setDragAndDropCommand(command);
                } else if (selected.getModel() instanceof XSDBaseAttributeAdapter) {
                    command = new XSDAttributeDragAndDropCommand(viewer, (ChangeBoundsRequest) request, target, selected, location);
                    selectionHandlesEditPolicy.setDragAndDropCommand(command);
                }
            }
        }
    }
    return command;
}
Also used : ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest) XSDElementDragAndDropCommand(org.eclipse.wst.xsd.ui.internal.commands.XSDElementDragAndDropCommand) XSDBaseFieldEditPart(org.eclipse.wst.xsd.ui.internal.design.editparts.XSDBaseFieldEditPart) XSDBaseAttributeAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAttributeAdapter) BaseDragAndDropCommand(org.eclipse.wst.xsd.ui.internal.commands.BaseDragAndDropCommand) List(java.util.List) Point(org.eclipse.draw2d.geometry.Point) XSDAttributeDragAndDropCommand(org.eclipse.wst.xsd.ui.internal.commands.XSDAttributeDragAndDropCommand) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) XSDElementDeclarationAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDElementDeclarationAdapter)

Example 14 with ChangeBoundsRequest

use of org.eclipse.gef.requests.ChangeBoundsRequest in project cubrid-manager by CUBRID.

the class GefViewerKeyHandler method moveHANodesByKey.

/**
	 * move figures by keyboard.
	 * 
	 * @param event KeyEvent
	 * @return if handled the event return true else return false.
	 */
private boolean moveHANodesByKey(KeyEvent event) {
    List<?> selectedEditParts = getViewer().getSelectedEditParts();
    boolean flag = false;
    for (Object obj : selectedEditParts) {
        if (!(obj instanceof HANodePart)) {
            continue;
        }
        GraphicalEditPart editPart = (GraphicalEditPart) obj;
        Command command = null;
        if ((event.stateMask & SWT.ALT) == 0 && (event.stateMask & SWT.CTRL) == 0 && (event.stateMask & SWT.SHIFT) == 0 && (event.keyCode == SWT.ARROW_DOWN || event.keyCode == SWT.ARROW_LEFT || event.keyCode == SWT.ARROW_RIGHT || event.keyCode == SWT.ARROW_UP)) {
            HANode node = (HANode) editPart.getModel();
            ChangeBoundsRequest request = new ChangeBoundsRequest(RequestConstants.REQ_MOVE);
            request.setLocation(node.getLocation());
            request.setEditParts(editPart);
            //get move delta
            Point moveDelta = null;
            switch(event.keyCode) {
                case SWT.ARROW_LEFT:
                    moveDelta = new Point(-1, 0);
                    break;
                case SWT.ARROW_RIGHT:
                    moveDelta = new Point(1, 0);
                    break;
                case SWT.ARROW_UP:
                    moveDelta = new Point(0, -1);
                    break;
                case SWT.ARROW_DOWN:
                    moveDelta = new Point(0, 1);
                    break;
                default:
                    return true;
            }
            request.setMoveDelta(moveDelta);
            command = editPart.getCommand(request);
        }
        if (command != null && !(command instanceof UnexecutableCommand)) {
            command.execute();
            flag = true;
        }
    }
    return flag;
}
Also used : ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest) UnexecutableCommand(org.eclipse.gef.commands.UnexecutableCommand) Command(org.eclipse.gef.commands.Command) Point(org.eclipse.draw2d.geometry.Point) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) HANode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HANode) UnexecutableCommand(org.eclipse.gef.commands.UnexecutableCommand) HANodePart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HANodePart)

Example 15 with ChangeBoundsRequest

use of org.eclipse.gef.requests.ChangeBoundsRequest in project knime-core by knime.

the class SnapToPortGeometry method snapRectangle.

/**
 * {@inheritDoc}
 */
@Override
public int snapRectangle(final Request request, int snapOrientation, PrecisionRectangle baseRect, final PrecisionRectangle result) {
    assert (request instanceof ChangeBoundsRequest) : "Unexpected request type: " + request.getClass();
    ChangeBoundsRequest changeBoundsRequest = (ChangeBoundsRequest) request;
    baseRect = baseRect.getPreciseCopy();
    makeRelative(m_container.getContentPane(), baseRect);
    PrecisionRectangle correction = new PrecisionRectangle();
    makeRelative(m_container.getContentPane(), correction);
    // Recalculate snapping locations if needed
    boolean isClone = request.getType().equals(RequestConstants.REQ_CLONE);
    List exclusionSet = null;
    if (m_rows == null || m_cols == null || isClone != m_cachedCloneBool) {
        m_cachedCloneBool = isClone;
        exclusionSet = Collections.EMPTY_LIST;
        if (!isClone) {
            exclusionSet = changeBoundsRequest.getEditParts();
        }
        populateRowsAndCols(generateSnapPartsList(exclusionSet), exclusionSet);
    }
    if ((snapOrientation & HORIZONTAL) != 0) {
        double xcorrect = getCorrectionFor(m_cols, changeBoundsRequest.getExtendedData(), true, baseRect.preciseX, baseRect.preciseRight());
        if (xcorrect != THRESHOLD) {
            snapOrientation &= ~HORIZONTAL;
            correction.preciseX += xcorrect;
        }
    }
    // get y values of the draged node part ports
    if (exclusionSet != null) {
        List<AbstractPortEditPart> ports = getPorts(exclusionSet);
        Entry[] yValues = new Entry[ports.size()];
        int i = 0;
        for (AbstractPortEditPart port : ports) {
            boolean inport = false;
            if (port instanceof NodeInPortEditPart || port instanceof WorkflowInPortEditPart) {
                inport = true;
            }
            yValues[i] = new Entry(0, getFigureBounds(port).getLeft().y, inport, port.getType());
            i++;
        }
        m_yValues = yValues;
    }
    // get the move delta of the orignial location
    Point moveDeltaPoint = changeBoundsRequest.getMoveDelta();
    WorkflowEditor.adaptZoom(m_zoomManager, moveDeltaPoint, false);
    int moveDelta = moveDeltaPoint.y;
    if ((snapOrientation & VERTICAL) != 0) {
        double ycorrect = THRESHOLD;
        ycorrect = getCorrectionForY(m_rows, changeBoundsRequest.getExtendedData(), m_yValues, moveDelta);
        if (Math.abs(ycorrect) < THRESHOLD) {
            snapOrientation &= ~VERTICAL;
            correction.preciseY += ycorrect;
        }
    }
    if ((snapOrientation & EAST) != 0) {
        double rightCorrection = getCorrectionFor(m_cols, request.getExtendedData(), true, baseRect.preciseRight() - 1, 1);
        if (rightCorrection != THRESHOLD) {
            snapOrientation &= ~EAST;
            correction.preciseWidth += rightCorrection;
        }
    }
    if ((snapOrientation & WEST) != 0) {
        double leftCorrection = getCorrectionFor(m_cols, request.getExtendedData(), true, baseRect.preciseX, -1);
        if (leftCorrection != THRESHOLD) {
            snapOrientation &= ~WEST;
            correction.preciseWidth -= leftCorrection;
            correction.preciseX += leftCorrection;
        }
    }
    if ((snapOrientation & SOUTH) != 0) {
        double bottom = getCorrectionFor(m_rows, request.getExtendedData(), false, baseRect.preciseBottom() - 1, 1);
        if (bottom != THRESHOLD) {
            snapOrientation &= ~SOUTH;
            correction.preciseHeight += bottom;
        }
    }
    if ((snapOrientation & NORTH) != 0) {
        double topCorrection = getCorrectionFor(m_rows, request.getExtendedData(), false, baseRect.preciseY, -1);
        if (topCorrection != THRESHOLD) {
            snapOrientation &= ~NORTH;
            correction.preciseHeight -= topCorrection;
            correction.preciseY += topCorrection;
        }
    }
    correction.updateInts();
    makeAbsolute(m_container.getContentPane(), correction);
    result.preciseX += correction.preciseX;
    result.preciseY += correction.preciseY;
    result.preciseWidth += correction.preciseWidth;
    result.preciseHeight += correction.preciseHeight;
    result.updateInts();
    return snapOrientation;
}
Also used : PrecisionRectangle(org.eclipse.draw2d.geometry.PrecisionRectangle) AbstractPortEditPart(org.knime.workbench.editor2.editparts.AbstractPortEditPart) Point(org.eclipse.draw2d.geometry.Point) Point(org.eclipse.draw2d.geometry.Point) NodeInPortEditPart(org.knime.workbench.editor2.editparts.NodeInPortEditPart) ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest) ArrayList(java.util.ArrayList) PointList(org.eclipse.draw2d.geometry.PointList) List(java.util.List) WorkflowInPortEditPart(org.knime.workbench.editor2.editparts.WorkflowInPortEditPart)

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