use of net.sourceforge.pmd.RulePriority in project pmd-eclipse-plugin by pmd.
the class PreferencesManagerImpl method loadRulePriorityDescriptors.
private void loadRulePriorityDescriptors() {
for (Map.Entry<RulePriority, String> entry : STORE_KEYS_BY_PRIORITY.entrySet()) {
PriorityDescriptor desc = defaultDescriptorFor(entry.getKey());
loadPreferencesStore.setDefault(entry.getValue(), desc.storeString());
String storeKey = STORE_KEYS_BY_PRIORITY.get(entry.getKey());
preferences.setPriorityDescriptor(entry.getKey(), PriorityDescriptor.from(loadPreferencesStore.getString(storeKey)));
}
}
use of net.sourceforge.pmd.RulePriority in project pmd-eclipse-plugin by pmd.
the class ViolationOverviewMenuManager method setupActions.
/**
* Setup the Actions for the ActionBars
*/
public void setupActions() {
RulePriority[] priorities = UISettings.currentPriorities(true);
priorityActions = new PriorityFilterAction[priorities.length];
// create the Actions for the PriorityFilter
for (int i = 0; i < priorities.length; i++) {
// NOPMD by Herlin on 09/10/06 15:02
priorityActions[i] = new PriorityFilterAction(priorities[i], overview);
priorityActions[i].setChecked(PriorityUtil.isPriorityActive(priorities[i]));
}
}
use of net.sourceforge.pmd.RulePriority in project pmd-eclipse-plugin by pmd.
the class ViolationOutline method addFilterControls.
/**
* Creates a DropDownMenu for the view
*/
private void addFilterControls() {
IMenuManager manager = getViewSite().getActionBars().getMenuManager();
List<Integer> filterList = priorityFilter.getPriorityFilterList();
// we add the PriorityFilter-Actions to this Menu
RulePriority[] priorities = UISettings.currentPriorities(true);
for (RulePriority priority : priorities) {
Action filterAction = new PriorityFilterAction(priority, this);
if (filterList.contains(priority.getPriority())) {
filterAction.setChecked(true);
}
manager.add(filterAction);
}
}
use of net.sourceforge.pmd.RulePriority in project pmd-eclipse-plugin by pmd.
the class UISettings method markerImgDescriptorsByPriority.
public static Map<Integer, ImageDescriptor> markerImgDescriptorsByPriority() {
RulePriority[] priorities = currentPriorities(true);
Map<Integer, ImageDescriptor> overlaysByPriority = new HashMap<Integer, ImageDescriptor>(priorities.length);
for (RulePriority priority : priorities) {
overlaysByPriority.put(priority.getPriority(), markerDescriptorFor(priority));
}
return overlaysByPriority;
}
use of net.sourceforge.pmd.RulePriority in project pmd-eclipse-plugin by pmd.
the class RuleUtil method fractionsByPriority.
/**
*/
public static Map<RulePriority, Float> fractionsByPriority(RuleCollection collection) {
if (collection.isEmpty()) {
return Collections.emptyMap();
}
final Map<RulePriority, Integer> priorityCounts = new HashMap<RulePriority, Integer>(5);
final int[] count = new int[1];
RuleVisitor visitor = new RuleVisitor() {
public boolean accept(Rule rule) {
RulePriority priority = rule.getPriority();
count[0] = count[0] + 1;
Integer count = priorityCounts.get(priority);
if (count == null) {
priorityCounts.put(priority, Integer.valueOf(1));
} else {
priorityCounts.put(priority, Integer.valueOf(count + 1));
}
return true;
}
};
collection.rulesDo(visitor);
int total = count[0];
Map<RulePriority, Float> priorityFractions = new HashMap<RulePriority, Float>();
for (Map.Entry<RulePriority, Integer> entry : priorityCounts.entrySet()) {
float fraction = (float) entry.getValue() / total;
priorityFractions.put(entry.getKey(), fraction);
}
return priorityFractions;
}
Aggregations