[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.gmf] EMF / GMF : sharing Editing Domain

Hi,

I am trying to develop a GMF editor based on an EMF model. I previously posted to sutomize the properties view which is now OK.

What I want to do now is to save the text entered in a Text field of my properties view inside the selected element of my diagram. To do that, I am able to get my element with the following code :

public void setInput(IWorkbenchPart part, ISelection selection) {
		super.setInput(part, selection);
		Object input = ((IStructuredSelection) selection).getFirstElement();
		if (input instanceof EditPart) {
			EditPart editPart = (EditPart) input;
			Object model = editPart.getModel();	
		
			if (model instanceof NodeImpl) {
				NodeImpl node = (NodeImpl) model;
				EObject element = node.getElement();
				if (element instanceof Element) {
					this.element = (Element) element;
				}
			} else if (model instanceof DiagramImpl) {
				DiagramImpl diagram = (DiagramImpl) model;
				EObject element = diagram.getElement();
				if (element instanceof Element) {
					this.element = (Element) element;
				}
			}
		}
   }

Then, in the refresh method of the AbtractSection class, I am trying to store the text value inside a field of my Element :

this.element.setName(text.getText());

but I get the following exception:
An error has occurred. See error log for more details.
Cannot modify resource set without a write transaction

I searched on the net and found something about sharing the same editing domain. I applied all recommandations written in Eclipse Modeling project book (4.4 Sharing an editing domain) but it doen't work...

I tried adding final TransactionalEditingDomain txDomain = TransactionalEditingDomain.Registry.INSTANCE.getEditingDomain("org.bonitasoft.studio.diagram.EditingDomain");
as the first line of refresh method but I still get the same error.


I will really appreciate your help... I think this is very common use case for GMF users to save datas inside EMF model objects... If you have a tutorial it will be a very good link !

Thanks a lot
Regards,
Charles

In my .metadata/.log:

!ENTRY org.eclipse.ui.views.properties.tabbed 4 2 2009-06-16 18:08:20.862
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.ui.views.properties.tabbed".
!STACK 0
java.lang.IllegalStateException: Cannot modify resource set without a write transaction
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.assertWriting(TransactionChangeRecorder.java:338)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.appendNotification(TransactionChangeRecorder.java:300)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.processObjectNotification(TransactionChangeRecorder.java:282)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.notifyChanged(TransactionChangeRecorder.java:238)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:247)
at org.bonitasoft.studio.model.bpmn.impl.ElementImpl.setName(ElementImpl.java:203)
at org.bonitasoft.studio.properties.sections.general.NameSection.refresh(NameSection.java:22)
at org.eclipse.ui.views.properties.tabbed.TabContents$6.run(TabContents.java:217)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
at org.eclipse.core.runtime.Platform.run(Platform.java:880)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
at org.eclipse.ui.views.properties.tabbed.TabContents.refresh(TabContents.java:220)
at org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage$SelectionChangedListener.selectionChanged(TabbedPropertySheetPage.java:222)
at org.eclipse.jface.viewers.Viewer$2.run(Viewer.java:162)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
at org.eclipse.core.runtime.Platform.run(Platform.java:880)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
at org.eclipse.jface.viewers.Viewer.fireSelectionChanged(Viewer.java:160)
at org.eclipse.jface.viewers.StructuredViewer.updateSelection(StructuredViewer.java:2062)
at org.eclipse.jface.viewers.StructuredViewer.handleSelect(StructuredViewer.java:1138)
at org.eclipse.jface.viewers.StructuredViewer$4.widgetSelected(StructuredViewer.java:1168)
at org.eclipse.jface.util.OpenStrategy.fireSelectionEvent(OpenStrategy.java:227)
at org.eclipse.jface.util.OpenStrategy.access$3(OpenStrategy.java:221)
at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:388)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1561)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1585)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1570)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1360)
at org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyList.select(TabbedPropertyList.java:664)
at org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyViewer.setSelectionToWidget(TabbedPropertyViewer.java:122)
at org.eclipse.jface.viewers.StructuredViewer.setSelectionToWidget(StructuredViewer.java:1680)
at org.eclipse.jface.viewers.StructuredViewer.setSelection(StructuredViewer.java:1636)
at org.eclipse.jface.viewers.Viewer.setSelection(Viewer.java:392)
at org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage.setInput(TabbedPropertySheetPage.java:713)
at org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage.selectionChanged(TabbedPropertySheetPage.java:538)
at org.eclipse.gmf.runtime.diagram.ui.properties.views.PropertiesBrowserPage.selectionChanged(PropertiesBrowserPage.java:253)
at org.eclipse.ui.views.properties.PropertySheet.partActivated(PropertySheet.java:199)
at org.eclipse.ui.part.PageBookView.showBootstrapPart(PageBookView.java:907)
at org.eclipse.ui.part.PageBookView.createPartControl(PageBookView.java:482)
at org.eclipse.ui.views.properties.PropertySheet.createPartControl(PropertySheet.java:98)
at org.eclipse.ui.internal.ViewReference.createPartHelper(ViewReference.java:371)
at org.eclipse.ui.internal.ViewReference.createPart(ViewReference.java:230)
at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:594)
at org.eclipse.ui.internal.Perspective.showView(Perspective.java:2131)
at org.eclipse.ui.internal.WorkbenchPage.busyShowView(WorkbenchPage.java:1062)
at org.eclipse.ui.internal.WorkbenchPage$19.run(WorkbenchPage.java:3773)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.internal.WorkbenchPage.showView(WorkbenchPage.java:3770)
at org.eclipse.ui.internal.WorkbenchPage.showView(WorkbenchPage.java:3746)
at org.eclipse.gmf.runtime.common.ui.util.WorkbenchPartActivator$ShowViewRunnable.run(WorkbenchPartActivator.java:72)
at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:178)
at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:150)
at org.eclipse.swt.widgets.Display.syncExec(Display.java:3955)
at org.eclipse.gmf.runtime.common.ui.util.WorkbenchPartActivator.showView(WorkbenchPartActivator.java:129)
at org.eclipse.gmf.runtime.common.ui.util.WorkbenchPartActivator.showPropertySheet(WorkbenchPartActivator.java:179)
at org.eclipse.gmf.runtime.diagram.ui.actions.ShowPropertiesViewAction.doRun(ShowPropertiesViewAction.java:67)
at org.eclipse.gmf.runtime.common.ui.action.AbstractActionHandler.run(AbstractActionHandler.java:359)
at org.eclipse.gmf.runtime.common.ui.action.ActionManager$1.run(ActionManager.java:225)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.gmf.runtime.common.ui.action.ActionManager.run(ActionManager.java:223)
at org.eclipse.gmf.runtime.common.ui.action.AbstractActionHandler.runWithEvent(AbstractActionHandler.java:377)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:583)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:500)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1561)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1585)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1570)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1360)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3482)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3068)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2384)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2348)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2200)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:495)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:490)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
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(EclipseStarter.java:386)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
at org.eclipse.equinox.launcher.Main.main(Main.java:1212)