annotationsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
final TableViewer annotationsTable = new TableViewer(annotationsComposite, SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
annotationsTable.setComparator(new ViewerComparator(new Comparator() {
public int compare(Object o1, Object o2) {
Annotation annotation1 = (Annotation) o1;
Annotation annotation2 = (Annotation) o2;
String line1 = getLineNumber(annotation1);
String line2 = getLineNumber(annotation2);
return Integer.parseInt(line1) - Integer.parseInt(line2);
}
}));
annotationsTable.setContentProvider(new ArrayContentProvider());
annotationsTable.getTable().setHeaderVisible(true);
annotationsTable.getTable().setLinesVisible(true);
String[] columns = new String[]{"Line", "Owner", "Type", "Class", "Message"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
annotationsTable.setLabelProvider(new ITableLabelProvider() {
public void addListener(ILabelProviderListener listener) {
}
public void dispose() {
}
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
public String getColumnText(Object element, int columnIndex) {
Annotation annotation = (Annotation) element;
String text = null;
switch (columnIndex) {
case 0 :
text = getLineNumber(annotation);
break;
case 1 :
text = getOwner(annotation);
break;
case 2 :
text = getType(annotation); //$NON-NLS-1$
break;
case 3 :
text = annotation.getClass().getName();
break;
case 4 :
text = annotation.getText();
break;
}
if (text == null)
text = ""; //$NON-NLS-1$
return text;
}
private String getOwner(Annotation annotation) {
String owner = null;
if (annotation instanceof MarkerAnnotation) {
owner = ((MarkerAnnotation) annotation).getMarker().getAttribute("owner", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
else if (annotation instanceof TemporaryAnnotation) {
Object key = ((TemporaryAnnotation) annotation).getKey();
if (key != null) {
if (key instanceof ReconcileAnnotationKey) {
key = key.getClass().getName();
}
if (key != null)
owner = key.toString();
}
}
return owner;
}
private String getType(Annotation annotation) {
String type = null;
if (annotation instanceof MarkerAnnotation) {
type = "M:"+MarkerUtilities.getMarkerType(((MarkerAnnotation) annotation).getMarker()); //$NON-NLS-1$
}
else {
type = "A:"+annotation.getType(); //$NON-NLS-1$
}
if (type == null)
type = ""; //$NON-NLS-1$
return type;
}
public boolean isLabelProperty(Object element, String property) {
return true;
}
public void removeListener(ILabelProviderListener listener) {
}
});
TableLayout tlayout = new TableLayout();
CellEditor[] cellEditors = new CellEditor[columns.length];
int columnWidths[] = new int[]{Display.getCurrent().getBounds().width / 14, Display.getCurrent().getBounds().width / 7, Display.getCurrent().getBounds().width / 7, Display.getCurrent().getBounds().width / 14, Display.getCurrent().getBounds().width / 7};
for (int i = 0; i < columns.length; i++) {
tlayout.addColumnData(new ColumnWeightData(1));
TableColumn tc = new TableColumn(annotationsTable.getTable(), SWT.NONE);
tc.setText(columns[i]);
tc.setResizable(true);
tc.setWidth(columnWidths[i]);
}
annotationsTable.setCellEditors(cellEditors);
annotationsTable.setColumnProperties(columns);
List matchingAnnotations = new ArrayList(0);
if (fTextEditor != null) {
IAnnotationModel annotationModel = fTextEditor.getDocumentProvider().getAnnotationModel(fTextEditor.getEditorInput());
if (annotationModel != null) {
Iterator iterator = annotationModel.getAnnotationIterator();
while (iterator.hasNext()) {
Annotation element = (Annotation) iterator.next();
if (true) {
matchingAnnotations.add(element);
}
}
}