Skip to main content


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 12:00 Go to next message
Matthias N is currently offline Matthias NFriend
Messages: 66
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 12:16 Go to previous messageGo to next message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
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 - Red Hat
Senior Software Engineer in Fuse Tooling team
Re: Change domain model when diagram was opened [message #1001820 is a reply to message #1001818] Thu, 17 January 2013 12:23 Go to previous messageGo to next message
Matthias N is currently offline Matthias NFriend
Messages: 66
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 12:23 Go to previous messageGo to next message
Matthias N is currently offline Matthias NFriend
Messages: 66
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 13:18 Go to previous message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
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 13: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: Fri Apr 19 10:34:20 GMT 2024

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

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

Back to the top