Iam having a project explorer view in my RCP application. Iam using CNF for the project explorer. Everything was working fine and i loved working with CNF. But,when i added context menu to the tree viewer for adding a new node, deleting a node etc..., the refresh action is not working fine. Iam having a listener, which notifies the viewer whenever a data change exist and the listener automatically triggers the refresh action of tree viewer. But when iam refreshing like treeviewer.refresh(), the refresh operation works fine but the tree gets collapsed to the root node of the tree. When iam calling treeviewer.refresh(node, true), the refresh operation does works.

Can anyone please help me out and provide a solution to the problem such that the refresh operation happens perfectly fine and the treeviewer should not collapse. It should in the same state as it was before.

I think, i have issues while calling the data change listener. Because after the treeviewer.refresh() operation, the control automatically goes to the getChildren() method and it returns the childrens under the project node.
But i would like to have a case such that, the tree should be refreshed and the tree needs to be expanded as it was earlier before the refresh operation.

I have already tried using setExpandedElements(Object[] elements), but was not able to get the desired result

I tried and got it. I did collapsed my tree to one level of the data being changed and expanded the tree manually and then refreshed the node in a thread when the expansion reaches the changed node. Thanks Jan. Thanks for your support.

Iam having one more issues. I have an editor, which changes values according to the node being selected in the explorer. So when i change a value, the data change listener activates the tree refresh and i set the selection on the tree node as treeviewer.setselection(selection,true);

I works fine. But when it sets the selection , a flickering happens in the editor and we can be able to see the flickering effect. Is there any method by which this flickering can be stopped.

Hi Girish,
allthough you already have a solution, there is one thing that comes into my mind reading this. If get- and setExpandedElements does not work, the reason might be that your elements do not implement hashCode() and equals(). In that case the viewer might not be able to find the elements in the new model. Make sure that elements considered to be equal return the same hashCode and true upon a call to equals(otherObject).