Skip to content

Commit 6338e99

Browse files
committed
When changing the PMD marker color, the annotation markers in the overview
ruler should use the same color
1 parent f98d1fb commit 6338e99

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/GeneralPreferencesPage.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.apache.log4j.Level;
1313
import org.eclipse.core.resources.IFile;
1414
import org.eclipse.core.resources.ResourcesPlugin;
15+
import org.eclipse.core.runtime.preferences.InstanceScope;
1516
import org.eclipse.jface.preference.ColorSelector;
1617
import org.eclipse.jface.preference.PreferenceDialog;
1718
import org.eclipse.jface.preference.PreferencePage;
@@ -48,6 +49,7 @@
4849
import org.eclipse.ui.IWorkbench;
4950
import org.eclipse.ui.IWorkbenchPreferencePage;
5051
import org.eclipse.ui.dialogs.PreferencesUtil;
52+
import org.eclipse.ui.preferences.ScopedPreferenceStore;
5153

5254
import net.sourceforge.pmd.PMD;
5355
import net.sourceforge.pmd.RulePriority;
@@ -821,13 +823,23 @@ private void updateMarkerIcons() {
821823

822824
PriorityDescriptorCache.INSTANCE.storeInPreferences();
823825

826+
// refresh the resources so that the rule label decorator is updated
824827
RootRecord root = new RootRecord(ResourcesPlugin.getWorkspace().getRoot());
825828
Set<IFile> files = MarkerUtil.allMarkedFiles(root);
826829
PMDPlugin.getDefault().changedFiles(files);
827830

828-
/* Refresh the views to pick up the marker change */
831+
// Refresh the views to pick up the marker change
829832
PMDPlugin.getDefault().refreshView(PMDPlugin.VIOLATIONS_OVERVIEW_ID);
830-
PMDPlugin.getDefault().refreshView(PMDPlugin.VIOLATIONS_OUTLINE_ID);
833+
PMDPlugin.getDefault().refreshView(PMDPlugin.VIOLATIONS_OUTLINE_ID);
834+
835+
// Take the color to set the overview ruler color
836+
// net.sourceforge.pmd.eclipse.plugin.annotation.prio1.color
837+
ScopedPreferenceStore editorsPreferenceStore = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.eclipse.ui.editors");
838+
for (RulePriority priority : RulePriority.values()) {
839+
PriorityDescriptor descriptor = PriorityDescriptorCache.INSTANCE.descriptorFor(priority);
840+
editorsPreferenceStore.setValue("net.sourceforge.pmd.eclipse.plugin.annotation.prio" + priority.getPriority() + ".color",
841+
descriptor.shape.rgbColor.red + "," + descriptor.shape.rgbColor.green + "," + descriptor.shape.rgbColor.blue);
842+
}
831843
}
832844

833845
public boolean performCancel() {

0 commit comments

Comments
 (0)