Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Exception while creating View for certain elements
Exception while creating View for certain elements [message #487216] Tue, 22 September 2009 13:29 Go to next message
No real name is currently offline No real nameFriend
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 #487324 is a reply to message #487216] Tue, 22 September 2009 18:45 Go to previous messageGo to next message
Alex Shatalin is currently offline Alex ShatalinFriend
Messages: 141
Registered: July 2009
Senior Member
Hello Sascha,

Looks like the problem is in ViewProvider constraitns specified in plugin.xml
(known GMF generator problem).
Try openning plugin.xml end removing corresponding ViewProvider constraints.
You can ensure the reason of this problem is in ViewProvider constraints
by: - openning new diagram, creating new view using palette tool and then
executing this code.

-----------------
Alex Shatalin
Re: Exception while creating View for certain elements [message #487329 is a reply to message #487324] Tue, 22 September 2009 19:05 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
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 #487336 is a reply to message #487329] Tue, 22 September 2009 19:18 Go to previous messageGo to next message
Alex Shatalin is currently offline Alex ShatalinFriend
Messages: 141
Registered: July 2009
Senior Member
Hello Sascha,

Try (1.) remove all the context nodes.

-----------------
Alex Shatalin
Re: Exception while creating View for certain elements [message #487342 is a reply to message #487336] Tue, 22 September 2009 19:51 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 31
Registered: September 2009
Member
Hello Alex,

didn't do the trick ;(

At least now the view provider's provide-method returns true, but still I get the same exception.

Further ideas are greatly appreciated.
Thanks in advance,

sas

[Updated on: Tue, 22 September 2009 19:52]

Report message to a moderator

Re: Exception while creating View for certain elements [message #488168 is a reply to message #487342] Fri, 25 September 2009 18:23 Go to previous messageGo to next message
Alex Shatalin is currently offline Alex ShatalinFriend
Messages: 141
Registered: July 2009
Senior Member
Hello Sascha,

> At least now the view provider's provide-method returns true, but
> still I get the same exception.
Does IViewProvider.provides(CreateNodeViewOperation op) return true now?

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.

-----------------
Alex Shatalin
Re: Exception while creating View for certain elements [message #488238 is a reply to message #488168] Sat, 26 September 2009 15:04 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
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

Re: Exception while creating View for certain elements [message #488282 is a reply to message #488238] Sun, 27 September 2009 12:39 Go to previous messageGo to next message
Alex Shatalin is currently offline Alex ShatalinFriend
Messages: 141
Registered: July 2009
Senior Member
Hello Sascha,

AFAIR, you are trying to create an element using custom code, right?
In this case you probably have to modify this code to pass proper visualID
into CreateNodeViewOperation passed finally to the provider..

-----------------
Alex Shatalin
Re: Exception while creating View for certain elements [message #488285 is a reply to message #488282] Sun, 27 September 2009 15:38 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 31
Registered: September 2009
Member
Hi Alex,

Quote:

AFAIR, you are trying to create an element using custom code, right?



actually not. I provide customized code by means of a separate plug-in. The generated code is located in the sampel.diagram plug-in and doesn't contain any modifications at all. All customizations are located in the sampel.diagram.custom plug-in and are based on GMF Runtime extensions. Therefore I can test (1.) purely generated code as well as (2.) generated code with customizations using different runtime configurations loading (1.) "sampel.diagram plug-in + requirements" and respectively (2.) "sampel.diagram.custom + requirements").

Problems already occur in the generated diagram editor (sampel.diagram) when I try to create (for example) a clone element using a creation tool from the diagram editor's toolbar. At this point no customized code is involved.

Quote:

In this case you probably have to modify this code to pass proper visualID
into CreateNodeViewOperation passed finally to the provider..


I'll try to provide a customized view provider (or advice binding) that handles the necessary changes. But as mentioned above I think there might be a problem with the generated code / generation model.

Thank you,

sas
Re: Exception while creating View for certain elements [message #488339 is a reply to message #488285] Mon, 28 September 2009 09:51 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 31
Registered: September 2009
Member
Hi,

as it turns out I resolved the problem by changing the ecore domain model (which is derived from an xsd). I simply introduced 4 subclasses of the "requires" element (which is now abstract) and use those (instead of the generic "requires" element) as reference type in the "sequence" element .

This way the generated IViewProvider works like a charm.

But still I'm not sure whether this
(1.) has been a problem of the ecore model that has been generated from the xsd,
(2.) a problem regarding the xsd file itself,
(2.) some inconsistency of the generator model or
(3.) a problem of the GMF runtime (for example regarding the generated SampelVisualIDRegistry)?!

Special thanks to Alex, you've been a great help,

sas
Re: Exception while creating View for certain elements [message #488653 is a reply to message #488339] Tue, 29 September 2009 15:42 Go to previous message
Alex Shatalin is currently offline Alex ShatalinFriend
Messages: 141
Registered: July 2009
Senior Member
Hello Sascha,

You can use one element to represent 4 different diagram nodes, but you need
to introduce corresponding constraints in order to help GMF to determine
which particular NodeMapping should be used for underlying domain model element..
In other words, i suppose original domain model can be used to model this
situation, but you have to introduce proper constraints/feature sequence
initializers there.

-----------------
Alex Shatalin
Previous Topic:Migration to GMF 2.2: Compile errors
Next Topic:Copy diagram screenshot to clipboard
Goto Forum:
  


Current Time: Wed Apr 24 17:18:58 GMT 2024

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

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

Back to the top