Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Set name of a created element
Set name of a created element [message #500931] Mon, 30 November 2009 06:02 Go to next message
Eclipse UserFriend
Hi!

I manually create an element and its view by invoking
CreateViewRequestFactory.getCreateShapeRequest()
and the associated command. This works fine.

After that I want to set the name of this element by this:

ElementNameEditPart elementNameEditPart = (ElementNameEditPart) createdEditPart;

elementNameEditPart.setLabelText("new one");


First, this works so that the created element gets the name but after saving and reloading the diagram the name disappears though the element is visible.

Has somebody a clue?

regards
Re: Set name of a created element [message #502149 is a reply to message #500931] Sun, 06 December 2009 10:59 Go to previous message
Eclipse UserFriend
Hi again.

I've worked out a solution. It looks like this:


EditPart createdEditPart = ... ; // previously created EditPart

ElementImpl el = (ElementImpl)createdEditPart.resolveSemanticElement();

editor.getDiagramEditDomain().getDiagramCommandStack().execute(
						new Command() {
							@Override
							public void execute() {
								super.execute();
                                                                el.setName("new name...");
							}
						}
				);


Maybe this helps anyone with similar problems.

regards
Previous Topic:Restrict the sharing of a Editingdomain to a Project
Next Topic:Garbled generated code
Goto Forum:
  


Current Time: Tue Jul 08 03:34:50 EDT 2025

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

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

Back to the top