Search in sources :

Example 6 with FileRecord

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

the class MarkerUtil method allMarkedFiles.

public static Set<IFile> allMarkedFiles(RootRecord root) {
    gatherRuleNames();
    Set<IFile> files = new HashSet<IFile>();
    for (AbstractPMDRecord projectRecord : root.getChildren()) {
        for (AbstractPMDRecord packageRecord : projectRecord.getChildren()) {
            for (AbstractPMDRecord fileRecord : packageRecord.getChildren()) {
                ((FileRecord) fileRecord).updateChildren();
                for (AbstractPMDRecord mRecord : fileRecord.getChildren()) {
                    MarkerRecord markerRecord = (MarkerRecord) mRecord;
                    for (IMarker marker : markerRecord.findMarkers()) {
                        Rule rule = ruleFrom(marker);
                        if (rule == null) {
                            continue;
                        }
                        files.add((IFile) fileRecord.getResource());
                        break;
                    }
                }
            }
        }
    }
    return files;
}
Also used : IFile(org.eclipse.core.resources.IFile) MarkerRecord(net.sourceforge.pmd.eclipse.ui.model.MarkerRecord) FileRecord(net.sourceforge.pmd.eclipse.ui.model.FileRecord) IMarker(org.eclipse.core.resources.IMarker) Rule(net.sourceforge.pmd.Rule) HashSet(java.util.HashSet) AbstractPMDRecord(net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord)

Example 7 with FileRecord

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

the class AbstractResourceView method getResourcePath.

protected IPath getResourcePath() {
    AbstractStructureInspectorPage page = getCurrentViewPage();
    FileRecord record = page.getFileRecord();
    IResource resource = record.getResource();
    return resource.getFullPath();
}
Also used : FileRecord(net.sourceforge.pmd.eclipse.ui.model.FileRecord) IResource(org.eclipse.core.resources.IResource)

Example 8 with FileRecord

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

the class AbstractResourceView method doDestroyPage.

@Override
protected void doDestroyPage(IWorkbenchPart part, PageRec pageRecord) {
    FileRecord resourceRecord = getFileRecordFromWorkbenchPart(part);
    if (resourceRecord != null) {
        resourceRecord.getResource().getWorkspace().removeResourceChangeListener(this);
    }
    AbstractStructureInspectorPage page = (AbstractStructureInspectorPage) pageRecord.page;
    if (page != null) {
        page.dispose();
    }
    pageRecord.dispose();
}
Also used : FileRecord(net.sourceforge.pmd.eclipse.ui.model.FileRecord)

Example 9 with FileRecord

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

the class ViolationOverviewContentProvider method getParent.

/**
 * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
 */
public Object getParent(Object element) {
    Object parent = null;
    AbstractPMDRecord record = (AbstractPMDRecord) element;
    switch(violationView.getShowType()) {
        case ViolationOverview.SHOW_FILES_MARKERS:
            if (element instanceof FileRecord) {
                parent = root;
            } else {
                parent = record.getParent();
            }
            break;
        case ViolationOverview.SHOW_MARKERS_FILES:
            if (element instanceof FileToMarkerRecord) {
                parent = record.getParent();
            } else if (element instanceof PackageRecord) {
                parent = root;
            } else if (element instanceof MarkerRecord) {
                parent = record.getParent().getParent();
            }
            break;
        case ViolationOverview.SHOW_PACKAGES_FILES_MARKERS:
            if (element instanceof PackageRecord) {
                parent = root;
            } else {
                parent = record.getParent();
            }
            break;
        default:
    }
    return parent;
}
Also used : FileToMarkerRecord(net.sourceforge.pmd.eclipse.ui.model.FileToMarkerRecord) MarkerRecord(net.sourceforge.pmd.eclipse.ui.model.MarkerRecord) FileRecord(net.sourceforge.pmd.eclipse.ui.model.FileRecord) PackageRecord(net.sourceforge.pmd.eclipse.ui.model.PackageRecord) FileToMarkerRecord(net.sourceforge.pmd.eclipse.ui.model.FileToMarkerRecord) AbstractPMDRecord(net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord)

Example 10 with FileRecord

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

the class ViolationOverviewDoubleClickListener method doubleClick.

/**
 * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
 */
public void doubleClick(DoubleClickEvent event) {
    final IStructuredSelection selection = (IStructuredSelection) event.getSelection();
    final Object object = selection.getFirstElement();
    if (object instanceof PackageRecord) {
        doubleClickToPackageRecord((PackageRecord) object);
    } else if (object instanceof FileRecord) {
        doubleClickToFileRecord((FileRecord) object);
    } else if (object instanceof MarkerRecord) {
        doubleClickToMarkerRecord((MarkerRecord) object);
    } else if (object instanceof FileToMarkerRecord) {
        doubleClickToFileToMarkerRecord((FileToMarkerRecord) object);
    }
}
Also used : FileToMarkerRecord(net.sourceforge.pmd.eclipse.ui.model.FileToMarkerRecord) MarkerRecord(net.sourceforge.pmd.eclipse.ui.model.MarkerRecord) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PackageRecord(net.sourceforge.pmd.eclipse.ui.model.PackageRecord) FileRecord(net.sourceforge.pmd.eclipse.ui.model.FileRecord) FileToMarkerRecord(net.sourceforge.pmd.eclipse.ui.model.FileToMarkerRecord)

Aggregations

FileRecord (net.sourceforge.pmd.eclipse.ui.model.FileRecord)15 AbstractPMDRecord (net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord)8 PackageRecord (net.sourceforge.pmd.eclipse.ui.model.PackageRecord)8 MarkerRecord (net.sourceforge.pmd.eclipse.ui.model.MarkerRecord)7 FileToMarkerRecord (net.sourceforge.pmd.eclipse.ui.model.FileToMarkerRecord)5 IMarker (org.eclipse.core.resources.IMarker)2 IResource (org.eclipse.core.resources.IResource)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Rule (net.sourceforge.pmd.Rule)1 IFile (org.eclipse.core.resources.IFile)1 IProject (org.eclipse.core.resources.IProject)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 Image (org.eclipse.swt.graphics.Image)1