|
|
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 |
Ed Merks Messages: 33133 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/
|
|
|
Powered by
FUDForum. Page generated in 0.01865 seconds