|
Re: How to merge/reparent items from subtree when displaying model in treeviewer? [message #427422 is a reply to message #427421] |
Tue, 17 February 2009 17:02 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Kyle,
Comments below.
Kyle J Nolan wrote:
> I created an EMF.edit model from my schema.
> The schema basically defines the tree as follows:
>
> TreeType
> ->ConfigType
> ->TestbedListType
> --->TestbedType
> ->TopologyListType
> --->TopologyType
> ...
> ->UserListType
> --->UserType
> ---->ConfigType
> ---->TestbedListType
> ------>TestbedType
> ---->TopologyListType
> ------>TopologyType
>
> Currently, I load my xml file that conforms to the schema, and in a
> tree viewer, it automagically displays the data like:
>
> Tree1
> ->GlobalConfig
> ->Testbeds
> --->Testbed1
> ->Topologies
> --->Topology1
> ...
> ->Users
> --->knolan
> ---->KnolanConfig
> ---->Testbeds
> ----->Testbed2
> ---->Topologies
> ------>Topology2
>
> I would like to take the stuff under the Users section and display it
> along with the global-level items of the same type in a treeViewer.
> For the example, above the output would now be:
>
> Tree1
> ->GlobalConfig
> ->KnolanConfig
> ->Testbeds
> --->Testbed1
> --->Testbed2
> ->Topologies
> --->Topology1
> --->Topology2
>
> Could someone point me to what I should be looking at to be able to do
> this?
>
Each generated item provider is implemented to return something specific
for getChildren(). Generally that's done by marking which features to
consider as children (containment references by default) and those will
show up. If you want there to be children that wouldn't otherwise be
there, you'll need to specialize what getChildren returns for the parent
AbcItemProvider under which you want them to appear. You should
consider specializing the getParent method for the child item providers
as well. Then test lots of things like drag and drop to be sure they
are behaving correctly...
> Currently in my createPartControl, I am just doing the following (and
> it uses all the stuff that was created when I exported my XSD to a
> EMF.edit model to display the tree):
>
> adapterFactory = new
>
> ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Reg istry.INSTANCE);
> adapterFactory.addAdapterFactory(new
> ResourceItemProviderAdapterFactory());
> adapterFactory.addAdapterFactory(new
> TreeTypeItemProviderAdapterFactory());
> adapterFactory.addAdapterFactory(new
> ReflectiveItemProviderAdapterFactory());
> navigator = new TreeViewer(parent, SWT.MULTI | SWT.V_SCROLL);
> navigator.setContentProvider(new
> AdapterFactoryContentProvider(adapterFactory));
> navigator.setLabelProvider(new
> AdapterFactoryLabelProvider(adapterFactory));
> getSite().setSelectionProvider(navigator);
> createModel(TREE_EXPLORER_FILE);
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.02806 seconds