exception when creating a connection via a command [message #889900] |
Wed, 20 June 2012 04:04  |
Eclipse User |
|
|
|
Hello everyone,
currently i'm trying to create a polyline connection automatically between 2 compartment elements of different nodes via a command when the user performs a specific action. Although i'm executing the command with the TransactionalCommandStack it throws the following exception:
Caused by: 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)
at org.eclipse.emf.workspace.AbstractEMFOperation.execute(AbstractEMFOperation.java:147)
at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:511)
at org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.doExecute(WorkspaceCommandStackImpl.java:208)
at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:165)
at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:219)
at com.softwareag.adiwa.tool.graphicaleventmodeller.extend.helper.advice.ExpressionEditHelperAdvice.getAfterCreateRelationshipCommand(ExpressionEditHelperAdvice.java:114)
at org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice.getAfterEditCommand(AbstractEditHelperAdvice.java:114)
at org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelper.getEditCommand(AbstractEditHelper.java:206)
at org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelper.getEditCommand(AbstractEditHelper.java:137)
at org.eclipse.gmf.runtime.emf.type.core.MetamodelType.getEditCommand(MetamodelType.java:107)
at GraphicalEventModeller.diagram.edit.policies.GraphicalEventModellerBaseItemSemanticEditPolicy.getEditHelperCommand(GraphicalEventModellerBaseItemSemanticEditPolicy.java:137)
at GraphicalEventModeller.diagram.edit.policies.GraphicalEventModellerBaseItemSemanticEditPolicy.getSemanticCommand(GraphicalEventModellerBaseItemSemanticEditPolicy.java:100)
at org.eclipse.gmf.runtime.diagram.ui.editpolicies.SemanticEditPolicy.getCommand(SemanticEditPolicy.java:69)
at GraphicalEventModeller.diagram.edit.policies.GraphicalEventModellerBaseItemSemanticEditPolicy.getCommand(GraphicalEventModellerBaseItemSemanticEditPolicy.java:82)
at org.eclipse.gef.editparts.AbstractEditPart.getCommand(AbstractEditPart.java:501)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.access$1(GraphicalEditPart.java:1)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart$1.run(GraphicalEditPart.java:482)
at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.runExclusive(TransactionalEditingDomainImpl.java:328)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.getCommand(GraphicalEditPart.java:477)
at org.eclipse.gmf.runtime.diagram.ui.editpolicies.GraphicalNodeEditPolicy.getConnectionAndRelationshipCreateCommand(GraphicalNodeEditPolicy.java:628)
at org.eclipse.gmf.runtime.diagram.ui.editpolicies.GraphicalNodeEditPolicy.getCommand(GraphicalNodeEditPolicy.java:593)
at org.eclipse.gef.editparts.AbstractEditPart.getCommand(AbstractEditPart.java:501)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.access$1(GraphicalEditPart.java:1)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart$1.run(GraphicalEditPart.java:482)
at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.runExclusive(TransactionalEditingDomainImpl.java:328)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.getCommand(GraphicalEditPart.java:477)
at org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest.getCreateCommand(CreateConnectionViewRequest.java:341)
at org.eclipse.gmf.runtime.diagram.ui.commands.DeferredCreateConnectionViewAndElementCommand.doExecuteWithResult(DeferredCreateConnectionViewAndElementCommand.java:266)
at org.eclipse.gmf.runtime.common.core.command.AbstractCommand.execute(AbstractCommand.java:135)
at org.eclipse.gmf.runtime.common.core.command.CompositeCommand.doExecuteWithResult(CompositeCommand.java:403)
at org.eclipse.gmf.runtime.common.core.command.AbstractCommand.execute(AbstractCommand.java:135)
at org.eclipse.gmf.runtime.common.core.command.CompositeCommand.doExecuteWithResult(CompositeCommand.java:403)
at org.eclipse.gmf.runtime.common.core.command.AbstractCommand.execute(AbstractCommand.java:135)
at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:511)
... 37 more
Here's my code:
InternalTransactionalEditingDomain editingDomain = (InternalTransactionalEditingDomain) AdapterFactoryEditingDomain
.getEditingDomainFor(aggr);
TransactionalCommandStack commandStack = (TransactionalCommandStack) editingDomain.getCommandStack();
commandStack.execute(new GmfICommandtoEmfCommandBridge(new TransactionalCommand(editingDomain,
"create expression link", null, aggr, aggrFunc)));
TransactionalCommand is a subclass of AbstractTransactionalCommand.
What am i doing wrong? Any suggestions how to fix this?
Regards
Chris
|
|
|
|
Re: exception when creating a connection via a command [message #1454127 is a reply to message #893449] |
Mon, 27 October 2014 21:22  |
Eclipse User |
|
|
|
Where can I find GmfICommandtoEmfCommandBridge (or something similar)?
Romain Bioteau wrote on Wed, 04 July 2012 08:12Hello
you should try to return a CompositeCommand instead of executing your command directly in getAfterCreateRelationshipCommand.
GmfICommandtoEmfCommandBridge newCommand = new GmfICommandtoEmfCommandBridge(new TransactionalCommand(editingDomain,
"create expression link", null, aggr, aggrFunc));
ICommand command = super.getAfterCreateRelationshipCommand(request);
ICompositeCommand compositeCommand = new CompositeCommand();
if (command != null) {
compositeCommand.add(command);
}
compositeCommand.add(newCommand);
return compositeCommand;
Regards
|
|
|
Powered by
FUDForum. Page generated in 0.05844 seconds