Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Updating treeviewer from editor
Updating treeviewer from editor [message #824307] Mon, 19 March 2012 14:13 Go to next message
El Shorty is currently offline El ShortyFriend
Messages: 37
Registered: March 2012
Member
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 #824345 is a reply to message #824307] Mon, 19 March 2012 15:01 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
If you used EMF's item providers for the tree viewer, the support for
updates in response to notifications would just work out of the box.

On 19/03/2012 3:13 PM, El Shorty wrote:
> 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?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Updating treeviewer from editor [message #824354 is a reply to message #824345] Mon, 19 March 2012 15:15 Go to previous messageGo to next message
El Shorty is currently offline El ShortyFriend
Messages: 37
Registered: March 2012
Member
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 15:38]

Report message to a moderator

Re: Updating treeviewer from editor [message #824395 is a reply to message #824354] Mon, 19 March 2012 16:16 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
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


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Updating treeviewer from editor [message #824907 is a reply to message #824395] Tue, 20 March 2012 08:12 Go to previous messageGo to next message
El Shorty is currently offline El ShortyFriend
Messages: 37
Registered: March 2012
Member
It never was my intention to let you solve my problems, I just asked if you needed that code to know what I meant.
Thanks for all the help
Re: Updating treeviewer from editor [message #824923 is a reply to message #824907] Tue, 20 March 2012 08:41 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
If you hand code stuff you can use EMF-Databinding and JFace-Databinding
to keep the tree in sync with your model.

My tutorial series
http://tomsondev.bestsolution.at/category/databinding/emf/tutorials/
comes with sourcecode, ...

Tom

Am 20.03.12 09:12, schrieb El Shorty:
> It never was my intention to let you solve my problems, I just asked if
> you needed that code to know what I meant. Thanks for all the help
Re: Updating treeviewer from editor [message #825742 is a reply to message #824923] Wed, 21 March 2012 07:51 Go to previous message
El Shorty is currently offline El ShortyFriend
Messages: 37
Registered: March 2012
Member
Thanks for the help Tom Smile
Previous Topic:Activator not found after product export
Next Topic:ToggelCommand dynamically assign state
Goto Forum:
  


Current Time: Thu Mar 28 19:36:34 GMT 2024

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

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

Back to the top