[英]Color some specific trees in a JFace treeviewer
我必须在视觉上区分JFace树中的某些节点及其子节点。 由于限制,我只能扩展标签提供商。
如何为节点及其子节点颜色? 我对其他让节点脱颖而出的方法持开放态度。
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);
}
}
从树中的可用节点,我可以根据条件仅为我想要的节点着色,以便将它们与其他节点区分开来吗?
如果您的标签提供者实现了org.eclipse.jface.viewers.IColorProvider
那么将要求它们提供各种元素的颜色。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.