Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » EMF / GMF : sharing Editing Domain
EMF / GMF : sharing Editing Domain [message #233820] Tue, 16 June 2009 16:14 Go to next message
Charles SOUILLARD is currently offline Charles SOUILLARDFriend
Messages: 12
Registered: July 2009
Junior Member
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.getEditingDomai n( "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.a ssertWriting(TransactionChangeRecorder.java:338)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:300)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:282)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:238)
at
org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:247)
at
org.bonitasoft.studio.model.bpmn.impl.ElementImpl.setName(El ementImpl.java:203)
at
org.bonitasoft.studio.properties.sections.general.NameSectio n.refresh(NameSection.java:22)
at
org.eclipse.ui.views.properties.tabbed.TabContents$6.run(Tab Contents.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:17 5)
at
org.eclipse.ui.views.properties.tabbed.TabContents.refresh(T abContents.java:220)
at
org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPa ge$SelectionChangedListener.selectionChanged(TabbedPropertyS heetPage.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:17 5)
at org.eclipse.jface.viewers.Viewer.fireSelectionChanged(Viewer .java:160)
at
org.eclipse.jface.viewers.StructuredViewer.updateSelection(S tructuredViewer.java:2062)
at
org.eclipse.jface.viewers.StructuredViewer.handleSelect(Stru cturedViewer.java:1138)
at
org.eclipse.jface.viewers.StructuredViewer$4.widgetSelected( StructuredViewer.java:1168)
at
org.eclipse.jface.util.OpenStrategy.fireSelectionEvent(OpenS trategy.java:227)
at org.eclipse.jface.util.OpenStrategy.access$3(OpenStrategy.ja va:221)
at
org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrate gy.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:1 360)
at
org.eclipse.ui.internal.views.properties.tabbed.view.TabbedP ropertyList.select(TabbedPropertyList.java:664)
at
org.eclipse.ui.internal.views.properties.tabbed.view.TabbedP ropertyViewer.setSelectionToWidget(TabbedPropertyViewer.java :122)
at
org.eclipse.jface.viewers.StructuredViewer.setSelectionToWid get(StructuredViewer.java:1680)
at
org.eclipse.jface.viewers.StructuredViewer.setSelection(Stru cturedViewer.java:1636)
at org.eclipse.jface.viewers.Viewer.setSelection(Viewer.java:39 2)
at
org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPa ge.setInput(TabbedPropertySheetPage.java:713)
at
org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPa ge.selectionChanged(TabbedPropertySheetPage.java:538)
at
org.eclipse.gmf.runtime.diagram.ui.properties.views.Properti esBrowserPage.selectionChanged(PropertiesBrowserPage.java:25 3)
at
org.eclipse.ui.views.properties.PropertySheet.partActivated( PropertySheet.java:199)
at
org.eclipse.ui.part.PageBookView.showBootstrapPart(PageBookV iew.java:907)
at
org.eclipse.ui.part.PageBookView.createPartControl(PageBookV iew.java:482)
at
org.eclipse.ui.views.properties.PropertySheet.createPartCont rol(PropertySheet.java:98)
at
org.eclipse.ui.internal.ViewReference.createPartHelper(ViewR eference.java:371)
at
org.eclipse.ui.internal.ViewReference.createPart(ViewReferen ce.java:230)
at
org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:594)
at org.eclipse.ui.internal.Perspective.showView(Perspective.jav a:2131)
at
org.eclipse.ui.internal.WorkbenchPage.busyShowView(Workbench Page.java:1062)
at org.eclipse.ui.internal.WorkbenchPage$19.run(WorkbenchPage.j ava: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.WorkbenchPartActivato r$ShowViewRunnable.run(WorkbenchPartActivator.java:72)
at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.j ava:178)
at
org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchroniz er.java:150)
at org.eclipse.swt.widgets.Display.syncExec(Display.java:3955)
at
org.eclipse.gmf.runtime.common.ui.util.WorkbenchPartActivato r.showView(WorkbenchPartActivator.java:129)
at
org.eclipse.gmf.runtime.common.ui.util.WorkbenchPartActivato r.showPropertySheet(WorkbenchPartActivator.java:179)
at
org.eclipse.gmf.runtime.diagram.ui.actions.ShowPropertiesVie wAction.doRun(ShowPropertiesViewAction.java:67)
at
org.eclipse.gmf.runtime.common.ui.action.AbstractActionHandl er.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(A ctionManager.java:223)
at
org.eclipse.gmf.runtime.common.ui.action.AbstractActionHandl er.runWithEvent(AbstractActionHandler.java:377)
at
org.eclipse.jface.action.ActionContributionItem.handleWidget Selection(ActionContributionItem.java:583)
at
org.eclipse.jface.action.ActionContributionItem.access$2(Act ionContributionItem.java:500)
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: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:1 360)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3482)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3068)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2384)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2348)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 00)
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(Work bench.java:490)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at
org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:113)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.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(EclipseS tarter.java:386)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.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)
Re: EMF / GMF : sharing Editing Domain [message #233831 is a reply to message #233820] Tue, 16 June 2009 16:34 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Charles,

Try to:
- create subclass of AbstractEMFOperation, implement doExecute() operation,
put model modification code into doExecute() method implementation
- run OperationHistoryFactory.getOperationHistory().execute() passing this
operation as a parameter.

-----------------
Alex Shatalin
Re: EMF / GMF : sharing Editing Domain [message #233864 is a reply to message #233831] Wed, 17 June 2009 09:34 Go to previous messageGo to next message
Charles SOUILLARD is currently offline Charles SOUILLARDFriend
Messages: 12
Registered: July 2009
Junior Member
Hi,

I tried your solution. I still have an error :
While executing the operation, an exception occurred
Caused by: java.lang.NullPointerException
at
org.eclipse.emf.workspace.AbstractEMFOperation.inheritedOpti ons(AbstractEMFOperation.java:240)
at
org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:149)
at
org.eclipse.core.commands.operations.DefaultOperationHistory .execute(DefaultOperationHistory.java:511)
... 50 more

The problem I have is that when I try to get my editing domain (from
refresh method or inside My Operation), it returns to me null.

Do I have something special to do to register my editing domain ?

here is the code I added :
public void refresh() {
TransactionalEditingDomain.Registry registry =
TransactionalEditingDomain.Registry.INSTANCE;
final TransactionalEditingDomain txDomain =
registry.getEditingDomain("org.bonitasoft.studio.diagram.EditingDomain ");
try {
OperationHistoryFactory.getOperationHistory().execute(new
MyOperation(txDomain, "mylabel", this), null, null);
} catch (ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}

private static class MyOperation extends AbstractEMFOperation {
private NameSection nameSection;
public MyOperation(TransactionalEditingDomain domain, String label,
NameSection nameSection) {
super(TransactionalEditingDomain.Registry.INSTANCE.getEditin gDomain( "org.bonitasoft.studio.diagram.EditingDomain"),
label);
this.nameSection = nameSection;
}
@Override
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
this.nameSection.element.setName(this.nameSection.getText(). getText());
return null;
}
}
Thanks
Charles
Re: EMF / GMF : sharing Editing Domain [message #233883 is a reply to message #233864] Wed, 17 June 2009 10:25 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Charles,

You can get appropriate instance of TransactionalEditingDomain by calling
TransactionUtil.getEditingDomain(). You can pass domain selected model element
as a parameter there.

-----------------
Alex Shatalin
Re: EMF / GMF : sharing Editing Domain [message #233906 is a reply to message #233883] Wed, 17 June 2009 11:40 Go to previous messageGo to next message
Charles SOUILLARD is currently offline Charles SOUILLARDFriend
Messages: 12
Registered: July 2009
Junior Member
Thanks !
No my domain is not null...
I have another error...
java.lang.NullPointerException
at
org.eclipse.core.commands.operations.DefaultOperationHistory .execute(DefaultOperationHistory.java:526)
at
org.bonitasoft.studio.properties.sections.general.NameSectio n.refresh(NameSection.java:30)
...

Thanks a lot for your help
Regards
Charles
Re: EMF / GMF : sharing Editing Domain [message #233922 is a reply to message #233883] Wed, 17 June 2009 11:44 Go to previous messageGo to next message
Charles SOUILLARD is currently offline Charles SOUILLARDFriend
Messages: 12
Registered: July 2009
Junior Member
Hi Alex,

please ignore my next post (nullpointerException), I forgot to return a
valid status. I don't have NPE anymore

Regards
Charles
Re: EMF / GMF : sharing Editing Domain [message #233929 is a reply to message #233906] Wed, 17 June 2009 11:45 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Charles,

Looks like you have to return non-null status object from doExecute() method.

-----------------
Alex Shatalin
Re: EMF / GMF : sharing Editing Domain [message #233974 is a reply to message #233929] Wed, 17 June 2009 13:36 Go to previous message
Charles SOUILLARD is currently offline Charles SOUILLARDFriend
Messages: 12
Registered: July 2009
Junior Member
Hi,

I don't have any exception by now but my goal is not reached !
In fact I wanted to do that to store values in my model but this is not
the case...

I can enter text in my text boxes but the value is not stored in my model.
When I change from a node to the diagram for example, I loose the data...

Do you know what I need to do ?

Thanks,
Charles
Previous Topic:[Announce] GMF 2.2.0RC5 is available
Next Topic:Wizard launch
Goto Forum:
  


Current Time: Sun Mar 29 16:19:00 GMT 2020

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

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

Back to the top