Search in sources :

Example 6 with RulePriority

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)));
    }
}
Also used : PriorityDescriptor(net.sourceforge.pmd.eclipse.ui.priority.PriorityDescriptor) RulePriority(net.sourceforge.pmd.RulePriority) HashMap(java.util.HashMap) Map(java.util.Map)

Example 7 with RulePriority

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]));
    }
}
Also used : PriorityFilterAction(net.sourceforge.pmd.eclipse.ui.views.actions.PriorityFilterAction) RulePriority(net.sourceforge.pmd.RulePriority)

Example 8 with RulePriority

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);
    }
}
Also used : DisableRuleAction(net.sourceforge.pmd.eclipse.ui.views.actions.DisableRuleAction) ReviewAction(net.sourceforge.pmd.eclipse.ui.views.actions.ReviewAction) PriorityFilterAction(net.sourceforge.pmd.eclipse.ui.views.actions.PriorityFilterAction) Action(org.eclipse.jface.action.Action) RemoveViolationAction(net.sourceforge.pmd.eclipse.ui.views.actions.RemoveViolationAction) ShowRuleAction(net.sourceforge.pmd.eclipse.ui.views.actions.ShowRuleAction) QuickFixAction(net.sourceforge.pmd.eclipse.ui.views.actions.QuickFixAction) PriorityFilterAction(net.sourceforge.pmd.eclipse.ui.views.actions.PriorityFilterAction) IMenuManager(org.eclipse.jface.action.IMenuManager) RulePriority(net.sourceforge.pmd.RulePriority)

Example 9 with RulePriority

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;
}
Also used : HashMap(java.util.HashMap) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) RulePriority(net.sourceforge.pmd.RulePriority)

Example 10 with RulePriority

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;
}
Also used : HashMap(java.util.HashMap) RulePriority(net.sourceforge.pmd.RulePriority) Rule(net.sourceforge.pmd.Rule) XPathRule(net.sourceforge.pmd.lang.rule.XPathRule) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

RulePriority (net.sourceforge.pmd.RulePriority)13 HashMap (java.util.HashMap)5 Map (java.util.Map)4 PriorityDescriptor (net.sourceforge.pmd.eclipse.ui.priority.PriorityDescriptor)3 IPreferences (net.sourceforge.pmd.eclipse.runtime.preferences.IPreferences)2 PriorityFilterAction (net.sourceforge.pmd.eclipse.ui.views.actions.PriorityFilterAction)2 GridData (org.eclipse.swt.layout.GridData)2 VBox (javafx.scene.layout.VBox)1 Text (javafx.scene.text.Text)1 TextFlow (javafx.scene.text.TextFlow)1 HBox (jfxtras.scene.layout.HBox)1 Rule (net.sourceforge.pmd.Rule)1 IPreferencesManager (net.sourceforge.pmd.eclipse.runtime.preferences.IPreferencesManager)1 LabelProvider (net.sourceforge.pmd.eclipse.ui.LabelProvider)1 ShapePicker (net.sourceforge.pmd.eclipse.ui.ShapePicker)1 PriorityDescriptorCache (net.sourceforge.pmd.eclipse.ui.priority.PriorityDescriptorCache)1 DisableRuleAction (net.sourceforge.pmd.eclipse.ui.views.actions.DisableRuleAction)1 QuickFixAction (net.sourceforge.pmd.eclipse.ui.views.actions.QuickFixAction)1 RemoveViolationAction (net.sourceforge.pmd.eclipse.ui.views.actions.RemoveViolationAction)1 ReviewAction (net.sourceforge.pmd.eclipse.ui.views.actions.ReviewAction)1