Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Create node's children programmatically on drag&drop
Create node's children programmatically on drag&drop [message #1705601] Mon, 17 August 2015 17:27 Go to next message
Gin SulFriend
Messages: 5
Registered: February 2013
Junior Member
Hello,

when I try to modify an element programatically, I get the following error:
!ENTRY org.eclipse.emf.transaction 4 41 2015-11-12 13:56:17.934
!MESSAGE Read-only transaction rolled back
!SUBENTRY 1 org.eclipse.emf.transaction 4 40 2015-11-12 13:56:17.935
!MESSAGE Transaction aborted due to concurrent write
!ENTRY org.eclipse.gmf.runtime.diagram.ui 4 2 2015-11-12 13:56:17.937
!MESSAGE IRJS0007E Semantic refresh failed.
!STACK 0
java.lang.IllegalStateException: Cannot modify resource set without a write transaction

The whole stack trace is at the bottom [1].

I have an editor where I can drag & drop palette element TimingInterval onto canvas.
Upon TimingInterval creation I want to create its attribute Trigger. The custom code (marked 111) that does that reisdes in TimingIntervalCreateCommand class.
Why do I get transaction-related exception even though I wrap my actions in Command statements?
public class TimingIntervalCreateCommand extends EditElementCommand {
	protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
		TimingInterval newElement = TimingintervalFactory.eINSTANCE.createTimingInterval();

		//111 BEGIN CUSTOM CODE (Gives Cannot modify resource set without a write transaction)
		this.getEditingDomain().getCommandStack().execute(
				AddCommand.create(this.getEditingDomain(), 
				newElement,
				TimingintervalPackage.Literals.TRIGGER, 
				TimingintervalFactory.eINSTANCE.createTrigger()));
		//111 END CUSTOM CODE 

		TimingIntervalOwner owner = (TimingIntervalOwner) getElementToEdit();
		owner.getTimingIntervals().add(newElement);

		//222 BEGIN CUSTOM CODE (Works fine)
		String name = NameUtils.getName(owner) + "_Ti";
		name = NameUtils.getSafeName(newElement, name, owner, null);
		newElement.setName(name);
		//222 END CUSTOM CODE 
		doConfigure(newElement, monitor, info);

		((CreateElementRequest) getRequest()).setNewElement(newElement);
		return CommandResult.newOKCommandResult(newElement);
	}


Strangely custom code 222 works just fine even without the Command.

Thanks!
Gin


[1] Stack Trace
!ENTRY org.eclipse.emf.transaction 4 41 2015-11-11 23:15:51.828
!MESSAGE Read-only transaction rolled back
!SUBENTRY 1 org.eclipse.emf.transaction 4 40 2015-11-11 23:15:51.828
!MESSAGE Transaction aborted due to concurrent write

!ENTRY org.eclipse.gmf.runtime.diagram.ui 4 2 2015-11-11 23:15:51.832
!MESSAGE IRJS0007E Semantic refresh failed.
!STACK 0
java.lang.IllegalStateException: Cannot modify resource set without a write transaction
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.assertWriting(TransactionChangeRecorder.java:348)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.appendNotification(TransactionChangeRecorder.java:302)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.processObjectNotification(TransactionChangeRecorder.java:284)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.notifyChanged(TransactionChangeRecorder.java:240)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:374)
at ac.soton.eventb.emf.core.extension.coreextension.impl.EventBCommentedLabeledEventGroupElementImpl.eNotify(EventBCommentedLabeledEventGroupElementImpl.java:437)
at org.eventb.emf.core.impl.EventBElementImpl.setInternalId(EventBElementImpl.java:515)
at org.eventb.emf.core.impl.EventBElementImpl.getElementIdentification(EventBElementImpl.java:217)
at org.eventb.emf.core.impl.EventBElementImpl.doGetReference(EventBElementImpl.java:326)
at org.eventb.emf.core.impl.EventBElementImpl.getReference(EventBElementImpl.java:204)
at org.eventb.emf.core.impl.EventBElementImpl.eIsSet(EventBElementImpl.java:452)
at org.eventb.emf.core.impl.EventBCommentedElementImpl.eIsSet(EventBCommentedElementImpl.java:149)
at ac.soton.eventb.emf.core.extension.coreextension.impl.EventBCommentedLabeledElementImpl.eIsSet(EventBCommentedLabeledElementImpl.java:101)
at ac.soton.eventb.emf.core.extension.coreextension.impl.EventBCommentedLabeledEventGroupElementImpl.eIsSet(EventBCommentedLabeledEventGroupElementImpl.java:370)
at ac.soton.eventb.ti.timinginterval.impl.AbstractEventRoleImpl.eIsSet(AbstractEventRoleImpl.java:266)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eIsSet(BasicEObjectImpl.java:1237)
at org.eclipse.emf.ecore.util.EcoreUtil.getID(EcoreUtil.java:3511)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.getURIFragment(ResourceImpl.java:655)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.getURIFragment(XMLResourceImpl.java:630)
at org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil.getProxyID(EMFCoreUtil.java:567)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.registerModel(GraphicalEditPart.java:1201)
at org.eclipse.gef.editparts.AbstractEditPart.register(AbstractEditPart.java:817)
at org.eclipse.gef.editparts.AbstractEditPart.addNotify(AbstractEditPart.java:248)
at org.eclipse.gef.editparts.AbstractGraphicalEditPart.addNotify(AbstractGraphicalEditPart.java:223)
at org.eclipse.gef.editparts.AbstractEditPart.addChild(AbstractEditPart.java:212)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.addChild(GraphicalEditPart.java:1319)
at org.eclipse.gef.editparts.AbstractEditPart.refreshChildren(AbstractEditPart.java:781)
at org.eclipse.gef.editparts.AbstractEditPart.refresh(AbstractEditPart.java:726)
at org.eclipse.gef.editparts.AbstractGraphicalEditPart.refresh(AbstractGraphicalEditPart.java:644)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.access$3(GraphicalEditPart.java:1)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart$3.run(GraphicalEditPart.java:861)
at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.runExclusive(TransactionalEditingDomainImpl.java:328)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.refresh(GraphicalEditPart.java:851)
at org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy.postProcessRefreshSemantic(CanonicalEditPolicy.java:1190)
at ac.soton.eventb.ti.timinginterval.diagram.edit.policies.TimingIntervalTriggersCompartmentCanonicalEditPolicy.refreshSemantic(TimingIntervalTriggersCompartmentCanonicalEditPolicy.java:156)
at org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy.refresh(CanonicalEditPolicy.java:961)
at org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy.refreshOnActivate(CanonicalEditPolicy.java:638)
at ac.soton.eventb.ti.timinginterval.diagram.edit.policies.TimingIntervalTriggersCompartmentCanonicalEditPolicy.refreshOnActivate(TimingIntervalTriggersCompartmentCanonicalEditPolicy.java:44)
at org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy.activate(CanonicalEditPolicy.java:628)
at org.eclipse.gef.editparts.AbstractEditPart.activateEditPolicies(AbstractEditPart.java:174)
at org.eclipse.gef.editparts.AbstractEditPart.activate(AbstractEditPart.java:156)
at org.eclipse.gef.editparts.AbstractGraphicalEditPart.activate(AbstractGraphicalEditPart.java:195)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.access$0(GraphicalEditPart.java:1)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.activate(GraphicalEditPart.java:205)
at org.eclipse.gef.editparts.AbstractEditPart.activate(AbstractEditPart.java:160)
at org.eclipse.gef.editparts.AbstractGraphicalEditPart.activate(AbstractGraphicalEditPart.java:195)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.access$0(GraphicalEditPart.java:1)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.activate(GraphicalEditPart.java:205)
at org.eclipse.gef.editparts.AbstractEditPart.addChild(AbstractEditPart.java:215)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.addChild(GraphicalEditPart.java:1319)
at org.eclipse.gef.editparts.AbstractEditPart.refreshChildren(AbstractEditPart.java:781)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.handleNotificationEvent(GraphicalEditPart.java:1464)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.notifyChanged(GraphicalEditPart.java:1438)
at org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker.fireNotification(DiagramEventBroker.java:504)
at org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker.resourceSetChanged(DiagramEventBroker.java:399)
at org.eclipse.gmf.runtime.diagram.ui.DiagramEventBrokerThreadSafe.resourceSetChanged(DiagramEventBrokerThreadSafe.java:73)
at org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFactory$DiagramEditingDomain.postcommit(DiagramEditingDomainFactory.java:214)
at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.deactivate(TransactionalEditingDomainImpl.java:543)
at org.eclipse.emf.transaction.impl.TransactionImpl.close(TransactionImpl.java:712)
at org.eclipse.emf.transaction.impl.TransactionImpl.commit(TransactionImpl.java:474)
at org.eclipse.emf.workspace.AbstractEMFOperation.execute(AbstractEMFOperation.java:155)
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:134)
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:134)
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:134)
at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:513)
at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack.execute(DiagramCommandStack.java:206)
at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack.execute(DiagramCommandStack.java:169)
at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack.execute(DiagramCommandStack.java:156)
at org.eclipse.gef.tools.AbstractTool.executeCommand(AbstractTool.java:425)
at org.eclipse.gef.tools.AbstractTool.executeCurrentCommand(AbstractTool.java:438)
at org.eclipse.gmf.runtime.diagram.ui.tools.CreationTool.performCreation(CreationTool.java:133)
at org.eclipse.gef.tools.CreationTool.handleButtonUp(CreationTool.java:189)
at org.eclipse.gef.tools.AbstractTool.mouseUp(AbstractTool.java:1200)
at org.eclipse.gef.EditDomain.mouseUp(EditDomain.java:301)
at org.eclipse.gef.ui.parts.DomainEventDispatcher.dispatchMouseReleased(DomainEventDispatcher.java:380)
at org.eclipse.draw2d.LightweightSystem$EventHandler.mouseUp(LightweightSystem.java:548)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:220)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4454)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1388)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3799)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3409)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
at org.eclipse.equinox.launcher.Main.main(Main.java:1438)

[Updated on: Thu, 12 November 2015 17:41]

Report message to a moderator

Re: Create node's children programmatically on drag&drop [message #1714447 is a reply to message #1705601] Thu, 12 November 2015 17:42 Go to previous message
Gin SulFriend
Messages: 5
Registered: February 2013
Junior Member
I've updated my first post.
Any ideas guys? I am still stuck with this.
Previous Topic:Right way to specify Fonts?
Next Topic:Move connected elements together to hold initial position of creation
Goto Forum:
  


Current Time: Thu Dec 12 23:20:55 GMT 2024

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

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

Back to the top