Updating treeviewer from editor [message #824307] |
Mon, 19 March 2012 10:13  |
Eclipse User |
|
|
|
Hey all,
I have a view in that contains a treeviewer, when you click an item in the treeviewer it opens an editor for this object. Here you are able to edit it and save the object. This all works fine, however the treeviewer doesn't update itself. I have to close my application and restart it to see the change in the treeviewer.
I'm working with eclipse, it's an RCP application and using EMF as the framework. I know it's in there somewhere, I believe you have to somehow put a notificationlistener in there somewhere but I really can't seem to figure out how it exactly works. Anyone can help me with this?
|
|
|
|
Re: Updating treeviewer from editor [message #824354 is a reply to message #824345] |
Mon, 19 March 2012 11:15   |
Eclipse User |
|
|
|
I didn't use the EMF item providers, when looking on how to best create a treeview I came upon a tutorial from vogela. It's a jface treeviewer.
Here is the code from the treeviewer:
treeViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL
| SWT.V_SCROLL);
Tree tree = treeViewer.getTree();
tree.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
tree.setLocation(0, 0);
tree.setSize(576, 429);
getSite().setSelectionProvider(treeViewer);
treeViewer.setContentProvider(new GroupContentProvider());
treeViewer.setLabelProvider(new GroupLabelProvider());
treeViewer.setAutoExpandLevel(3);
treeViewer.setInput(new GroupList());
treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
(this is to open the editor for the selected item
}
});
But apparently EMF has its own item providers (well I know this, just don't know how to use them), I'll try google it and maybe change my treeviewer. Still I would like to know if there is a way to do it using this code. I have created my own content provider and label provider, you need that code aswell? I'm new to the whole EMF/RCP story but I only got 2 months to finish my project and learn how to understand it all. It is a lot to take in, so sorry for if I ask alot of questions but really thanks for all the help
[Updated on: Mon, 19 March 2012 11:38] by Moderator
|
|
|
Re: Updating treeviewer from editor [message #824395 is a reply to message #824354] |
Mon, 19 March 2012 12:16   |
Eclipse User |
|
|
|
Comments below.
On 19/03/2012 4:15 PM, El Shorty wrote:
> I didn't use the EMF item providers, when looking on how to best
> create a treeview I came upon a tutorial from vogela. It's a jface
> treeviewer.
>
> Here is the code from the treeviewer:
>
>
> treeViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL
> | SWT.V_SCROLL);
> Tree tree = treeViewer.getTree();
> tree.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
> tree.setLocation(0, 0);
> tree.setSize(576, 429);
> getSite().setSelectionProvider(treeViewer);
> treeViewer.setContentProvider(new GroupContentProvider());
> treeViewer.setLabelProvider(new GroupLabelProvider());
> treeViewer.setAutoExpandLevel(3);
> treeViewer.setInput(new GroupList());
> treeViewer.addSelectionChangedListener(new
> ISelectionChangedListener() {
> public void selectionChanged(SelectionChangedEvent event) {
> (this is to open the editor for the selected item
> }
> });
>
>
> But apparently EMF has its own item providers, I'll try google it and
> maybe change my treeviewer. Still I would like to know if there is a
> way to do it using this code.
Yes, you can listen to notifications from the model. That's what the
item providers do. The introductory EMF overview describes this.
> I have created my own content provider and label provider, you need
> that code aswell?
I'm not going to solve your problems for you. You can look at working
examples, like EMF's generated editor. Wouldn't that be faster, given
it just works out of the box?
> I'm new to the whole EMF/RCP story but I only got 2 months to finish
> my project and learn how to understand it all. It is a lot to take in,
> so sorry for if I ask alot of questions but really thanks for all the
> help
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.15371 seconds