Tree View for workspace [message #68605] |
Tue, 10 June 2003 00:17  |
Eclipse User |
|
|
|
Originally posted by: bharatkhatri2000.yahoo.com
Hi All,
I am trying to make a view which shows all the projects files, folders and
more in the workspace, much like the resource navigator, but I'll have my
own labels and other stuff about the file. I am using the jface treeviewer
for the view. Everything works fine. I have written a class whose objects
are represented in the view. Now I have two questions:
[1] Is it a good idea to use objects of my own class to represent the
elements of the tree, or should I make the tree items using widgets (like
TreeItem) ?
[2] The next step I'll go for is to define a context menu for the view, so
that the tree structure can be manipulated. Most, but not all, of the
items will be same as the context menu for the resource navigator, and
implementation of most, but not all, menu items will be the same as in the
resource navigator (like file/folder creation). Now is there a way to
inherit the itmes and functionality of resource navigator menu in my menu
(and maybe override some of it), or I have to write everything myself ?
And if I do have to write it myself, I'll ask the first question again in
this context, i.e. is it better to use my own class or use swt widgets for
the tree elements.
Sorry for the long message
Any help would be greatly appreciated
Bharat
|
|
|
Re: Tree View for workspace [message #69702 is a reply to message #68605] |
Tue, 10 June 2003 15:21  |
Eclipse User |
|
|
|
Originally posted by: knut_radloff.oti.com
"Bharat" <bharatkhatri2000@yahoo.com> wrote in message news:bc3m5j$ha0$1@rogue.oti.com...
>
> Hi All,
>
> I am trying to make a view which shows all the projects files, folders and
> more in the workspace, much like the resource navigator, but I'll have my
> own labels and other stuff about the file. I am using the jface treeviewer
> for the view. Everything works fine. I have written a class whose objects
> are represented in the view. Now I have two questions:
If all you are changing is the labels/item presentation you can use decorators for that. There is a decorator extension point
defined in org.eclipse.ui for this purpose.
> [1] Is it a good idea to use objects of my own class to represent the
> elements of the tree, or should I make the tree items using widgets (like
> TreeItem) ?
If you are using a JFace TreeViewer (vs. plain SWT Tree widget) then you should use a content provider and label provider. For what
you want to do you are better off using the JFace support and not deal with SWT widgets/items. You can use the
WorkbenchContentProvider if you want to display the workspace resources like the Resource Navigator does (except you want to use a
different label and change menus).
> [2] The next step I'll go for is to define a context menu for the view, so
> that the tree structure can be manipulated. Most, but not all, of the
> items will be same as the context menu for the resource navigator, and
> implementation of most, but not all, menu items will be the same as in the
> resource navigator (like file/folder creation). Now is there a way to
> inherit the itmes and functionality of resource navigator menu in my menu
> (and maybe override some of it), or I have to write everything myself ?
> And if I do have to write it myself, I'll ask the first question again in
> this context, i.e. is it better to use my own class or use swt widgets for
> the tree elements.
In general, to avoid copying a lot of code you can subclass the ResourceNavigator and override methods that you need to customize.
The Navigator actions are defined in action groups subclassed from ResourceNavigatorActionGroup. If you want to customize any of
these you will again have to subclass and/or replace action groups. You will probably want to subclass MainActionGroup if you are
keeping most Navigator actions and perhaps only adding or changing a few. This main group is created in
ResourceNavigator.makeActions. It then goes on and creates sub groups and eventually the actions themselves.
The actions may be subclassed as well, if you want to change any of them.
For the 3.0 release we plan to make customizing the Navigator a lot easier. If you only want to add a few actions to a Navigator
view you shouldn't have to create an entirely new view. Bug 36961 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=36961) tracks this
plan item. Feel free to add any input and requirements you have.
Knut
|
|
|
Powered by
FUDForum. Page generated in 0.05857 seconds