Java 类org.eclipse.gef.requests.ChangeBoundsRequest 实例源码

项目:bdf2    文件:ColumnOrderedLayoutEditPolicy.java   
@SuppressWarnings("unchecked")
@Override
protected EditPart getInsertionReference(Request request) {
    int y = ((ChangeBoundsRequest) request).getLocation().y;
    List<ColumnEditPart> columnEditParts = getHost().getChildren();
    ColumnEditPart afterColumn = null;
    for (Iterator<ColumnEditPart> iter = columnEditParts.iterator(); iter.hasNext();) {
        ColumnEditPart columnEditPart = iter.next();
        Rectangle r = columnEditPart.getFigure().getBounds();
        if (y < r.y) {
            return afterColumn;
        }
        afterColumn = columnEditPart;
    }
    return afterColumn;
}
项目:ermaster-k    文件:ERDiagramLayoutEditPolicy.java   
/**
 * {@inheritDoc}
 */
@Override
protected Command createChangeConstraintCommand(
        ChangeBoundsRequest request, EditPart child, Object constraint) {
    ERDiagram diagram = (ERDiagram) this.getHost().getModel();

    List selectedEditParts = this.getHost().getViewer()
            .getSelectedEditParts();

    if (!(child instanceof NodeElementEditPart)) {
        return null;
    }

    return createChangeConstraintCommand(diagram, selectedEditParts,
            (NodeElementEditPart) child, (Rectangle) constraint);
}
项目:ForgedUI-Eclipse    文件:TitaniumTreeContainerEditPolicy.java   
protected Command getAddCommand(ChangeBoundsRequest request) {
    CompoundCommand command = new CompoundCommand();
    List editparts = request.getEditParts();
    int index = findIndexOfTreeItemAt(request.getLocation());

    for (int i = 0; i < editparts.size(); i++) {
        EditPart child = (EditPart) editparts.get(i);
        if (GUIEditorPlugin.getComponentValidator().isAncestor((Element)child.getModel(),(Element)getHost().getModel()))
            command.add(UnexecutableCommand.INSTANCE);
        else {
            TitaniumUIBoundedElement childModel = (TitaniumUIBoundedElement) child.getModel();
            command.add(createCreateCommand(childModel,
                    new Rectangle(new org.eclipse.draw2d.geometry.Point(),
                            new Dimension(-1, -1)), index,
                    "Reparent LogicSubpart"));//$NON-NLS-1$
        }
    }
    return command;
}
项目:ForgedUI-Eclipse    文件:TitaniumTreeContainerEditPolicy.java   
protected Command getMoveChildrenCommand(ChangeBoundsRequest request) {
    CompoundCommand command = new CompoundCommand();
    List editparts = request.getEditParts();
    List children = getHost().getChildren();
    int newIndex = findIndexOfTreeItemAt(request.getLocation());
    for (int i = 0; i < editparts.size(); i++) {
        EditPart child = (EditPart) editparts.get(i);
        int tempIndex = newIndex;
        int oldIndex = children.indexOf(child);
        if (tempIndex == -1 || oldIndex == tempIndex || oldIndex + 1 == tempIndex) {
            command.add(UnexecutableCommand.INSTANCE);
            return command;
        } else if (oldIndex <= tempIndex) {
            tempIndex--;
        }
        command.add(new MoveChildCommand((Element) child.getModel(),tempIndex));
    }
    return command;
}
项目:ForgedUI-Eclipse    文件:AddStackElementEditPolicy.java   
@SuppressWarnings("unchecked")
@Override
protected Command getAddCommand(Request generic) {
    ChangeBoundsRequest request = (ChangeBoundsRequest) generic;
    if (acceptReorder(request)){
        List<EditPart> editParts = request.getEditParts();
        ElementEditPart movedElement = (ElementEditPart)editParts.get(0);
        Container parent = (Container) getHost().getParent().getModel();
        int siblingIndex = parent.getChildren().indexOf(getHost().getModel());
        int currentIndex = parent.getChildren().indexOf(movedElement.getModel());
        if (siblingIndex >= 0){
            if (isInsertAfter((DropRequest) request)) siblingIndex++;
            if (currentIndex <= siblingIndex) siblingIndex--;
            /*MoveChildCommand command = new MoveChildCommand(
                    movedElement.getModel(), siblingIndex);*/
            AddCommand command = new AddCommand();
            command.setParent(parent);
            command.setChild(movedElement.getModel());
            command.setIndex(siblingIndex);
            return command;
        }
    }
    return super.getAddCommand(generic);
}
项目:ForgedUI-Eclipse    文件:AddStackElementEditPolicy.java   
@Override
protected void showLayoutTargetFeedback(Request request) {
    eraseLayoutTargetFeedback(request);
    if (request instanceof ChangeBoundsRequest || (request instanceof CreateRequest
            && acceptCreate((CreateRequest) request))){
        targetFeedback = new RectangleFigure();
        Rectangle parentBounds = ((ElementEditPart)getHost()).getBounds();
        translateToAbsolute(getContainerFigure(), parentBounds);
        Rectangle lineBounds = parentBounds.getCopy();
        lineBounds.height = 4;
        lineBounds.y--;
        targetFeedback.setForegroundColor(ColorConstants.green);
        targetFeedback.setBackgroundColor(ColorConstants.green);
        if (isInsertAfter((DropRequest) request)){
            lineBounds.y += parentBounds.height;
        }
        targetFeedback.setBounds(lineBounds);
        addFeedback(targetFeedback);
    } else if (request instanceof ChangeBoundsRequest){

    }

}
项目:ForgedUI-Eclipse    文件:ContainerHighlightEditPolicy.java   
public void showTargetFeedback(Request request) {
    if (request.getType().equals(RequestConstants.REQ_MOVE)
            || request.getType().equals(RequestConstants.REQ_ADD)
            //|| request.getType().equals(RequestConstants.REQ_CLONE)
            || request.getType().equals(RequestConstants.REQ_CREATE)) {

        List<Element> children = new ArrayList<Element>();
        if (request instanceof ChangeBoundsRequest) { 
            ChangeBoundsRequest req = (ChangeBoundsRequest)request;
            List<?> editParts = req.getEditParts();
            for (Object editPart : editParts) {
                children.add((Element) ((EditPart)editPart).getModel());
            }
        } else if (request instanceof CreateRequest){
            children.add((Element) ((CreateRequest)request).getNewObject());
        } else {
            //what is this???
        }

        showHighlight(children);
    }

}
项目:NEXCORE-UML-Modeler    文件:CompartmentResizableEditPolicy.java   
/**
 * @see org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy#getCommand(org.eclipse.gef.Request)
 */
public Command getCommand(Request request) {
    try {
        if (!(getHost() instanceof AbstractDiagramEditPart)) {
            if (REQ_RESIZE.equals(request.getType())) {
                if (request instanceof ChangeBoundsRequest) {
                    CompoundCommand resize = new CompoundCommand();
                    List<EditPart> children = ((ChangeBoundsRequest) request).getEditParts();
                    for (EditPart child : children) {
                        resize.add(createChangeConstraintCommand(child,
                            ((ChangeBoundsRequest) request).getResizeDirection(),
                            ((ChangeBoundsRequest) request).getSizeDelta().preciseHeight()));
                    }
                    return resize;
                }
            } else {
                return new EmptyCommand();
            }
        }
        return super.getCommand(request);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
项目:NEXCORE-UML-Modeler    文件:LifeLineResizeableEditPolicy.java   
/**
 * @see org.eclipse.gef.editpolicies.ResizableEditPolicy#getResizeCommand(org.eclipse.gef.requests.ChangeBoundsRequest)
 */
@Override
protected Command getResizeCommand(ChangeBoundsRequest request) {

    ChangeBoundsRequest req = new ChangeBoundsRequest(REQ_RESIZE_CHILDREN);
    req.setEditParts(getHost().getParent());

    if(getHost() instanceof LifeLineNameEditPart && request.getSizeDelta().height > 0) {
        request.getSizeDelta().height = 0;
    }

    if(getHost() instanceof LineEditPart && request.getSizeDelta().width > 0) {
        request.getSizeDelta().width = 0;
    }

    req.setMoveDelta(request.getMoveDelta());
    req.setSizeDelta(request.getSizeDelta());
    req.setLocation(request.getLocation());
    req.setExtendedData(request.getExtendedData());
    req.setResizeDirection(request.getResizeDirection());
    return getHost().getParent().getParent().getCommand(req);

}
项目:NEXCORE-UML-Modeler    文件:SequenceLineResizableEditPolicy.java   
/**
 * @see org.eclipse.gef.editpolicies.ResizableEditPolicy#getResizeCommand(org.eclipse.gef.requests.ChangeBoundsRequest)
 */
protected Command getResizeCommand(ChangeBoundsRequest request) {

    ChangeBoundsRequest req = new ChangeBoundsRequest(REQ_RESIZE_CHILDREN);
    req.setEditParts(getHost().getParent());

    if(getHost() instanceof LifeLineNameEditPart && request.getSizeDelta().height > 0) {
        request.getSizeDelta().height = 0;
    }

    if(getHost() instanceof LineEditPart && request.getSizeDelta().width > 0) {
        request.getSizeDelta().width = 0;
    }

    req.setMoveDelta(request.getMoveDelta());
    req.setSizeDelta(request.getSizeDelta());
    req.setLocation(request.getLocation());
    req.setExtendedData(request.getExtendedData());
    req.setResizeDirection(request.getResizeDirection());
    return getHost().getParent().getParent().getCommand(req);

}
项目:statecharts    文件:EnlargeContainerEditPolicy.java   
@SuppressWarnings("unchecked")
/**
 * containerFeedbackBounds as absolute
 * 
 * @param containerEditPart
 * @param containerFigure
 * @param containerFeedbackBounds
 */
protected void showChildrenFeedback(final IGraphicalEditPart containerEditPart, final IFigure containerFigure,
        final Rectangle containerFeedbackBounds, ChangeBoundsRequest request) {
    Rectangle originalBounds = getOriginalBounds(containerFigure);

    Point moveDelta = new Point(containerFeedbackBounds.width - originalBounds.width,
            containerFeedbackBounds.height - originalBounds.height);

    List<IGraphicalEditPart> children = containerEditPart.getParent().getChildren();

    for (IGraphicalEditPart childPart : children) {
        if (request.getEditParts().contains(childPart)) {
            continue;
        }
        if (childPart == containerEditPart)
            continue;
        showChildFeedback(childPart, moveDelta, containerFeedbackBounds);
    }
}
项目:statecharts    文件:EnlargeContainerEditPolicy.java   
@SuppressWarnings({ "unchecked" })
private Rectangle calculateFeedbackBounds(ChangeBoundsRequest request, Rectangle feedbackBounds, int level,
        IFigure containerFigure) {
    Rectangle result = feedbackBounds.getCopy();
    List<IGraphicalEditPart> editParts = request.getEditParts();
    for (IGraphicalEditPart editPart : editParts) {
        PrecisionRectangle transformedRect = new PrecisionRectangle(editPart.getFigure().getBounds());
        editPart.getFigure().translateToAbsolute(transformedRect);
        transformedRect.translate(request.getMoveDelta());
        transformedRect.resize(request.getSizeDelta());
        transformedRect.expand(SPACEING * level, SPACEING * level);
        result.union(transformedRect);
        Dimension preferredSize = containerFigure.getPreferredSize().getCopy();
        editPart.getFigure().translateToAbsolute(preferredSize);
        Dimension max = Dimension.max(result.getSize(), preferredSize);
        result.setSize(max);
        if (result.x < feedbackBounds.x || result.y < feedbackBounds.y) {
            return feedbackBounds;
        }
    }
    return result;
}
项目:statecharts    文件:BarResizeEditPolicy.java   
@Override
protected void showChangeBoundsFeedback(final ChangeBoundsRequest request) {
    final IFigure feedback = getDragSourceFeedbackFigure();

    final PrecisionRectangle rect = new PrecisionRectangle(
            getInitialFeedbackBounds().getCopy());
    getHostFigure().translateToAbsolute(rect);
    rect.translate(request.getMoveDelta());
    rect.resize(request.getSizeDelta());
    // the unchanged value can be set to zero, because
    // the size will be recalculated later
    checkAndPrepareConstraint(request, rect);

    feedback.translateToRelative(rect);
    feedback.setBounds(rect);
}
项目:statecharts    文件:BarResizeEditPolicy.java   
@Override
protected Command getResizeCommand(final ChangeBoundsRequest request) {
    GraphicalEditPart editPart = (IGraphicalEditPart) getHost();
    Rectangle locationAndSize = new PrecisionRectangle(editPart.getFigure()
            .getBounds());
    editPart.getFigure().translateToAbsolute(locationAndSize);

    final Rectangle origRequestedBounds = request
            .getTransformedRectangle(locationAndSize);
    final Rectangle modified = origRequestedBounds.getCopy();
    checkAndPrepareConstraint(request, modified);
    // final Dimension sizeDelta = request.getSizeDelta();

    Dimension newDelta = new Dimension(modified.width
            - locationAndSize.width, modified.height
            - locationAndSize.height);
    // ((IGraphicalEditPart) getHost()).getFigure()
    // .translateToAbsolute(newDelta);
    request.setSizeDelta(newDelta);
    final Point moveDelta = request.getMoveDelta();
    request.setMoveDelta(new Point(moveDelta.x - origRequestedBounds.x
            + modified.x, moveDelta.y - origRequestedBounds.y + modified.y));
    return super.getResizeCommand(request);
}
项目:statecharts    文件:TreeLayoutEditPolicy.java   
@Override
protected Object getConstraintFor(ChangeBoundsRequest request,
        GraphicalEditPart child) {

    if (request instanceof AlignmentRequest) {
        return super.getConstraintFor(request, child);
    }
    final Rectangle rect = (Rectangle) super.getConstraintFor(request,
            child);
    final Rectangle cons = getCurrentConstraintFor(child);
    final int newTreePosition = TreeLayoutUtil.getNewTreeNodePosition(
            request.getLocation(),
            TreeLayoutUtil.getSiblings((IGraphicalEditPart) child));
    if (cons instanceof TreeLayoutConstraint) {
        final TreeLayoutConstraint treeLayoutConstraint = (TreeLayoutConstraint) cons;
        return new TreeLayoutConstraint(rect,
                treeLayoutConstraint.isRoot(), newTreePosition);
    }
    return new TreeLayoutConstraint(rect, false, newTreePosition);
}
项目:PDFReporter-Studio    文件:FromContainerEditPolicy.java   
/**
 * @see AbstractEditPolicy#getTargetEditPart(org.eclipse.gef.Request)
 */
public EditPart getTargetEditPart(Request request) {
    if (request instanceof ChangeBoundsRequest) {
        ChangeBoundsRequest cbr = (ChangeBoundsRequest) request;
        for (EditPart ep : (List<EditPart>) cbr.getEditParts()) {
            if (ep instanceof TableEditPart)
                return ep.getParent();
        }
    }
    if (REQ_CREATE.equals(request.getType()))
        return getHost();
    if (REQ_ADD.equals(request.getType()))
        return getHost();
    if (REQ_MOVE.equals(request.getType()))
        return getHost();
    return super.getTargetEditPart(request);
}
项目:PDFReporter-Studio    文件:TableCellResizableEditPolicy.java   
@Override
protected Command getMoveCommand(ChangeBoundsRequest request) {
    Point p = request.getMoveDelta();
    p.y = 0;
    request.setMoveDelta(p);
    MColumn model = getHost().getModel();

    IFigure hfigure = getHostFigure();
    Rectangle hbounds = hfigure.getBounds().getCopy();
    double zoom = GEFUtil.getZoom(getHost());

    TableCellEditPart ep = movePlace.calcMovePlace(
            (int) Math.floor(request.getMoveDelta().x / zoom), hbounds);
    if (ep != null)
        return new MoveColumnCommand(model, ep.getModel());
    return null;
}
项目:PDFReporter-Studio    文件:BandResizeTracker.java   
/**
 * This method can be overridden by clients to customize the snapping behavior.
 * 
 * @param request
 *          the <code>ChangeBoundsRequest</code> from which the move delta can be extracted and updated
 * @since 3.4
 */
protected void snapPoint(ChangeBoundsRequest request) {
    Point moveDelta = request.getMoveDelta();
    if (editpart != null && getOperationSet().size() > 0)
        snapToHelper = (SnapToHelper) editpart.getParent().getAdapter(SnapToHelper.class);
    if (snapToHelper != null && !getCurrentInput().isModKeyDown(MODIFIER_NO_SNAPPING)) {
        PrecisionRectangle baseRect = sourceRectangle.getPreciseCopy();
        PrecisionRectangle jointRect = compoundSrcRect.getPreciseCopy();
        baseRect.translate(moveDelta);
        jointRect.translate(moveDelta);

        PrecisionPoint preciseDelta = new PrecisionPoint(moveDelta);
        snapToHelper.snapPoint(request, PositionConstants.HORIZONTAL | PositionConstants.VERTICAL,
                new PrecisionRectangle[] { baseRect, jointRect }, preciseDelta);
        request.setMoveDelta(preciseDelta);
    }
}
项目:PDFReporter-Studio    文件:BandResizableEditPolicy.java   
protected void showChangeBoundsFeedback(ChangeBoundsRequest request) {
    if (getHost().getModel() instanceof IGraphicElement) {
        // if (getHost() instanceof BandEditPart
        // && ((BandEditPart) getHost()).getModelNode().getValue() instanceof JRDesignBand) {
        APropertyNode n = (APropertyNode) getHost().getModel();
        int bandHeight = (Integer) n.getPropertyValue(JRDesignElement.PROPERTY_HEIGHT);
        Integer bWidth = (Integer) n.getPropertyValue(JRDesignElement.PROPERTY_WIDTH);

        Rectangle oldBounds = new Rectangle(0, 0, bWidth != null ? bWidth : 0, bandHeight);

        PrecisionRectangle rect2 = new PrecisionRectangle(new Rectangle(0, 0, request.getSizeDelta().width,
                request.getSizeDelta().height));
        getHostFigure().translateToRelative(rect2);

        oldBounds.resize(rect2.width, rect2.height);
        setFeedbackText(oldBounds.height + (bWidth != null ? "," + oldBounds.width : "") + " px");
    }
    super.showChangeBoundsFeedback(request);

}
项目:PDFReporter-Studio    文件:BandResizableEditPolicy.java   
protected void showChangeBoundsFeedback(ChangeBoundsRequest request) {
    if (getHost().getModel() instanceof IGraphicElement) {
        // if (getHost() instanceof BandEditPart
        // && ((BandEditPart) getHost()).getModelNode().getValue() instanceof JRDesignBand) {
        APropertyNode n = (APropertyNode) getHost().getModel();
        int bandHeight = (Integer) n.getPropertyValue(JRDesignElement.PROPERTY_HEIGHT);
        Integer bWidth = (Integer) n.getPropertyValue(JRDesignElement.PROPERTY_WIDTH);

        Rectangle oldBounds = new Rectangle(0, 0, bWidth != null ? bWidth : 0, bandHeight);

        PrecisionRectangle rect2 = new PrecisionRectangle(new Rectangle(0, 0, request.getSizeDelta().width,
                request.getSizeDelta().height));
        getHostFigure().translateToRelative(rect2);

        oldBounds.resize(rect2.width, rect2.height);
        setFeedbackText(oldBounds.height + (bWidth != null ? "," + oldBounds.width : "") + " px");
    }
    super.showChangeBoundsFeedback(request);

}
项目:PDFReporter-Studio    文件:SearchParentDragTracker.java   
/**
 * Modify the drag behavior when the shift key is pressed. when it is pressed if the mouse
 * if moved over an offset (actually ten pixel) in horizontal or in vertical then the element
 * will be moved only on the horizontal or vertical axis, with all the snap deactivated 
 */
@Override
protected void snapPoint(ChangeBoundsRequest request) {
    boolean shiftPressed = JasperReportsPlugin.isPressed(SWT.SHIFT);
    if (!shiftPressed) {
        //Shift was released so use the default snap hander and reset the mouse direction
        firstMovment = MOUSE_DIRECTION.UNDEFINED;
        super.snapPoint(request);
    }
    else {
        Point moveDelta = request.getMoveDelta();
        int x = Math.abs(moveDelta.x);
        int y = Math.abs(moveDelta.y);
        //check if the offset threshold is passed
        if (x>10 && x>y && firstMovment == MOUSE_DIRECTION.UNDEFINED) firstMovment = MOUSE_DIRECTION.HORIZONTAL;
        if (y>10 && y>x && firstMovment == MOUSE_DIRECTION.UNDEFINED) firstMovment = MOUSE_DIRECTION.VERTICAL;
        if (firstMovment != MOUSE_DIRECTION.UNDEFINED){
            if (firstMovment == MOUSE_DIRECTION.VERTICAL) moveDelta.x = 0;
            else moveDelta.y = 0;
        }
    }
}
项目:PDFReporter-Studio    文件:JDDragGuidePolicy.java   
public Command getCommand(Request request) {
    Command cmd = null;
    final ChangeBoundsRequest req = (ChangeBoundsRequest) request;
    if (isDeleteRequest(req)) {
        cmd = getGuideEditPart().getRulerProvider().getDeleteGuideCommand(getHost().getModel());
    } else {
        int pDelta = 0;
        if (getGuideEditPart().isHorizontal()) {
            pDelta = req.getMoveDelta().y;
        } else {
            pDelta = req.getMoveDelta().x;
        }
        if (isMoveValid(getGuideEditPart().getZoomedPosition() + pDelta)) {
            ZoomManager zoomManager = getGuideEditPart().getZoomManager();
            if (zoomManager != null) {
                pDelta = (int) Math.round(pDelta / zoomManager.getZoom());
            }
            cmd = getGuideEditPart().getRulerProvider().getMoveGuideCommand(getHost().getModel(), pDelta);
        } else {
            cmd = UnexecutableCommand.INSTANCE;
        }
    }
    return cmd;
}
项目:PDFReporter-Studio    文件:JDTreeContainerEditPolicy.java   
@Override
protected Command getAddCommand(ChangeBoundsRequest request) {
    JSSCompoundCommand command = new JSSCompoundCommand(null);
    List<?> editparts = request.getEditParts();
    int index = findIndexOfTreeItemAt(request.getLocation());
    for (int i = 0; i < editparts.size(); i++) {
        EditPart child = (EditPart) editparts.get(i);
        command.setReferenceNodeIfNull(child.getModel());
        if (isAncestor(child, getHost())) {
            command.add(UnexecutableCommand.INSTANCE);
        } else {
            ANode childModel = (ANode) child.getModel();
            command.add(createCreateCommand(childModel, index));
        }
    }
    return command;
}
项目:PDFReporter-Studio    文件:JDTreeContainerEditPolicy.java   
@Override
protected Command getMoveChildrenCommand(ChangeBoundsRequest request) {
    JSSCompoundCommand command = new JSSCompoundCommand(null);
    List<?> editparts = request.getEditParts();
    List<?> children = getHost().getChildren();
    int newIndex = findIndexOfTreeItemAt(request.getLocation());
    for (int i = 0; i < editparts.size(); i++) {
        EditPart child = (EditPart) editparts.get(i);
        command.setReferenceNodeIfNull(child.getModel());
        int tempIndex = newIndex;
        int oldIndex = children.indexOf(child);
        if (oldIndex == tempIndex || oldIndex + 1 == tempIndex) {
            command.add(UnexecutableCommand.INSTANCE);
            return command;
        } else if (oldIndex <= tempIndex) {
            tempIndex--;
        }
        command.add(OutlineTreeEditPartFactory.getReorderCommand((ANode) child.getModel(), (ANode) getHost().getModel(),
                tempIndex));
    }
    return command;
}
项目:PDFReporter-Studio    文件:JDStyleTreeContainerEditPolicy.java   
protected Command getAddCommand(ChangeBoundsRequest request) {
    JSSCompoundCommand command = new JSSCompoundCommand(null);
    List<?> editparts = request.getEditParts();
    int index = findIndexOfTreeItemAt(request.getLocation());

    for (int i = 0; i < editparts.size(); i++) {
        EditPart child = (EditPart) editparts.get(i);
        command.setReferenceNodeIfNull(child.getModel());
        if (isAncestor(child, getHost())) {
            command.add(UnexecutableCommand.INSTANCE);
        } else {
            ANode childModel = (ANode) child.getModel();
            command.add(createCreateCommand(childModel, index));
        }
    }
    return command;
}
项目:PDFReporter-Studio    文件:JDStyleTreeContainerEditPolicy.java   
protected Command getMoveChildrenCommand(ChangeBoundsRequest request) {
    JSSCompoundCommand command = new JSSCompoundCommand(null);
    List<?> editparts = request.getEditParts();
    List<?> children = getHost().getChildren();
    int newIndex = findIndexOfTreeItemAt(request.getLocation());
    for (int i = 0; i < editparts.size(); i++) {
        EditPart child = (EditPart) editparts.get(i);
        command.setReferenceNodeIfNull(child.getModel());
        int tempIndex = newIndex;
        int oldIndex = children.indexOf(child);
        if (oldIndex == tempIndex || oldIndex + 1 == tempIndex) {
            command.add(UnexecutableCommand.INSTANCE);
            return command;
        } else if (oldIndex <= tempIndex) {
            tempIndex--;
        }
        command.add(OutlineTreeEditPartFactory.getReorderCommand((ANode) child.getModel(), (ANode) getHost().getModel(),
                tempIndex));
    }
    return command;
}
项目:OpenSPIFe    文件:MoveThread.java   
public void queueMove(ChangeBoundsRequest request) {
        if (!isDragging()) {
            return;
        }
        List editParts = request.getEditParts();
        if (editParts.isEmpty()) {
            return;
        }
        Page page = planTimeline.getPage();
        long timeDelta = (int) page.convertToMilliseconds(request.getMoveDelta().x);
        long tolerance = page.getZoomOption().getMsMoveThreshold();
        tolerance *= MissionConstants.getInstance().getEarthSecondsPerLocalSeconds();
        timeDelta = timeDelta - (timeDelta % tolerance);
        if (Math.abs(timeDelta - lastTimeDelta) < tolerance) {
            return;
        }
        synchronized (queueLock) {
//          if (nextEditParts != null) {
//              System.out.println("skipped");
//          }
            hasWork = true;
            nextEditParts = editParts;
            nextDelta = timeDelta;
            queueLock.notify();
        }
    }
项目:OpenSPIFe    文件:TemporalNodeMoveEditPolicy.java   
@Override
protected void showChangeBoundsFeedback(ChangeBoundsRequest request) {
    IFigure feedback = getDragSourceFeedbackFigure();
    Rectangle bounds = feedback.getBounds().getCopy();

    getStartFigure(bounds);
    getEndFigure(bounds);

    // TODO: temporary fix - see Handle class below
    updateHighlightFollowAlong();
    // end temporary fix

    if(TimelineConstants.REQ_MOVE_INITIATED.equals(lastRequestType)
            || TimelineConstants.REQ_MOVE_COMPLETED.equals(lastRequestType)) {
        this.isCursorFocus = false;
    }
    updateCursorTime();
}
项目:OpenSPIFe    文件:TimelineOrderedLayoutEditPolicy.java   
@Override
protected EditPart getInsertionReference(Request request) {
    if (request instanceof ChangeBoundsRequest) {
        ChangeBoundsRequest r = (ChangeBoundsRequest) request;
        Point pt = r.getLocation();
        EditPart reference = getHost().getViewer().findObjectAt(pt);
        if (reference == getHost() || reference instanceof TimelineRootEditPart) {
            reference = getHost().getViewer().findObjectAt(pt.translate(0, 3));
        }

        Position position = getPosition((GraphicalEditPart) reference, pt);
        if (Position.ABOVE == position) {
            return reference;
        }

        EditPart parent = reference.getParent();
        List children = parent.getChildren();
        int index = children.indexOf(reference) + 1;
        if (index == children.size()) {
            return null;
        }
        return (EditPart) children.get(index);
    }
    return null;
}
项目:OpenSPIFe    文件:TimelineNodeMoveEditPolicy.java   
@Override
public Command getCommand(Request request) {
    Object type = request.getType();
    if (!canMove()) {
        return null;
    }

    if (getHost()==null || getHost().getParent() == null) {
        // SPF-9135 NPE:  GEF 3.6 superclass will try to access  getHost().getParent().getCommand(req)
        return null;
    }

    if (REQ_MOVE.equals(type) && isDragAllowed())
        return getMoveCommand((ChangeBoundsRequest)request);
    if (REQ_MOVE_INITIATED.equals(type))
        return forwardToParent((ChangeBoundsRequest)request, REQ_MOVE_CHILDREN_INITIATED);
    if (REQ_MOVE_COMPLETED.equals(type))
        return forwardToParent((ChangeBoundsRequest)request, REQ_MOVE_CHILDREN_COMPLETED);
    if (REQ_ORPHAN.equals(type))
        return getOrphanCommand(request);
    if (REQ_ALIGN.equals(type))
        return getAlignCommand((AlignmentRequest)request);
    return null;
}
项目:OpenSPIFe    文件:TimelineNodeMoveEditPolicy.java   
/**
 * Returns the command contribution to a change bounds request. The implementation
 * actually dispatches the request to the host's parent edit part as a {@link
 * RequestConstants#REQ_MOVE_CHILDREN} request.  The parent's contribution is returned.
 * @param request the change bounds request
 * @return the command contribution to the request
 */
private Command forwardToParent(ChangeBoundsRequest request, Object type) {
    ChangeBoundsRequest req = new ChangeBoundsRequest(type);
    EditPart host = getHost();
    req.setEditParts(host);
    req.setMoveDelta(request.getMoveDelta());
    req.setSizeDelta(request.getSizeDelta());
    req.setLocation(request.getLocation());
    req.setExtendedData(request.getExtendedData());
    if (host != null) {
        EditPart parent = host.getParent();
        if (parent != null) {
            return parent.getCommand(req);
        }
    }
    return null;
}
项目:ermaster-nhit    文件:ERDiagramLayoutEditPolicy.java   
/**
 * {@inheritDoc}
 */
@Override
protected Command createChangeConstraintCommand(
        ChangeBoundsRequest request, EditPart child, Object constraint) {
    ERDiagram diagram = (ERDiagram) this.getHost().getModel();

    List selectedEditParts = this.getHost().getViewer()
            .getSelectedEditParts();

    if (!(child instanceof NodeElementEditPart)) {
        return null;
    }

    return createChangeConstraintCommand(diagram, selectedEditParts,
            (NodeElementEditPart) child, (Rectangle) constraint);
}
项目:gef-gwt    文件:ConstrainedLayoutEditPolicy.java   
/**
 * Overrides <code>getAddCommand()</code> to generate the proper constraint
 * for each child being added. Once the constraint is calculated,
 * {@link #createAddCommand(EditPart,Object)} is called. Subclasses must
 * implement this method.
 * 
 * @see org.eclipse.gef.editpolicies.LayoutEditPolicy#getAddCommand(Request)
 */
protected Command getAddCommand(Request generic) {
    ChangeBoundsRequest request = (ChangeBoundsRequest) generic;
    List editParts = request.getEditParts();
    CompoundCommand command = new CompoundCommand();
    command.setDebugLabel("Add in ConstrainedLayoutEditPolicy");//$NON-NLS-1$
    GraphicalEditPart child;

    for (int i = 0; i < editParts.size(); i++) {
        child = (GraphicalEditPart) editParts.get(i);
        command.add(createAddCommand(
                request,
                child,
                translateToModelConstraint(getConstraintFor(request, child))));
    }
    return command.unwrap();
}
项目:gef-gwt    文件:ConstrainedLayoutEditPolicy.java   
/**
 * Returns the <code>Command</code> for changing bounds for a group of
 * children.
 * 
 * @param request
 *            the ChangeBoundsRequest
 * @return the Command
 * 
 * @since 3.7
 */
protected Command getChangeConstraintCommand(ChangeBoundsRequest request) {
    CompoundCommand resize = new CompoundCommand();
    Command c;
    GraphicalEditPart child;
    List children = request.getEditParts();

    for (int i = 0; i < children.size(); i++) {
        child = (GraphicalEditPart) children.get(i);
        c = createChangeConstraintCommand(
                request,
                child,
                translateToModelConstraint(getConstraintFor(request, child)));
        resize.add(c);
    }
    return resize.unwrap();
}
项目:gef-gwt    文件:LayoutEditPolicy.java   
/**
 * Factors incoming requests into various specific methods.
 * 
 * @see org.eclipse.gef.EditPolicy#getCommand(Request)
 */
public Command getCommand(Request request) {
    if (REQ_DELETE_DEPENDANT.equals(request.getType()))
        return getDeleteDependantCommand(request);

    if (REQ_ADD.equals(request.getType()))
        return getAddCommand(request);

    if (REQ_ORPHAN_CHILDREN.equals(request.getType()))
        return getOrphanChildrenCommand(request);

    if (REQ_MOVE_CHILDREN.equals(request.getType()))
        return getMoveChildrenCommand(request);

    if (REQ_CLONE.equals(request.getType()))
        return getCloneCommand((ChangeBoundsRequest) request);

    if (REQ_CREATE.equals(request.getType()))
        return getCreateCommand((CreateRequest) request);

    return null;
}
项目:gef-gwt    文件:XYLayoutEditPolicy.java   
/**
 * Overridden to preserve existing width and height (as well as preferred
 * sizes) during MOVE requests.
 * 
 * @see org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy#getConstraintFor(org.eclipse.gef.Request,
 *      org.eclipse.gef.GraphicalEditPart,
 *      org.eclipse.draw2d.geometry.Rectangle)
 */
protected Object getConstraintFor(Request request, GraphicalEditPart child,
        Rectangle rect) {
    if (request instanceof ChangeBoundsRequest) {
        if (((ChangeBoundsRequest) request).getSizeDelta().width == 0
                && ((ChangeBoundsRequest) request).getSizeDelta().height == 0) {
            if (getCurrentConstraintFor(child) != null) {
                // Bug 86473 allows for unintended use of this method
                rect.setSize(getCurrentConstraintFor(child).getSize());
            }
        } else {
            // for backwards compatibility, ensure minimum size is respected
            rect.setSize(Dimension.max(getMinimumSizeFor(child),
                    rect.getSize()));
        }
    }
    return super.getConstraintFor(request, child, rect);
}
项目:gef-gwt    文件:DragGuidePolicy.java   
public Command getCommand(Request request) {
    Command cmd;
    final ChangeBoundsRequest req = (ChangeBoundsRequest) request;
    if (isDeleteRequest(req)) {
        cmd = getGuideEditPart().getRulerProvider().getDeleteGuideCommand(
                getHost().getModel());
    } else {
        int pDelta;
        if (getGuideEditPart().isHorizontal()) {
            pDelta = req.getMoveDelta().y;
        } else {
            pDelta = req.getMoveDelta().x;
        }
        if (isMoveValid(getGuideEditPart().getZoomedPosition() + pDelta)) {
            ZoomManager zoomManager = getGuideEditPart().getZoomManager();
            if (zoomManager != null) {
                pDelta = (int) Math.round(pDelta / zoomManager.getZoom());
            }
            cmd = getGuideEditPart().getRulerProvider()
                    .getMoveGuideCommand(getHost().getModel(), pDelta);
        } else {
            cmd = UnexecutableCommand.INSTANCE;
        }
    }
    return cmd;
}
项目:gef-gwt    文件:DragEditPartsTracker.java   
/**
 * This method can be overridden by clients to customize the snapping
 * behavior.
 * 
 * @param request
 *            the <code>ChangeBoundsRequest</code> from which the move delta
 *            can be extracted and updated
 * @since 3.4
 */
protected void snapPoint(ChangeBoundsRequest request) {
    Point moveDelta = request.getMoveDelta();
    if (snapToHelper != null && request.isSnapToEnabled()) {
        PrecisionRectangle baseRect = sourceRectangle.getPreciseCopy();
        PrecisionRectangle jointRect = compoundSrcRect.getPreciseCopy();
        baseRect.translate(moveDelta);
        jointRect.translate(moveDelta);

        PrecisionPoint preciseDelta = new PrecisionPoint(moveDelta);
        snapToHelper.snapPoint(request, PositionConstants.HORIZONTAL
                | PositionConstants.VERTICAL, new PrecisionRectangle[] {
                baseRect, jointRect }, preciseDelta);
        request.setMoveDelta(preciseDelta);
    }
}
项目:birt    文件:EditorDragGuidePolicy.java   
/**
 * When drag the margin guide, the attache editparts move with the guide.
 * Now do nothing
 * 
 * @param request
 */
private void eraseAttachedPartsFeedback( Request request )
{
    if ( attachedEditParts != null )
    {
        ChangeBoundsRequest req = new ChangeBoundsRequest( request
                .getType( ) );
        req.setEditParts( attachedEditParts );

        Iterator i = attachedEditParts.iterator( );

        while ( i.hasNext( ) )
            ( (EditPart) i.next( ) ).eraseSourceFeedback( req );
        attachedEditParts = null;
    }
}
项目:birt    文件:EditorDragGuidePolicy.java   
private Rectangle getDummyLineFigureBounds( ChangeBoundsRequest request )
{
    Rectangle bounds = new Rectangle( );
    EditorRulerEditPart source = getRulerEditPart( );
    if ( source.isHorizontal( ) )
    {
        bounds.x = getCurrentPositionZoomed( request );
        bounds.y = source.getGuideLayer( ).getBounds( ).y;
        bounds.width = 1;
        bounds.height = source.getGuideLayer( ).getBounds( ).height;
    }
    else
    {
        bounds.x = source.getGuideLayer( ).getBounds( ).x;
        bounds.y = getCurrentPositionZoomed( request );
        bounds.width = source.getGuideLayer( ).getBounds( ).width;
        bounds.height = 1;
    }
    return bounds;
}