use of net.sourceforge.pmd.eclipse.ui.model.ProjectRecord in project pmd-eclipse-plugin by pmd.
the class ViolationOverviewMenuManager method createProjectFilterMenu.
/**
* Create the Menu for filtering Projects
*
* @param manager, the MenuManager
*/
private void createProjectFilterMenu(IMenuManager manager) {
final List<AbstractPMDRecord> projectFilterList = this.overview.getProjectFilterList();
final List<ProjectRecord> projectList = new ArrayList<ProjectRecord>();
// We get a List of all Projects
final AbstractPMDRecord[] projects = this.overview.getAllProjects();
for (int i = 0; i < projects.length; i++) {
final ProjectRecord project = (ProjectRecord) projects[i];
// we add a FilterAction for it
if (project.hasMarkers()) {
// NOPMD by Herlin on 09/10/06 15:03
final Action projectFilterAction = new ProjectFilterAction(project, this.overview);
// we set it as "visible"
if (!projectFilterList.contains(projects[i])) {
// NOPMD by Herlin on 09/10/06 15:04
projectFilterAction.setChecked(true);
}
manager.add(projectFilterAction);
projectList.add(project);
}
}
manager.add(new Separator());
}
use of net.sourceforge.pmd.eclipse.ui.model.ProjectRecord in project pmd-eclipse-plugin by pmd.
the class ChangeEvaluator method changeRecordFor.
public ChangeRecord<AbstractPMDRecord> changeRecordFor(IResourceChangeEvent event) {
List<IMarkerDelta> markerDeltas = MarkerUtil.markerDeltasIn(event);
// first we get a List of changes to Files and Projects so we won't be
// updating everything
List<IResource> changedFiles = new ArrayList<IResource>();
List<IProject> changedProjects = new ArrayList<IProject>();
for (IMarkerDelta markerDelta : markerDeltas) {
IResource resource = markerDelta.getResource();
IProject project = resource.getProject();
// the lists should not contain Projects or Resources twice
if (!changedFiles.contains(resource)) {
changedFiles.add(resource);
// LOG.debug("Resource " + resource.getName() + " has changed");
}
if (!changedProjects.contains(project)) {
changedProjects.add(project);
// LOG.debug("Project " + project.getName() + " has changed");
}
}
// we can add, change, or remove Resources
// all the changes are given to the viewer later
ChangeRecord<AbstractPMDRecord> changeRec = new ChangeRecord<AbstractPMDRecord>();
// we go through the changed Projects
for (IProject project : changedProjects) {
// LOG.debug("Processing changes for project " + project.getName());
ProjectRecord projectRec = (ProjectRecord) root.findResource(project);
// Model and go on
if (!(project.isOpen() && project.isAccessible())) {
// LOG.debug("The project is not open or not accessible. Remove
// it");
List<AbstractPMDRecord>[] array = updateFiles(project, changedFiles);
changeRec.removed(array[1]);
root.removeResource(project);
} else if (projectRec == null) {
// if we couldn't find the Project then it has to be new
// LOG.debug("Cannot find a project record for it. Add it.");
projectRec = (ProjectRecord) root.addResource(project);
}
// then we can update the Files for the new or updated Project
List<AbstractPMDRecord>[] array = updateFiles(project, changedFiles);
changeRec.added(array[0]);
changeRec.removed(array[1]);
changeRec.changed(array[2]);
}
return changeRec;
}
use of net.sourceforge.pmd.eclipse.ui.model.ProjectRecord in project pmd-eclipse-plugin by pmd.
the class ChangeEvaluator method updateFiles.
/**
* Updates the Files for a given Project
*
* @param project
* @param changedFiles,
* a List of all changed Files
* @return an List of Lists containing additions [0], removals [1] and
* changes [2] (Array-Position in Brackets)
*/
private List<AbstractPMDRecord>[] updateFiles(IProject project, List<IResource> changedFiles) {
// TODO use ChangeRecord
List<AbstractPMDRecord> additions = new ArrayList<AbstractPMDRecord>();
List<AbstractPMDRecord> removals = new ArrayList<AbstractPMDRecord>();
List<AbstractPMDRecord> changes = new ArrayList<AbstractPMDRecord>();
List<AbstractPMDRecord>[] updatedFiles = new List[] { additions, removals, changes };
// we search for the ProjectRecord to the Project
// if it doesn't exist, we return nothing
ProjectRecord projectRec = (ProjectRecord) root.findResource(project);
// we got through all files
if (projectRec != null && project.isAccessible()) {
updatedFiles = searchProjectForModifications(projectRec, changedFiles);
} else if (projectRec != null) {
// if the project is deleted or closed
List<AbstractPMDRecord> packages = projectRec.getChildrenAsList();
// ... we add all Packages to the removals so they are not shown
// anymore
removals.addAll(packages);
for (int k = 0; k < packages.size(); k++) {
PackageRecord packageRec = (PackageRecord) packages.get(k);
removals.addAll(packageRec.getChildrenAsList());
}
updatedFiles = new List[] { additions, removals, changes };
}
return updatedFiles;
}
use of net.sourceforge.pmd.eclipse.ui.model.ProjectRecord in project pmd-eclipse-plugin by pmd.
the class ViolationOverviewContentProvider method getChildrenOfRoot.
/**
* Gets the children of the root depending on the show type.
*
* @return children
*/
private Object[] getChildrenOfRoot() {
// ... we care about its Project's
List<AbstractPMDRecord> projects = root.getChildrenAsList();
ProjectRecord[] projectArray = new ProjectRecord[projects.size()];
projects.toArray(projectArray);
// we make a List of all Packages
List<AbstractPMDRecord> packages = new ArrayList<AbstractPMDRecord>();
for (ProjectRecord element : projectArray) {
if (element.isProjectOpen()) {
packages.addAll(element.getChildrenAsList());
}
}
switch(violationView.getShowType()) {
case ViolationOverview.SHOW_MARKERS_FILES:
case ViolationOverview.SHOW_PACKAGES_FILES_MARKERS:
// show packages
return packages.toArray();
case ViolationOverview.SHOW_FILES_MARKERS:
// show files
List<AbstractPMDRecord> files = new ArrayList<AbstractPMDRecord>();
for (AbstractPMDRecord packageRec : packages) {
files.addAll(packageRec.getChildrenAsList());
}
return files.toArray();
default:
}
return Util.EMPTY_ARRAY;
}
Aggregations