I have to visually differentiate certain nodes and its children in a JFace tree. Due to limitations, I can only extend the label provider.
How can I color the nodes and their children? I'm open to other methods for making the nodes stand out.
class ExistingScheduleLabelProvider extends LabelProvider {
@Override
public String getText(Object element) {
if (element instanceof Schedule) {
Schedule schedule = (Schedule) element;
return schedule.getDescription();
} else if (element instanceof BatchReport) {
BatchReport report = (BatchReport) element;
Schedule schedule = (Schedule)report.eContainer();
return (schedule.getBatchReports().indexOf(report)+1) + " - " + report.getDescription(); //$NON-NLS-1$
}
return null;
}
@Override
public Image getImage(Object element) {
if (element instanceof Schedule)
return SchedulingUIPlugin.getImage(SchedulingImageConstants.IMG_SCHEDULE);
else if (element instanceof BatchReport)
return SchedulingUIPlugin.getImage(SchedulingImageConstants.IMG_BATCH_REPORT);
return super.getImage(element);
}
}
From the available nodes in the tree, can I color only the nodes which I want based on a condition in order to differentiate them from other nodes?