TreeViewer's inputChanged method is not called? [message #553559] |
Wed, 18 August 2010 02:17 |
Stumppi 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 |
Thomas Schindl 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!
|
|
|
|
Powered by
FUDForum. Page generated in 0.03302 seconds