Revision: 7061
http://pmd.svn.sourceforge.net/pmd/?rev=7061&view=rev
Author: hooperbloob
Date: 2010-01-09 16:10:44 +0000 (Sat, 09 Jan 2010)
Log Message:
-----------
Priority column now uses compact icons, new property editor tester
Modified Paths:
--------------
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/ReviewCodeCmd.java
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/preferences/impl/PreferencesManagerImpl.java
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/actions/PMDRemoveMarkersAction.java
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/ImageColumnDescriptor.java
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/NewPropertyDialog.java
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/PMDPreferencePage.java
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/RuleFieldAccessor.java
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/TODO items
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/editors/AbstractMultiValueEditorFactory.java
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/editors/AbstractRealNumberEditor.java
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/ExclusionPanelManager.java
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/FormArranger.java
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/PerRulePropertyPanelManager.java
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/util/Util.java
Added Paths:
-----------
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/IconColumnDescriptor.java
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/Configuration.java
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/test/
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/test/net/
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/test/net/sourceforge/
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/test/net/sourceforge/pmd/
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/test/net/sourceforge/pmd/eclipse/
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/test/net/sourceforge/pmd/eclipse/ui/
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/test/net/sourceforge/pmd/eclipse/ui/preferences/
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/test/net/sourceforge/pmd/eclipse/ui/preferences/editors/
trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/test/net/sourceforge/pmd/eclipse/ui/preferences/editors/EditorTester.java
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/ReviewCodeCmd.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/ReviewCodeCmd.java 2010-01-08 17:16:35 UTC (rev 7060)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/ReviewCodeCmd.java 2010-01-09 16:10:44 UTC (rev 7061)
@@ -394,12 +394,12 @@
*/
private void applyMarkers() {
log.info("Processing marker directives");
- int violationsCount = 0;
+ int violationCount = 0;
final Timer timer = new Timer();
String currentFile = ""; // for logging
try {
- final Set<IFile> filesSet = this.markers.keySet();
+ final Set<IFile> filesSet = markers.keySet();
final Iterator<IFile> i = filesSet.iterator();
beginTask("PMD Applying markers", filesSet.size());
@@ -408,7 +408,7 @@
final IFile file = i.next();
currentFile = file.getName();
- final Set<MarkerInfo> markerInfoSet = this.markers.get(file);
+ final Set<MarkerInfo> markerInfoSet = markers.get(file);
file.deleteMarkers(PMDRuntimeConstants.PMD_MARKER, true, IResource.DEPTH_INFINITE);
file.deleteMarkers(PMDRuntimeConstants.PMD_DFA_MARKER, true, IResource.DEPTH_INFINITE);
final Iterator<MarkerInfo> j = markerInfoSet.iterator();
@@ -416,7 +416,7 @@
final MarkerInfo markerInfo = j.next();
final IMarker marker = file.createMarker(markerInfo.getType());
marker.setAttributes(markerInfo.getAttributeNames(), markerInfo.getAttributeValues());
- violationsCount++;
+ violationCount++;
}
worked(1);
@@ -428,10 +428,8 @@
} finally {
timer.stop();
PMDPlugin.getDefault().logInformation(
- "" + violationsCount + " markers applied on " + this.markers.size() + " files in " + timer.getDuration()
- + "ms.");
- log.info("End of processing marker directives. " + violationsCount + " violations for " + this.markers.size()
- + " files.");
+ "" + violationCount + " markers applied on " + markers.size() + " files in " + timer.getDuration() + "ms.");
+ log.info("End of processing marker directives. " + violationCount + " violations for " + markers.size() + " files.");
}
}
@@ -495,7 +493,7 @@
count++;
if (resource instanceof IFile && ((IFile) resource).getFileExtension() != null
- && ((IFile) resource).getFileExtension().equals("java")) {
+ && "JAVA".equalsIgnoreCase(((IFile) resource).getFileExtension())) {
fVisitChildren = false;
}
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/preferences/impl/PreferencesManagerImpl.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/preferences/impl/PreferencesManagerImpl.java 2010-01-08 17:16:35 UTC (rev 7060)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/preferences/impl/PreferencesManagerImpl.java 2010-01-09 16:10:44 UTC (rev 7061)
@@ -38,7 +38,6 @@
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/actions/PMDRemoveMarkersAction.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/actions/PMDRemoveMarkersAction.java 2010-01-08 17:16:35 UTC (rev 7060)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/actions/PMDRemoveMarkersAction.java 2010-01-09 16:10:44 UTC (rev 7061)
@@ -35,14 +35,15 @@
import java.util.Iterator;
+import net.sourceforge.pmd.eclipse.plugin.PMDPlugin;
import net.sourceforge.pmd.eclipse.runtime.PMDRuntimeConstants;
-import net.sourceforge.pmd.eclipse.plugin.PMDPlugin;
import net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord;
import net.sourceforge.pmd.eclipse.ui.nls.StringKeys;
import net.sourceforge.pmd.eclipse.ui.views.ViolationOverview;
import org.apache.log4j.Logger;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
@@ -83,8 +84,9 @@
log.info("Remove Markers action requested");
try {
if (action.getId().equals(VIEW_ACTION)) {
- ResourcesPlugin.getWorkspace().getRoot().deleteMarkers(PMDRuntimeConstants.PMD_MARKER, true, IResource.DEPTH_INFINITE);
- ResourcesPlugin.getWorkspace().getRoot().deleteMarkers(PMDRuntimeConstants.PMD_DFA_MARKER, true, IResource.DEPTH_INFINITE);
+ final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ root.deleteMarkers(PMDRuntimeConstants.PMD_MARKER, true, IResource.DEPTH_INFINITE);
+ root.deleteMarkers(PMDRuntimeConstants.PMD_DFA_MARKER, true, IResource.DEPTH_INFINITE);
log.debug("Remove markers on the entire workspace");
} else if (action.getId().equals(OBJECT_ACTION)) {
processResource();
@@ -138,8 +140,7 @@
((IFileEditorInput) editorInput).getFile().deleteMarkers(PMDRuntimeConstants.PMD_MARKER, true, IResource.DEPTH_INFINITE);
log.debug("Remove markers " + PMDRuntimeConstants.PMD_MARKER + " on currently edited file " + ((IFileEditorInput) editorInput).getFile().getName());
} else {
- log.debug("The kind of editor input is not supported. The editor input if of type: "
- + editorInput.getClass().getName());
+ log.debug("The kind of editor input is not supported. The editor input if of type: " + editorInput.getClass().getName());
}
}
Added: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/IconColumnDescriptor.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/IconColumnDescriptor.java (rev 0)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/IconColumnDescriptor.java 2010-01-09 16:10:44 UTC (rev 7061)
@@ -0,0 +1,64 @@
+package net.sourceforge.pmd.eclipse.ui.preferences.br;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.pmd.Rule;
+import net.sourceforge.pmd.RulePriority;
+import net.sourceforge.pmd.eclipse.ui.nls.StringKeys;
+import net.sourceforge.pmd.eclipse.util.ResourceManager;
+import net.sourceforge.pmd.util.CollectionUtil;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+/**
+ *
+ * @author Brian Remedios
+ */
+public class IconColumnDescriptor extends AbstractRuleColumnDescriptor {
+
+ private Map<Object, Image> iconsByValue;
+
+ private static final Map<Object, String> iconNamesByValue = CollectionUtil.mapFrom(
+ new Object[] { RulePriority.LOW, RulePriority.MEDIUM_LOW, RulePriority.MEDIUM, RulePriority.MEDIUM_HIGH, RulePriority.HIGH },
+ new String[] {"btn_prio5.gif", "btn_prio4.gif", "btn_prio3.gif","btn_prio2.gif", "btn_prio1.gif"}
+ );
+
+ public static final RuleColumnDescriptor priority = new IconColumnDescriptor(StringKeys.MSGKEY_PREF_RULESET_COLUMN_PRIORITY, SWT.RIGHT, 53, RuleFieldAccessor.priority, true, iconNamesByValue, "/icons/");
+
+ public IconColumnDescriptor(String labelKey, int theAlignment, int theWidth, RuleFieldAccessor theAccessor, boolean resizableFlag, Map<Object, String> imageNamesByValue, String optionalPath) {
+ super(labelKey, theAlignment, theWidth, theAccessor, resizableFlag);
+
+ iconsByValue = iconsFor(imageNamesByValue, optionalPath);
+ }
+
+ private static Map<Object, Image> iconsFor(Map<Object, String> imageNamesByValue, String optionalPath) {
+
+ Map<Object, Image> imagesByValue = new HashMap<Object, Image>(imageNamesByValue.size());
+ for (Map.Entry<Object, String> entry : imageNamesByValue.entrySet()) {
+ String fullPath = optionalPath == null ? entry.getValue() : optionalPath + entry.getValue();
+ imagesByValue.put(entry.getKey(), ResourceManager.imageFor(fullPath));
+ }
+ return imagesByValue;
+ }
+
+ public Image imageFor(Rule rule) {
+ Object value = valueFor(rule);
+ return iconsByValue.get(value);
+ }
+
+ public TreeColumn newTreeColumnFor(Tree parent, int columnIndex, RuleSortListener sortListener, Map<Integer, List<Listener>> paintListeners) {
+ TreeColumn tc = buildTreeColumn(parent, sortListener);
+ tc.setToolTipText(tooltip());
+ return tc;
+ }
+
+ public String stringValueFor(Rule rule) {
+ return null;
+ }
+
+}
Property changes on: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/IconColumnDescriptor.java
___________________________________________________________________
Added: svn:executable
+ *
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/ImageColumnDescriptor.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/ImageColumnDescriptor.java 2010-01-08 17:16:35 UTC (rev 7060)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/ImageColumnDescriptor.java 2010-01-09 16:10:44 UTC (rev 7061)
@@ -4,6 +4,7 @@
import java.util.Map;
import net.sourceforge.pmd.Rule;
+import net.sourceforge.pmd.RulePriority;
import net.sourceforge.pmd.eclipse.ui.PMDUiConstants;
import net.sourceforge.pmd.eclipse.ui.nls.StringKeys;
import net.sourceforge.pmd.eclipse.util.ResourceManager;
@@ -26,8 +27,7 @@
public static final RuleColumnDescriptor filterViolationRegex = new ImageColumnDescriptor(StringKeys.MSGKEY_PREF_RULESET_COLUMN_FILTERS_REGEX, SWT.LEFT, 25, RuleFieldAccessor.violationRegex, false, PMDUiConstants.ICON_FILTER, Util.textAsColorShapeFor(16, 16, Util.shape.square));
public static final RuleColumnDescriptor filterViolationXPath = new ImageColumnDescriptor(StringKeys.MSGKEY_PREF_RULESET_COLUMN_FILTERS_XPATH, SWT.LEFT, 25, RuleFieldAccessor.violationXPath, false, PMDUiConstants.ICON_FILTER_X, Util.textAsColorShapeFor(16, 16, Util.shape.circle));
-
-
+
public ImageColumnDescriptor(String labelKey, int theAlignment, int theWidth, RuleFieldAccessor theAccessor, boolean resizableFlag, String theImagePath, CellPainterBuilder thePainterBuilder) {
super(labelKey, theAlignment, theWidth, theAccessor, resizableFlag);
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/NewPropertyDialog.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/NewPropertyDialog.java 2010-01-08 17:16:35 UTC (rev 7060)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/NewPropertyDialog.java 2010-01-09 16:10:44 UTC (rev 7061)
@@ -8,7 +8,6 @@
import net.sourceforge.pmd.PropertyDescriptor;
import net.sourceforge.pmd.Rule;
-import net.sourceforge.pmd.eclipse.plugin.PMDPlugin;
import net.sourceforge.pmd.eclipse.ui.nls.StringKeys;
import net.sourceforge.pmd.eclipse.ui.preferences.editors.MethodEditorFactory;
import net.sourceforge.pmd.eclipse.ui.preferences.editors.SWTUtil;
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/PMDPreferencePage.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/PMDPreferencePage.java 2010-01-08 17:16:35 UTC (rev 7060)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/PMDPreferencePage.java 2010-01-09 16:10:44 UTC (rev 7061)
@@ -24,6 +24,7 @@
import net.sourceforge.pmd.eclipse.ui.preferences.RuleDialog;
import net.sourceforge.pmd.eclipse.ui.preferences.RuleSetSelectionDialog;
import net.sourceforge.pmd.eclipse.ui.preferences.editors.SWTUtil;
+import net.sourceforge.pmd.eclipse.ui.preferences.panelmanagers.Configuration;
import net.sourceforge.pmd.eclipse.ui.preferences.panelmanagers.DescriptionPanelManager;
import net.sourceforge.pmd.eclipse.ui.preferences.panelmanagers.ExamplePanelManager;
import net.sourceforge.pmd.eclipse.ui.preferences.panelmanagers.ExclusionPanelManager;
@@ -32,8 +33,6 @@
import net.sourceforge.pmd.eclipse.ui.preferences.panelmanagers.XPathPanelManager;
import net.sourceforge.pmd.eclipse.util.ResourceManager;
import net.sourceforge.pmd.eclipse.util.Util;
-import net.sourceforge.pmd.lang.rule.XPathRule;
-import net.sourceforge.pmd.lang.rule.stat.StatisticalRule;
import net.sourceforge.pmd.util.FileUtil;
import net.sourceforge.pmd.util.StringUtil;
import net.sourceforge.pmd.util.designer.Designer;
@@ -99,7 +98,8 @@
// columns shown in the rule treetable in the desired order
private static final RuleColumnDescriptor[] availableColumns = new RuleColumnDescriptor[] {
TextColumnDescriptor.name,
- TextColumnDescriptor.priorityName,
+ //TextColumnDescriptor.priorityName,
+ IconColumnDescriptor.priority,
TextColumnDescriptor.since,
TextColumnDescriptor.ruleSetName,
TextColumnDescriptor.ruleType,
@@ -121,16 +121,6 @@
{ null, StringKeys.MSGKEY_PREF_RULESET_GROUPING_NONE }
};
- // properties that should not be shown in the PerRuleProperty page
- private static final PropertyDescriptor<?>[] excludedRuleProperties = new PropertyDescriptor<?>[] {
- Rule.VIOLATION_SUPPRESS_REGEX_DESCRIPTOR,
- Rule.VIOLATION_SUPPRESS_XPATH_DESCRIPTOR,
- XPathRule.XPATH_DESCRIPTOR,
- XPathRule.VERSION_DESCRIPTOR,
- StatisticalRule.SIGMA_DESCRIPTOR,
- StatisticalRule.TOP_SCORE_DESCRIPTOR
- };
-
// private static final int RuleTableFraction = 55; // percent of screen height vs property tabs
private static final Map<Class<?>, ValueFormatter> formattersByType = new HashMap<Class<?>, ValueFormatter>();
@@ -327,17 +317,6 @@
propertySection.setLayoutData(data);
}
- public static Map<PropertyDescriptor<?>, Object> filteredPropertiesOf(Rule rule) {
-
- Map<PropertyDescriptor<?>, Object> valuesByProp = rule.getPropertiesByPropertyDescriptor();
-
- for (PropertyDescriptor<?> excludedRulePropertie : excludedRuleProperties) {
- valuesByProp.remove(excludedRulePropertie);
- }
-
- return valuesByProp;
- }
-
public static void formatValueOn(StringBuilder target, Object value, Class<?> datatype) {
ValueFormatter formatter = formattersByType.get(datatype);
@@ -355,7 +334,7 @@
*/
public static String propertyStringFrom(Rule rule) {
- Map<PropertyDescriptor<?>, Object> valuesByProp = filteredPropertiesOf(rule);
+ Map<PropertyDescriptor<?>, Object> valuesByProp = Configuration.filteredPropertiesOf(rule);
if (valuesByProp.isEmpty()) return "";
StringBuilder sb = new StringBuilder();
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/RuleFieldAccessor.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/RuleFieldAccessor.java 2010-01-08 17:16:35 UTC (rev 7060)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/RuleFieldAccessor.java 2010-01-09 16:10:44 UTC (rev 7061)
@@ -42,7 +42,7 @@
RuleFieldAccessor priority = new BasicRuleFieldAccessor() {
public Comparable<?> valueFor(Rule rule) {
- return Integer.valueOf(rule.getPriority().getPriority());
+ return rule.getPriority();
}
};
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/TODO items
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/TODO items 2010-01-08 17:16:35 UTC (rev 7060)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/TODO items 2010-01-09 16:10:44 UTC (rev 7061)
@@ -1,10 +1,14 @@
-ToDo items: Jan 6th 2010
+ToDo items: Jan 9th 2010
Finish remaining editors and the Add Property dialog
Enable delete key on rule table
Highlight non-default values in editors and/or summary column
Enable 'Use defaults' option in popup menu
+Sort indicators on rule column headings
+Add selection column selected rules in per-project rule settings table
+Rework context menu - build on-demand, not before
+Cleanup icons
Remember settings for:
chosen grouping selection (or none)
sort column & order
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/editors/AbstractMultiValueEditorFactory.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/editors/AbstractMultiValueEditorFactory.java 2010-01-08 17:16:35 UTC (rev 7060)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/editors/AbstractMultiValueEditorFactory.java 2010-01-09 16:10:44 UTC (rev 7061)
@@ -174,14 +174,7 @@
protected boolean canAddNewRowFor(final PropertyDescriptor<?> desc, final Rule rule) {
return true;
}
-
- protected void setupDefaultActionFor(Control widget, Listener listener) {
-
- // if (widget instanceof Text || widget instanceof Spinner) {
- widget.addListener(SWT.DefaultSelection, listener);
- // }
- }
-
+
private void addNewValueRow(final Composite parent, final PropertyDescriptor<?> desc, final Rule rule, final Text parentWidget, final ValueChangeListener changeListener, final SizeChangeListener sizeListener, final List<Control> newControls, int i) {
if (!canAddNewRowFor(desc, rule)) return;
@@ -219,7 +212,8 @@
}
};
butt.addListener(SWT.Selection, addListener);
- setupDefaultActionFor(widget, addListener); // allow for CR on entry widgets themselves, no need to click the '+' button
+ widget.addListener(SWT.DefaultSelection, addListener); // allow for CR on entry widgets themselves, no need to click the '+' button
+ widget.setFocus();
}
private void convertToDelete(final Button button, final Object toDeleteValue, final Composite parent, final List<Control> newControls, final PropertyDescriptor<?> desc, final Rule rule, final Text parentWidget, final Label number, final Control widget, final ValueChangeListener changeListener, final SizeChangeListener sizeListener) {
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/editors/AbstractRealNumberEditor.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/editors/AbstractRealNumberEditor.java 2010-01-08 17:16:35 UTC (rev 7060)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/editors/AbstractRealNumberEditor.java 2010-01-09 16:10:44 UTC (rev 7061)
@@ -27,9 +27,11 @@
spinner.setMinimum(min);
spinner.setMaximum(max);
- double value = ((Number)valueFor(rule, numDesc)).doubleValue();
- int intVal = (int)(value * scale);
- spinner.setSelection(intVal);
+ Number value = ((Number)valueFor(rule, numDesc));
+ if (value != null) {
+ int intVal = (int)(value.doubleValue() * scale);
+ spinner.setSelection(intVal);
+ }
return spinner;
}
Added: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/Configuration.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/Configuration.java (rev 0)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/Configuration.java 2010-01-09 16:10:44 UTC (rev 7061)
@@ -0,0 +1,35 @@
+package net.sourceforge.pmd.eclipse.ui.preferences.panelmanagers;
+
+import java.util.Map;
+
+import net.sourceforge.pmd.PropertyDescriptor;
+import net.sourceforge.pmd.Rule;
+import net.sourceforge.pmd.lang.rule.XPathRule;
+import net.sourceforge.pmd.lang.rule.stat.StatisticalRule;
+/**
+ *
+ * @author br
+ */
+public class Configuration {
+
+ // properties that should not be shown in the PerRuleProperty page
+ public static final PropertyDescriptor<?>[] excludedRuleProperties = new PropertyDescriptor<?>[] {
+ Rule.VIOLATION_SUPPRESS_REGEX_DESCRIPTOR,
+ Rule.VIOLATION_SUPPRESS_XPATH_DESCRIPTOR,
+ XPathRule.XPATH_DESCRIPTOR,
+ XPathRule.VERSION_DESCRIPTOR,
+ StatisticalRule.SIGMA_DESCRIPTOR,
+ StatisticalRule.TOP_SCORE_DESCRIPTOR
+ };
+
+ public static Map<PropertyDescriptor<?>, Object> filteredPropertiesOf(Rule rule) {
+
+ Map<PropertyDescriptor<?>, Object> valuesByProp = rule.getPropertiesByPropertyDescriptor();
+
+ for (PropertyDescriptor<?> excludedRulePropertie : excludedRuleProperties) {
+ valuesByProp.remove(excludedRulePropertie);
+ }
+
+ return valuesByProp;
+ }
+}
Property changes on: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/Configuration.java
___________________________________________________________________
Added: svn:executable
+ *
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/ExclusionPanelManager.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/ExclusionPanelManager.java 2010-01-08 17:16:35 UTC (rev 7060)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/ExclusionPanelManager.java 2010-01-09 16:10:44 UTC (rev 7061)
@@ -1,10 +1,8 @@
package net.sourceforge.pmd.eclipse.ui.preferences.panelmanagers;
import net.sourceforge.pmd.Rule;
-import net.sourceforge.pmd.eclipse.ui.PMDUiConstants;
import net.sourceforge.pmd.eclipse.ui.preferences.br.ValueChangeListener;
import net.sourceforge.pmd.eclipse.util.ColourManager;
-import net.sourceforge.pmd.eclipse.util.ResourceManager;
import net.sourceforge.pmd.lang.rule.properties.StringProperty;
import net.sourceforge.pmd.util.StringUtil;
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/FormArranger.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/FormArranger.java 2010-01-08 17:16:35 UTC (rev 7060)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/FormArranger.java 2010-01-09 16:10:44 UTC (rev 7061)
@@ -9,8 +9,8 @@
import net.sourceforge.pmd.Rule;
import net.sourceforge.pmd.eclipse.ui.PMDUiConstants;
import net.sourceforge.pmd.eclipse.ui.preferences.br.EditorFactory;
+import net.sourceforge.pmd.eclipse.ui.preferences.br.NewPropertyDialog;
import net.sourceforge.pmd.eclipse.ui.preferences.br.PMDPreferencePage;
-import net.sourceforge.pmd.eclipse.ui.preferences.br.NewPropertyDialog;
import net.sourceforge.pmd.eclipse.ui.preferences.br.SizeChangeListener;
import net.sourceforge.pmd.eclipse.ui.preferences.br.ValueChangeListener;
import net.sourceforge.pmd.eclipse.util.ResourceManager;
@@ -86,7 +86,8 @@
if (rule == null) return -1;
- Map<PropertyDescriptor<?>, Object> valuesByDescriptor = PMDPreferencePage.filteredPropertiesOf(rule);
+ Map<PropertyDescriptor<?>, Object> valuesByDescriptor = Configuration.filteredPropertiesOf(rule);
+
if (valuesByDescriptor.isEmpty()) {
if (rule.hasDescriptor(XPathRule.XPATH_DESCRIPTOR)) {
addAddButton();
@@ -212,10 +213,13 @@
for (Control[] widgetRow : widgets) {
Button butt = (Button)widgetRow[2];
- boolean isReferenced = varNames.contains(butt.getData());
+ String buttonName = (String)butt.getData();
+ boolean isReferenced = varNames.contains(buttonName);
butt.setToolTipText(
- isReferenced ? "Delete variable" : "Delete unreferenced variable"
+ isReferenced ?
+ "Delete variable: $" + buttonName :
+ "Delete unreferenced variable: $" + buttonName
);
if (!isReferenced) unreferenced.add((String) butt.getData());
}
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/PerRulePropertyPanelManager.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/PerRulePropertyPanelManager.java 2010-01-08 17:16:35 UTC (rev 7060)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/PerRulePropertyPanelManager.java 2010-01-09 16:10:44 UTC (rev 7061)
@@ -1,6 +1,7 @@
package net.sourceforge.pmd.eclipse.ui.preferences.panelmanagers;
import java.lang.reflect.Method;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -47,26 +48,28 @@
private static final int MaxWidgetHeight = 30; // TODO derive this instead
- private static final Map<Class<?>, EditorFactory> editorFactoriesByPropertyType;
+ public static final Map<Class<?>, EditorFactory> editorFactoriesByPropertyType;
static {
- editorFactoriesByPropertyType = new HashMap<Class<?>, EditorFactory>();
+ Map<Class<?>, EditorFactory> factoriesByPropertyType = new HashMap<Class<?>, EditorFactory>();
- editorFactoriesByPropertyType.put(Boolean.class, BooleanEditorFactory.instance);
- editorFactoriesByPropertyType.put(String.class, StringEditorFactory.instance);
- editorFactoriesByPropertyType.put(Integer.class, IntegerEditorFactory.instance);
- editorFactoriesByPropertyType.put(Float.class, FloatEditorFactory.instance);
- editorFactoriesByPropertyType.put(Double.class, DoubleEditorFactory.instance);
- editorFactoriesByPropertyType.put(Object.class, EnumerationEditorFactory.instance);
- editorFactoriesByPropertyType.put(Character.class, CharacterEditorFactory.instance);
+ factoriesByPropertyType.put(Boolean.class, BooleanEditorFactory.instance);
+ factoriesByPropertyType.put(String.class, StringEditorFactory.instance);
+ factoriesByPropertyType.put(Integer.class, IntegerEditorFactory.instance);
+ factoriesByPropertyType.put(Float.class, FloatEditorFactory.instance);
+ factoriesByPropertyType.put(Double.class, DoubleEditorFactory.instance);
+ factoriesByPropertyType.put(Object.class, EnumerationEditorFactory.instance);
+ factoriesByPropertyType.put(Character.class, CharacterEditorFactory.instance);
- editorFactoriesByPropertyType.put(Class.class, TypeEditorFactory.instance);
- editorFactoriesByPropertyType.put(Class[].class, MultiTypeEditorFactory.instance);
- editorFactoriesByPropertyType.put(Method.class, MethodEditorFactory.instance);
- editorFactoriesByPropertyType.put(Method[].class, MultiMethodEditorFactory.instance);
- editorFactoriesByPropertyType.put(String[].class, MultiStringEditorFactory.instance);
- editorFactoriesByPropertyType.put(Integer[].class, MultiIntegerEditorFactory.instance);
- editorFactoriesByPropertyType.put(Object[].class, MultiEnumerationEditorFactory.instance);
+ factoriesByPropertyType.put(Class.class, TypeEditorFactory.instance);
+ factoriesByPropertyType.put(Class[].class, MultiTypeEditorFactory.instance);
+ factoriesByPropertyType.put(Method.class, MethodEditorFactory.instance);
+ factoriesByPropertyType.put(Method[].class, MultiMethodEditorFactory.instance);
+ factoriesByPropertyType.put(String[].class, MultiStringEditorFactory.instance);
+ factoriesByPropertyType.put(Integer[].class, MultiIntegerEditorFactory.instance);
+ factoriesByPropertyType.put(Object[].class, MultiEnumerationEditorFactory.instance);
+
+ editorFactoriesByPropertyType = Collections.unmodifiableMap(factoriesByPropertyType);
}
public PerRulePropertyPanelManager(ValueChangeListener theListener) {
@@ -77,7 +80,7 @@
protected boolean canWorkWith(Rule rule) {
if (rule.hasDescriptor(XPathRule.XPATH_DESCRIPTOR)) return true;
- return !PMDPreferencePage.filteredPropertiesOf(rule).isEmpty();
+ return !Configuration.filteredPropertiesOf(rule).isEmpty();
}
protected void clearControls() {
Modified: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/util/Util.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/util/Util.java 2010-01-08 17:16:35 UTC (rev 7060)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/util/Util.java 2010-01-09 16:10:44 UTC (rev 7061)
@@ -3,6 +3,7 @@
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Comparator;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -15,6 +16,7 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.graphics.Region;
import org.eclipse.swt.widgets.Control;
@@ -184,7 +186,6 @@
public static CellPainterBuilder textAsColorShapeFor(final int width, final int height, final shape shapeId) {
-
return new CellPainterBuilder() {
private ColourManager colorManager;
@@ -398,4 +399,55 @@
target.append(separator).append(items[i]);
}
}
+
+ private static Map<Object, Image> imagesFor(Map<Object, String> imageNamesByValue) {
+
+ Map<Object, Image> imagesByValue = new HashMap<Object, Image>(imageNamesByValue.size());
+ for (Map.Entry<Object, String> entry : imageNamesByValue.entrySet()) {
+ imagesByValue.put(entry.getKey(), ResourceManager.imageFor(entry.getValue()));
+ }
+ return imagesByValue;
+ }
+
+// public static CellPainterBuilder iconsFromNameFor(final int width, final int height, final Map<Object, String> imageNamesByValue) {
+// return iconsFor(width, height, imagesFor(imageNamesByValue));
+// }
+//
+// public static CellPainterBuilder iconsFor(final int width, final int height, final Map<Object, Image> imagesByValue) {
+//
+// return new CellPainterBuilder() {
+//
+// private Object valueFrom(TreeItem tItem, RuleFieldAccessor getter) {
+//
+// Object item = tItem.getData();
+// if (!(item instanceof Rule)) return null;
+// return getter.valueFor((Rule) item);
+// }
+//
+// public void addPainterFor(final Tree tree, final int columnIndex, final RuleFieldAccessor getter, Map<Integer, List<Listener>> listenersByEventCode) {
+//
+// Listener paintListener = new Listener() {
+// public void handleEvent(Event event) {
+// if (event.index != columnIndex) return;
+//
+// Object value = valueFrom((TreeItem)event.item, getter);
+// if (value == null) return;
+// Image image = imagesByValue.get(value);
+// event.gc.drawImage(image, event.x+1, event.y+2);
+// }
+// };
+//
+// Listener measureListener = new Listener() {
+// public void handleEvent(Event e) {
+// if (e.index != columnIndex) return;
+// e.width = width + 2;
+// e.height = height + 2;
+// }
+// };
+//
+// addListener(tree, SWT.PaintItem, paintListener, listenersByEventCode);
+// addListener(tree, SWT.MeasureItem, measureListener, listenersByEventCode);
+// }
+// };
+// }
}
Added: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/test/net/sourceforge/pmd/eclipse/ui/preferences/editors/EditorTester.java
===================================================================
--- trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/test/net/sourceforge/pmd/eclipse/ui/preferences/editors/EditorTester.java (rev 0)
+++ trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/test/net/sourceforge/pmd/eclipse/ui/preferences/editors/EditorTester.java 2010-01-09 16:10:44 UTC (rev 7061)
@@ -0,0 +1,96 @@
+package net.sourceforge.pmd.eclipse.ui.preferences.editors;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import net.sourceforge.pmd.PropertyDescriptor;
+import net.sourceforge.pmd.Rule;
+import net.sourceforge.pmd.eclipse.ui.preferences.br.EditorFactory;
+import net.sourceforge.pmd.eclipse.ui.preferences.br.RuleSelection;
+import net.sourceforge.pmd.eclipse.ui.preferences.br.SizeChangeListener;
+import net.sourceforge.pmd.eclipse.ui.preferences.br.ValueChangeListener;
+import net.sourceforge.pmd.eclipse.ui.preferences.panelmanagers.FormArranger;
+import net.sourceforge.pmd.eclipse.ui.preferences.panelmanagers.PerRulePropertyPanelManager;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+import test.net.sourceforge.pmd.properties.NonRuleWithAllPropertyTypes;
+/**
+ *
+ * @author Brian Remedios
+ */
+public class EditorTester implements ValueChangeListener, SizeChangeListener {
+
+ // these are the ones we've tested, the others may work but might not make sense in the xpath source context...
+ private static final Class<?>[] validEditorTypes = new Class[] { String.class, Integer.class, Boolean.class };
+
+ public static Map<Class<?>, EditorFactory> withOnly(Map<Class<?>, EditorFactory> factoriesByType, Class<?>[] legalTypeKeys) {
+ Map<Class<?>, EditorFactory> results = new HashMap<Class<?>, EditorFactory>(legalTypeKeys.length);
+
+ for (Class<?> type : legalTypeKeys) {
+ if (factoriesByType.containsKey(type)) {
+ results.put(type, factoriesByType.get(type));
+ }
+ }
+ return results;
+ }
+
+ public EditorTester() {
+
+ Display d = new Display();
+ Shell s = new Shell(d);
+ GridLayout gl = new GridLayout();
+ gl.numColumns = 2;
+ s.setLayout(gl);
+ s.setSize(850, 595);
+
+ s.setText("Type Editor Tester");
+ s.setLayout(gl);
+ Composite gc = new Composite(s, SWT.BORDER);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalSpan = 4;
+ gc.setLayoutData(gd);
+ gd = new GridData();
+
+ Composite c1 = new Composite(s, SWT.NO_FOCUS);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ c1.setLayoutData(gd);
+ Composite c2 = new Composite(s, SWT.NO_FOCUS);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ c2.setLayoutData(gd);
+
+ Composite c = new Composite(s, SWT.NO_FOCUS); c.setLayout(new RowLayout());
+ Button b1 = new Button(c, SWT.PUSH | SWT.BORDER); b1.setText("OK");
+ Button b2 = new Button(c, SWT.PUSH | SWT.BORDER); b2.setText("Cancel");
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ c.setLayoutData(gd);
+
+ FormArranger formArranger = new FormArranger(gc, PerRulePropertyPanelManager.editorFactoriesByPropertyType, this, this);
+ formArranger.arrangeFor(new NonRuleWithAllPropertyTypes());
+ s.open();
+ while (!s.isDisposed()) {
+ if (!d.readAndDispatch())
+ d.sleep();
+ }
+ d.dispose();
+ }
+
+ public static void main(String[] arg) {
+ new EditorTester();
+ }
+
+ // ignore these callbacks
+ public void changed(RuleSelection rule, PropertyDescriptor<?> desc, Object newValue) { }
+
+ public void changed(Rule rule, PropertyDescriptor<?> desc, Object newValue) { }
+
+ public void addedRows(int newRowCount) { }
+
+}
\ No newline at end of file
Property changes on: trunk/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/test/net/sourceforge/pmd/eclipse/ui/preferences/editors/EditorTester.java
___________________________________________________________________
Added: svn:executable
+ *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|