Search in sources :

Example 6 with ISearchResultViewEntry

use of org.eclipse.search.ui.ISearchResultViewEntry in project eclipse.platform.text by eclipse.

the class RemoveMatchAction method getMarkers.

private IMarker[] getMarkers(ISelection s) {
    if (!(s instanceof IStructuredSelection) || s.isEmpty())
        return null;
    IStructuredSelection selection = (IStructuredSelection) s;
    int size = selection.size();
    if (size != 1)
        return null;
    if (selection.getFirstElement() instanceof ISearchResultViewEntry) {
        IMarker marker = ((ISearchResultViewEntry) selection.getFirstElement()).getSelectedMarker();
        if (marker != null)
            return new IMarker[] { marker };
    }
    return null;
}
Also used : IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IMarker(org.eclipse.core.resources.IMarker) ISearchResultViewEntry(org.eclipse.search.ui.ISearchResultViewEntry)

Example 7 with ISearchResultViewEntry

use of org.eclipse.search.ui.ISearchResultViewEntry in project eclipse.platform.text by eclipse.

the class FileLabelProvider method getText.

@Override
public String getText(Object element) {
    if (!(element instanceof ISearchResultViewEntry))
        // $NON-NLS-1$
        return "";
    IResource resource = ((ISearchResultViewEntry) element).getResource();
    String text = null;
    if (resource == null || !resource.exists())
        text = SearchMessages.SearchResultView_removed_resource;
    else {
        IPath path = resource.getFullPath().removeLastSegments(1);
        if (path.getDevice() == null)
            path = path.makeRelative();
        if (fOrder == SHOW_LABEL || fOrder == SHOW_LABEL_PATH) {
            text = fLabelProvider.getText(resource);
            if (path != null && fOrder == SHOW_LABEL_PATH) {
                fArgs[0] = text;
                fArgs[1] = path.toString();
                text = MessageFormat.format(fgSeparatorFormat, fArgs);
            }
        } else {
            if (path != null)
                text = path.toString();
            else
                // $NON-NLS-1$
                text = "";
            if (fOrder == SHOW_PATH_LABEL) {
                fArgs[0] = text;
                fArgs[1] = fLabelProvider.getText(resource);
                text = MessageFormat.format(fgSeparatorFormat, fArgs);
            }
        }
    }
    // Do the decoration
    if (fDecorator != null) {
        String decoratedText = fDecorator.decorateText(text, resource);
        if (decoratedText != null)
            return decoratedText;
    }
    return text;
}
Also used : IPath(org.eclipse.core.runtime.IPath) ISearchResultViewEntry(org.eclipse.search.ui.ISearchResultViewEntry) IResource(org.eclipse.core.resources.IResource)

Aggregations

ISearchResultViewEntry (org.eclipse.search.ui.ISearchResultViewEntry)7 IResource (org.eclipse.core.resources.IResource)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 IMarker (org.eclipse.core.resources.IMarker)2 IPath (org.eclipse.core.runtime.IPath)2 ISelection (org.eclipse.jface.viewers.ISelection)2 Image (org.eclipse.swt.graphics.Image)1