Change domain model when diagram was opened [message #1001805] |
Thu, 17 January 2013 07:00  |
Eclipse User |
|
|
|
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 #1002364 is a reply to message #1001821] |
Fri, 18 January 2013 08:18  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.04402 seconds