Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » TreeViewer's inputChanged method is not called?
TreeViewer's inputChanged method is not called? [message #553559] Wed, 18 August 2010 02:17 Go to next message
Stumppi is currently offline StumppiFriend
Messages: 11
Registered: July 2010
Junior Member
Hi,

I went through the instructions presented here: http://www.eclipse.org/articles/Article-TreeViewer/TreeViewe rArticle.htm#inputChanged. The following explanation refers to the concepts presented there.

I then created my own classes (provider, etc.) for my own project. I guess everything should be ok, so I don't paste them in here for now.

However, I have the following problem: I have a class1 as root which is not visible. I initially added class1 using treeViewer.setInput(class1). class1 has a list for objects of type class2, which are added at runtime. The provider class is used as listener. Once an object of class2 is added to class1, at the end of the chain, method add(ChangeEvent event) of the provider class is called:

Provider class (also used as listener):

public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
....
}

public void add(ChangeEvent event) {
Object object = this.getParent(event.receiver());
viewer.refresh(object, false);
}

...

This method then calls the refresh() method of the TreeViewer.

Now coming to the point, having read the article above, I thought method inputChanged() is called right after viewer.refresh() has been called? This is important, because the provider is added as listener to the newly created classes in this method. Unfortunately, inputChanged() is not called in my case (besides during the initialization procedure, when treeViewer.setInput() is called, so class1 has the listener!).

Can anyone help and point me to the right direction?

Thanks!
Re: TreeViewer's inputChanged method is not called? [message #553575 is a reply to message #553559] Wed, 18 August 2010 05:22 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
inputChanged is only called when you set a new input. Refresh simply
recreates the whole structure from the already present input.

Tom

Am 18.08.10 04:17, schrieb Stumppi:
> Hi,
> I went through the instructions presented here:
> http://www.eclipse.org/articles/Article-TreeViewer/TreeViewe rArticle.htm#inputChanged
> The following explanation refers to the concepts presented there.
>
> I then created my own classes (provider, etc.) for my own project. I
> guess everything should be ok, so I don't paste them in here for now.
>
> However, I have the following problem: I have a class1 as root which is
> not visible. I initially added class1 using treeViewer.setInput(class1).
> class1 has a list for objects of type class2, which are added at
> runtime. The provider class is used as listener. Once an object of
> class2 is added to class1, at the end of the chain, method
> add(ChangeEvent event) of the provider class is called:
>
> Provider class (also used as listener):
>
> public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
> ...
> }
>
> public void add(ChangeEvent event) {
> Object object = this.getParent(event.receiver());
> viewer.refresh(object, false);
> }
>
> ..
>
> This method then calls the refresh() method of the TreeViewer.
> Now coming to the point, having read the article above, I thought method
> inputChanged() is called right after viewer.refresh() has been called?
> This is important, because the provider is added as listener to the
> newly created classes in this method. Unfortunately, inputChanged() is
> not called in my case (besides during the initialization procedure, when
> treeViewer.setInput() is called, so class1 has the listener!).
>
> Can anyone help and point me to the right direction?
>
> Thanks!
Re: TreeViewer's inputChanged method is not called? [message #553819 is a reply to message #553559] Thu, 19 August 2010 02:02 Go to previous message
Stumppi is currently offline StumppiFriend
Messages: 11
Registered: July 2010
Junior Member
Thanks for the hint... calling the addListener method at another place now...
Previous Topic:[Databinding][CDO] Removing CDOObjects, which are visible in a TreeViewer with Databinding, throws a
Next Topic:Why one additional column / row in TableViewer?
Goto Forum:
  


Current Time: Thu Apr 25 22:26:34 GMT 2024

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

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

Back to the top