Search in sources :

Example 6 with FileToMarkerRecord

use of net.sourceforge.pmd.eclipse.ui.model.FileToMarkerRecord in project pmd-eclipse-plugin by pmd.

the class PriorityFilter method select.

/*
     * @see
     * org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.
     * Viewer, java.lang.Object, java.lang.Object)
     */
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
    boolean select = false;
    if (element instanceof PackageRecord) {
        // ViolationOverview
        select = hasMarkersToShow((PackageRecord) element);
    } else if (element instanceof FileRecord) {
        // ViolationOverview
        select = hasMarkersToShow((FileRecord) element);
    } else if (element instanceof IMarker) {
        // ViolationOutline
        try {
            final IMarker marker = (IMarker) element;
            final Integer markerPrio = (Integer) marker.getAttribute(PMDUiConstants.KEY_MARKERATT_PRIORITY);
            select = isPriorityEnabled(markerPrio);
        } catch (CoreException ce) {
            PMDPlugin.getDefault().logError(StringKeys.ERROR_CORE_EXCEPTION + this.toString(), ce);
        }
    } else if (element instanceof MarkerRecord) {
        // ViolationOverview
        final MarkerRecord markerRec = (MarkerRecord) element;
        for (Integer priority : priorityList) {
            if (markerRec.getPriority() == priority.intValue()) {
                select = true;
                break;
            }
        }
    } else if (element instanceof FileToMarkerRecord) {
        select = true;
    }
    return select;
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) FileToMarkerRecord(net.sourceforge.pmd.eclipse.ui.model.FileToMarkerRecord) MarkerRecord(net.sourceforge.pmd.eclipse.ui.model.MarkerRecord) PackageRecord(net.sourceforge.pmd.eclipse.ui.model.PackageRecord) FileRecord(net.sourceforge.pmd.eclipse.ui.model.FileRecord) IMarker(org.eclipse.core.resources.IMarker) FileToMarkerRecord(net.sourceforge.pmd.eclipse.ui.model.FileToMarkerRecord)

Aggregations

FileToMarkerRecord (net.sourceforge.pmd.eclipse.ui.model.FileToMarkerRecord)6 MarkerRecord (net.sourceforge.pmd.eclipse.ui.model.MarkerRecord)6 FileRecord (net.sourceforge.pmd.eclipse.ui.model.FileRecord)5 PackageRecord (net.sourceforge.pmd.eclipse.ui.model.PackageRecord)5 AbstractPMDRecord (net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord)3 IMarker (org.eclipse.core.resources.IMarker)2 CoreException (org.eclipse.core.runtime.CoreException)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 Image (org.eclipse.swt.graphics.Image)1