Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » [ERROR] Cannot modify resource set without a write transaction
[ERROR] Cannot modify resource set without a write transaction [message #663700] Wed, 06 April 2011 09:08 Go to next message
akoeck is currently offline akoeckFriend
Messages: 62
Registered: December 2010
Member
I want to create an element in my diagram via an action which is called over an popmenu of another element.
But when I add the Elements to the Diagram I goet this errormessage:
Quote:

java.lang.IllegalStateException: Cannot modify resource set without a write transaction
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:348)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:302)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:284)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:240)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:380)
at org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(E coreEList.java:255)
at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUniq ue(NotifyingListImpl.java:300)
at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList. java:307)
at de.akoeck.diplomarbeit.diagram.part.ExportXMLAction.run(Expo rtXMLAction.java:193)
at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginActi on.java:251)
at org.eclipse.jface.action.ActionContributionItem.handleWidget Selection(ActionContributionItem.java:584)
at org.eclipse.jface.action.ActionContributionItem.access$2(Act ionContributionItem.java:501)
at org.eclipse.jface.action.ActionContributionItem$5.handleEven t(ActionContributionItem.java:411)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:4066)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3657)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2629)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:24 27)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
at org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:663)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:115)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
at org.eclipse.equinox.launcher.Main.main(Main.java:1383)




How can I avoid this error and create my elements? Do I have to call my createcommand for the element via the action?
Re: [ERROR] Cannot modify resource set without a write transaction [message #663824 is a reply to message #663700] Wed, 06 April 2011 15:05 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080504010103040906050108
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

You need to make *all changes* by executing commands on the command
stack. A RecordingCommand might be useful for what you're doing.


akoeck@gmx.de wrote:
> I want to create an element in my diagram via an action which is
> called over an popmenu of another element.
> But when I add the Elements to the Diagram I goet this errormessage:
> Quote:
>> java.lang.IllegalStateException: Cannot modify resource set without a
>> write transaction
>> at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a
>> ssertWriting(TransactionChangeRecorder.java:348)
>> at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a
>> ppendNotification(TransactionChangeRecorder.java:302)
>> at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p
>> rocessObjectNotification(TransactionChangeRecorder.java:284)
>> at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n
>> otifyChanged(TransactionChangeRecorder.java:240)
>> at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify
>> (BasicNotifierImpl.java:380)
>> at org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(E
>> coreEList.java:255)
>> at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUniq
>> ue(NotifyingListImpl.java:300)
>> at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.
>> java:307)
>> at de.akoeck.diplomarbeit.diagram.part.ExportXMLAction.run(Expo
>> rtXMLAction.java:193)
>> at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginActi
>> on.java:251)
>> at org.eclipse.jface.action.ActionContributionItem.handleWidget
>> Selection(ActionContributionItem.java:584)
>> at org.eclipse.jface.action.ActionContributionItem.access$2(Act
>> ionContributionItem.java:501)
>> at org.eclipse.jface.action.ActionContributionItem$5.handleEven
>> t(ActionContributionItem.java:411)
>> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java
>> :84)
>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
>> at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja
>> va:4066)
>> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java
>> :3657)
>> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav
>> a:2629)
>> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
>> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:24 27)
>> at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
>> at org.eclipse.core.databinding.observable.Realm.runWithDefault
>> (Realm.java:332)
>> at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work
>> bench.java:663)
>> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j
>> ava:149)
>> at org.eclipse.ui.internal.ide.application.IDEApplication.start
>> (IDEApplication.java:115)
>> at org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips
>> eAppHandle.java:196)
>> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher
>> .runApplication(EclipseAppLauncher.java:110)
>> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher
>> .start(EclipseAppLauncher.java:79)
>> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS
>> tarter.java:369)
>> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS
>> tarter.java:179)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>> at java.lang.reflect.Method.invoke(Unknown Source)
>> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:
>> 619)
>> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
>> at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
>> at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
>
>
> How can I avoid this error and create my elements? Do I have to call
> my createcommand for the element via the action?

--------------080504010103040906050108
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
You need to make <b>all changes</b> by executing commands on the
command stack.    A RecordingCommand might be useful for what you're
doing.<br>
<br>
<br>
<a class="moz-txt-link-abbreviated" href="mailto:akoeck@gmx.de">akoeck@gmx.de</a> wrote:
<blockquote cite="mid:inha55$lh4$1@news.eclipse.org" type="cite">I want
to create an element in my diagram via an action which is called over
an popmenu of another element.
<br>
But when I add the Elements to the Diagram I goet this errormessage:
<br>
Quote:
<br>
<blockquote type="cite">java.lang.IllegalStateException: Cannot
modify resource set without a write transaction
<br>
    at  org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a
ssertWriting(TransactionChangeRecorder.java:348)
<br>
    at  org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a
ppendNotification(TransactionChangeRecorder.java:302)
<br>
    at  org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p
rocessObjectNotification(TransactionChangeRecorder.java:284)
<br>
    at  org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n
otifyChanged(TransactionChangeRecorder.java:240)
<br>
    at  org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify
(BasicNotifierImpl.java:380)
<br>
    at  org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(E
coreEList.java:255)
<br>
    at  org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUniq
ue(NotifyingListImpl.java:300)
<br>
    at  org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.
java:307)
<br>
    at  de.akoeck.diplomarbeit.diagram.part.ExportXMLAction.run(Expo
rtXMLAction.java:193)
<br>
    at  org.eclipse.ui.internal.PluginAction.runWithEvent(PluginActi
on.java:251)
<br>
    at  org.eclipse.jface.action.ActionContributionItem.handleWidget
Selection(ActionContributionItem.java:584)
<br>
    at  org.eclipse.jface.action.ActionContributionItem.access$2(Act
ionContributionItem.java:501)
<br>
    at  org.eclipse.jface.action.ActionContributionItem$5.handleEven
t(ActionContributionItem.java:411)
<br>
    at  org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java
:84)
<br>
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
<br>
    at  org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja
va:4066)
<br>
    at  org.eclipse.swt.widgets.Display.readAndDispatch(Display.java
:3657)
<br>
    at  org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav
a:2629)
<br>
    at  org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
<br>
    at  org.eclipse.ui.internal.Workbench.access$4(Workbench.java:24
27)
<br>
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
<br>
    at  org.eclipse.core.databinding.observable.Realm.runWithDefault
(Realm.java:332)
<br>
    at  org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work
bench.java:663)
<br>
    at  org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j
ava:149)
<br>
    at  org.eclipse.ui.internal.ide.application.IDEApplication.start
(IDEApplication.java:115)
<br>
    at  org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips
eAppHandle.java:196)
<br>
    at  org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher
..runApplication(EclipseAppLauncher.java:110)
<br>
    at  org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher
..start(EclipseAppLauncher.java:79)
<br>
    at  org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS
tarter.java:369)
<br>
    at  org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS
tarter.java:179)
<br>
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
<br>
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
<br>
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
<br>
    at java.lang.reflect.Method.invoke(Unknown Source)
<br>
    at  org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:
619)
<br>
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
<br>
    at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
<br>
    at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
<br>
</blockquote>
<br>
<br>
How can I avoid this error and create my elements? Do I have to call my
createcommand for the element via the action?
<br>
</blockquote>
</body>
</html>

--------------080504010103040906050108--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [ERROR] Cannot modify resource set without a write transaction [message #663851 is a reply to message #663824] Wed, 06 April 2011 15:54 Go to previous messageGo to next message
Elhamlaoui Mahmoud is currently offline Elhamlaoui MahmoudFriend
Messages: 268
Registered: March 2010
Senior Member
Hi,

perhaps i have an easy solution, before creating your element add this
Quote:
X.eSetDeliver(false);
, and just after add this code
Quote:
X.eSetDeliver(true);
Re: [ERROR] Cannot modify resource set without a write transaction [message #663853 is a reply to message #663700] Wed, 06 April 2011 15:37 Go to previous messageGo to next message
Ugo Sangiorgi is currently offline Ugo SangiorgiFriend
Messages: 59
Registered: January 2010
Member
Le 06/04/11 11:08, akoeck@gmx.de a écrit :
> I want to create an element in my diagram via an action which is
> called over an popmenu of another element.
> But when I add the Elements to the Diagram I goet this errormessage:
> Quote:
>> java.lang.IllegalStateException: Cannot modify resource set without a
>> write transaction
>> at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a
>> ssertWriting(TransactionChangeRecorder.java:348)
>> at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a
>> ppendNotification(TransactionChangeRecorder.java:302)
>> at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p
>> rocessObjectNotification(TransactionChangeRecorder.java:284)
>> at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n
>> otifyChanged(TransactionChangeRecorder.java:240)
>> at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify
>> (BasicNotifierImpl.java:380)
>> at org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(E
>> coreEList.java:255)
>> at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUniq
>> ue(NotifyingListImpl.java:300)
>> at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.
>> java:307)
>> at de.akoeck.diplomarbeit.diagram.part.ExportXMLAction.run(Expo
>> rtXMLAction.java:193)
>> at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginActi
>> on.java:251)
>> at org.eclipse.jface.action.ActionContributionItem.handleWidget
>> Selection(ActionContributionItem.java:584)
>> at org.eclipse.jface.action.ActionContributionItem.access$2(Act
>> ionContributionItem.java:501)
>> at org.eclipse.jface.action.ActionContributionItem$5.handleEven
>> t(ActionContributionItem.java:411)
>> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java
>> :84)
>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
>> at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja
>> va:4066)
>> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java
>> :3657)
>> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav
>> a:2629)
>> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
>> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:24 27)
>> at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
>> at org.eclipse.core.databinding.observable.Realm.runWithDefault
>> (Realm.java:332)
>> at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work
>> bench.java:663)
>> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j
>> ava:149)
>> at org.eclipse.ui.internal.ide.application.IDEApplication.start
>> (IDEApplication.java:115)
>> at org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips
>> eAppHandle.java:196)
>> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher
>> .runApplication(EclipseAppLauncher.java:110)
>> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher
>> .start(EclipseAppLauncher.java:79)
>> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS
>> tarter.java:369)
>> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS
>> tarter.java:179)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>> at java.lang.reflect.Method.invoke(Unknown Source)
>> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:
>> 619)
>> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
>> at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
>> at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
>
>
> How can I avoid this error and create my elements? Do I have to call
> my createcommand for the element via the action?

Try this:
Command c = new Command(){

@Override
public void execute() {
AbstractEMFOperation emfOp = new
AbstractEMFOperation(editor.getEditingDomain(), "Insert sketched element") {

@Override
protected IStatus doExecute(IProgressMonitor
monitor, IAdaptable info) throws ExecutionException {


* XXXImpl n = (XXXImpl)editor.getDiagramEditPart().getModel();
MMM model = (MMM) n.basicGetElement();

model.addsomething();
*
return Status.OK_STATUS;
}
};


try {

OperationHistoryFactory.getOperationHistory().execute(emfOp, null, null);
} catch (ExecutionException e) {}
}
};

Then you execute like:
final DiagramEditor editor = (DiagramEditor)
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().getActiveEditor();

editor.getDiagramEditDomain().getDiagramCommandStack().execu te(c);
Re: [ERROR] Cannot modify resource set without a write transaction [message #663869 is a reply to message #663851] Wed, 06 April 2011 16:45 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
That's easy, but leaves the command stack in a precarious state, won't
update the UI, and might cause other problems too.


Elhamlaoui Mahmoud wrote:
> Hi,
> perhaps i have an easy solution, before creating your element add
> thisQuote:
>> X.eSetDeliver(false);
> , and just after add this codeQuote:
>> X.eSetDeliver(true);
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Path: 'editMenu' is invalid
Next Topic:Error in generated code: package name used wrongly
Goto Forum:
  


Current Time: Wed Apr 24 22:31:18 GMT 2024

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

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

Back to the top