Skip to main content



      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
Eclipse UserFriend
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
Eclipse UserFriend
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,
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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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] by 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: Tue Jul 22 23:46:50 EDT 2025

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

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

Back to the top