Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » TreeViewer refresh.
TreeViewer refresh. [message #284452] Mon, 25 April 2005 12:59 Go to next message
Eclipse UserFriend
Originally posted by: wim.nospam.org

Hello All,

I have copied the plugin treeviewer example to adapt and tried to add a lazy
load to it with. I ended up in the expansion event allright but i could not
get the tree to refresh. Here is the relevant part of the code:


private Action treeExpandAction; // declaration

hookExpandAction(); // called from createPartControl

.... // part of the hookExpandAction method

viewer.addTreeListener(new ITreeViewerListener()
{
public void treeExpanded(TreeExpansionEvent arg0)
{
treeExpandAction.run();
....

The treeExpandAction.run starts with:

ISelection selection = viewer.getSelection();
Object obj = ((IStructuredSelection) selection)
.getFirstElement();
TreeParent tp = (TreeParent) obj;

Then i do actions to add new children to the TreeParent and tried many ways
of using refresh and update and add methods against the viewer in order to
have it refreshed. These actions all failed. I noticed that when i did
drilldown, the node was build okay, which lead me to doing this.

viewer.setInput(viewer.getInput());
viewer.expandToLevel(obj, 1);

since this happens in the drilldownadapter.

This is working. Is this correct?

viewer.refresh(tp);

leaves me with one empty node

Thanks for your time.

Wim
Re: TreeViewer refresh. [message #284496 is a reply to message #284452] Tue, 26 April 2005 10:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wim.nospam.org

Let me simplify:

viewer.refresh does no good when i add items in an treeExpanded event.

but

viewer.setInput(viewer.getInput());
viewer.expandToLevel(obj, 1);

works

However, I don't have a good feeling about this approach. Can anybody help?


"Wim Jongman" <wim@nospam.org> wrote in message
news:d4j7mq$rsf$1@news.eclipse.org...
> Hello All,
>
> I have copied the plugin treeviewer example to adapt and tried to add a
> lazy load to it with. I ended up in the expansion event allright but i
> could not get the tree to refresh. Here is the relevant part of the code:
>
>
> private Action treeExpandAction; // declaration
>
> hookExpandAction(); // called from createPartControl
>
> ... // part of the hookExpandAction method
>
> viewer.addTreeListener(new ITreeViewerListener()
> {
> public void treeExpanded(TreeExpansionEvent arg0)
> {
> treeExpandAction.run();
> ...
>
> The treeExpandAction.run starts with:
>
> ISelection selection = viewer.getSelection();
> Object obj = ((IStructuredSelection) selection)
> .getFirstElement();
> TreeParent tp = (TreeParent) obj;
>
> Then i do actions to add new children to the TreeParent and tried many
> ways of using refresh and update and add methods against the viewer in
> order to have it refreshed. These actions all failed. I noticed that when
> i did drilldown, the node was build okay, which lead me to doing this.
>
> viewer.setInput(viewer.getInput());
> viewer.expandToLevel(obj, 1);
>
> since this happens in the drilldownadapter.
>
> This is working. Is this correct?
>
> viewer.refresh(tp);
>
> leaves me with one empty node
>
> Thanks for your time.
>
> Wim
>
>
>
Re: TreeViewer refresh. [message #284728 is a reply to message #284496] Fri, 29 April 2005 08:10 Go to previous message
Eclipse UserFriend
Originally posted by: wim.nospam.org

viewer.setExpandedState(obj, true);
viewer.refresh(obj, false);

Did the trick.
(The Lord helps he who helps himself)

>> viewer.setInput(viewer.getInput());
>> viewer.expandToLevel(obj, 1);
>>
>> since this happens in the drilldownadapter.
>>
>> This is working. Is this correct?

Did only work in first glance

>>
>> viewer.refresh(tp);
>>
>> leaves me with one empty node

Because of the missing setExpandState()





"Wim Jongman" <wim@nospam.org> wrote in message
news:d4ljqb$qtb$1@news.eclipse.org...
> Let me simplify:
>
> viewer.refresh does no good when i add items in an treeExpanded event.
>
> but
>
> viewer.setInput(viewer.getInput());
> viewer.expandToLevel(obj, 1);
>
> works
>
> However, I don't have a good feeling about this approach. Can anybody
> help?
>
>
> "Wim Jongman" <wim@nospam.org> wrote in message
> news:d4j7mq$rsf$1@news.eclipse.org...
>> Hello All,
>>
>> I have copied the plugin treeviewer example to adapt and tried to add a
>> lazy load to it with. I ended up in the expansion event allright but i
>> could not get the tree to refresh. Here is the relevant part of the code:
>>
>>
>> private Action treeExpandAction; // declaration
>>
>> hookExpandAction(); // called from createPartControl
>>
>> ... // part of the hookExpandAction method
>>
>> viewer.addTreeListener(new ITreeViewerListener()
>> {
>> public void treeExpanded(TreeExpansionEvent arg0)
>> {
>> treeExpandAction.run();
>> ...
>>
>> The treeExpandAction.run starts with:
>>
>> ISelection selection = viewer.getSelection();
>> Object obj = ((IStructuredSelection) selection)
>> .getFirstElement();
>> TreeParent tp = (TreeParent) obj;
>>
>> Then i do actions to add new children to the TreeParent and tried many
>> ways of using refresh and update and add methods against the viewer in
>> order to have it refreshed. These actions all failed. I noticed that when
>> i did drilldown, the node was build okay, which lead me to doing this.
>>
>> viewer.setInput(viewer.getInput());
>> viewer.expandToLevel(obj, 1);
>>
>> since this happens in the drilldownadapter.
>>
>> This is working. Is this correct?
>>
>> viewer.refresh(tp);
>>
>> leaves me with one empty node
>>
>> Thanks for your time.
>>
>> Wim
>>
>>
>>
>
>
Previous Topic:[classname] cannot be resolved - where classname is part of my project
Next Topic:Line Count
Goto Forum:
  


Current Time: Sat Jul 19 08:58:38 EDT 2025

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

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

Back to the top