viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
viewer.setContentProvider(new ViewContentProvider());
viewer.setComparator(new ViewerComparator() {
public int compare(Viewer viewer, Object e1, Object e2) {
if (e1 instanceof BatchModelChange) {
BatchModelChange c1 = (BatchModelChange) e1;
BatchModelChange c2 = (BatchModelChange) e2;
// newest goes last
return (int) (c2.getTime() - c1.getTime());
}
// no sorting for resource changes
return 0;
}
});
viewer.getTree().setHeaderVisible(true);
viewer.getTree().setLinesVisible(true);
labelProvider = WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider();
final SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss"); //$NON-NLS-1$
final CompareConfiguration config = new CompareConfiguration();
TreeViewerColumn resourceColumn = new TreeViewerColumn(viewer, SWT.LEAD);
resourceColumn.getColumn().setText("Changes");
resourceColumn.getColumn().setWidth(100);
resourceColumn.setLabelProvider(new ColumnLabelProvider() {
public String getText(Object element) {
if (element instanceof BatchModelChange) {
StringBuffer buffer = new StringBuffer();
BatchModelChange batchChange = (BatchModelChange) element;
buffer.append(batchChange.isOutgoing() ? "Outgoing"
: "Incoming");
buffer.append(" (");
buffer.append(formatter.format(new Date(batchChange
.getTime())));
buffer.append(')');
return buffer.toString();
} else {
return new Path(((ResourceChangeMessage) element).getPath())