Search in sources :

Example 1 with TreeContentProvider

use of org.eclipse.titan.log.viewer.search.TreeContentProvider in project titan.EclipsePlug-ins by eclipse.

the class LogSearchResultPage method configureTreeViewer.

@Override
protected void configureTreeViewer(final TreeViewer viewer) {
    treeViewer = viewer;
    contentProvider = new TreeContentProvider(this);
    viewer.setContentProvider(contentProvider);
    viewer.setLabelProvider(new SearchLabelProvider());
    viewer.setInput(ResourcesPlugin.getWorkspace().getRoot());
    treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            try {
                Object selectedElement = ((TreeSelection) event.getSelection()).getFirstElement();
                if (selectedElement instanceof Match) {
                    showMatch((Match) selectedElement, 0, 0, true);
                    return;
                }
            } catch (PartInitException e) {
                ErrorReporter.logExceptionStackTrace(e);
                // $NON-NLS-1$
                TitanLogExceptionHandler.handleException(new TechnicalException("Could not show the selected match. Reason: " + e.getMessage()));
            }
        }
    });
}
Also used : TreeContentProvider(org.eclipse.titan.log.viewer.search.TreeContentProvider) TechnicalException(org.eclipse.titan.log.viewer.exceptions.TechnicalException) SearchLabelProvider(org.eclipse.titan.log.viewer.search.SearchLabelProvider) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) PartInitException(org.eclipse.ui.PartInitException) Match(org.eclipse.search.ui.text.Match)

Aggregations

ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 Match (org.eclipse.search.ui.text.Match)1 TechnicalException (org.eclipse.titan.log.viewer.exceptions.TechnicalException)1 SearchLabelProvider (org.eclipse.titan.log.viewer.search.SearchLabelProvider)1 TreeContentProvider (org.eclipse.titan.log.viewer.search.TreeContentProvider)1 PartInitException (org.eclipse.ui.PartInitException)1