Search in sources :

Example 1 with ViolationOverview

use of net.sourceforge.pmd.eclipse.ui.views.ViolationOverview in project pmd-eclipse-plugin by pmd.

the class PMDRemoveMarkersAction method processElement.

private void processElement(Object element) throws CoreException {
    if (element instanceof AbstractPMDRecord) {
        final AbstractPMDRecord record = (AbstractPMDRecord) element;
        final IResource resource = record.getResource();
        if (isViolationOverview()) {
            ((ViolationOverview) targetPart()).deleteMarkers(record);
        }
        LOG.debug("Remove markers on resource " + resource.getName());
    } else if (element instanceof IAdaptable) {
        final IAdaptable adaptable = (IAdaptable) element;
        final IResource resource = (IResource) adaptable.getAdapter(IResource.class);
        if (resource == null) {
            LOG.warn("The selected object cannot adapt to a resource");
            LOG.debug("   -> selected object : " + element);
        } else {
            MarkerUtil.deleteAllMarkersIn(resource);
            LOG.debug("Remove markers on resrouce " + resource.getName());
        }
    } else {
        LOG.warn("The selected object is not adaptable");
        LOG.debug("   -> selected object : " + element);
    }
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) ViolationOverview(net.sourceforge.pmd.eclipse.ui.views.ViolationOverview) IResource(org.eclipse.core.resources.IResource) AbstractPMDRecord(net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord)

Aggregations

AbstractPMDRecord (net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord)1 ViolationOverview (net.sourceforge.pmd.eclipse.ui.views.ViolationOverview)1 IResource (org.eclipse.core.resources.IResource)1 IAdaptable (org.eclipse.core.runtime.IAdaptable)1