tree.setHeaderVisible(true);
tree.setLinesVisible(true);
viewer = new TreeViewer(tree);
final TreeViewerColumn column0 = new TreeViewerColumn(viewer, SWT.LEFT);
column0.setLabelProvider(new CellLabelProvider() {
private final ILabelProvider delegate = new WorkbenchLabelProvider();
@Override
public void update(ViewerCell cell) {
if (cell.getElement() == LOADING_ELEMENT) {
cell.setText(UIMessages.CoverageView_loadingMessage);
cell.setImage(null);
} else {
cell.setText(cellTextConverter.getElementName(cell.getElement()));
cell.setImage(delegate.getImage(cell.getElement()));
}
}
});
sorter.addColumn(column0, COLUMN_ELEMENT);
final TreeViewerColumn column1 = new TreeViewerColumn(viewer, SWT.RIGHT);
column1.setLabelProvider(new OwnerDrawLabelProvider() {
@Override
public void update(ViewerCell cell) {
if (cell.getElement() == LOADING_ELEMENT) {
cell.setText(""); //$NON-NLS-1$
} else {
cell.setText(cellTextConverter.getRatio(cell.getElement()));
}
}
@Override
protected void erase(Event event, Object element) {
}
@Override
protected void measure(Event event, Object element) {
}
@Override
protected void paint(Event event, Object element) {
final ICoverageNode coverage = CoverageTools.getCoverageInfo(element);
if (coverage != null) {
final ICounter counter = coverage.getCounter(settings.getCounters());
RedGreenBar.draw(event, column1.getColumn().getWidth(), counter,
maxTotalCache.getMaxTotal(element));
}
}
});
sorter.addColumn(column1, COLUMN_RATIO);
final TreeViewerColumn column2 = new TreeViewerColumn(viewer, SWT.RIGHT);
column2.setLabelProvider(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
if (cell.getElement() == LOADING_ELEMENT) {
cell.setText(""); //$NON-NLS-1$
} else {
cell.setText(cellTextConverter.getCovered(cell.getElement()));
}
}
});
sorter.addColumn(column2, COLUMN_COVERED);
final TreeViewerColumn column3 = new TreeViewerColumn(viewer, SWT.RIGHT);
column3.setLabelProvider(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
if (cell.getElement() == LOADING_ELEMENT) {
cell.setText(""); //$NON-NLS-1$
} else {
cell.setText(cellTextConverter.getMissed(cell.getElement()));
}
}
});
sorter.addColumn(column3, COLUMN_MISSED);
final TreeViewerColumn column4 = new TreeViewerColumn(viewer, SWT.RIGHT);
column4.setLabelProvider(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
if (cell.getElement() == LOADING_ELEMENT) {
cell.setText(""); //$NON-NLS-1$