use of alma.acs.eventbrowser.parts.ChannelTreeProviders.ChannelTreeLabelProvider in project ACS by ACS-Community.
the class ChannelTreePart method postConstruct.
/**
* See http://www.vogella.com/articles/EclipseJFaceTree/article.html
*/
@PostConstruct
public void postConstruct(Composite parent, final IEclipseContext context, EMenuService menuService, IEventBroker eventBroker) {
try {
eventModel = EventModel.getInstance();
} catch (Throwable thr) {
thr.printStackTrace();
IStatus someStatus = statusReporter.newStatus(IStatus.ERROR, "Connection with NCs failed.", thr);
statusReporter.report(someStatus, StatusReporter.SHOW);
throw new RuntimeException(thr);
}
// eventModel.getLogger().info("ChannelTreePart got EventModel instance.");
statusLineWriter = new StatusLineWriter(eventBroker);
viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
viewer.setContentProvider(new ChannelTreeContentProvider());
viewer.setLabelProvider(new ChannelTreeLabelProvider());
// Expand the tree. '2' means to show only the visible top-level nodes.
viewer.setAutoExpandLevel(2);
viewer.setComparator(new ServiceViewerComparator());
// Provide the root node to the ContentProvider
viewer.setInput(eventModel.getNotifyServicesRoot());
// Expand with doubleclick
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
IStructuredSelection thisSelection = (IStructuredSelection) event.getSelection();
Object selectedNode = thisSelection.getFirstElement();
viewer.setExpandedState(selectedNode, !viewer.getExpandedState(selectedNode));
}
});
// Attach a selection listener to our tree that will post selections to the ESelectionService
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
selectionService.setSelection(selection.size() == 1 ? selection.getFirstElement() : selection.toArray());
}
});
// TODO: Take care of help system. Here's the E3 code:
// // Create the help context id for the viewer's control
// PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "alma.acs.eventbrowser.viewer");
hookContextMenu(menuService);
// TODO: this could be used by handlers etc, currently it's not
context.set(ChannelTreePart.class, this);
}
Aggregations