CreateElementCommand - elements do not appear on diagram [message #547579] |
Mon, 19 July 2010 02:47 ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Al![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=artraid%40gmail.com) Messages: 1 Registered: July 2010 |
Junior Member |
|
|
Hey,
I'm having some trouble creating elements programmatically. The problem is that the new element is not displayed on the diagram, no matter how many refreshes - it gets put in the model though. However, it starts to work after I place an element with the editor's palette.
Here's the gist of the code:
public void createElement(Object originalEditPart, DiagramCommandStack dcs, IProgressMonitor progressMonitor) {
IGraphicalEditPart gEditPart = (IGraphicalEditPart)originalEditPart;
final EObject originalImpl = gEditPart.getNotationView().getElement();
TransactionalEditingDomain domain = gEditPart.getEditingDomain();
GraphicalEditPart part = (GraphicalEditPart)originalEditPart;
GraphicalEditPart container = (GraphicalEditPart)part.getParent();
CreateElementRequest req = new CreateElementRequest(domain, originalImpl.eContainer(), Blah_modelElementTypes.SomeType_2005);
CreateElementCommand create = new CreateElementCommand(req);
dcs.execute(new ICommandProxy(create));
refresh();
}
Again, this actually works perfectly fine after I place an element on the diagram with the editor palette, just not before. Has anyone else encountered this problem before?
Thank you!
|
|
|
Re: CreateElementCommand - elements do not appear on diagram [message #548587 is a reply to message #547579] |
Thu, 22 July 2010 11:59 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: marius.groeger.googlemail.com
Am 19.07.2010 04:47, schrieb Al:
> CreateElementRequest req = new CreateElementRequest(domain,
> originalImpl.eContainer(), Blah_modelElementTypes.SomeType_2005);
....
> Again, this actually works perfectly fine after I place an element on
> the diagram with the editor palette, just not before. Has anyone else
> encountered this problem before?
I think you're only creating a semantic element with this code, but no
View (Edit Part) for it. You're probably getting the View with the next
"kick" of the CanonicalEditPolicy. So you can either:
* locate the responsible CanonicalEditPolicy and trigger a manual refresh
* use a CreateViewAndElementReques
Regards
Marius
|
|
|
|
Powered by
FUDForum. Page generated in 0.03717 seconds