Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Manipulate Notational Model on Element Creation
Manipulate Notational Model on Element Creation [message #660579] Sat, 19 March 2011 15:45 Go to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 697
Registered: November 2009
Senior Member
Hi all,

I want to set a value in the notational model when adding an editpart to the diagram. I added the following code in the add Notify of the editpart. This code throes an exception saying that I am in a read only transaction. Is there a way to get around this? Set values in the notational model, by using a Initializer in the gmfmap?

EditingDomain domain = getEditingDomain();
Command cmd = SetCommand.create(domain, getNotationView(), NotationPackage.eINSTANCE.getView_Visible(), false);
getEditingDomain().getCommandStack().execute(cmd);


Ralph
Re: Manipulate Notational Model on Element Creation [message #660652 is a reply to message #660579] Sun, 20 March 2011 16:49 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
On 19-03-11 08:45, ralph. wrote:
> Hi all,
>
> I want to set a value in the notational model when adding an editpart to
> the diagram.
Hi, you could modify the ViewProvider (in package xxx.yyy.providers).
This is the place where initial views of the Notation model are populated.


I added the following code in the add Notify of the
It's generally not a good idea to let editparts create commands.
A better place is edit policies. (Edit parts, actually delegate
getCommand(request) to all installed editing policies.

> editpart. This code throes an exception saying that I am in a read only
> transaction.
Is there a way to get around this? Set values in the
> notational model, by using a Initializer in the gmfmap?
I believe the initializers are meant for the semantic model, the
ViewProvider is your best bet. BTW, if you don't want to mess with the
original ViewProvider, just copy it to a new plugin, and copy the view
provider declaration from the plugin.xml to the new plugin.xml and
change the priority to a higher level. Modify the ViewProvider at wish.
>
>
> EditingDomain domain = getEditingDomain();
> Command cmd = SetCommand.create(domain, getNotationView(),
> NotationPackage.eINSTANCE.getView_Visible(), false);
> getEditingDomain().getCommandStack().execute(cmd);
>
>
> Ralph
Re: Manipulate Notational Model on Element Creation [message #660718 is a reply to message #660652] Mon, 21 March 2011 11:54 Go to previous message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 697
Registered: November 2009
Senior Member
Hi,

i changed the createXXX_XXX Method in ViewProvider. This works realy creat for me. I think I need to take care when the shape's look is changed to refelect this in the create method.

Thank you a lot!!!


Ralph
Previous Topic:OutlineView: 2 TreeEditParts -> 1 Model
Next Topic:LabelEditPart for multiple Strings (List<String>)
Goto Forum:
  


Current Time: Thu Dec 18 05:37:48 GMT 2014

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

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