use of net.sourceforge.pmd.eclipse.ui.model.PackageRecord in project pmd-eclipse-plugin by pmd.
the class ViolationOverviewLabelProvider method getProjectName.
/**
* Return the project name.
*
* @param element
* @return
*/
private String getProjectName(Object element) {
String projectName = "";
AbstractPMDRecord projectRec = null;
if (element instanceof PackageRecord) {
projectRec = ((PackageRecord) element).getParent();
} else if (element instanceof FileRecord) {
projectRec = ((FileRecord) element).getParent().getParent();
} else if (element instanceof MarkerRecord) {
projectRec = ((MarkerRecord) element).getParent().getParent().getParent();
} else if (element instanceof FileToMarkerRecord) {
projectRec = ((FileToMarkerRecord) element).getParent().getParent().getParent().getParent();
}
if (projectRec != null) {
projectName = projectRec.getName();
}
return projectName;
}
use of net.sourceforge.pmd.eclipse.ui.model.PackageRecord in project pmd-eclipse-plugin by pmd.
the class ViolationOverviewLabelProvider method getColumnImage.
/**
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object,
* int)
*/
public Image getColumnImage(Object element, int columnIndex) {
Image image = null;
// the first column
if (columnIndex == 0) {
if (element instanceof PackageRecord) {
image = getImage(KEY_IMAGE_PACKAGE, PMDUiConstants.ICON_PACKAGE);
} else if (element instanceof FileRecord || element instanceof FileToMarkerRecord) {
image = getImage(KEY_IMAGE_JAVAFILE, PMDUiConstants.ICON_JAVACU);
} else if (element instanceof MarkerRecord) {
MarkerRecord markerRecord = (MarkerRecord) element;
int priority = markerRecord.getPriority();
image = getPriorityImage(priority);
}
}
return image;
}
use of net.sourceforge.pmd.eclipse.ui.model.PackageRecord 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;
}
use of net.sourceforge.pmd.eclipse.ui.model.PackageRecord in project pmd-eclipse-plugin by pmd.
the class ProjectFilter 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 = true;
AbstractPMDRecord projectRec = null;
if (element instanceof PackageRecord) {
projectRec = ((PackageRecord) element).getParent();
} else if (element instanceof FileRecord) {
projectRec = ((FileRecord) element).getParent().getParent();
} else if (element instanceof MarkerRecord) {
projectRec = ((MarkerRecord) element).getParent().getParent().getParent();
}
// we don't want the Element to be shown
if (projectFilterList.contains(projectRec)) {
select = false;
}
return select;
}
use of net.sourceforge.pmd.eclipse.ui.model.PackageRecord in project pmd-eclipse-plugin by pmd.
the class CalculateStatisticsAction method run.
/**
* Executes the Action
*/
public void run() {
try {
final ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
dialog.setCancelable(true);
dialog.run(false, false, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
final TreeItem[] items = getViewer().getTree().getItems();
final int unitCount = calculateWorkUnits(items);
monitor.beginTask(getString(StringKeys.MONITOR_CALC_STATS_TASK), unitCount);
for (TreeItem item : items) {
if (monitor.isCanceled()) {
break;
}
if (item.getData() instanceof PackageRecord) {
final PackageRecord record = (PackageRecord) item.getData();
final AbstractPMDRecord[] children = record.getChildren();
monitor.subTask(getString(StringKeys.MONITOR_CALC_STATS_OF_PACKAGE) + ": " + record.getName());
for (AbstractPMDRecord kid : children) {
if (kid instanceof FileRecord) {
calculateFileRecord((FileRecord) kid);
monitor.worked(1);
}
}
} else if (item.getData() instanceof FileRecord) {
calculateFileRecord((FileRecord) item.getData());
monitor.worked(1);
}
}
getViewer().refresh(true);
}
});
} catch (InvocationTargetException e) {
logErrorByKey(StringKeys.ERROR_INVOCATIONTARGET_EXCEPTION, e);
} catch (InterruptedException e) {
logErrorByKey(StringKeys.ERROR_INTERRUPTED_EXCEPTION, e);
}
}
Aggregations