Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » exception when creating a connection via a command
exception when creating a connection via a command [message #889900] Wed, 20 June 2012 08:04 Go to next message
Chris B. is currently offline Chris B.
Messages: 37
Registered: November 2011
Member
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 #893449 is a reply to message #889900] Wed, 04 July 2012 08:12 Go to previous message
Romain Bioteau is currently offline Romain Bioteau
Messages: 62
Registered: August 2009
Location: Grenoble
Member
Hello
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


R&D Engineer at BonitaSoft
Previous Topic:Customize icon
Next Topic:Adding hyperlink to a message in MessageDialog
Goto Forum:
  


Current Time: Wed Sep 17 15:42:43 GMT 2014

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

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