Search in sources :

Example 1 with ISearchResultViewEntry

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

the class RemoveResultAction method usePluralLabel.

private boolean usePluralLabel() {
    ISelection s = fSelectionProvider.getSelection();
    if (s == null || s.isEmpty() || !(s instanceof IStructuredSelection))
        return false;
    IStructuredSelection selection = (IStructuredSelection) s;
    if (selection.size() != 1)
        return true;
    Object firstElement = selection.getFirstElement();
    if (firstElement instanceof ISearchResultViewEntry)
        return ((ISearchResultViewEntry) firstElement).getMatchCount() > 1;
    return false;
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISearchResultViewEntry(org.eclipse.search.ui.ISearchResultViewEntry)

Example 2 with ISearchResultViewEntry

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

the class SearchResultViewEntryAdapterFactory method getAdapter.

@SuppressWarnings("unchecked")
@Override
public <T> T getAdapter(Object element, Class<T> key) {
    ISearchResultViewEntry entry = (ISearchResultViewEntry) element;
    if (IMarker.class.equals(key)) {
        return (T) entry.getSelectedMarker();
    }
    if (IResource.class.equals(key)) {
        IResource resource = entry.getResource();
        /*
			 * This is a trick to filter out dummy markers that
			 * have been attached to a project because there is no
			 * corresponding resource in the workspace.
			 */
        int type = resource.getType();
        if (type != IResource.PROJECT && type != IResource.ROOT)
            return (T) resource;
    }
    return null;
}
Also used : ISearchResultViewEntry(org.eclipse.search.ui.ISearchResultViewEntry) IResource(org.eclipse.core.resources.IResource)

Example 3 with ISearchResultViewEntry

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

the class SearchResultViewer method isPotentialMatchSelected.

private boolean isPotentialMatchSelected() {
    if (getSelectedEntriesCount() == 0)
        return false;
    Iterator<?> iter = Collections.emptyList().iterator();
    ISelection selection = getSelection();
    if (selection instanceof IStructuredSelection)
        iter = ((IStructuredSelection) selection).iterator();
    while (iter.hasNext()) {
        Object entry = iter.next();
        if (entry instanceof ISearchResultViewEntry) {
            IMarker marker = ((ISearchResultViewEntry) entry).getSelectedMarker();
            if (marker != null && marker.getAttribute(SearchUI.POTENTIAL_MATCH, false))
                return true;
        }
    }
    return false;
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IMarker(org.eclipse.core.resources.IMarker) ISearchResultViewEntry(org.eclipse.search.ui.ISearchResultViewEntry)

Example 4 with ISearchResultViewEntry

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

the class SearchResultViewer method updateStatusLine.

void updateStatusLine() {
    boolean hasSingleSelection = getSelectedEntriesCount() == 1;
    // $NON-NLS-1$
    String location = "";
    if (hasSingleSelection) {
        ISearchResultViewEntry entry = (ISearchResultViewEntry) getTable().getItem(getTable().getSelectionIndex()).getData();
        IPath path = entry.getResource().getFullPath();
        if (path != null)
            location = path.makeRelative().toString();
    }
    setStatusLineMessage(location);
}
Also used : IPath(org.eclipse.core.runtime.IPath) ISearchResultViewEntry(org.eclipse.search.ui.ISearchResultViewEntry)

Example 5 with ISearchResultViewEntry

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

the class FileLabelProvider method getImage.

@Override
public Image getImage(Object element) {
    if (!(element instanceof ISearchResultViewEntry))
        return null;
    IResource resource = ((ISearchResultViewEntry) element).getResource();
    Image image = fLabelProvider.getImage(resource);
    if (fDecorator != null) {
        Image decoratedImage = fDecorator.decorateImage(image, resource);
        if (decoratedImage != null)
            return decoratedImage;
    }
    return image;
}
Also used : Image(org.eclipse.swt.graphics.Image) 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