Exception while creating View for certain elements [message #487216] |
Tue, 22 September 2009 13:29 |
No real name Messages: 31 Registered: September 2009 |
Member |
|
|
Hi there,
I'm creating a GMF diagram editor for a BPEL like process description language. The domain model has been been derived from an xml schema definition (see appendix 1).
Customization of the editor is done in a seperate plug-in by means of the GMF runtime (e.g. subclassing different providers). So far the editor works quite well.
Problems arise if I try to store certain elements of type tRequires in an different compartments. For example a scope is a container that (along with other elements) contains/references
one element of an group activity (see appendix 1). 4 of these elements are of type tRequires: copy, clone, move, requires. I can only create the requires element/reference.
If I try to create a copy, clone or move element an exception (see appendix 2) is thrown that indicates that no view could be created. The notation element actually is created.
The problematic code is located in a CreateCommand:
View view =
ViewService.getInstance().createView(
viewDescriptor.getViewKind(),
viewDescriptor.getElementAdapter(),
containerView,
viewDescriptor.getSemanticHint(),
index,
viewDescriptor.isPersisted(),
viewDescriptor.getPreferencesHint());
Assert.isNotNull(view, "failed to create a view"); //$NON-NLS-1$
Doing further debugging I found that the ViewService delegates the node creation to the available IViewProviders by calling IViewProvides.createNode(...). And here it comes. In the view provider
that is generated along with my diagram editor this method is never called if I try to create a copy, clone or move element. This seems to be due to the fact that a call of the ViewService to
IViewProvider.provides(CreateNodeViewOperation op) returns false.
Any hint how to handle this problem or why this happens is greatly appreciated,
sas
=======
appendix 1:
=======
Scope EClass derived form the xml schema shown below (for every element contained by a scope there is one EReferences):
Scope
[...]
-> clone: Requires
-> copy: Requires
-> move: Requires
-> requires: Requires
[...]
Excepert of schema definition used to derive domain model:
<xsd:element name="scope" type="tScope"/>
<xsd:complexType name="tScope">
<xsd:complexContent>
<xsd:extension base="tExtensibleElements">
<xsd:sequence>
<xsd:element ref="partnerLinks" minOccurs="0"/>
<xsd:element ref="variables" minOccurs="0"/>
<xsd:group ref="activity" minOccurs="1"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:group name="activity">
<xsd:choice>
<xsd:element ref="activity"/>
<xsd:element ref="assign"/>
<xsd:element name="clone" type="tRequires"/>
<xsd:element name="copy" type="tRequires"/>
<xsd:element ref="exit"/>
<xsd:element ref="flow"/>
<xsd:element ref="if"/>
<xsd:element ref="invoke"/>
<xsd:element name="move" type="tRequires"/>
<xsd:element ref="receive"/>
<xsd:element ref="repeatUntil"/>
<xsd:element ref="reply"/>
<xsd:element ref="requires"/>
<xsd:element ref="scope"/>
<xsd:element ref="sequence"/>
<xsd:element ref="wait"/>
<xsd:element ref="while"/>
</xsd:choice>
</xsd:group>
=======
appendix 2:
=======
Exception thrown if I try to create an clone, copy or move element (which are of type tRequires).
Also see appendix 2:
org.eclipse.core.commands.ExecutionException: While executing the operation, an exception occurred
at org.eclipse.core.commands.operations.DefaultOperationHistory .execute(DefaultOperationHistory.java:519)
at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack .execute(DiagramCommandStack.java:206)
at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack .execute(DiagramCommandStack.java:169)
at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack .execute(DiagramCommandStack.java:156)
at org.eclipse.gef.tools.AbstractTool.executeCommand(AbstractTo ol.java:399)
at org.eclipse.gef.tools.AbstractTool.executeCurrentCommand(Abs tractTool.java:411)
at org.eclipse.gmf.runtime.diagram.ui.tools.CreationTool.perfor mCreation(CreationTool.java:133)
at org.eclipse.gef.tools.CreationTool.handleButtonUp(CreationTo ol.java:178)
[...]
Caused by: org.eclipse.core.runtime.AssertionFailedException: null argument:failed to create a view
at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:85)
at sampel.diagram.custom.edit.commands.CompartmentChildCreateCo mmand.doExecuteWithResult(CompartmentChildCreateCommand.java :37)
at org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTr ansactionalCommand.doExecute(AbstractTransactionalCommand.ja va:247)
at org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:150)
at org.eclipse.gmf.runtime.common.core.command.CompositeCommand .doExecuteWithResult(CompositeCommand.java:403)
at org.eclipse.gmf.runtime.common.core.command.AbstractCommand. execute(AbstractCommand.java:135)
at org.eclipse.gmf.runtime.common.core.command.CompositeCommand .doExecuteWithResult(CompositeCommand.java:403)
at org.eclipse.gmf.runtime.common.core.command.AbstractCommand. execute(AbstractCommand.java:135)
at org.eclipse.core.commands.operations.DefaultOperationHistory .execute(DefaultOperationHistory.java:511)
... 40 more
|
|
|
|
Re: Exception while creating View for certain elements [message #487329 is a reply to message #487324] |
Tue, 22 September 2009 19:05 |
No real name Messages: 31 Registered: September 2009 |
Member |
|
|
Hi,
Quote: |
Try openning plugin.xml end removing corresponding ViewProvider constraints.
|
thanks for your quick answer but I'm not quite sure what to remove exactly. The corresponding (and abbreviated) excerpt of the diagram editor's plug-in.xml looks as follows:
<extension point="org.eclipse.gmf.runtime.diagram.core.viewProviders" id="view-provider">
<?gmfgen generated="true"?>
<viewProvider class="sampel.diagram.providers.SampelViewProvider">
<Priority name="Lowest"/>
<context viewClass="org.eclipse.gmf.runtime.notation.Diagram" semanticHints="Sampel"/>
<context viewClass="org.eclipse.gmf.runtime.notation.Node" semanticHints="2001,2002,2003,2004,3001,3002,3003,[...]"/>
<context viewClass="org.eclipse.gmf.runtime.notation.Edge" semanticHints=""/>
</viewProvider>
</extension>
Should I (1.) remove all the context nodes or (2.) simply set the semanticHints of the Node context to an empty string?
Thanks in advance,
sas
|
|
|
|
|
|
Re: Exception while creating View for certain elements [message #488238 is a reply to message #488168] |
Sat, 26 September 2009 15:04 |
No real name Messages: 31 Registered: September 2009 |
Member |
|
|
Hi Alex,
Quote: |
I suggest you to put a breakpoint into ???CreateCommand generated for child
element to see if it is executed and is actual element was created.
|
Already did so. The domain element is (correctly) instantiated by the According Requires<someNumber>CreateCommand. I double checked by saving the diagram and opening the .sampel file in an text editor.
Quote: |
Does IViewProvider.provides(CreateNodeViewOperation op) return true now?
|
Checked it again and as it turns out it still returns false (I'm sorry ... somehow misread the debugging output).
Further debugging showed that this is because the visual id for node EClass doesn't match the visual id from the element type according to the following excerpt (for full method body see attached file) from method SampelViewProvider.provides(CreateNodeViewOperation op):
if (domainElement != null
&& visualID != SampelVisualIDRegistry.getNodeVisualID(
op.getContainerView(), domainElement)) {
return false; // visual id for node EClass should match visual id from element type
}
Could this be
(1.) some kind of generator bug
(2.) or might this rather result from the usage of the xsd file (see first post) my domain model is derived from?
Since I've no idea how to tackle this
(1.) either by modifying the GMF tooling parts, for example .gmfgen
(2.) or by means of the GMF runtime in the custom plug-in (since all customizations to the generated diagram editor are done in a seperate plug-in)
any hint is greatly appreciated.
AND: Thank you very, very much for the effort you've already made,
sas
[Updated on: Sat, 26 September 2009 15:07] Report message to a moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03360 seconds