Bug in drop comment? [message #640951] |
Tue, 23 November 2010 11:21  |
Eclipse User |
|
|
|
Hi,
I'm using this code to visualize a Comment created from code:
public static void dropObjectAt(EObject obj, EditPart epart, int x, int y){
DropObjectsRequest dropObjectsRequest = new DropObjectsRequest();
ArrayList<Object> objectList = new ArrayList<Object>();
objectList.add(obj);
dropObjectsRequest.setObjects(objectList);
dropObjectsRequest.setLocation(new Point(x, y));
org.eclipse.gef.commands.Command cmd = epart.getCommand(dropObjectsRequest);
PapyrusMultiDiagramEditor editor = (PapyrusMultiDiagramEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
editor.getDiagramEditPart().getDiagramEditDomain().getDiagramCommandStack().execute(cmd);
}
The problem is that this Comment has one annotated element, and if I drop it manually the link is created, but if I use the dropObjectAt method it doesn't.
Debugging it turns out that the drop is processed in OldCommonDiagramDragAndDropEditPolicy.getDropConstraintComma nd:
the creation of the node Comment works, but the CommonDeferredCreateConnectionViewCommand doesn't find the edit part of the Comment.
So my question: should the parent of the Comment do a refresh to create an edit part for the Comment?
Why does it work when I drop the Comment manually?
If this is a bug I think it's related to another problem I'm having: in another post I asked how to modify the appearance of the Comment, Remi told me where to look, I found the code and tried to execute it in my code, but nothing happens.
I use the exact code that AppearanceForAppliedStereotypeComposite uses:
domain = EditorUtils.getTransactionalEditingDomain();
//appearance for the stereotype
domain.getCommandStack().execute(
AppliedStereotypeHelper.getAddAppliedStereotypeCommand(domain, comment, stereoQualifiedName, presentationKind));
//appearance for the property
domain.getCommandStack().execute(
AppliedStereotypeHelper.getAddAppliedStereotypePropertiesCommand(domain, comment, stereoQualifiedName+ "." + property.getName()));
The Comment remains unchanged and in this way the icons of the properties tree that appears in the appearance tab are not modified.
Is it possible to access directly to the instance of AppearanceForAppliedStereotypeComposite and simulate an user interaction (even if some methods are protected)?
Thanks in advance and sorry for the long post, 123star
|
|
|
|
|
|
|
Re: Bug in drop comment? [message #642285 is a reply to message #640951] |
Tue, 30 November 2010 11:57  |
Eclipse User |
|
|
|
Quote: |
Debugging I found out that a Command is created in OldCommonDiagramDragDropEditPolicy.getDropCommentCommand: there the link is not created because there is no edit part for the comment, so I thought that a refresh should be done on the containter of the comment for creating its edit part before the command for creating the link.
|
I think that the refresh of the container can't be done because the command that creates the comment is not processed yet.
I'm out of options.... here's the situation:
I use the method dropObjectAt(described above) to drop in a composite structure diagram a comment that has an annotated element( a port )
The comment is created but the link is not showing
If I drop the same comment manually the link is created
Why the manual drop works? What kind of command does it use?
Thanks in advance
|
|
|
Powered by
FUDForum. Page generated in 0.03710 seconds