Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Use same ECORE class with different creation tools
Use same ECORE class with different creation tools [message #236230] Wed, 15 July 2009 13:53 Go to next message
Eclipse UserFriend
Originally posted by: ML1984.gmx.de

This is a multi-part message in MIME format.
--------------040401020908030905080801
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

I have a problem using the same ECORE class with different creation
tools. Let's assume there is a (diagram) class A, referencing class B
twice: via EReference b1 and b2. Let's further assume there is one node
in graphical model and two creation tools (B1 and B2) in tooling model.

In mapping model I created the following:

Top Node Reference
Containment Feature: A.b1
Element: B
Diagram Node: Node B
Tool: Creation Tool B1

Top Node Reference
Containment Feature: A.b2
Element: B
Diagram Node: Node B
Tool: Creation Tool B2

Code generation succeeds, but: If you use the B2 creation tool (in an
newly started eclipse application), an exception is thrown (see below)
and no B element is created.

------------------------------------------------
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
org.eclipse.gmf.runtime.diagram.ui.commands.CreateCommand.do ExecuteWithResult(CreateCommand.java:99)
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)
------------------------------------------------

Using debugger, I could find the origin of the above mentioned
AssertionFailedException. In class

org.eclipse.gmf.runtime.common.core.service.ExecutionStrateg y

there is a static final attribute 'FIRST' of type ExecutionStrategy,
implementing method

public List execute(Service service, IOperation operation)

This method returns Collections.EMPTY_LIST, causing its caller to return
null.

I don't know how to proceed further. Anyway, do you have any suggestions
how to make the example work? BTW, used models are attached to this message.

Cheers,
Mark

PS. I am using Eclipse Galileo pre packaged as Eclipse Modeling Tools.

--------------040401020908030905080801
Content-Type: text/xml;
name="My.gmfgraph"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="My.gmfgraph"

<?xml version="1.0" encoding="UTF-8"?>
<gmfgraph:Canvas xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:gmfgraph="http://www.eclipse.org/gmf/2006/GraphicalDefinition" name="my">
<figures
name="Default">
<descriptors
name="BFigure">
<actualFigure
xsi:type="gmfgraph:Rectangle"
name="BFigure"/>
</descriptors>
</figures>
<nodes
name="B"
figure="BFigure"/>
</gmfgraph:Canvas>

--------------040401020908030905080801
Content-Type: text/xml;
name="My.gmfmap"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="My.gmfmap"

<?xml version="1.0" encoding="UTF-8"?>
<gmfmap:Mapping xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:gmfmap="http://www.eclipse.org/gmf/2008/mappings"
xmlns:gmftool="http://www.eclipse.org/gmf/2005/ToolDefinition">
<nodes>
<containmentFeature
href="My.ecore#//A/b1"/>
<ownedChild>
<domainMetaElement
href="My.ecore#//B"/>
<tool
xsi:type="gmftool:CreationTool"
href="My.gmftool#//@palette/@tools.0/@tools.0"/>
<diagramNode
href="My.gmfgraph#B"/>
</ownedChild>
</nodes>
<nodes>
<containmentFeature
href="My.ecore#//A/b2"/>
<ownedChild>
<domainMetaElement
href="My.ecore#//B"/>
<tool
xsi:type="gmftool:CreationTool"
href="My.gmftool#//@palette/@tools.0/@tools.1"/>
<diagramNode
href="My.gmfgraph#B"/>
</ownedChild>
</nodes>
<diagram>
<diagramCanvas
href="My.gmfgraph#my"/>
<domainModel
href="My.ecore#/"/>
<domainMetaElement
href="My.ecore#//A"/>
<palette
href="My.gmftool#//@palette"/>
</diagram>
</gmfmap:Mapping>

--------------040401020908030905080801
Content-Type: text/xml;
name="My.gmftool"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="My.gmftool"

<?xml version="1.0" encoding="UTF-8"?>
<gmftool:ToolRegistry xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:gmftool="http://www.eclipse.org/gmf/2005/ToolDefinition">
<palette
title="myPalette">
<tools
xsi:type="gmftool:ToolGroup"
title="my">
<tools
xsi:type="gmftool:CreationTool"
title="B1"
description="Create new B1">
<smallIcon
xsi:type="gmftool:DefaultImage"/>
<largeIcon
xsi:type="gmftool:DefaultImage"/>
</tools>
<tools
xsi:type="gmftool:CreationTool"
title="B2"
description="Create new B2">
<smallIcon
xsi:type="gmftool:DefaultImage"/>
<largeIcon
xsi:type="gmftool:DefaultImage"/>
</tools>
</tools>
</palette>
</gmftool:ToolRegistry>

--------------040401020908030905080801
Content-Type: text/xml;
name="My.ecore"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="My.ecore"

<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="my"
nsURI="file://My.ecore" nsPrefix="my">
<eClassifiers xsi:type="ecore:EClass" name="A">
<eStructuralFeatures xsi:type="ecore:EReference" name="b1" eType="#//B" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="b2" eType="#//B" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="B"/>
</ecore:EPackage>

--------------040401020908030905080801
Content-Type: text/xml;
name="My.genmodel"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="My.genmodel"

<?xml version="1.0" encoding="UTF-8"?>
<genmodel:GenModel xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" modelDirectory="/de.hpi.sam.mark.test/src"
modelPluginID="de.hpi.sam.mark.test" modelName="My" importerID="org.eclipse.emf.importer.ecore"
complianceLevel="6.0" copyrightFields="false">
<foreignModel>My.ecore</foreignModel>
<genPackages prefix="My" disposableProviderFactory="true" ecorePackage="My.ecore#/">
<genClasses ecoreClass="My.ecore#//A">
<genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference My.ecore#//A/b1"/>
<genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference My.ecore#//A/c"/>
<genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference My.ecore#//A/b2"/>
</genClasses>
<genClasses ecoreClass="My.ecore#//B"/>
<genClasses ecoreClass="My.ecore#//C"/>
</genPackages>
</genmodel:GenModel>

--------------040401020908030905080801
Content-Type: text/xml;
name="My.gmfgen"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="My.gmfgen"

<?xml version="1.0" encoding="UTF-8"?>
<gmfgen:GenEditorGenerator xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:gmfgen="http://www.eclipse.org/gmf/2009/GenModel">
<diagram
visualID="1000"
editPartClassName="AEditPart"
itemSemanticEditPolicyClassName="AItemSemanticEditPolicy"
canonicalEditPolicyClassName="ACanonicalEditPolicy"
iconProviderPriority="Low"
validationProviderPriority="Low">
<diagramRunTimeClass
href=" ../../../plugin/org.eclipse.gmf.runtime.notation/model/notat ion.genmodel#//notation/Diagram "/>
<elementType
xsi:type="gmfgen:MetamodelType"
editHelperClassName="AEditHelper"/>
<viewmap
xsi:type="gmfgen:FigureViewmap"
figureQualifiedClassName="org.eclipse.draw2d.FreeformLayer"/ >
<domainDiagramElement
href="My.genmodel#//my/A"/>
<topLevelNodes
visualID="2001"
editPartClassName="BEditPart"
itemSemanticEditPolicyClassName="BItemSemanticEditPolicy"
canonicalEditPolicyClassName="BCanonicalEditPolicy"
graphicalNodeEditPolicyClassName="BGraphicalNodeEditPolicy"
createCommandClassName="BCreateCommand">
<diagramRunTimeClass
href=" ../../../plugin/org.eclipse.gmf.runtime.notation/model/notat ion.genmodel#//notation/Node "/>
<elementType
xsi:type="gmfgen:MetamodelType"
editHelperClassName="BEditHelper"/>
<viewmap
xsi:type="gmfgen:FigureViewmap"
figureQualifiedClassName="org.eclipse.draw2d.RectangleFigure "/>
<modelFacet>
<metaClass
href="My.genmodel#//my/B"/>
<containmentMetaFeature
href="My.genmodel#//my/A/b1"/>
<childMetaFeature
href="My.genmodel#//my/A/b1"/>
</modelFacet>
</topLevelNodes>
<topLevelNodes
visualID="2002"
editPartClassName="B2EditPart"
itemSemanticEditPolicyClassName="B2ItemSemanticEditPolicy"
canonicalEditPolicyClassName="B2CanonicalEditPolicy"
graphicalNodeEditPolicyClassName="B2GraphicalNodeEditPolicy "
createCommandClassName="B2CreateCommand">
<diagramRunTimeClass
href=" ../../../plugin/org.eclipse.gmf.runtime.notation/model/notat ion.genmodel#//notation/Node "/>
<elementType
xsi:type="gmfgen:SpecializationType"
metamodelType="//@diagram/@topLevelNodes.0/@elementType"/>
<viewmap
xsi:type="gmfgen:FigureViewmap"
figureQualifiedClassName="org.eclipse.draw2d.RectangleFigure "/>
<modelFacet>
<metaClass
href="My.genmodel#//my/B"/>
<containmentMetaFeature
href="My.genmodel#//my/A/b2"/>
<childMetaFeature
href="My.genmodel#//my/A/b2"/>
</modelFacet>
</topLevelNodes>
<palette>
<groups
title="my">
<entries
xsi:type="gmfgen:ToolEntry"
title="B1"
description="Create new B1"
genNodes="//@diagram/@topLevelNodes.0"/>
<entries
xsi:type="gmfgen:ToolEntry"
title="B2"
description="Create new B2"
genNodes="//@diagram/@topLevelNodes.1"/>
</groups>
</palette>
<preferencePages
xsi:type="gmfgen:GenStandardPreferencePage"
iD="de.hpi.sam.mark.test.diagram.general"
name="My Diagram">
<children
xsi:type="gmfgen:GenStandardPreferencePage"
iD="de.hpi.sam.mark.test.diagram.appearance"
name="Appearance"
kind="Appearance"/>
<children
xsi:type="gmfgen:GenStandardPreferencePage"
iD="de.hpi.sam.mark.test.diagram.connections"
name="Connections"
kind="Connections"/>
<children
xsi:type="gmfgen:GenStandardPreferencePage"
iD="de.hpi.sam.mark.test.diagram.printing"
name="Printing"
kind="Printing"/>
<children
xsi:type="gmfgen:GenStandardPreferencePage"
iD="de.hpi.sam.mark.test.diagram.rulersAndGrid"
name="Rulers And Grid"
kind="RulersAndGrid"/>
</preferencePages>
</diagram>
<plugin>
<requiredPlugins>org.eclipse.draw2d</requiredPlugins>
</plugin>
<editor/>
<navigator>
<childReferences
child="//@diagram"/>
<childReferences
parent="//@diagram"
child="//@diagram/@topLevelNodes.0"/>
<childReferences
parent="//@diagram"
child="//@diagram/@topLevelNodes.1"/>
</navigator>
<diagramUpdater/>
<propertySheet>
<tabs
xsi:type="gmfgen:GenStandardPropertyTab"
iD="appearance"/>
<tabs
xsi:type="gmfgen:GenStandardPropertyTab"
iD="diagram"/>
<tabs
xsi:type="gmfgen:GenCustomPropertyTab"
iD="domain"
label="Core">
<filter
xsi:type="gmfgen:TypeTabFilter">
<types>org.eclipse.gmf.runtime.notation.View</types>
<types>org.eclipse.gef.EditPart</types>
<generatedTypes>abstractNavigatorItem</generatedTypes>
</filter>
</tabs>
</propertySheet>
<domainGenModel
href="My.genmodel#/"/>
<contextMenus
context="//@diagram">
<items
xsi:type="gmfgen:LoadResourceAction"/>
</contextMenus>
</gmfgen:GenEditorGenerator>

--------------040401020908030905080801--
Re: Use same ECORE class with different creation tools [message #236253 is a reply to message #236230] Wed, 15 July 2009 23:19 Go to previous messageGo to next message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

Hi Mark,

I think that you need to set constraint on the different node, on
containment feature for instance.

Aurelien Pupier


Mark L. wrote:

> Hi,

> I have a problem using the same ECORE class with different creation
> tools. Let's assume there is a (diagram) class A, referencing class B
> twice: via EReference b1 and b2. Let's further assume there is one node
> in graphical model and two creation tools (B1 and B2) in tooling model.

> In mapping model I created the following:

> Top Node Reference
> Containment Feature: A.b1
> Element: B
> Diagram Node: Node B
> Tool: Creation Tool B1

> Top Node Reference
> Containment Feature: A.b2
> Element: B
> Diagram Node: Node B
> Tool: Creation Tool B2

> Code generation succeeds, but: If you use the B2 creation tool (in an
> newly started eclipse application), an exception is thrown (see below)
> and no B element is created.

> ------------------------------------------------
> 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
>
org.eclipse.gmf.runtime.diagram.ui.commands.CreateCommand.do ExecuteWithResult(CreateCommand.java:99)
> 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)
> ------------------------------------------------

> Using debugger, I could find the origin of the above mentioned
> AssertionFailedException. In class

> org.eclipse.gmf.runtime.common.core.service.ExecutionStrateg y

> there is a static final attribute 'FIRST' of type ExecutionStrategy,
> implementing method

> public List execute(Service service, IOperation operation)

> This method returns Collections.EMPTY_LIST, causing its caller to return
> null.

> I don't know how to proceed further. Anyway, do you have any suggestions
> how to make the example work? BTW, used models are attached to this message.

> Cheers,
> Mark

> PS. I am using Eclipse Galileo pre packaged as Eclipse Modeling Tools.


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Re: Use same ECORE class with different creation tools [message #468371 is a reply to message #236253] Wed, 05 August 2009 10:11 Go to previous messageGo to next message
Sinisa is currently offline SinisaFriend
Messages: 10
Registered: July 2009
Junior Member
Hi Aurelien,

I have the same problem and I wasn't understand you very well.
Can you please be a little more specific?

I have one ECORE element and several graphical presentation of that
element on diagram.

Thanks,
Sinisa
Re: Use same ECORE class with different creation tools [message #468479 is a reply to message #468371] Wed, 05 August 2009 15:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ML1984.gmx.de

Hi Sinisa.

At
http://wiki.eclipse.org/GMF_Tutorial_Part_2#Mapping_Definiti on_3
is a description, that should help you.

To you the most important is probably:
"In fact, whenever you create multiple mappings to a single domain
element, you will need to add constraints such that each can be uniquely
identified."

Cheers,
Mark

PS. Of course, you could alter your meta model to have distinguishable
elements (like I did to solve the problem).

> Hi Aurelien,
>
> I have the same problem and I wasn't understand you very well. Can you
> please be a little more specific?
>
> I have one ECORE element and several graphical presentation of that
> element on diagram.
>
> Thanks, Sinisa
Re: Use same ECORE class with different creation tools [message #468486 is a reply to message #468479] Wed, 05 August 2009 16:11 Go to previous message
Sinisa is currently offline SinisaFriend
Messages: 10
Registered: July 2009
Junior Member
Hi Mark

Thanks for response.
This link is exactly what I need.
I also need to alter meta model because my ECORE element doesn't have
appropriate attribute.

Also, I am not familiar with OCL syntax,
so I will try to create a Constraint with the Java syntax.

Again, thank you very much.

Sinisa
Previous Topic:EMF-GMF tabbed.propertySections
Next Topic:unexpected behavior of cut/paste in GMF
Goto Forum:
  


Current Time: Thu Apr 25 23:44:00 GMT 2024

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

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

Back to the top