|
|
|
Re: [ERROR] Cannot modify resource set without a write transaction [message #663853 is a reply to message #663700] |
Wed, 06 April 2011 15:37 |
|
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);
|
|
|
|
Powered by
FUDForum. Page generated in 0.03162 seconds