Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Optimize TreeViewer refresh()
Optimize TreeViewer refresh() [message #557513] Tue, 07 September 2010 18:11 Go to next message
Eclipse UserFriend
Hello All,

I have a JFace TreeViewer that displays a lot of elements (2000 or so) directly depending on the root. I want to be able to add a new child to the root, and move approximately 100 elements from the root to this new child. It takes several seconds for the treeViewer to refresh, using the refresh(false) method.

Is there an efficient way to refresh the tree using MVC or should I use the underlying SWT class? In this case, is it safe to make modifications mixing MVC mechanisms and direct accesses to the SWT class?

Any help would be nice.

Best,
Re: Optimize TreeViewer refresh() [message #628734 is a reply to message #557513] Thu, 23 September 2010 16:09 Go to previous messageGo to next message
Eclipse UserFriend
Hi.

Take a look at TreeViewer#update(Object element, String[] properties) method. Where element is the parent of your new child, and properties are the names of the properties affected. i.e. this.treeViewer.update(rootNode, new String[]{"name"}) where "name" is used by the LabelProvider.

This method is much more efficient than the refresh.

Re: Optimize TreeViewer refresh() [message #628788 is a reply to message #557513] Fri, 24 September 2010 03:34 Go to previous messageGo to next message
Eclipse UserFriend
Thank you, but the update method cannot handle structural changes, such as addition or removal of children.
Re: Optimize TreeViewer refresh() [message #628812 is a reply to message #557513] Fri, 24 September 2010 05:01 Go to previous messageGo to next message
Eclipse UserFriend
On 08.09.2010 00:11, Nicolas wrote:
> Hello All,
>
> I have a JFace TreeViewer that displays a lot of elements (2000 or so)
> directly depending on the root. I want to be able to add a new child to
> the root, and move approximately 100 elements from the root to this new
> child. It takes several seconds for the treeViewer to refresh, using the
> refresh(false) method.
>
> Is there an efficient way to refresh the tree using MVC or should I use
> the underlying SWT class? In this case, is it safe to make modifications
> mixing MVC mechanisms and direct accesses to the SWT class?
>
> Any help would be nice.

It sounds as if you are modifying the tree via the Viewer operations, is
that correct? I would modify your model and would after the complete
change I would require a single viewer.refresh call.

If you need to perform some viewer-related actions within a single
block, you can optimize that by wrapping the code in a block sourrounded
with

getViewer().getControl().setRedraw(false);
try {
// Operations
} finally {
getViewer().getControl().setRedraw(true);
}

HTH & Greetings from Bremen,

Daniel Krügler
Re: Optimize TreeViewer refresh() [message #628885 is a reply to message #628788] Fri, 24 September 2010 11:26 Go to previous messageGo to next message
Eclipse UserFriend
Using
IObservableFactory observableFactory = BeansObservables.setFactory(Realm.getDefault(), "children", TreeNode.class);
this.viewer.setContentProvider(new ObservableSetTreeContentProvider(observableFactory, null));

and firing "children" property, you will get the TreeViewer#add method called. There is where you can call the #update.
I use this approach in my Problem View and works perfectly.
Re: Optimize TreeViewer refresh() [message #628899 is a reply to message #557513] Fri, 24 September 2010 12:27 Go to previous messageGo to next message
Eclipse UserFriend

Thank you for both answers: I will try and combine your advices.

Best,
Re: Optimize TreeViewer refresh() [message #629169 is a reply to message #557513] Mon, 27 September 2010 08:07 Go to previous messageGo to next message
Eclipse UserFriend
Nicolas wrote:
> Hello All,
>
> I have a JFace TreeViewer that displays a lot of elements (2000 or so)
> directly depending on the root. I want to be able to add a new child
> to the root, and move approximately 100 elements from the root to this
> new child. It takes several seconds for the treeViewer to refresh,
> using the refresh(false) method.
>
> Is there an efficient way to refresh the tree using MVC or should I
> use the underlying SWT class? In this case, is it safe to make
> modifications mixing MVC mechanisms and direct accesses to the SWT class?
You should consider using a virtual tree, see org.eclipse.swt.SWT.VIRTUAL.

Dani
>
> Any help would be nice.
>
> Best,
Re: Optimize TreeViewer refresh() [message #629940 is a reply to message #629169] Thu, 30 September 2010 01:21 Go to previous message
Eclipse UserFriend
Dani Megert wrote on Mon, 27 September 2010 08:07

You should consider using a virtual tree, see org.eclipse.swt.SWT.VIRTUAL.



It seems that I cannot: I need sorting capabilities and the virtual version of the treeviewer does not support them (I think)
Previous Topic:Context menu for table viewer
Next Topic:Job progress popup behavior change from eclipse 3.5 to 3.6 ?
Goto Forum:
  


Current Time: Sat Jul 05 23:34:43 EDT 2025

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

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

Back to the top