|
Re: jface TreeViewer - add new tree item to root without setInput()? [message #1734773 is a reply to message #1734736] |
Sat, 11 June 2016 15:13   |
Eclipse User |
|
|
|
With JFace viewers you don't add items to the viewer or control (Tree), but rather to the underlying model
(IContentProvider) and then refresh() the viewer.
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Am 11.06.2016 um 17:24 schrieb Sean Horton:
> I'm having some unexpected difficulty with the jface TreeViewer.
> The tree is working, but I've hit a situation that could cause user frustration in our app.
> We have a TreeViewer tree as follows:
>
> - TreeItem1
> - Child1
> - Child2
> - TreeItem2
> - Child1
> This tree is created by using TreeViewer.setInput(TreeItems)
>
> The problem is that we need to add tree items to the root level. For example, if we started with the tree above, we
> may dynamically need to create a new item as follows:
> - TreeItem1
> - Child1
> - Child2
> - TreeItem2
> - Child1 - TreeItem3
> - Child1
>
>
> So, we dynamically added a new root TreeItem (TreeItem3). Currently we are achieving this by calling
> TreeViewer.setInput(TreeItems) again. The problem is:
>
> 1) This is a lot of unnecessary work to update a single tree item as it's causing the modal to be completely new. 2)
> This can be called multiple times in a short period of time, causing the tree to bounce to the top of the list each time.
> Questions:
> Is there a way to refresh the root list of the tree without setInput()?
> I've tried TreeViewer.add(TreeViewer.getInput(), <newItem>). However, this only updates the tree, not the modal.
> A TreeViewer.refresh() will then remove the added item. Is there a way I can update the ContentProvider directly?
> Also using ITreeContentProvider.
>
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03851 seconds