Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to display emf data model items in logical folders in treeview
How to display emf data model items in logical folders in treeview [message #431511] Tue, 14 July 2009 16:45 Go to next message
Kyle is currently offline KyleFriend
Messages: 16
Registered: July 2009
Junior Member
I created an emf model from an XML definition, where I have a MyFiles
object that contains a list of filename objects:

DocumentRoot
+- MyExplorer
+-MyFiles
---file1
---file2
---file3
---file4

where:
file1 = /root/file1
file2 = /root/subdir1/file2
file3 = /root/subdir1/file3
file4 = /root/subdir2/file4

Currently, when I display the data model in a treeview, I see each
filename object listed in the main MyFiles folder.

Instead, I would like to display each filename either under the
MyFiles root folder, or in logical subfolders based on the directory
where the file resides, so:

So I would want to see:

DocumentRoot
+- MyExplorer
+-MyFiles
--- file1
+- subdir1
---file2
---file3
+-subdir2
---file4

I would like to be able to do this in such a way that I wouldn't need
to modify my model in order to display these virtual folders. Can
anyone give me any pointers or suggestions?
Re: How to display emf data model items in logical folders in treeview [message #431514 is a reply to message #431511] Tue, 14 July 2009 19:39 Go to previous messageGo to next message
Kyle is currently offline KyleFriend
Messages: 16
Registered: July 2009
Junior Member
It looks like what I am trying to do is what the user describes he is
doing in this old thread:

http://dev.eclipse.org/newslists/news.eclipse.technology.emf t/msg00572.html

However, he did not post his code he is using to do this.
Re: How to display emf data model items in logical folders in treeview [message #431537 is a reply to message #431511] Wed, 15 July 2009 13:54 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 31484
Registered: July 2009
Senior Member
Kyle,

Comments below.

Kyle J Nolan wrote:
> I created an emf model from an XML definition, where I have a MyFiles
> object that contains a list of filename objects:
>
> DocumentRoot
> +- MyExplorer
> +-MyFiles
> ---file1
> ---file2
> ---file3
> ---file4
>
> where:
> file1 = /root/file1
> file2 = /root/subdir1/file2
> file3 = /root/subdir1/file3
> file4 = /root/subdir2/file4
>
> Currently, when I display the data model in a treeview, I see each
> filename object listed in the main MyFiles folder.
>
> Instead, I would like to display each filename either under the
> MyFiles root folder, or in logical subfolders based on the directory
> where the file resides, so:
>
> So I would want to see:
>
> DocumentRoot
> +- MyExplorer
> +-MyFiles
> --- file1
> +- subdir1
> ---file2
> ---file3
> +-subdir2
> ---file4
>
> I would like to be able to do this in such a way that I wouldn't need
> to modify my model in order to display these virtual folders. Can
> anyone give me any pointers or suggestions?
>
It depends a little bit on how fancy you want to get. Certainly it's
possible to make MyFiles be stateful (a GenFeature property) and modify
the getChildren method to return something different from now. You
could use ItemProvider instances to induce folders that ultimately
contain files as the leaves. Or you could reuse specialized instances
of the MyFilesItemProvider to act as folders where basically the
getChildren shows a filtered list of "folders" and file leaves,
depending on the "folder path" they represent. That approach will be
more amenable to dealing with notifications to changes in the structure.


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Model referencing existing emf classes
Next Topic:[EMF] Combining Reflective EMF with generated model code
Goto Forum:
  


Current Time: Fri Sep 25 11:32:37 GMT 2020

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

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

Back to the top