org.eclipse.gef.requests.ChangeBoundsRequest Java Examples

The following examples show how to use org.eclipse.gef.requests.ChangeBoundsRequest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TreeLayoutEditPolicy.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
@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);
}
 
Example #2
Source File: CustomResizableEditPolicyEx.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected boolean isResizeValid(final ChangeBoundsRequest request) {
    if (request.getEditParts() != null && !request.getEditParts().isEmpty()) {
        final IGraphicalEditPart ep = (IGraphicalEditPart) request.getEditParts().get(0);
        if (request.getSizeDelta().height <= 0 && request.getSizeDelta().width <= 0 && ep.resolveSemanticElement() instanceof SubProcessEvent) {
            return checkSubprocessEventCanReduce(request);
        } else if (ep.resolveSemanticElement() instanceof Lane) {
            if (request.getSizeDelta().height <= 0 && request.getSizeDelta().width <= 0) {
                return checkSwimLanesCanReduce(request);
            } else {
                return true;
            }
        } else if (ep.resolveSemanticElement() instanceof Pool) {
            if (request.getSizeDelta().height <= 0 && request.getSizeDelta().width <= 0) {
                return checkSwimLanesCanReduce(request);
            } else {
                return true;
            }
        }
        return !checkOverlapOtherFigures(request);
    }

    return true;
}
 
Example #3
Source File: MultipleShapesHorizontalMoveTool.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * creates the command to move the shapes left or right.
 */
protected Command getCommand() {
	if (_container == null) {
		return null;
	}
	CompoundCommand command = new CompoundCommand("Multiple Shape Move");
	TransactionalEditingDomain editingDomain = _container.getEditingDomain();

	Point moveDelta  = ((ChangeBoundsRequest) getSourceRequest()).getMoveDelta().getCopy();
	Dimension spSizeDelta = new Dimension(moveDelta.x, moveDelta.y);
	ZoomManager zoomManager = ((DiagramRootEditPart) 
			getCurrentViewer().getRootEditPart()).getZoomManager();
	spSizeDelta.scale(1/zoomManager.getZoom());

	command.add(_container.getCommand(getSourceRequest()));


	for (IGraphicalEditPart sp : _subProcesses) {
		Dimension spDim = sp.getFigure().getBounds().getSize().getCopy();
		spDim.expand(spSizeDelta);
		SetBoundsCommand setBounds = 
			new SetBoundsCommand(editingDomain,"MultipleShape Move", sp, spDim);
		command.add(new ICommandProxy(setBounds));
	}
	return command;
}
 
Example #4
Source File: CustomDragDropEditPolicy.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private boolean isSourceAndTargetAreEventSubProc(final ChangeBoundsRequest request) {
    final EditPartViewer hostViewer = getHost().getViewer();
    if(hostViewer.findObjectAt(request.getLocation()) instanceof IGraphicalEditPart){
        final IGraphicalEditPart target = (IGraphicalEditPart) hostViewer.findObjectAt(request.getLocation());
        if(target.resolveSemanticElement() instanceof SubProcessEvent){
            for(final Object ep : request.getEditParts()){
                if(ep instanceof IGraphicalEditPart){
                    if(((IGraphicalEditPart) ep).resolveSemanticElement() instanceof SubProcessEvent){
                        return true ;
                    }
                }
            }
        }
    }
    return false;
}
 
Example #5
Source File: LiveFeedbackResizableEditPolicy.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected Command getResizeCommand(ChangeBoundsRequest request) {
	if (RequestConstants.REQ_DROP.equals(request.getType())) {
		return super.getMoveCommand(request);
	}

	if (request instanceof SetPreferredSizeRequest) {
		SetPreferredSizeRequest req = new SetPreferredSizeRequest(REQ_RESIZE_CHILDREN);
		req.setEditParts(getHost());
		req.setCenteredResize(request.isCenteredResize());
		req.setConstrainedMove(request.isConstrainedMove());
		req.setConstrainedResize(request.isConstrainedResize());
		req.setSnapToEnabled(request.isSnapToEnabled());
		req.setMoveDelta(request.getMoveDelta());
		req.setSizeDelta(request.getSizeDelta());
		req.setLocation(request.getLocation());
		req.setExtendedData(request.getExtendedData());
		req.setResizeDirection(request.getResizeDirection());
		return getHost().getParent().getCommand(req);
	}
	NULL_REQUEST.setEditParts(getHost());
	return getHost().getParent().getCommand(NULL_REQUEST);
}
 
Example #6
Source File: EditorDragGuidePolicy.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private int getCurrentPositionZoomed( ChangeBoundsRequest request )
{

	int newPosition;
	if ( getGuideEditPart( ).isHorizontal( ) )
	{
		newPosition = getGuideEditPart( ).getZoomedPosition( )
				+ request.getMoveDelta( ).y;
	}
	else
	{
		newPosition = getGuideEditPart( ).getZoomedPosition( )
				+ request.getMoveDelta( ).x;
	}
	return newPosition;
}
 
Example #7
Source File: EditorDragGuidePolicy.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
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;
}
 
Example #8
Source File: BarResizeEditPolicy.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected ResizeTracker getResizeTracker(int direction) {

	return new ResizeTracker((GraphicalEditPart) getHost(), direction) {
		@Override
		protected void enforceConstraintsForResize(ChangeBoundsRequest request) {
			Rectangle locationAndSize = getOriginalBounds();
			
			final Rectangle origRequestedBounds = request.getTransformedRectangle(locationAndSize);
			final Rectangle modified = origRequestedBounds.getCopy();
			checkAndPrepareConstraint(request, modified);
			Dimension newDelta = new Dimension(modified.width - locationAndSize.width,
					modified.height - locationAndSize.height);
			request.setSizeDelta(newDelta);
			final Point moveDelta = request.getMoveDelta();
			request.setMoveDelta(new Point(moveDelta.x - origRequestedBounds.x + modified.x,
					moveDelta.y - origRequestedBounds.y + modified.y));
		}
	};
}
 
Example #9
Source File: UpdatePoolSizeCommand.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void decreaseHeight() {
	ChangeBoundsRequest setRequest1 = new ChangeBoundsRequest(RequestConstants.REQ_RESIZE) ; 
	List<EditPart> epToMove = new ArrayList<EditPart>();
	epToMove.add(gep);
	setRequest1.setEditParts(epToMove);
	setRequest1.setResizeDirection(PositionConstants.NORTH);
	setRequest1.setSizeDelta(new Dimension(0,-150));
	gep.getDiagramEditDomain().getDiagramCommandStack().execute(gep.getCommand(setRequest1));
	for(Object o : gep.getChildren()){
		if(o instanceof CustomPoolCompartmentEditPart){
			for(CustomLaneEditPart lane : ((CustomPoolCompartmentEditPart)o).getPoolLanes()){
				lane.refresh();
			}
		}
		
	}
	
}
 
Example #10
Source File: ReportFlowLayoutEditPolicy.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Generates a draw2d constraint object derived from the specified child
 * EditPart using the provided Request. The returned constraint will be
 * translated to the application's model later using
 * {@link #translateToModelConstraint(Object)}.
 * 
 * @param request
 *            the ChangeBoundsRequest
 * @param child
 *            the child EditPart for which the constraint should be
 *            generated
 * @return the draw2d constraint
 */
protected Object getConstraintFor( ChangeBoundsRequest request,
		GraphicalEditPart child )
{
	IFigure figure = child.getFigure( );
	Rectangle rect = new PrecisionRectangle(figure.getBounds());
	figure.translateToAbsolute(rect);
	rect = request.getTransformedRectangle( rect );
	
	figure.translateToRelative(rect);
	rect.translate( getLayoutOrigin( ).getNegated( ) );
	if (figure instanceof IOutsideBorder)
	{
		Border border = ((IOutsideBorder)figure).getOutsideBorder( );
		if (border !=  null)
		{
			Insets insets = border.getInsets( figure );
			rect.shrink( insets.right, insets.bottom );
		}
	}

	return getConstraintFor( rect );
}
 
Example #11
Source File: UpdatePoolSizeCommand.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void increaseWidth() {
	ChangeBoundsRequest setRequest1 = new ChangeBoundsRequest(RequestConstants.REQ_RESIZE) ; 
	List<EditPart> epToMove = new ArrayList<EditPart>();
	epToMove.add(gep);
	for(Object o : gep.getChildren()){
		if(o instanceof CustomPoolCompartmentEditPart){
			for(CustomLaneEditPart lane : ((CustomPoolCompartmentEditPart)o).getPoolLanes()){
				epToMove.add(lane);
			}
		}
		
	}
	setRequest1.setEditParts(epToMove);
	setRequest1.setResizeDirection(PositionConstants.EAST);
	setRequest1.setSizeDelta(new Dimension(150,0));
	gep.getDiagramEditDomain().getDiagramCommandStack().execute(gep.getCommand(setRequest1));
}
 
Example #12
Source File: LiveFeedbackNonResizableEditPolicy.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void showChangeBoundsFeedback(ChangeBoundsRequest request) {
	// If REQ_DROP is delivered 2 times in a row it is a "real" drop and not only a
	// hover over existing elements in the same region
	if (RequestConstants.REQ_DROP.equals(request.getType()) && RequestConstants.REQ_DROP.equals(lastRequest)) {
		Rectangle rect = getOriginalBounds();
		getHostFigure().getParent().translateToRelative(rect);
		getHostFigure().setBounds(rect);
		super.showChangeBoundsFeedback(request);
		lastRequest = (String) request.getType();
		return;
	}
	super.eraseChangeBoundsFeedback(request);
	 enforceConstraintForMove(request);
	if (connectionStart) {
		updateOriginalBounds();
		connectionStart = false;
	}
	Rectangle bounds = request.getTransformedRectangle(getOriginalBounds());
	getHostFigure().getParent().translateToRelative(bounds);
	getHostFigure().setBounds(bounds);
	getHostFigure().getParent().setConstraint(getHostFigure(), bounds);
	lastRequest = (String) request.getType();
}
 
Example #13
Source File: FixedBendpointEditPolicy.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
protected void eraseChangeBoundsFeedback(ChangeBoundsRequest request) {
	connectionStart = true;
	router.commitBoxDrag();
	for (ConnectionEditPart connectionEditPart : getAllConnectionParts(request)) {
		List<?> children = connectionEditPart.getChildren();
		Connection connection = connectionEditPart.getConnectionFigure();
		for (Object child : children) {
			if (child instanceof ExternalXtextLabelEditPart) {
				IFigure figure = ((ExternalXtextLabelEditPart) child).getFigure();
				Object currentConstraint = connection.getLayoutManager().getConstraint(figure);
				if (currentConstraint instanceof EdgeLabelLocator) {
					EdgeLabelLocator edgeLabelLocator = (EdgeLabelLocator) currentConstraint;
					edgeLabelLocator.eraseFeedbackData();
				}
			}
		}
	}

}
 
Example #14
Source File: CustomResizableEditPolicyEx.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private boolean isMoveValid(final ChangeBoundsRequest request) {
    if (request.getEditParts() != null && !request.getEditParts().isEmpty()) {
        getHost().getParent().refresh();
        final PoolEditPart pe = getPoolEditPart(getHost());
        if (pe instanceof IGraphicalEditPart) {
            final Rectangle transformedRectangle = request.getTransformedRectangle(getHostFigure().getBounds()).expand(new Insets(10, 10, 10, 10));
            final Rectangle poolBounds = ((IGraphicalEditPart) pe).getFigure().getBounds();
            FiguresHelper.translateToAbsolute(getHostFigure(), transformedRectangle);
            FiguresHelper.translateToAbsolute(((IGraphicalEditPart) pe).getFigure(), poolBounds);
            if (poolBounds.x > transformedRectangle.x) {
                return false;
            }
            if (poolBounds.y > transformedRectangle.y) {
                return false;
            }
        }
    }
    return true;
}
 
Example #15
Source File: RegionCompartmentEditPart.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void createDefaultEditPolicies() {
	super.createDefaultEditPolicies();
	installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CompartmentCreationEditPolicy());
	installEditPolicy(EditPolicyRoles.CANONICAL_ROLE, new RegionCompartmentCanonicalEditPolicy());
	installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
	// Removes the collapse expand handler
	installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableEditPolicyEx());
	installEditPolicy(EditPolicyRoles.SNAP_FEEDBACK_ROLE, new SimpleSnapFeedbackPolicy());
	installEditPolicy(EditPolicy.LAYOUT_ROLE, new XYLayoutEditPolicy() {
		// This is required when live feedback is used
		@Override
		protected Object getConstraintFor(ChangeBoundsRequest request, GraphicalEditPart child) {
			if (request instanceof SetPreferredSizeRequest || RequestConstants.REQ_ADD.equals(request.getType())) {
				return super.getConstraintFor(request, child);
			}
			request.setSizeDelta(new Dimension(0, 0));
			request.setMoveDelta(new Point(0, 0));
			return super.getConstraintFor(request, child);
		}
	});
}
 
Example #16
Source File: ERDiagramLayoutEditPolicy.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected Command createChangeConstraintCommand(final ChangeBoundsRequest request, final EditPart child, final Object constraint) {
    final ERDiagram diagram = (ERDiagram) getHost().getModel();

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

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

    return createChangeConstraintCommand(diagram, selectedEditParts, (NodeElementEditPart) child, (Rectangle) constraint);
}
 
Example #17
Source File: CustomLaneEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void showSourceFeedback(final Request request) {
    if (request instanceof ChangeBoundsRequest) {
        if (request.getType().equals(RequestConstants.REQ_RESIZE)) {
            super.showSourceFeedback(request);
        }
    }

}
 
Example #18
Source File: MultipleEditPart.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected Command getResizeCommand( ChangeBoundsRequest request )
{
	Command command = super.getResizeCommand( request );
	if (command instanceof SetConstraintCommand)
	{
		((SetConstraintCommand)command).setModel( (ReportItemHandle)getTrueHost( ).getModel( ) );
	}
	return command;
}
 
Example #19
Source File: CustomLaneCompartmentEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void showTargetFeedback(Request request) {
	if(request instanceof ChangeBoundsRequest){
		if(!(((GraphicalEditPart)((ChangeBoundsRequest)request).getEditParts().get(0)).resolveSemanticElement() instanceof Container)){
			super.showTargetFeedback(request);
		}
	}else{
		super.showTargetFeedback(request);
	}
}
 
Example #20
Source File: ProcessPart.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private Command getCommand(ProcessPart part, ChangeBoundsRequest request) {
	IFigure figure = part.getModel().figure;
	Rectangle bounds = figure.getBounds().getCopy();
	figure.translateToAbsolute(bounds);
	Rectangle moveResize = new Rectangle(request.getMoveDelta(), request.getSizeDelta());
	bounds.resize(moveResize.getSize());
	bounds.translate(moveResize.getLocation());
	figure.translateToRelative(bounds);
	if (request.getSizeDelta().height != 0 || request.getSizeDelta().width != 0)
		return XYLayoutCommand.resize(part.getModel(), bounds);
	if (request.getMoveDelta().x != 0 || request.getMoveDelta().y != 0)
		return XYLayoutCommand.move(part.getModel(), bounds);
	return null;
}
 
Example #21
Source File: FiguresHelper.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public static void resizeActivitiesFigure(final IGraphicalEditPart parentEp, final String text) {

        final int lineNumber = text.length() / LINE_LENGTH;

        final ChangeBoundsRequest req = new ChangeBoundsRequest(RequestConstants.REQ_RESIZE);

        final int currentWidth = parentEp.getFigure().getSize().width;
        final int defaultWidth = parentEp.getFigure().getPreferredSize().width;
        final int withDeltaFromDefault = currentWidth - defaultWidth;

        final int currentHeight = parentEp.getFigure().getSize().height;
        final int defaultHeight = parentEp.getFigure().getPreferredSize().height;
        final int heightDeltaFromDefault = currentHeight - defaultHeight;

        req.setSizeDelta(new Dimension(20 * lineNumber - withDeltaFromDefault, 10 * lineNumber - heightDeltaFromDefault));
        req.setConstrainedResize(true);
        req.setCenteredResize(true);
        req.setResizeDirection(PositionConstants.CENTER);
        req.setEditParts(parentEp);
        // avoid to perform request on element creation (figure have no size)
        if (currentWidth > 0 && currentHeight > 0 && req.getSizeDelta().width > 0 && req.getSizeDelta().height > 0) {
            final Command cmd = parentEp.getCommand(req);
            if (cmd != null) {
                parentEp.getDiagramEditDomain().getDiagramCommandStack().execute(cmd);
            }
        }

    }
 
Example #22
Source File: CustomDragDropEditPolicy.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private boolean dropNotAllowed(final ChangeBoundsRequest request) {
    return getHost() instanceof LaneEditPart
            || getHost() instanceof PoolEditPart
            || isAnIllegalMove(request)
            || isTargetaCollapseSubprocess(request)
            || isSourceAndTargetAreEventSubProc(request)
            || isSourceFromExpandSubprocessAndSourceAlreadyConnected(request)
            || getHost().getParent() != null && getHost().getParent() instanceof MainProcessEditPart
            || isInvalidBoundaryMove(request)
            || !ChangeBoundsRequestUtil.isMovingToAnotherProcess(getHost(), request)
            || isALabelEditPart(request);
}
 
Example #23
Source File: MultipleShapesHorizontalMoveTool.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates the children move request
 */
@Override
protected void updateSourceRequest() {
 super.updateSourceRequest();
 int moved = getCurrentPosition() - _initialPosition;
 ((ChangeBoundsRequest) getSourceRequest()).
 setMoveDelta(new Point(moved, 0));
 ((ChangeBoundsRequest) getSourceRequest()).
 setEditParts(_movingShapes);
}
 
Example #24
Source File: MultipleShapesVerticalMoveTool.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates the initial request,
 * overridden to use a ChangeBoundsRequest.
 */
@Override
protected Request createSourceRequest() {
	ChangeBoundsRequest request = new ChangeBoundsRequest(getCommandName());
	request.setSizeDelta(new Dimension(0, 0));
	return request;
}
 
Example #25
Source File: CustomResizableEditPolicyEx.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected boolean checkSubprocessEventCanReduce(final ChangeBoundsRequest request) {
    for (final Object c : getHost().getChildren()) {
        if (c instanceof CustomSubprocessEventCompartmentEditPart) {
            final View view = ((org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart) c).getNotationView();
            if (view != null) {
                final DrawerStyle style = (DrawerStyle) view.getStyle(NotationPackage.eINSTANCE.getDrawerStyle());
                if (style != null) {
                    if (!style.isCollapsed()
                            && !((Container) ((CustomSubprocessEventCompartmentEditPart) c).resolveSemanticElement()).getElements().isEmpty()) {
                        final Rectangle bounds = request.getTransformedRectangle(getHostFigure().getBounds());
                        for (final Object child : ((CustomSubprocessEventCompartmentEditPart) c).getChildren()) {
                            final int x = ((IGraphicalEditPart) child).getFigure().getBounds().x;
                            final int width = ((IGraphicalEditPart) child).getFigure().getBounds().width;
                            final int y = ((IGraphicalEditPart) child).getFigure().getBounds().y;
                            final int height = ((IGraphicalEditPart) child).getFigure().getBounds().height;

                            if ((request.getSizeDelta().height < 0 || request.getSizeDelta().width < 0)
                                    && (bounds.width + bounds.x - 20 <= x + width || bounds.height + bounds.y - 30 <= y + height)) {
                                return false;
                            }
                        }
                    }
                }
            }
        }
    }
    return true;
}
 
Example #26
Source File: ReportFlowLayoutEditPolicy.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected Command getAddCommand( Request req )
{
	EditPart parent = getHost( );
	ChangeBoundsRequest request = (ChangeBoundsRequest) req;
	List editParts = request.getEditParts( );
	CompoundCommand command = new CompoundCommand( );
	for ( int i = 0; i < editParts.size( ); i++ )
	{
		EditPart child = (EditPart) editParts.get( i );
		command.add( createAddCommand( parent,
				child,
				getInsertionReference( request ) ) );
	}
	return command.unwrap( );
}
 
Example #27
Source File: DiagramElementsModifier.java    From txtUML with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Moves a GraphicalEditPart to the given location
 * 
 * @param graphEP
 *            - The GraphicalEditPart
 * @param new_X
 *            - The new x coordinate
 * @param new_Y
 *            - The new y coordinate
 */
public static void moveGraphicalEditPart(GraphicalEditPart graphEP, int new_X, int new_Y) {
	Rectangle figurebounds = graphEP.getFigure().getBounds();
	ChangeBoundsRequest move_req = new ChangeBoundsRequest(RequestConstants.REQ_MOVE);
	move_req.setMoveDelta(new Point(new_X - figurebounds.x(), new_Y - figurebounds.y()));
	move_req.setEditParts(graphEP);

	Command cmd = graphEP.getCommand(move_req);
	if (cmd != null && cmd.canExecute())
		cmd.execute();
}
 
Example #28
Source File: EditorDragGuidePolicy.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void showAttachedPartsFeedback( ChangeBoundsRequest request )
{
	ChangeBoundsRequest req = new ChangeBoundsRequest( request.getType( ) );
	req.setEditParts( getAttachedEditParts( ) );

	if ( getGuideEditPart( ).isHorizontal( ) )
		req.setMoveDelta( new Point( 0, request.getMoveDelta( ).y ) );
	else
		req.setMoveDelta( new Point( request.getMoveDelta( ).x, 0 ) );

	Iterator i = getAttachedEditParts( ).iterator( );

	while ( i.hasNext( ) )
		( (EditPart) i.next( ) ).showSourceFeedback( req );
}
 
Example #29
Source File: EditorDragGuidePolicy.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
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;
}
 
Example #30
Source File: CompartmentEditPolicy.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Command getCommand(Request request) {

	if(request.getType() == RequestConstants.REQ_RESIZE_CHILDREN
			&& request instanceof ChangeBoundsRequest){
		ChangeBoundsRequest changeBoundsRequest = (ChangeBoundsRequest)request;
		EditPart ep = (EditPart) changeBoundsRequest.getEditParts().get(0);
		if(ep instanceof IGraphicalEditPart){
			Node node = (Node)((IGraphicalEditPart)ep).getModel() ;
			Size size =(Size)node.getLayoutConstraint() ;
			Dimension s = new Dimension(size.getWidth(),size.getHeight());
			if(ep instanceof CustomPoolEditPart){
				if(s.height < 0){
					s.height = ((CustomPoolEditPart)ep).getDefaultHeight();
				}

				if(s.width < 0){
					s.width = ((CustomPoolEditPart)ep).getDefaultWidth();
				}
			}

			Location loc =(Location)node.getLayoutConstraint() ;
			Dimension delta = changeBoundsRequest.getSizeDelta();
			Rectangle constraint = new Rectangle(loc.getX(), loc.getY(), s.width + delta.width, s.height + delta.height);
			return createChangeConstraintCommand((ChangeBoundsRequest) request,ep,constraint);
		}
	}

	return super.getCommand(request);
}