Drop location [message #634802] |
Sat, 23 October 2010 17:13 |
123star Messages: 70 Registered: June 2010 |
Member |
|
|
Hi,
in a Composite diagram I change the model by adding some ports to a Component and a Property inside this Component, then I try to visualize the new ports with this method:
public static void dropObject(EObject element, EObject where){
DropObjectsRequest dropObjectsRequest = new DropObjectsRequest();
dropObjectsRequest.setLocation(new Point(1, 1));
ArrayList<Object> objectList = new ArrayList<Object>();
objectList.add(element);
dropObjectsRequest.setObjects(objectList);
List<EditPart> eparts = getEditPart(where);
org.eclipse.gef.commands.Command cmd = eparts.get(0).getCommand(dropObjectsRequest);
PapyrusMultiDiagramEditor editor = (PapyrusMultiDiagramEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
editor.getDiagramEditPart().getDiagramEditDomain().getDiagramCommandStack().execute(cmd);
}
The ports are visualized, but I have the same problem that I mentioned in my previous post: the rectangles of the ports are at the same position.
So I tried to change the location of the drop, changing:
dropObjectsRequest.setLocation(new Point(x, y));
with no results.
Why when I drop the ports manually from the model viewer they are visualized in the location of the mouse drop?
Isn't this method used in the mouse drop from the user?
Another question: I tried to drop a Connector (between a port of the Component and a port of the Property inside the Component) with the dropObject method, but doesn't work, it throws an exception; DropObjectsRequest doesn't work with Connectors?
Thanks in advance, 123star
|
|
|
Re: Drop location [message #634925 is a reply to message #634802] |
Mon, 25 October 2010 07:27 |
Vincent Messages: 35 Registered: December 2009 |
Member |
|
|
Hello, here are a few answers.
123star wrote on Sat, 23 October 2010 13:13 |
The ports are visualized, but I have the same problem that I mentioned in my previous post: the rectangles of the ports are at the same position.
|
By the way, have you posted a bug so that the locator handles conflicting positions as I suggested ?
123star wrote on Sat, 23 October 2010 13:13 |
So I tried to change the location of the drop, changing:
dropObjectsRequest.setLocation(new Point(x, y));
with no results.
Why when I drop the ports manually from the model viewer they are visualized in the location of the mouse drop?
Isn't this method used in the mouse drop from the user?
|
I haven't tried, but I'm pretty sure this is the correct way.
Though, the definition of a location is very often confusing betwen absolute and local locations.
So my bet is that you probably used local coordinates (relative to the target figure) whereas I think absolute coordinates shall be used (relative to the whole diagram).
I suggest you put a breakpoint at the very beginning of the method
org.eclipse.papyrus.diagram.composite.custom.edit.policies.CustomDiagramDragDropEditPolicy.dropAffixedNode(DropObjectsRequest, Element, int)
to try and compare what the locations are in case of a manual drop and in case of a programmatic drop. You may also check that the traslation delta which is then applied later in the method is the same.
123star wrote on Sat, 23 October 2010 13:13 |
Another question: I tried to drop a Connector (between a port of the Component and a port of the Property inside the Component) with the dropObject method, but doesn't work, it throws an exception; DropObjectsRequest doesn't work with Connectors?
|
Probably a bug... There is specific code to handle this drop in the
org.eclipse.papyrus.diagram.composite.custom.edit.policies.CustomDiagramDragDropEditPolicy.dropConnector(DropObjectsRequest, Element, int)
method. So this "should" (meaning if it doesn't, this is an unexpected behavior) work correctly. If it does not and if there is not already a bug on that subject, you may post a new bug with the complete steps to reproduce and the associated stack trace.
Best regards,
Vincent.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03425 seconds