Bug in drop comment? [message #640951] |
Tue, 23 November 2010 16:21 |
123star Messages: 70 Registered: June 2010 |
Member |
|
|
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 #641654 is a reply to message #641540] |
Fri, 26 November 2010 14:31 |
|
Hi 123Star,
First, I have dropped the comment into the diagram and the link has not be drawn. I have done that for the class diagram. And you which type is it your diagram?
For the class diagram this a bug, when I drop a comment I have also to display the link that is the annotated element.
Patrick
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03823 seconds