I'm trying to implement search functionality in Jface Treeviewer, I have tried using SearchableTreeViewer but it didn't help, I want to highlight all the columns that contain the corresponding text
public void searchTree(String searchtext) {
viewer.collapseAll();
final int itemCount = viewer.getTree().getItemCount();
for (int itemIndex = 0; itemIndex < itemCount; itemIndex++) {
TreeItem item = viewer.getTree().getItem(itemIndex);
if (item.getData().toString().toUpperCase().contains(searchtext.toUpperCase())) {
viewer.expandToLevel(item.getData(), TreeViewer.ALL_LEVELS);
item.setForeground(new Color(Display.getCurrent(), 255, 0, 0));
}
else {
item.setForeground(new Color(Display.getCurrent(), 0, 0, 0));
}
}
}
Here I'm able to highlight the parent row but what I'm trying to achieve is to highlight the exact column(Symbol Name)
Any idea to highlight the child node specific columns?
Try to do tree.setSelection to that child item before setting the foreground color.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.