use of eu.esdihumboldt.hale.ui.views.report.properties.details.tree.ReportTreeLabelProvider in project hale by halestudio.
the class DefaultReportDetailsPage method createControls.
/**
* @see CustomReportDetailsPage#createControls(Composite)
*/
@Override
public Control createControls(Composite parent) {
// filtered tree sets itself GridData, so set layout to gridlayout
parent.setLayout(GridLayoutFactory.fillDefaults().create());
// create pattern filter for FilteredTree
PatternFilter filter = new PatternFilter();
// create FilteredTree
FilteredTree filteredTree = new FilteredTree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL, filter, true);
treeViewer = filteredTree.getViewer();
// set content provider
treeViewer.setContentProvider(new ReportTreeContentProvider());
// set label provider
treeViewer.setLabelProvider(new ReportTreeLabelProvider() {
@Override
public MessageType getMessageType(Message message) {
// the current message type
return messageType;
}
});
// add menu on right-click
MenuManager menuMgr = new MenuManager();
Menu menu = menuMgr.createContextMenu(treeViewer.getTree());
menuMgr.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager manager) {
if (treeViewer.getSelection() instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
Object o = selection.getFirstElement();
if (o instanceof Message) {
Message m = (Message) o;
// check if a stacktrace exists
if (m.getStackTrace() != null && !m.getStackTrace().equals("")) {
// add Action to the menu
manager.add(new ShowStackTraceAction("Show Stack Trace", null, m));
}
}
}
}
});
// remove previous menus
menuMgr.setRemoveAllWhenShown(true);
// add menu to viewer
treeViewer.getTree().setMenu(menu);
// open stacktrace on double click
treeViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
TreeSelection o = (TreeSelection) event.getSelection();
if (o.getFirstElement() instanceof Message) {
Message m = (Message) o.getFirstElement();
DefaultReportDetailsPage.this.onDoubleClick(m);
}
}
});
return filteredTree;
}
Aggregations