CNF, tree refresh problem [message #891529] |
Mon, 25 June 2012 07:32 |
Girish Chandran Messages: 24 Registered: June 2012 |
Junior Member |
|
|
Hi all,
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.
Iam using eclipse 3.7 indigo.
Regards,
Girish
|
|
|
|
Re: CNF, tree refresh problem [message #891643 is a reply to message #891619] |
Mon, 25 June 2012 12:00 |
Girish Chandran Messages: 24 Registered: June 2012 |
Junior Member |
|
|
Hi Jan,
I tried calling calling setExpandedElements(object[] elements) after the refresh operation. But no effect on it.
I would like to show my code snippet of the content provider,
public Object[] getChildren(Object parentElement)
{
if (parentElement instanceof IProject)
{
resource.addDataChangeListener(this); // Notifies the viewer that a data change has been obtained. It is done by the
// emf notification.
return children(parentElement);
}
else
{
return children(parentElement);
}
}
// Listens to the data change
public void dataChanged(IChangedData object)
{
treeviewer.refresh(); or treeviewer.refresh(object,true);
}
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
Regards,
Girish
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03132 seconds