Comment doesn't show in model view [message #631986] |
Mon, 11 October 2010 03:19  |
Eclipse User |
|
|
|
Hi,
in my program I create a Comment like this:
// owner is a Class
// port is a port of owner
Comment comment = owner.createOwnedComment();
comment.getAnnotatedElements().add(port);
But as mentioned, it doesn't show in the model view and after creating the view, it doesn't show in the editor neither.
I already asked on uml2 forum, I did what they told, but no results, so they told me to ask here.
Thanks in advance, 123star
|
|
|
|
Re: Comment doesn't show in model view [message #632083 is a reply to message #631986] |
Mon, 11 October 2010 09:57  |
Eclipse User |
|
|
|
Hi Patrick,
The comment doesn't show in the model view.
The comment doesn't show in the editor.
The comment is like it never existed, so I think there's a problem in the way I create it.
I create the Comment executing a RecordingCommand in a TransactionalEditingDomain:
Command cmd = new RecordingCommand(domain) {
protected void doExecute() {
//owner is a Component
Comment comment = owner.createOwnedComment();
//edits the comment, e.g. apply stereotype to it
//creates the view:
ViewDescriptor viewDescriptor = new ViewDescriptor(
new EObjectAdapter(comment), Node.class,
((IHintedType) org.eclipse.papyrus.diagram.composite.providers.UMLElementTypes
.getElementType(CommentEditPart.VISUAL_ID)).getSemanticHint(),
diagEpart.getDiagramPreferencesHint());
viewDescriptor.setPersisted(true);
CreateViewRequest req = new CreateViewRequest(viewDescriptor);
Command comm = ownerPart.getCommand(req);
comm.execute();
}
}
domain.getCommandStack().execute(cmd);
I think it's not the best way to do it, but it's the only way I managed to get the visualization in the editor working( I've used it with ports).
Do you say that it's better if I use a command that create the element and the view at the same time?
Can you explain how?
Thank you again, 123star
|
|
|
Powered by
FUDForum. Page generated in 0.07177 seconds