CreateElementCommand - elements do not appear on diagram [message #547579] |
Mon, 19 July 2010 02:47 |
Al 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 |
Eclipse User |
|
|
|
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.03064 seconds