Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » CreateElementCommand - elements do not appear on diagram
CreateElementCommand - elements do not appear on diagram [message #547579] Mon, 19 July 2010 02:47 Go to next message
Al is currently offline AlFriend
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 messageGo to next message
Eclipse UserFriend
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
Re: CreateElementCommand - elements do not appear on diagram [message #550684 is a reply to message #547579] Wed, 04 August 2010 07:10 Go to previous message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

Hi,

take a look at this tip: http://wiki.eclipse.org/GMF_Tips#Creating_New_Elements_And_C orresponding_Views

Regards,


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Previous Topic:SVG rendering with GEF/GMF
Next Topic:problem about duplication function
Goto Forum:
  


Current Time: Sat Jun 22 22:25:54 GMT 2024

Powered by FUDForum. Page generated in 0.03870 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top