Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Change domain model when diagram was opened
Change domain model when diagram was opened [message #1001805] Thu, 17 January 2013 07:00 Go to next message
Matthias N is currently offline Matthias N
Messages: 65
Registered: June 2012
Member
Hi, I want to do the following:

When I open a diagram, I wan't to change the domain-model. For example, when I open the diagram, I wan't to add some new elements to an existing element (e.g. Ports to an Element)

I tried to add a method "modifyModel" within my DiagramEditPart's constructor:

public AnalysisFunctionTypeEditPart(View view) {
 super(view);
 modifyModel();


and in modifyModel, I do:
AddCommand addCmd = new AddCommand(getEditingDomain(), list, value);
addCmd.execute();


However, I always get:
java.lang.IllegalStateException: Cannot activate read/write transaction in read-only transaction context
	at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.acquire(TransactionalEditingDomainImpl.java:576)
	at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.activate(TransactionalEditingDomainImpl.java:508)
	at org.eclipse.emf.transaction.impl.TransactionImpl.start(TransactionImpl.java:204)
	at org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.createTransaction(WorkspaceCommandStackImpl.java:380)
	at org.eclipse.emf.workspace.EMFCommandOperation.createTransaction(EMFCommandOperation.java:215)
...


can you help me ?
Re: Change domain model when diagram was opened [message #1001818 is a reply to message #1001805] Thu, 17 January 2013 07:16 Go to previous messageGo to next message
Aurelien Pupier is currently offline Aurelien Pupier
Messages: 558
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

Hi,

are you sure that you don't want to use Feature Seq Initializer instead?

In your case you need to execute the command in a transactional editing domain. Something like getEditingDomain().getCommandStack().execute(addCmd)


Regards,


Aurélien Pupier - BonitaSoft S.A.
My blog
My company Eclipse-related blog
Re: Change domain model when diagram was opened [message #1001820 is a reply to message #1001818] Thu, 17 January 2013 07:23 Go to previous messageGo to next message
Matthias N is currently offline Matthias N
Messages: 65
Registered: June 2012
Member
I tried
TransactionalEditingDomain editingDomain = SharedEditingDomainUtil.getSharedEditingDomain("EASTADLSharedEditingDomain");
AddCommand addCmd = new AddCommand(editingDomain, prototype.getProxyPorts(), proxyPort);
CommandStack commandStack = editingDomain.getCommandStack();
commandStack.execute(addCmd);


same result Sad
Re: Change domain model when diagram was opened [message #1001821 is a reply to message #1001818] Thu, 17 January 2013 07:23 Go to previous messageGo to next message
Matthias N is currently offline Matthias N
Messages: 65
Registered: June 2012
Member
I tried
TransactionalEditingDomain editingDomain = SharedEditingDomainUtil.getSharedEditingDomain("EASTADLSharedEditingDomain");
AddCommand addCmd = new AddCommand(editingDomain, prototype.getProxyPorts(), proxyPort);
CommandStack commandStack = editingDomain.getCommandStack();
commandStack.execute(addCmd);


same result Sad
Re: Change domain model when diagram was opened [message #1002364 is a reply to message #1001821] Fri, 18 January 2013 08:18 Go to previous message
Ralph Gerbig is currently offline Ralph Gerbig
Messages: 697
Registered: November 2009
Senior Member
Hi Matthias,

your code should look like this:

TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(prototype);
Command addCmd = AddCommand.createAddCommand.create(domain, prototype, XXXPackage.eINSTANCE.getPrototype_ProxyPorts(), proxyPort);
domain.getCommandStack().execute(addCmd);


Ralph

[Updated on: Fri, 18 January 2013 08:18]

Report message to a moderator

Previous Topic:[EVL] Quick Fix not found when working in project with white space
Next Topic:Positionning a label above a figure
Goto Forum:
  


Current Time: Thu Aug 21 00:40:28 EDT 2014

Powered by FUDForum. Page generated in 0.06180 seconds