Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Refresh bounds of a node
Refresh bounds of a node [message #78527] Fri, 17 November 2006 10:01 Go to next message
Eclipse UserFriend
Originally posted by: seliva.gmail.com

Hi!

I am trying to change the location of one node of my gmf diagram
programatically. I think the proper way of doing this is using
ChangeBoundsRequest, but somehow I havent manage to do it.

Here is the code I have use:

ChangeBoundsRequest move_req = new
ChangeBoundsRequest(RequestConstants.REQ_MOVE);
EditPart trainEditPart = getTrainEditPart(diagramEditPart,trainName);
Point destinyLocation = getYardObjectLocation(objectEditPart);
move_req.setMoveDelta(destinyLocation);
Command move_cmd = trainEditPart.getCommand(move_req);
if (move_cmd == null || !(move_cmd.canExecute())) {
throw new IllegalArgumentException("Command is not executable.");
}
else {

diagramEditPart.getDiagramEditDomain().getDiagramCommandStac k().execute(move_cmd);
trainEditPart.refresh();
}

I know that trainEditPart and destinyLocation are the right ones, so the
problem is not there. I also know that the move_cmd is not null and it is
possible to execute it.

I tried to call trainEditPart.refresh() after the command is executed but
it did not make any difference. I dont get any error, so I dont know where
the problem can be, but just the my node is not moving.

Does someone has any idea? Thanks a lot!
Re: Refresh bounds of a node [message #78546 is a reply to message #78527] Fri, 17 November 2006 10:52 Go to previous messageGo to next message
Eclipse UserFriend
Hi Noelia;

You do not need to call refresh, since edit parts are supposed to
listen to the events and refresh when required.

This is done inside ShapeEditPart#handleNotificationEvent

you will find that this method is responding to X, Y and size change
events by calling refresh bounds. Try to add a break point to this
method, if you hit the break point and it does call refresh bounds then
you need to make sure that the delta you have calculated is correct
and it had been calculated using the correct mapping mode.







Noelia Rodriguez wrote:
> Hi!
>
> I am trying to change the location of one node of my gmf diagram
> programatically. I think the proper way of doing this is using
> ChangeBoundsRequest, but somehow I havent manage to do it.
> Here is the code I have use:
>
> ChangeBoundsRequest move_req = new
> ChangeBoundsRequest(RequestConstants.REQ_MOVE);
> EditPart trainEditPart = getTrainEditPart(diagramEditPart,trainName);
> Point destinyLocation = getYardObjectLocation(objectEditPart);
> move_req.setMoveDelta(destinyLocation);
> Command move_cmd = trainEditPart.getCommand(move_req);
> if (move_cmd == null || !(move_cmd.canExecute())) {
> throw new IllegalArgumentException("Command is not executable.");
> }
> else {
>
> diagramEditPart.getDiagramEditDomain().getDiagramCommandStac k().execute(move_cmd);
>
> trainEditPart.refresh();
> }
>
> I know that trainEditPart and destinyLocation are the right ones, so the
> problem is not there. I also know that the move_cmd is not null and it
> is possible to execute it.
> I tried to call trainEditPart.refresh() after the command is executed
> but it did not make any difference. I dont get any error, so I dont know
> where the problem can be, but just the my node is not moving.
>
> Does someone has any idea? Thanks a lot!
>
Re: Refresh bounds of a node [message #78772 is a reply to message #78546] Mon, 20 November 2006 05:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: seliva.gmail.com

Hi again!

I added breakpoints to the handlenotification and refreshVisuals
functions, and they are called when the command is executed, so I guess
the problem is not there.

What happens now is that when I execute this ChangeBoundsRequest, the view
of my object Train dissapears, even though the semantic object is still in
my diagram.

I am not sure I know what you mean by "mapping mode" but the new delta is
just a point created like new Point(x,y). Is there any other value I
should set to my request? Because right know I only set the value of the
delta:
move_req.setMoveDelta(new Point(100,200));
before creating the command:
move_cmd = trainEditPart.getCommand(move_req);

Does someone have any idea why my object view dissapears? Thanks!!
Re: Refresh bounds of a node [message #78921 is a reply to message #78772] Mon, 20 November 2006 12:43 Go to previous messageGo to next message
Eclipse UserFriend
Hi Noelia :

I have tried the following code in the logic example and it works as
expected :


GGraphicalEditPart editPart = (GraphicalEditPart) editParts.get(0);
ChangeBoundsRequest move_req = new
ChangeBoundsRequest(RequestConstants.REQ_MOVE);
move_req.setMoveDelta(new Point(100,100));
Command cmd = editPart.getCommand(move_req);
if (cmd == null || !cmd.canExecute()) {
throw new IllegalArgumentException("Command is not
executable.");
}
((DiagramEditPart)(editPart.getParent())).getDiagramEditDoma in().getDiagramCommandStack().execute(cmd);




Noelia Rodriguez wrote:




> Hi again!
>
> I added breakpoints to the handlenotification and refreshVisuals
> functions, and they are called when the command is executed, so I guess
> the problem is not there.
> What happens now is that when I execute this ChangeBoundsRequest, the
> view of my object Train dissapears, even though the semantic object is
> still in my diagram.
> I am not sure I know what you mean by "mapping mode" but the new delta
> is just a point created like new Point(x,y). Is there any other value I
> should set to my request? Because right know I only set the value of the
> delta:
> move_req.setMoveDelta(new Point(100,200));
> before creating the command:
> move_cmd = trainEditPart.getCommand(move_req);
>
> Does someone have any idea why my object view dissapears? Thanks!!
>
>
Re: Refresh bounds of a node [message #79094 is a reply to message #78921] Tue, 21 November 2006 03:11 Go to previous message
Eclipse UserFriend
Originally posted by: seliva.gmail.com

Hi Mohammed!

thank you very much for your tips. Now I manage to make my object visible
all the time, and moving it within my diagram. (Maybe my problem was that
I was using the plain EditPart without translating it to GraphicalEditPart)

The only problem I have now is that the position is not exact. I calculate
the delta by:

delta = new
Point(destinyLocation.x-currentLocation.x,destinyLocation.y- currentLocation.y);

and check that the delta is the desired one, but anyways, the object
appears a bit moved from that point. Maybe it has something to do with
Relative/Absolute coordinates? Thanks for the help!
Previous Topic:figure resize
Next Topic:modify context menu
Goto Forum:
  


Current Time: Mon Jun 02 23:27:53 EDT 2025

Powered by FUDForum. Page generated in 0.04214 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top