|
Re: [Xcore] Ecore Diagram problem [message #901798 is a reply to message #901771] |
Tue, 14 August 2012 15:47 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
Comments below.
On 14/08/2012 4:01 PM, Csaba Koncz wrote:
> Hi all,
>
> Although I prefer creating models with the Xcore editor, for showing
> the model to the colleagues a graphical representation is more
> suitable. I can not use the "Initialize Ecore Diagram File ..."
> context menu for an Xcore file, but can get a diagram by creating a
> .ecorediag file with the following content:
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <notation:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation"
> xmi:id="_d3eUYOYWEeG0J45nAFRXEg" type="EcoreTools" name="DefaultName"
> measurementUnit="Pixel">
> <styles xmi:type="notation:DiagramStyle"
> xmi:id="_d3eUYeYWEeG0J45nAFRXEg"/>
> <element xmi:type="ecore:EPackage" href="mymodel.xcore#/EPackage"/>
> </notation:Diagram>
>
>
> i.e. replacing the package reference href="mymodel.ecore#/" with
> href="mymodel.xcore#/EPackage"
>
> This works for simple cases. The issue I ran into is that when I
> specify a directory for the generated edit files, the diagram editor
> can not be loaded any more:
>
>
> @GenModel(editDirectory="/com.ck.mymodel.edit/src-gen")
> package com.ck.mymodel
> class Data
> {
> // content
> }
>
>
>
> 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
> org.eclipse.emf.codegen.ecore.genmodel.impl.GenModelImpl.setEditDirectory(GenModelImpl.java:4438)
> at
> org.eclipse.emf.ecore.xcore.resource.XcoreModelAssociator.installDerivedState(XcoreModelAssociator.java:130)
> at
> org.eclipse.xtext.resource.DerivedStateAwareResource.installDerivedState(DerivedStateAwareResource.java:125)
> at
> org.eclipse.xtext.resource.DerivedStateAwareResource.getContents(DerivedStateAwareResource.java:48)
> at
> org.eclipse.emf.ecore.util.EContentAdapter.setTarget(EContentAdapter.java:230)
That does this:
protected void setTarget(Resource target)
{
basicSetTarget(target);
List<EObject> contents = target.getContents();
for (int i = 0, size = contents.size(); i < size; ++i)
{
Notifier notifier = contents.get(i);
addAdapter(notifier);
}
}
So I guess the problem is that the adapter is added first and then
getContents computes the stuff that "nobody is supposed to have seen
yet", but because there is already an adapter attached, it sees the
results being added, and starts listening to them, and then see what
looks like a modification. I'm not sure how best to solve that. We
could add the adapter later, or perhaps we should be adding the contents
while suppressing notifications. I'll need to talk to the Xtext guys
given this is a problem any Xtext resource could also have. Please open
a bugzilla with a simple test case and I'll have a look.
> at
> org.eclipse.emf.ecore.util.EContentAdapter.setTarget(EContentAdapter.java:186)
>
> at
> org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.didAdd(BasicNotifierImpl.java:121)
> at
> org.eclipse.emf.common.util.BasicEList.addUnique(BasicEList.java:419)
> at
> org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:301)
> at
> org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.add(BasicNotifierImpl.java:193)
> at
> org.eclipse.emf.ecore.util.EContentAdapter.addAdapter(EContentAdapter.java:346)
> at
> org.eclipse.emf.ecore.util.EContentAdapter.setTarget(EContentAdapter.java:249)
> at
> org.eclipse.emf.ecore.util.EContentAdapter.setTarget(EContentAdapter.java:190)
> at
> org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.didAdd(BasicNotifierImpl.java:121)
> at
> org.eclipse.emf.common.util.BasicEList.addUnique(BasicEList.java:419)
> at
> org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:301)
> at
> org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.add(BasicNotifierImpl.java:193)
> at
> org.eclipse.emf.ecoretools.diagram.part.EcoreDocumentProvider$ResourceSetInfo.<init>(EcoreDocumentProvider.java:745)
> at
> org.eclipse.emf.ecoretools.diagram.part.EcoreDocumentProvider.createElementInfo(EcoreDocumentProvider.java:90)
> at
> org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.AbstractDocumentProvider.connect(AbstractDocumentProvider.java:387)
> at
> org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor.doSetInput(DiagramDocumentEditor.java:460)
> at
> org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor.setInput(DiagramDocumentEditor.java:423)
> at
> org.eclipse.gef.ui.parts.GraphicalEditor.init(GraphicalEditor.java:346)
> at
> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.init(DiagramEditor.java:653)
> at
> org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor.init(DiagramDocumentEditor.java:126)
> at
> org.eclipse.ui.internal.EditorManager.createSite(EditorManager.java:828)
>
>
> Is this a problem on the editor side and should not try to use it this
> way?
> Thank you in advance,
> Csaba
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Powered by
FUDForum. Page generated in 0.02850 seconds