Search in sources :

Example 6 with ChangeBoundsRequest

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);
}
Also used : ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest) PointList(org.eclipse.draw2d.geometry.PointList) PrecisionRectangle(org.eclipse.draw2d.geometry.PrecisionRectangle) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point) PrecisionPoint(org.eclipse.draw2d.geometry.PrecisionPoint) PrecisionPoint(org.eclipse.draw2d.geometry.PrecisionPoint)

Example 7 with ChangeBoundsRequest

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;
}
Also used : ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest) PointList(org.eclipse.draw2d.geometry.PointList) AbstractPolyModel(org.csstudio.opibuilder.widgets.model.AbstractPolyModel)

Example 8 with ChangeBoundsRequest

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());
}
Also used : ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) List(java.util.List)

Example 9 with ChangeBoundsRequest

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

Example 10 with ChangeBoundsRequest

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;
}
Also used : ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest) EditPart(org.eclipse.gef.EditPart) List(java.util.List) DnDCompoundCommand(org.whole.lang.ui.commands.DnDCompoundCommand)

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