ListViewer listViewer = new ListViewer(root);
listViewer.setLabelProvider(new LabelProvider(){
@Override
public String getText( Object element ) {
IService service = (IService) element;
return service.getIdentifier().toString();
}
});
listViewer.setContentProvider(new ArrayContentProvider());
listViewer.setInput(errors.keySet().toArray());
final Text text = new Text(root, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL
| SWT.SCROLL_LINE);
FormData layoutData = new FormData();
layoutData.top = new FormAttachment(0);
layoutData.left = new FormAttachment(0);
label.setLayoutData(layoutData);
layoutData = new FormData();
layoutData.top = new FormAttachment(label, 2, SWT.BOTTOM);
layoutData.left = new FormAttachment(0);
layoutData.right = new FormAttachment(100);
layoutData.bottom = new FormAttachment(50);
listViewer.getList().setLayoutData(layoutData);
layoutData = new FormData();
layoutData.top = new FormAttachment(listViewer.getList(), 2, SWT.BOTTOM);
layoutData.left = new FormAttachment(0);
layoutData.right = new FormAttachment(100);
layoutData.bottom = new FormAttachment(100);
text.setLayoutData(layoutData);
listViewer.addSelectionChangedListener(new ISelectionChangedListener(){
public void selectionChanged( SelectionChangedEvent event ) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (selection == null || selection.isEmpty())
return;
IService service = (IService) selection.getFirstElement();
Throwable t = errors.get(service);
ByteArrayOutputStream out = new ByteArrayOutputStream();
t.printStackTrace(new PrintStream(out));
text.setText(new String(out.toByteArray()));