[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.modeling.gmf] Re: How to make GMF represent recursive object model
|
- From: Vlad Ciubotariu <vcciubot@xxxxxxxxxxxx>
- Date: Tue, 23 Jan 2007 19:27:31 -0500
- Newsgroups: eclipse.modeling.gmf
- Organization: EclipseCorner
- User-agent: Pan/0.14.2.91 (As She Crawled Across the Table (Debian GNU/Linux))
You could allow some flexibility in the model to overcome the gmf
limitations. After bootstrapping the editor you can correct the
containment references by hand.
-vlad
On Tue, 23 Jan 2007 13:47:57 -0700, Johann wrote:
> Hi,
>
> I am having a problem representing a recursive object in GMF.
>
> I have an example emf model with 3 classes: Model, Filesystem, and Folder.
> The Model is the only root-level object and contains a Filesystem. The
> Filesystem contains Folders. And a Folder contains other Folders as
> subfolders.
>
> I need to set the Model object as the diagram root element. So ideally, I
> would be able to place a Filesystem object on the diagram, place Folder
> objects in the Filesystem, and then recursively place Folder objects in
> other Folders.
>
> I read that in order to reuse a Node Mapping in the gmfmap file, a Top Node
> Reference must be defined. So I tried to define a Folder as a Top Node
> Reference in order to reuse it in a recursive manner. But this does not seem
> to work because the root Model object does not have an aggregation
> relationship to Folder. If I try to make the gmfgen file, I get an error
> saying "Top level node 'Containment Feature' must be available in the
> diagram 'Domain Element' or its super-class."
>
> So I've been stuck for a while on how to get the recursive GMF behavior on
> the Folder object. I can't reuse the Folder node if I don't define it as a
> Top Node Reference. And I can't define the Folder node as a Top Node
> Reference because the diagram root element Model does not have a direct
> containment on a Folder object. Is this a limitation of GMF or am I doing
> something completely wrong? Can some one please give me a hint as to how to
> proceed?
>
> I've attached the related ecore, genmodel, gmfgraph, gmftool, and gmfmap
> files for reference.
>
> Thanks in advance,
>
> Johann
>
>
> <?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="example"
> nsURI="example" nsPrefix="example">
> <eClassifiers xsi:type="ecore:EClass" name="filesystem">
> <eStructuralFeatures xsi:type="ecore:EReference" name="folders" upperBound="-1"
> eType="#//folder" containment="true"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="folder">
> <eStructuralFeatures xsi:type="ecore:EReference" name="subfolders" upperBound="-1"
> eType="#//folder" containment="true"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="model">
> <eStructuralFeatures xsi:type="ecore:EReference" name="filesystem" eType="#//filesystem"
> containment="true"/>
> </eClassifiers>
> </ecore:EPackage>
>
> <?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="/recursionExample/src"
> modelPluginID="recursionExample" modelName="Example" importerID="org.eclipse.emf.importer.ecore">
> <foreignModel>example.ecore</foreignModel>
> <genPackages prefix="Example" disposableProviderFactory="true" ecorePackage="example.ecore#/">
> <genClasses ecoreClass="example.ecore#//filesystem">
> <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference example.ecore#//filesystem/folders"/>
> </genClasses>
> <genClasses ecoreClass="example.ecore#//folder">
> <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference example.ecore#//folder/subfolders"/>
> </genClasses>
> <genClasses ecoreClass="example.ecore#//model">
> <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference example.ecore#//model/filesystem"/>
> </genClasses>
> </genPackages>
> </genmodel:GenModel>
>
> <?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/2005/GraphicalDefinition" name="example">
> <figures
> name="Default">
> <figures
> xsi:type="gmfgraph:Rectangle"
> referencingElements="filesystem"
> name="filesystemFigure"/>
> <figures
> xsi:type="gmfgraph:Rectangle"
> referencingElements="folder"
> name="folderFigure"/>
> </figures>
> <nodes
> name="filesystem"
> figure="filesystemFigure"/>
> <nodes
> name="folder"
> figure="folderFigure"/>
> </gmfgraph:Canvas>
>
> <?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>
> <tools
> xsi:type="gmftool:ToolGroup"
> title="example">
> <tools
> xsi:type="gmftool:CreationTool"
> title="filesystem"
> description="Create new filesystem">
> <smallIcon
> xsi:type="gmftool:DefaultImage"/>
> <largeIcon
> xsi:type="gmftool:DefaultImage"/>
> </tools>
> <tools
> xsi:type="gmftool:CreationTool"
> title="folder"
> description="Create new folder">
> <smallIcon
> xsi:type="gmftool:DefaultImage"/>
> <largeIcon
> xsi:type="gmftool:DefaultImage"/>
> </tools>
> </tools>
> </palette>
> </gmftool:ToolRegistry>
>
> <?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/2005/mappings"
> xmlns:gmftool="http://www.eclipse.org/gmf/2005/ToolDefinition">
> <nodes>
> <containmentFeature
> href="example.ecore#//model/filesystem"/>
> <ownedChild>
> <domainMetaElement
> href="example.ecore#//filesystem"/>
> <tool
> xsi:type="gmftool:CreationTool"
> href="example.gmftool#//@palette/@tools.0/@tools.0"/>
> <diagramNode
> href="example.gmfgraph#filesystem"/>
> <children
> referencedChild="//@nodes.1/@ownedChild">
> <containmentFeature
> href="example.ecore#//filesystem/folders"/>
> <childrenFeature
> href="example.ecore#//filesystem/folders"/>
> </children>
> </ownedChild>
> </nodes>
> <nodes>
> <containmentFeature
> href="example.ecore#//filesystem/folders"/>
> <ownedChild>
> <domainMetaElement
> href="example.ecore#//folder"/>
> <tool
> xsi:type="gmftool:CreationTool"
> href="example.gmftool#//@palette/@tools.0/@tools.1"/>
> <diagramNode
> href="example.gmfgraph#folder"/>
> <children
> referencedChild="//@nodes.1/@ownedChild">
> <containmentFeature
> href="example.ecore#//folder/subfolders"/>
> <childrenFeature
> href="example.ecore#//folder/subfolders"/>
> </children>
> </ownedChild>
> </nodes>
> <diagram>
> <diagramCanvas
> href="example.gmfgraph#example"/>
> <domainModel
> href="example.ecore#/"/>
> <domainMetaElement
> href="example.ecore#//model"/>
> <palette
> href="example.gmftool#//@palette"/>
> </diagram>
> </gmfmap:Mapping>