Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » TreeViewer Collapses on refresh(TreeViewer Collapses on refresh)
TreeViewer Collapses on refresh [message #659120] Fri, 11 March 2011 02:32 Go to next message
Animesh Kumar is currently offline Animesh Kumar
Messages: 79
Registered: September 2010
Location: Bangalore
Member
Hi,
I have a FilteredTree which is defined as follows:-
PatternFilter patternFilter = new PatternFilter();
final FilteredTree filteredTree = new FilteredTree(container, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL, patternFilter);
TreeViewer treeViewer = filteredTree.getViewer();


I have an action whose selection or de-selection refreshes the tree. But when the treeviewer is refreshed, the tree gets collapsed. How can I prevent my tree from getting collapsed?

I am using the the following code for treeviewer refresh:-
actionShowObjects = new Action("Show Objects") {

				@Override
				public void run() {
					treeViewer.refresh();
					}

			};
			actionShowObjects.setChecked(true);


Regards,
Animesh
Re: TreeViewer Collapses on refresh [message #659161 is a reply to message #659120] Fri, 11 March 2011 05:13 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5245
Registered: July 2009
Senior Member
Your problem is very likely that you are recreating your domain objects
in your content provider and so you need to help the TableViewer to map
the old instance to the new one which is normally done by setting an
IElementComparer on the viewer.

Tom

Am 11.03.11 08:32, schrieb Animesh Kumar:
> Hi,
> I have a FilteredTree which is defined as follows:-
> PatternFilter patternFilter = new PatternFilter();
> final FilteredTree filteredTree = new FilteredTree(container, SWT.MULTI
> | SWT.H_SCROLL | SWT.V_SCROLL, patternFilter);
> TreeViewer treeViewer = filteredTree.getViewer();
>
>
> I have an action whose selection or de-selection refreshes the tree. But
> when the treeviewer is refreshed, the tree gets collapsed. How can I
> prevent my tree from getting collapsed?
>
> I am using the the following code for treeviewer refresh:-
>
> actionShowObjects = new Action("Show Objects") {
>
> @Override
> public void run() {
> treeViewer.refresh();
> }
>
> };
> actionShowObjects.setChecked(true);
>
Re: TreeViewer Collapses on refresh [message #659163 is a reply to message #659161] Fri, 11 March 2011 05:30 Go to previous message
Animesh Kumar is currently offline Animesh Kumar
Messages: 79
Registered: September 2010
Location: Bangalore
Member
Hi Tom,
Thanx for the reply. If you don't mind, can you give a small example on how i can use the IElementComparer for the TreeViewer.


Regards,
Animesh
Previous Topic:Virtual tableViewer
Next Topic:Regarding TreeViewer
Goto Forum:
  


Current Time: Mon Jul 28 02:33:40 EDT 2014

Powered by FUDForum. Page generated in 0.06326 seconds