use of net.sourceforge.pmd.eclipse.ui.model.PackageRecord in project pmd-eclipse-plugin by pmd.
the class ViolationOverview method newProjectNameSorter.
/**
* Build a sorter for the project name column.
*
* @param column
* @param sortOrder
* @return
*/
private ViewerSorter newProjectNameSorter(TreeColumn column, final int sortOrder) {
return new TableColumnSorter(column, sortOrder) {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
AbstractPMDRecord project1;
AbstractPMDRecord project2;
int result = 0;
if (e1 instanceof PackageRecord && e2 instanceof PackageRecord) {
project1 = ((PackageRecord) e1).getParent();
project2 = ((PackageRecord) e2).getParent();
result = project1.getName().compareToIgnoreCase(project2.getName()) * sortOrder;
}
return result;
}
};
}
use of net.sourceforge.pmd.eclipse.ui.model.PackageRecord in project pmd-eclipse-plugin by pmd.
the class ViolationOverview method treeExpanded.
/**
* Calculates the LOC of the expanded file record.
*
* @see org.eclipse.jface.viewers.ITreeViewerListener#treeExpanded(org.eclipse.jface.viewers.TreeExpansionEvent)
*/
public void treeExpanded(TreeExpansionEvent event) {
Object object = event.getElement();
if (object instanceof PackageRecord) {
PackageRecord record = (PackageRecord) object;
AbstractPMDRecord[] children = record.getChildren();
for (AbstractPMDRecord element : children) {
if (element instanceof FileRecord) {
FileRecord fileRecord = (FileRecord) element;
fileRecord.calculateLinesOfCode();
fileRecord.calculateNumberOfMethods();
}
}
}
// refresh the labels in the table
Display.getDefault().asyncExec(new Runnable() {
public void run() {
getViewer().refresh();
}
});
}
use of net.sourceforge.pmd.eclipse.ui.model.PackageRecord 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.PackageRecord 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;
}
use of net.sourceforge.pmd.eclipse.ui.model.PackageRecord 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);
}
}
Aggregations