+properties column now highlights non-default values (still a bit buggy)
+internals: new visitor pattern for manipulating all selections +able to disable rules from the violation list +grouped rules show all unique priority values +revised filter column icons +revised plugin.xml to export code for other plugins +new opening Rule panel for Rule creation wizard git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@7109 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin
.classpath
.settings
CHANGELOG.txtMETA-INF
icons
btn_diamond_white.pngbtn_dot_white.pngfilter_r.pngfilter_x.pngicon_filter.pngicon_spinningArrows.png
messages.propertiesplugin.xmlsrc/net/sourceforge/pmd/eclipse
@ -1,18 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry exported="true" kind="lib" path="lib/saxon9.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/asm-3.2.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/castor-1.1.2.1-xml.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/commons-logging-1.1.1.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/jaxen-1.1.1.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/junit.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/log4j-1.2.15.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/pmd-5.0.jar" sourcepath="/pmd/src"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/xercesImpl-2.6.2.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/xmlParserAPIs-2.6.2.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="lib" path="lib/js-cvs-12122009.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry exported="true" kind="lib" path="lib/saxon9.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/asm-3.2.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/castor-1.1.2.1-xml.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/jaxen-1.1.1.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/junit.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/log4j-1.2.15.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/pmd-5.0.jar" sourcepath="/pmd"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="test"/>
|
||||
<classpathentry kind="lib" path="/home/br/apps/eclipse/plugins/org.eclipse.core.commands_3.5.0.I20090525-2000.jar"/>
|
||||
<classpathentry kind="lib" path="/home/br/apps/eclipse/plugins/org.eclipse.equinox.common_3.5.1.R35x_v20090807-1100.jar"/>
|
||||
<classpathentry kind="lib" path="/home/br/apps/eclipse/plugins/org.apache.commons.logging_1.0.4.v200904062259.jar"/>
|
||||
<classpathentry kind="lib" path="lib/xercesImpl-2.6.2.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.tptp.platform.instrumentation.ui.ContainerInitializer/Build to Manage Libraries"/>
|
||||
<classpathentry kind="lib" path="/home/br/apps/eclipse/plugins/org.eclipse.swt_3.5.2.v3557f.jar" sourcepath="/home/br/apps/eclipse/plugins/swt-debug.jar"/>
|
||||
<classpathentry kind="lib" path="/home/br/apps/eclipse/plugins/org.eclipse.osgi_3.5.2.R35x_v20100126.jar"/>
|
||||
<classpathentry kind="lib" path="/home/br/apps/eclipse/plugins/org.eclipse.team.core_3.5.1.r35x_20100113-0800.jar"/>
|
||||
<classpathentry kind="lib" path="/home/br/apps/eclipse/plugins/org.tigris.subversion.subclipse.core_1.6.10.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
54
pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/.settings/org.eclipse.jdt.ui.prefs
Executable file
54
pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/.settings/org.eclipse.jdt.ui.prefs
Executable file
@ -0,0 +1,54 @@
|
||||
#Mon Mar 29 02:08:09 CDT 2010
|
||||
cleanup.add_default_serial_version_id=true
|
||||
cleanup.add_generated_serial_version_id=false
|
||||
cleanup.add_missing_annotations=true
|
||||
cleanup.add_missing_deprecated_annotations=true
|
||||
cleanup.add_missing_methods=false
|
||||
cleanup.add_missing_nls_tags=false
|
||||
cleanup.add_missing_override_annotations=false
|
||||
cleanup.add_serial_version_id=false
|
||||
cleanup.always_use_blocks=true
|
||||
cleanup.always_use_parentheses_in_expressions=false
|
||||
cleanup.always_use_this_for_non_static_field_access=false
|
||||
cleanup.always_use_this_for_non_static_method_access=false
|
||||
cleanup.convert_to_enhanced_for_loop=true
|
||||
cleanup.correct_indentation=false
|
||||
cleanup.format_source_code=false
|
||||
cleanup.format_source_code_changes_only=false
|
||||
cleanup.make_local_variable_final=true
|
||||
cleanup.make_parameters_final=false
|
||||
cleanup.make_private_fields_final=true
|
||||
cleanup.make_type_abstract_if_missing_method=false
|
||||
cleanup.make_variable_declarations_final=false
|
||||
cleanup.never_use_blocks=false
|
||||
cleanup.never_use_parentheses_in_expressions=true
|
||||
cleanup.organize_imports=true
|
||||
cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||
cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||
cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||
cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||
cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||
cleanup.remove_private_constructors=true
|
||||
cleanup.remove_trailing_whitespaces=true
|
||||
cleanup.remove_trailing_whitespaces_all=true
|
||||
cleanup.remove_trailing_whitespaces_ignore_empty=false
|
||||
cleanup.remove_unnecessary_casts=true
|
||||
cleanup.remove_unnecessary_nls_tags=true
|
||||
cleanup.remove_unused_imports=true
|
||||
cleanup.remove_unused_local_variables=false
|
||||
cleanup.remove_unused_private_fields=true
|
||||
cleanup.remove_unused_private_members=false
|
||||
cleanup.remove_unused_private_methods=true
|
||||
cleanup.remove_unused_private_types=true
|
||||
cleanup.sort_members=false
|
||||
cleanup.sort_members_all=false
|
||||
cleanup.use_blocks=false
|
||||
cleanup.use_blocks_only_for_return_and_throw=false
|
||||
cleanup.use_parentheses_in_expressions=false
|
||||
cleanup.use_this_for_non_static_field_access=true
|
||||
cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
||||
cleanup.use_this_for_non_static_method_access=false
|
||||
cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||
cleanup_profile=_hatchwater
|
||||
cleanup_settings_version=2
|
||||
eclipse.preferences.version=1
|
@ -5,6 +5,7 @@ v4.0.0 - xxx 2010?
|
||||
. Allows users to group/edit rules by multiple criteria
|
||||
. provides ability to enable/disable rules without removing them
|
||||
. larger editors for the various fields
|
||||
. new rule creation wizard supports new non-Java languages
|
||||
. group editing of filter exclusion rules
|
||||
. Color-tagged expressions in shown in rule table
|
||||
. new property editors are fully type-aware
|
||||
|
@ -2,23 +2,21 @@ Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %plugin.name
|
||||
Bundle-SymbolicName: net.sourceforge.pmd.eclipse.plugin;singleton:=true
|
||||
Bundle-Version: 5.0.0.v200810141040
|
||||
Bundle-Version: 5.0.0.v20100726
|
||||
Bundle-Activator: net.sourceforge.pmd.eclipse.plugin.PMDPlugin
|
||||
Require-Bundle: org.eclipse.core.resources;bundle-version="3.5.0",
|
||||
Require-Bundle: org.apache.commons.logging;bundle-version="1.0.4",
|
||||
org.eclipse.core.resources;bundle-version="3.5.0",
|
||||
org.eclipse.core.runtime;bundle-version="3.5.0",
|
||||
org.eclipse.jdt.core;bundle-version="3.5.0",
|
||||
org.eclipse.jface;bundle-version="3.5.0",
|
||||
org.eclipse.jface.text;bundle-version="3.5.0",
|
||||
org.eclipse.ui;bundle-version="3.5.0",
|
||||
org.eclipse.ui.editors;bundle-version="3.5.0",
|
||||
org.eclipse.ui.ide;bundle-version="3.5.0",
|
||||
org.eclipse.help
|
||||
org.eclipse.ui.editors;bundle-version="3.5.0"
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
Bundle-Vendor: %plugin.provider
|
||||
Bundle-ClassPath: lib/asm-3.2.jar,
|
||||
lib/castor-1.1.2.1-xml.jar,
|
||||
lib/commons-logging-1.1.1.jar,
|
||||
lib/jaxen-1.1.1.jar,
|
||||
lib/junit.jar,
|
||||
lib/log4j-1.2.15.jar,
|
||||
@ -27,12 +25,20 @@ Bundle-ClassPath: lib/asm-3.2.jar,
|
||||
lib/pmd-5.0.jar,
|
||||
lib/xercesImpl-2.6.2.jar,
|
||||
lib/xmlParserAPIs-2.6.2.jar,
|
||||
pmd-plugin.jar
|
||||
pmd-plugin.jar,
|
||||
lib/groupingTree.jar
|
||||
Bundle-Localization: plugin
|
||||
Export-Package: net.sourceforge.pmd,
|
||||
rulesets,
|
||||
net.sourceforge.pmd.eclipse.core,
|
||||
net.sourceforge.pmd.eclipse.plugin,
|
||||
net.sourceforge.pmd.eclipse.runtime,
|
||||
net.sourceforge.pmd.eclipse.runtime.builder,
|
||||
net.sourceforge.pmd.eclipse.runtime.properties,
|
||||
net.sourceforge.pmd.eclipse.runtime.writer
|
||||
net.sourceforge.pmd.eclipse.runtime.writer,
|
||||
net.sourceforge.pmd.eclipse.ui,
|
||||
net.sourceforge.pmd.eclipse.ui.model,
|
||||
net.sourceforge.pmd.eclipse.ui.nls,
|
||||
net.sourceforge.pmd.eclipse.ui.preferences.br,
|
||||
net.sourceforge.pmd.eclipse.ui.views.actions,
|
||||
net.sourceforge.pmd.util,
|
||||
rulesets
|
||||
|
BIN
pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/icons/btn_diamond_white.png
Executable file
BIN
pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/icons/btn_diamond_white.png
Executable file
Binary file not shown.
After ![]() (image error) Size: 175 B |
BIN
pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/icons/btn_dot_white.png
Executable file
BIN
pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/icons/btn_dot_white.png
Executable file
Binary file not shown.
After ![]() (image error) Size: 168 B |
BIN
pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/icons/filter_r.png
Executable file
BIN
pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/icons/filter_r.png
Executable file
Binary file not shown.
After ![]() (image error) Size: 391 B |
Binary file not shown.
Before ![]() (image error) Size: 562 B After ![]() (image error) Size: 354 B ![]() ![]() |
BIN
pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/icons/icon_filter.png
Executable file
BIN
pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/icons/icon_filter.png
Executable file
Binary file not shown.
After ![]() (image error) Size: 241 B |
BIN
pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/icons/icon_spinningArrows.png
Executable file
BIN
pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/icons/icon_spinningArrows.png
Executable file
Binary file not shown.
After ![]() (image error) Size: 382 B |
@ -65,6 +65,8 @@ preference.ruleset.column.example_count.tooltip = Number of examples
|
||||
preference.ruleset.column.rule_type.tooltip = Rule type:\n X = XPath\n D = dataflow\n T = type resolving
|
||||
preference.ruleset.column.minimum_version = Min ver
|
||||
preference.ruleset.column.minimum_version.tooltip = Minimum applicable version of the target language
|
||||
preference.ruleset.column.maximum_version = Max ver
|
||||
preference.ruleset.column.maximum_version.tooltip = Maximum applicable version of the target language
|
||||
preference.ruleset.column.filters.regex = Regex filter
|
||||
preference.ruleset.column.filters.regex.tooltip = Regular expression filters
|
||||
preference.ruleset.column.filters.xpath = XPath filter
|
||||
@ -73,6 +75,7 @@ preference.ruleset.column.since = Since
|
||||
preference.ruleset.column.since.tooltip = Incorporation within PMD
|
||||
preference.ruleset.column.priority = Priority
|
||||
preference.ruleset.column.fixCount = Fixes
|
||||
preference.ruleset.column.modCount = Changes
|
||||
preference.ruleset.column.priority.tooltip = Relative priority
|
||||
preference.ruleset.column.description = Description
|
||||
preference.ruleset.column.property = Property
|
||||
@ -106,6 +109,7 @@ preference.rulesetselection.button.browse = Browse...
|
||||
preference.rulesetselection.button.reference = Import by Reference
|
||||
preference.rulesetselection.button.copy = Import by Copy
|
||||
|
||||
preference.ruleedit.tab.rule = Rule
|
||||
preference.ruleedit.tab.properties = Properties
|
||||
preference.ruleedit.tab.description = Description
|
||||
preference.ruleedit.tab.filters = Filters
|
||||
@ -120,12 +124,16 @@ preference.ruleedit.label.min = Min
|
||||
preference.ruleedit.label.max = Max
|
||||
preference.ruleedit.label.default = Default
|
||||
|
||||
preference.ruleedit.label.ruleset_name = RuleSet name :
|
||||
preference.ruleedit.label.ruleset_name = RuleSet:
|
||||
preference.ruleedit.label.since = Since :
|
||||
preference.ruleedit.label.name = Rule name :
|
||||
preference.ruleedit.label.implementation_class = Rule implementation class :
|
||||
preference.ruleedit.label.implemented_by = Implemented by:
|
||||
preference.ruleedit.label.implementation_class = Implementation class:
|
||||
preference.ruleedit.label.message = Message :
|
||||
preference.ruleedit.label.priority = Priority :
|
||||
preference.ruleedit.label.language = Target language:
|
||||
preference.ruleedit.label.language.version.min = Min version:
|
||||
preference.ruleedit.label.language.version.max = Max version:
|
||||
preference.ruleedit.label.priority = Priority:
|
||||
preference.ruleedit.label.description = Description :
|
||||
preference.ruleedit.label.external_info_url = External Info URL :
|
||||
preference.ruleedit.label.examples = Examples :
|
||||
@ -133,8 +141,8 @@ preference.ruleedit.label.xpath = XPath :
|
||||
preference.ruleedit.label.xpath.version = XPath version :
|
||||
preference.ruleedit.button.rule_reference = Rule Reference
|
||||
preference.ruleedit.button.xpath_rule = XPath rule
|
||||
preference.ruleedit.button.uses_type_resolution = Uses Type Resolution
|
||||
preference.ruleedit.button.uses_dfa = Uses DFA
|
||||
preference.ruleedit.button.uses_type_resolution = Uses type resolution
|
||||
preference.ruleedit.button.uses_dfa = Uses data flow analysis
|
||||
preference.ruleedit.button.open_external_info_url = Open in Browser
|
||||
|
||||
# CPD preference page
|
||||
@ -180,6 +188,7 @@ view.filter.priority.4 = Show priority 4 violations
|
||||
view.filter.priority.5 = Show priority 5 violations
|
||||
view.filter.project_prefix = Show Project
|
||||
|
||||
view.action.disable.rule = Disable rule
|
||||
view.action.show_rule = Show Details ...
|
||||
view.action.review = Mark as reviewed
|
||||
view.action.remove_violation = Remove violation(s)
|
||||
@ -247,6 +256,7 @@ monitor.review = PMD : Review in progress...
|
||||
monitor.remove_reviews = PMD : Removing violations reviews...
|
||||
monitor.calc_stats = Calculating statistics ...
|
||||
monitor.calc_stats.package = Calculating package
|
||||
monitor.collect_markers = Collecting markers
|
||||
|
||||
# Error messages
|
||||
message.error.title = PMD Error
|
||||
|
@ -94,8 +94,10 @@
|
||||
id="net.sourceforge.pmd.eclipse.ui.preferences.pmdPreferencePage">
|
||||
</page>
|
||||
|
||||
<!--
|
||||
<page name="Ruleset preferences - BR" category="net.sourceforge.pmd.ui.preferences.generalPreferencesPage" class="net.sourceforge.pmd.eclipse.ui.preferences.br.PMDPreferencePage2" id="net.sourceforge.pmd.ui.preferences.pmdPreferencePage">
|
||||
<page name="PMD - Original" category="net.sourceforge.pmd.ui.preferences.generalPreferencesPage" class="net.sourceforge.pmd.eclipse.ui.preferences.PMDPreferencePage" id="net.sourceforge.pmd.ui.preferences.pmdPreferencePage">
|
||||
</page>
|
||||
<!--
|
||||
<page name="PMD -v1" category="net.sourceforge.pmd.ui.preferences.generalPreferencesPage" class="net.sourceforge.pmd.eclipse.ui.preferences.br.PMDPreferencePage" id="net.sourceforge.pmd.ui.preferences.pmdPreferencePage">
|
||||
</page>
|
||||
-->
|
||||
<page
|
||||
@ -271,6 +273,7 @@
|
||||
id="net.sourceforge.pmd.eclipse.ui.pmdClearReviewsAction">
|
||||
</action>
|
||||
</objectContribution>
|
||||
|
||||
<viewerContribution
|
||||
id="net.sourceforge.pmd.eclipse.ui.pmdTaskListContribution"
|
||||
targetID="org.eclipse.ui.views.TaskList">
|
||||
@ -344,7 +347,22 @@
|
||||
id="net.sourceforge.pmd.eclipse.ui.pmdFileCheckProjectAction"
|
||||
label="%action.checkpmd"
|
||||
menubarPath="additions"/>
|
||||
</objectContribution>
|
||||
</objectContribution>
|
||||
|
||||
<objectContribution
|
||||
adaptable="false"
|
||||
id="net.sourceforge.pmd.eclipse.ui.ruleContribution"
|
||||
objectClass="net.sourceforge.pmd.eclipse.ui.views.br.ViewRecord">
|
||||
<action
|
||||
class="net.sourceforge.pmd.eclipse.ui.actions.PMDCheckAction"
|
||||
enablesFor="+"
|
||||
icon="icons/pmd-icon-16.gif"
|
||||
id="net.sourceforge.pmd.eclipse.ui.pmdFileCheckProjectAction"
|
||||
label="%action.checkpmd"
|
||||
menubarPath="additions"/>
|
||||
</objectContribution>
|
||||
|
||||
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
@ -368,15 +386,8 @@
|
||||
category="net.sourceforge.pmd.eclipse.ui.views"
|
||||
name="%view.overview"
|
||||
id="net.sourceforge.pmd.eclipse.ui.views.violationOverview"/>
|
||||
<!--
|
||||
<view
|
||||
allowMultiple="false"
|
||||
icon="icons/icon_overview.gif"
|
||||
class="net.sourceforge.pmd.eclipse.ui.views.br.ViolationOverviewBR"
|
||||
category="net.sourceforge.pmd.eclipse.ui.views"
|
||||
name="Violation Overview BR"
|
||||
id="net.sourceforge.pmd.eclipse.ui.views.violationOverview.br"/>
|
||||
-->
|
||||
|
||||
|
||||
<view
|
||||
allowMultiple="false"
|
||||
icon="icons/icon_dataflow.png"
|
||||
@ -401,5 +412,31 @@
|
||||
name="%view.perspective"
|
||||
id="net.sourceforge.pmd.eclipse.ui.views.pmdPerspective"/>
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
point="org.eclipse.ui.commands">
|
||||
<command
|
||||
defaultHandler="net.sourceforge.pmd.eclipse.runtime.cmd.DisableRuleHandler"
|
||||
id="net.sourceforge.pmd.eclipse.plugin.rule.disable"
|
||||
name="DisableRule">
|
||||
</command>
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
point="org.eclipse.ui.menus">
|
||||
<menuContribution
|
||||
locationURI="menu:org.eclipse.ui.main.menu">
|
||||
<menu
|
||||
id="editMenu"
|
||||
label="Rule">
|
||||
<command
|
||||
commandId="net.sourceforge.pmd.eclipse.plugin.rule.disable"
|
||||
label="Disable"
|
||||
style="push"
|
||||
tooltip="Disables the rule">
|
||||
</command>
|
||||
</menu>
|
||||
</menuContribution>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
@ -1,8 +1,11 @@
|
||||
package net.sourceforge.pmd.eclipse.plugin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import net.sourceforge.pmd.RulePriority;
|
||||
import net.sourceforge.pmd.RuleSet;
|
||||
import net.sourceforge.pmd.RuleSetFactory;
|
||||
import net.sourceforge.pmd.RuleSetNotFoundException;
|
||||
@ -38,6 +41,7 @@ import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.resource.ImageRegistry;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.osgi.framework.Bundle;
|
||||
@ -62,6 +66,15 @@ public class PMDPlugin extends AbstractUIPlugin {
|
||||
Integer.valueOf(5)
|
||||
};
|
||||
|
||||
public static final Map<Object, RGB> colorsByPriority = new HashMap<Object, RGB>();
|
||||
|
||||
static {
|
||||
colorsByPriority.put(RulePriority.LOW, new RGB( 0,0,255) ); // blue
|
||||
colorsByPriority.put(RulePriority.MEDIUM_LOW, new RGB( 0,255,0) ); // green
|
||||
colorsByPriority.put(RulePriority.MEDIUM, new RGB( 255,255,0) ); // yellow
|
||||
colorsByPriority.put(RulePriority.MEDIUM_HIGH, new RGB( 255,0,255) ); // purple
|
||||
colorsByPriority.put(RulePriority.HIGH, new RGB( 255,0,0) ); // red
|
||||
}
|
||||
/**
|
||||
* The constructor
|
||||
*/
|
||||
|
@ -1,7 +1,9 @@
|
||||
package net.sourceforge.pmd.eclipse.runtime.builder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import net.sourceforge.pmd.RuleSet;
|
||||
@ -12,8 +14,10 @@ import net.sourceforge.pmd.util.StringUtil;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IResourceVisitor;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
@ -28,7 +32,7 @@ public class MarkerUtil {
|
||||
|
||||
public static boolean hasAnyRuleMarkers(IResource resource) throws CoreException {
|
||||
|
||||
final boolean foundOne[] = new boolean[] { false };
|
||||
final boolean[] foundOne = new boolean[] { false };
|
||||
|
||||
IResourceVisitor ruleMarkerFinder = new IResourceVisitor() {
|
||||
|
||||
@ -64,6 +68,25 @@ public class MarkerUtil {
|
||||
return foundOne[0];
|
||||
}
|
||||
|
||||
private static IProject projectFor(IResource resource) {
|
||||
|
||||
if (resource instanceof IWorkspaceRoot) return null;
|
||||
if (resource instanceof IProject) return (IProject)resource;
|
||||
return projectFor(resource.getParent());
|
||||
}
|
||||
|
||||
public static Set<IProject> commonProjectsOf(IMarker[] markers) {
|
||||
|
||||
Set<IProject> projects = new HashSet<IProject>();
|
||||
|
||||
for (IMarker marker : markers) {
|
||||
IProject project = projectFor(marker.getResource());
|
||||
if (project != null) projects.add(project);
|
||||
}
|
||||
|
||||
return projects;
|
||||
}
|
||||
|
||||
public static String ruleNameFor(IMarker marker) {
|
||||
return marker.getAttribute(PMDUiConstants.KEY_MARKERATT_RULENAME, "");
|
||||
}
|
||||
@ -72,6 +95,31 @@ public class MarkerUtil {
|
||||
return ((Integer)marker.getAttribute(PMDUiConstants.KEY_MARKERATT_PRIORITY)).intValue();
|
||||
}
|
||||
|
||||
public static int deleteViolationsOf(String ruleName, IResource resource) {
|
||||
|
||||
try {
|
||||
IMarker[] markers = findAllMarkers(resource);
|
||||
if (markers.length == 0) return 0;
|
||||
|
||||
List<IMarker> matches = new ArrayList<IMarker>(markers.length);
|
||||
|
||||
for (IMarker marker : markers) {
|
||||
String name = ruleNameFor(marker);
|
||||
if (ruleName.equals(name)) {
|
||||
matches.add(marker);
|
||||
}
|
||||
}
|
||||
|
||||
markers = new IMarker[matches.size()];
|
||||
matches.toArray(markers);
|
||||
resource.getWorkspace().deleteMarkers(markers);
|
||||
|
||||
return markers.length;
|
||||
} catch (CoreException ex) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Rule> rulesFor(IMarker[] markers) {
|
||||
|
||||
List<Rule> rules = new ArrayList<Rule>(markers.length);
|
||||
|
16
pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/DisableRuleHandler.java
Executable file
16
pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/DisableRuleHandler.java
Executable file
@ -0,0 +1,16 @@
|
||||
package net.sourceforge.pmd.eclipse.runtime.cmd;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.ui.handlers.HandlerUtil;
|
||||
|
||||
public class DisableRuleHandler extends AbstractHandler {
|
||||
|
||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||
HandlerUtil.getActiveWorkbenchWindow(event).close();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -198,14 +198,14 @@ public class RenderReportCmd extends AbstractProjectCommand {
|
||||
|
||||
if (marker.getResource() instanceof IFile) {
|
||||
final ICompilationUnit unit = JavaCore.createCompilationUnitFrom((IFile) marker.getResource());
|
||||
final IPackageDeclaration packages[] = unit.getPackageDeclarations();
|
||||
final IPackageDeclaration[] packages = unit.getPackageDeclarations();
|
||||
if (packages.length > 0) {
|
||||
ruleViolation.setPackageName(packages[0].getElementName());
|
||||
} else {
|
||||
ruleViolation.setPackageName("(default)");
|
||||
}
|
||||
|
||||
IType types[] = unit.getAllTypes();
|
||||
IType[] types = unit.getAllTypes();
|
||||
if (types.length > 0) {
|
||||
ruleViolation.setClassName(types[0].getElementName());
|
||||
} else {
|
||||
|
@ -257,7 +257,7 @@ public class ReviewCodeCmd extends AbstractDefaultCommand {
|
||||
if (resources.isEmpty()) {
|
||||
rule = ruleFactory.markerRule(resourceDelta.getResource().getProject());
|
||||
} else {
|
||||
ISchedulingRule rules[] = new ISchedulingRule[resources.size()];
|
||||
ISchedulingRule[] rules = new ISchedulingRule[resources.size()];
|
||||
for (int i = 0; i < rules.length; i++) {
|
||||
rules[i] = ruleFactory.markerRule((IResource) resources.get(i));
|
||||
}
|
||||
@ -313,6 +313,8 @@ public class ReviewCodeCmd extends AbstractDefaultCommand {
|
||||
fileCount += visitor.getProcessedFilesCount();
|
||||
pmdDuration += visitor.getActualPmdDuration();
|
||||
|
||||
worked(1); // TODO - temp fix? BR
|
||||
|
||||
} catch (PropertiesException e) {
|
||||
throw new CommandException(e);
|
||||
} catch (CoreException e) {
|
||||
@ -432,7 +434,7 @@ public class ReviewCodeCmd extends AbstractDefaultCommand {
|
||||
currentFile = file.getName();
|
||||
|
||||
final Set<MarkerInfo> markerInfoSet = markersByFile.get(file);
|
||||
MarkerUtil.deleteAllMarkersIn(file);
|
||||
// MarkerUtil.deleteAllMarkersIn(file);
|
||||
final Iterator<MarkerInfo> j = markerInfoSet.iterator();
|
||||
while (j.hasNext()) {
|
||||
final MarkerInfo markerInfo = j.next();
|
||||
|
@ -35,8 +35,9 @@ public class PreferenceUIStore {
|
||||
private static final char stringSeparator = ',';
|
||||
|
||||
private static final RuleColumnDescriptor[] defaultHiddenColumns = new RuleColumnDescriptor[] {
|
||||
TextColumnDescriptor.externalURL, TextColumnDescriptor.minLangVers,
|
||||
TextColumnDescriptor.exampleCount, TextColumnDescriptor.since
|
||||
TextColumnDescriptor.externalURL, TextColumnDescriptor.minLangVers, TextColumnDescriptor.fixCount,
|
||||
TextColumnDescriptor.exampleCount, TextColumnDescriptor.maxLangVers, TextColumnDescriptor.since,
|
||||
TextColumnDescriptor.modCount
|
||||
};
|
||||
|
||||
private static final boolean defaultSortUp = false;
|
||||
|
@ -74,12 +74,15 @@ public class PMDUiConstants {
|
||||
public static final String ICON_LABEL_ERR5 = "icons/lab_err5.gif";
|
||||
public static final String ICON_LABEL_ERR_DFA = "icons/lab_errdfa.gif";
|
||||
|
||||
public static final String ICON_FILTER = "icons/filter.gif";
|
||||
public static final String ICON_FILTER_R = "icons/filter_r.png";
|
||||
public static final String ICON_FILTER_X = "icons/filter_x.png";
|
||||
|
||||
public static final String ICON_PROJECT = "icons/obj_project.gif";
|
||||
public static final String ICON_PACKAGE = "icons/obj_package.gif";
|
||||
public static final String ICON_JAVACU = "icons/obj_javacu.gif";
|
||||
|
||||
|
||||
public static final String ICON_BUTTON_DIAMOND_WHITE = "icons/btn_diamond_white.png";
|
||||
|
||||
public static final String ICON_BUTTON_PRIO0 = "icons/btn_prio0.png";
|
||||
public static final String ICON_BUTTON_PRIO1 = "icons/btn_prio1.gif";
|
||||
@ -112,6 +115,7 @@ public class PMDUiConstants {
|
||||
public static final String ICON_BUTTON_EXPORT = "icons/export.gif";
|
||||
public static final String ICON_BUTTON_EDITOR = "icons/editTool.png";
|
||||
public static final String ICON_BUTTON_SORT_CHECKED = "icons/sortChecked.png";
|
||||
public static final String ICON_BUTTON_RELOAD = "icons/icon_spinningArrows.png";
|
||||
|
||||
public static final String ICON_GREEN_CHECK = "icons/icon_greenCheck.png";
|
||||
public static final String ICON_EMPTY = "icons/icon_empty.png";
|
||||
|
@ -2,7 +2,6 @@ package net.sourceforge.pmd.eclipse.ui.actions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.sourceforge.pmd.Rule;
|
||||
@ -14,6 +13,8 @@ import net.sourceforge.pmd.RuleSet;
|
||||
*/
|
||||
public class RuleSetUtil {
|
||||
|
||||
private RuleSetUtil() {}
|
||||
|
||||
public static RuleSet newCopyOf(RuleSet original) {
|
||||
|
||||
RuleSet rs = new RuleSet();
|
||||
|
@ -51,7 +51,6 @@ import java.util.StringTokenizer;
|
||||
import net.sourceforge.pmd.eclipse.plugin.PMDPlugin;
|
||||
import net.sourceforge.pmd.eclipse.runtime.PMDRuntimeConstants;
|
||||
import net.sourceforge.pmd.eclipse.runtime.builder.MarkerUtil;
|
||||
import net.sourceforge.pmd.eclipse.ui.PMDUiConstants;
|
||||
import net.sourceforge.pmd.eclipse.ui.nls.StringKeys;
|
||||
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
@ -267,17 +266,16 @@ public class FileRecord extends AbstractPMDRecord {
|
||||
* The Function is adapted from the Eclipse Metrics-Plugin available at:
|
||||
* http://www.sourceforge.net/projects/metrics
|
||||
*
|
||||
* @return the Lines of Code
|
||||
*/
|
||||
public void calculateLinesOfCode() {
|
||||
if (this.resource.isAccessible()) {
|
||||
if (resource.isAccessible()) {
|
||||
|
||||
// the whole while has to be a String for this operation
|
||||
// so we read the File line-wise into a String
|
||||
|
||||
final String source = resourceToString(this.resource);
|
||||
final String source = resourceToString(resource);
|
||||
|
||||
this.numberOfLOC = linesOfCodeIn(source, true);
|
||||
numberOfLOC = linesOfCodeIn(source, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,8 +95,10 @@ public class StringKeys {
|
||||
public static final String MSGKEY_PREF_RULESET_COLUMN_FILTERS_REGEX = "preference.ruleset.column.filters.regex";
|
||||
public static final String MSGKEY_PREF_RULESET_COLUMN_FILTERS_XPATH = "preference.ruleset.column.filters.xpath";
|
||||
public static final String MSGKEY_PREF_RULESET_COLUMN_MIN_VER = "preference.ruleset.column.minimum_version";
|
||||
public static final String MSGKEY_PREF_RULESET_COLUMN_MAX_VER = "preference.ruleset.column.maximum_version";
|
||||
public static final String MSGKEY_PREF_RULESET_COLUMN_PRIORITY = "preference.ruleset.column.priority";
|
||||
public static final String MSGKEY_PREF_RULESET_COLUMN_FIXCOUNT = "preference.ruleset.column.fixCount";
|
||||
public static final String MSGKEY_PREF_RULESET_COLUMN_MODCOUNT = "preference.ruleset.column.modCount";
|
||||
public static final String MSGKEY_PREF_RULESET_COLUMN_PROPERTIES = "preference.ruleset.column.properties";
|
||||
public static final String MSGKEY_PREF_RULESET_COLUMN_DESCRIPTION = "preference.ruleset.column.description";
|
||||
public static final String MSGKEY_PREF_RULESET_COLUMN_PROPERTY = "preference.ruleset.column.property";
|
||||
@ -126,7 +128,8 @@ public class StringKeys {
|
||||
|
||||
public static final String MSGKEY_PREF_RULESET_BUTTON_CHECK_ALL = "preference.ruleset.button.tooltip.check.all";
|
||||
public static final String MSGKEY_PREF_RULESET_BUTTON_UNCHECK_ALL = "preference.ruleset.button.tooltip.uncheck.all";
|
||||
|
||||
|
||||
public static final String MSGKEY_PREF_RULESET_TAB_RULE = "preference.ruleedit.tab.rule";
|
||||
public static final String MSGKEY_PREF_RULESET_TAB_PROPERTIES = "preference.ruleedit.tab.properties";
|
||||
public static final String MSGKEY_PREF_RULESET_TAB_DESCRIPTION = "preference.ruleedit.tab.description";
|
||||
public static final String MSGKEY_PREF_RULESET_TAB_FILTERS = "preference.ruleedit.tab.filters";
|
||||
@ -148,7 +151,11 @@ public class StringKeys {
|
||||
public static final String MSGKEY_PREF_RULEEDIT_LABEL_SINCE = "preference.ruleedit.label.since";
|
||||
public static final String MSGKEY_PREF_RULEEDIT_LABEL_NAME = "preference.ruleedit.label.name";
|
||||
public static final String MSGKEY_PREF_RULEEDIT_LABEL_IMPLEMENTATION_CLASS = "preference.ruleedit.label.implementation_class";
|
||||
public static final String MSGKEY_PREF_RULEEDIT_LABEL_IMPLEMENTED_BY = "preference.ruleedit.label.implemented_by";
|
||||
public static final String MSGKEY_PREF_RULEEDIT_LABEL_MESSAGE = "preference.ruleedit.label.message";
|
||||
public static final String MSGKEY_PREF_RULEEDIT_LABEL_LANGUAGE = "preference.ruleedit.label.language";
|
||||
public static final String MSGKEY_PREF_RULEEDIT_LABEL_LANGUAGE_MIN = "preference.ruleedit.label.language.version.min";
|
||||
public static final String MSGKEY_PREF_RULEEDIT_LABEL_LANGUAGE_MAX = "preference.ruleedit.label.language.version.max";
|
||||
public static final String MSGKEY_PREF_RULEEDIT_LABEL_PRIORITY = "preference.ruleedit.label.priority";
|
||||
public static final String MSGKEY_PREF_RULEEDIT_LABEL_DESCRIPTION = "preference.ruleedit.label.description";
|
||||
public static final String MSGKEY_PREF_RULEEDIT_LABEL_EXTERNAL_INFO_URL = "preference.ruleedit.label.external_info_url";
|
||||
@ -228,7 +235,7 @@ public class StringKeys {
|
||||
public static final String MSGKEY_VIEW_TOOLTIP_CALCULATE_STATS = "view.tooltip.calc_stats";
|
||||
public static final String MSGKEY_VIEW_TOOLTIP_COMPUTE_METRICS = "view.tooltip.compute_metrics";
|
||||
public static final String MSGKEY_VIEW_ACTION_PROJECT = "view.action.project";
|
||||
public static final String MSGKEY_VIEW_ACTION_DISABLE = "view.action.disable";
|
||||
public static final String MSGKEY_VIEW_ACTION_DISABLE_RULE = "view.action.disable.rule";
|
||||
public static final String MSGKEY_VIEW_ACTION_FILE = "view.action.file";
|
||||
public static final String MSGKEY_VIEW_ACTION_ERRORHIGH = "view.action.errorhigh";
|
||||
public static final String MSGKEY_VIEW_ACTION_ERROR = "view.action.error";
|
||||
@ -321,6 +328,7 @@ public class StringKeys {
|
||||
public static final String MSGKEY_MONITOR_REMOVE_REVIEWS = "monitor.remove_reviews";
|
||||
public static final String MSGKEY_MONITOR_CALC_STATS_TASK = "monitor.calc_stats";
|
||||
public static final String MSGKEY_MONITOR_CALC_STATS_OF_PACKAGE = "monitor.calc_stats.package";
|
||||
public static final String MSGKEY_MONITOR_COLLECTING_MARKERS = "monitor.collect_markers";
|
||||
|
||||
/**
|
||||
* This class is not meant to be instanciated
|
||||
|
@ -5,7 +5,6 @@ import net.sourceforge.pmd.eclipse.runtime.preferences.IPreferences;
|
||||
import net.sourceforge.pmd.eclipse.ui.nls.StringKeys;
|
||||
import net.sourceforge.pmd.eclipse.ui.preferences.br.AbstractPMDPreferencePage;
|
||||
|
||||
import org.eclipse.jface.preference.PreferencePage;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
|
54
pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/AbstractColumnDescriptor.java
Executable file
54
pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/AbstractColumnDescriptor.java
Executable file
@ -0,0 +1,54 @@
|
||||
package net.sourceforge.pmd.eclipse.ui.preferences.br;
|
||||
|
||||
import net.sourceforge.pmd.eclipse.ui.preferences.editors.SWTUtil;
|
||||
import net.sourceforge.pmd.eclipse.util.ResourceManager;
|
||||
|
||||
import org.eclipse.swt.widgets.Tree;
|
||||
import org.eclipse.swt.widgets.TreeColumn;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Brian Remedios
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractColumnDescriptor implements ColumnDescriptor {
|
||||
|
||||
private final String label;
|
||||
private final String tooltip;
|
||||
private final int alignment;
|
||||
private final int width;
|
||||
private final boolean isResizable;
|
||||
private final String imagePath;
|
||||
|
||||
public AbstractColumnDescriptor(String labelKey, int theAlignment, int theWidth, boolean resizableFlag, String theImagePath) {
|
||||
super();
|
||||
|
||||
label = SWTUtil.stringFor(labelKey);
|
||||
tooltip = SWTUtil.tooltipFor(labelKey);
|
||||
alignment = theAlignment;
|
||||
width = theWidth;
|
||||
isResizable = resizableFlag;
|
||||
imagePath = theImagePath;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.sourceforge.pmd.eclipse.ui.preferences.br.ColumnDescriptor#label()
|
||||
*/
|
||||
public String label() { return label; }
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.sourceforge.pmd.eclipse.ui.preferences.br.ColumnDescriptor#tooltip()
|
||||
*/
|
||||
public String tooltip() { return tooltip; }
|
||||
|
||||
protected TreeColumn buildTreeColumn(Tree parent, final RuleSortListener sortListener) {
|
||||
|
||||
final TreeColumn tc = new TreeColumn(parent, alignment);
|
||||
tc.setWidth(width);
|
||||
tc.setResizable(isResizable);
|
||||
tc.setToolTipText(tooltip);
|
||||
if (imagePath != null) tc.setImage(ResourceManager.imageFor(imagePath));
|
||||
|
||||
return tc;
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import net.sourceforge.pmd.eclipse.plugin.PMDPlugin;
|
||||
import net.sourceforge.pmd.eclipse.runtime.preferences.IPreferences;
|
||||
|
||||
import org.eclipse.jface.preference.PreferencePage;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||
|
||||
@ -12,10 +13,10 @@ public abstract class AbstractPMDPreferencePage extends PreferencePage implement
|
||||
protected IPreferences preferences;
|
||||
private boolean modified;
|
||||
|
||||
protected static PMDPlugin plugin = PMDPlugin.getDefault();
|
||||
|
||||
protected static PMDPlugin plugin = PMDPlugin.getDefault();
|
||||
|
||||
abstract protected String descriptionId();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the isModified.
|
||||
* @return boolean
|
||||
@ -23,7 +24,7 @@ public abstract class AbstractPMDPreferencePage extends PreferencePage implement
|
||||
public boolean isModified() {
|
||||
return modified;
|
||||
}
|
||||
|
||||
|
||||
public void setModified() {
|
||||
setModified(true);
|
||||
}
|
||||
@ -33,31 +34,35 @@ public abstract class AbstractPMDPreferencePage extends PreferencePage implement
|
||||
*/
|
||||
public void setModified(boolean isModified) {
|
||||
modified = isModified;
|
||||
|
||||
// can be null for some reason ..argh
|
||||
Button button = getApplyButton();
|
||||
if (button != null) button.setEnabled(modified);
|
||||
|
||||
getApplyButton().setEnabled(modified);
|
||||
getDefaultsButton().setEnabled(!modified);
|
||||
button = getDefaultsButton();
|
||||
if (button != null) button.setEnabled(!modified);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert the method's description here.
|
||||
* @see PreferencePage#init
|
||||
*/
|
||||
|
||||
|
||||
public void init(IWorkbench workbench) {
|
||||
setDescription(getMessage(descriptionId()));
|
||||
preferences = PMDPlugin.getDefault().loadPreferences();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jface.preference.IPreferencePage#performOk()
|
||||
*/
|
||||
public boolean performOk() {
|
||||
|
||||
|
||||
preferences.sync();
|
||||
|
||||
return super.performOk();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper method to shorten message access
|
||||
* @param key a message key
|
||||
@ -66,5 +71,5 @@ public abstract class AbstractPMDPreferencePage extends PreferencePage implement
|
||||
protected String getMessage(String key) {
|
||||
return PMDPlugin.getDefault().getStringTable().getString(key);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,9 @@
|
||||
package net.sourceforge.pmd.eclipse.ui.preferences.br;
|
||||
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import net.sourceforge.pmd.eclipse.ui.preferences.editors.SWTUtil;
|
||||
import net.sourceforge.pmd.eclipse.util.ResourceManager;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Tree;
|
||||
@ -13,59 +12,55 @@ import org.eclipse.swt.widgets.TreeColumn;
|
||||
/**
|
||||
* Retains all values necessary to hydrate a table column for holding a set of rules. Invoke the buildTreeColumn()
|
||||
* method to constitute one. As descriptors they can be held as static items since they they're immutable.
|
||||
*
|
||||
*
|
||||
* @author Brian Remedios
|
||||
*/
|
||||
public abstract class AbstractRuleColumnDescriptor implements RuleColumnDescriptor {
|
||||
public abstract class AbstractRuleColumnDescriptor extends AbstractColumnDescriptor implements RuleColumnDescriptor {
|
||||
|
||||
private final String label;
|
||||
private final String tooltip;
|
||||
private final int alignment;
|
||||
private final int width;
|
||||
private final RuleFieldAccessor accessor;
|
||||
private final boolean isResizable;
|
||||
private final String imagePath;
|
||||
|
||||
|
||||
protected AbstractRuleColumnDescriptor(String labelKey, int theAlignment, int theWidth, RuleFieldAccessor theAccessor, boolean resizableFlag, String theImagePath) {
|
||||
super();
|
||||
|
||||
label = SWTUtil.stringFor(labelKey);
|
||||
tooltip = SWTUtil.tooltipFor(labelKey);
|
||||
alignment = theAlignment;
|
||||
width = theWidth;
|
||||
super(labelKey, theAlignment, theWidth, resizableFlag, theImagePath);
|
||||
|
||||
accessor = theAccessor;
|
||||
isResizable = resizableFlag;
|
||||
imagePath = theImagePath;
|
||||
}
|
||||
|
||||
|
||||
protected TreeColumn buildTreeColumn(Tree parent, final RuleSortListener sortListener) {
|
||||
|
||||
final TreeColumn tc = new TreeColumn(parent, alignment);
|
||||
tc.setWidth(width);
|
||||
tc.setResizable(isResizable);
|
||||
tc.setToolTipText(tooltip);
|
||||
if (imagePath != null) tc.setImage(ResourceManager.imageFor(imagePath));
|
||||
|
||||
|
||||
TreeColumn tc = super.buildTreeColumn(parent, sortListener);
|
||||
|
||||
tc.addListener(SWT.Selection, new Listener() {
|
||||
public void handleEvent(Event e) {
|
||||
sortListener.sortBy(accessor(), e.widget);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
return tc;
|
||||
}
|
||||
|
||||
|
||||
protected Object valueFor(Rule rule) {
|
||||
return accessor.valueFor(rule);
|
||||
return accessor.valueFor(rule);
|
||||
}
|
||||
|
||||
protected Object valueFor(RuleCollection collection) {
|
||||
return accessor.valueFor(collection);
|
||||
}
|
||||
|
||||
public String label() { return label; }
|
||||
|
||||
public String tooltip() { return tooltip; }
|
||||
|
||||
public RuleFieldAccessor accessor() { return accessor; }
|
||||
|
||||
|
||||
public String detailStringFor(Rule rule) {
|
||||
return accessor.labelFor(rule);
|
||||
}
|
||||
|
||||
public String detailStringFor(RuleGroup group) {
|
||||
return "TODO in AbstractRuleColumnDescriptor";
|
||||
}
|
||||
|
||||
public Image imageFor(RuleCollection collection) {
|
||||
return null; // override in subclasses
|
||||
}
|
||||
|
||||
public String stringValueFor(RuleCollection collection) {
|
||||
return null; // override in subclasses
|
||||
}
|
||||
}
|
466
pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/AbstractTreeTableManager.java
Executable file
466
pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/AbstractTreeTableManager.java
Executable file
File diff suppressed because it is too large
Load Diff
@ -1,9 +1,12 @@
|
||||
package net.sourceforge.pmd.eclipse.ui.preferences.br;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import net.sourceforge.pmd.Rule;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Brian Remedios
|
||||
*/
|
||||
public class BasicRuleFieldAccessor implements RuleFieldAccessor {
|
||||
@ -19,4 +22,30 @@ public class BasicRuleFieldAccessor implements RuleFieldAccessor {
|
||||
public Comparable<?> valueFor(Rule rule) {
|
||||
throw new RuntimeException("unimplemented method");
|
||||
}
|
||||
|
||||
public Comparable<?> valueFor(RuleCollection collection) {
|
||||
Comparable<?> aspect = RuleUtil.commonAspect(collection, this);
|
||||
if (aspect != null) return aspect;
|
||||
return asString( RuleUtil.uniqueAspects(collection, this) );
|
||||
}
|
||||
|
||||
public Set<Comparable<?>> uniqueValuesFor(RuleCollection collection) {
|
||||
return RuleUtil.uniqueAspects(collection, this);
|
||||
}
|
||||
|
||||
protected String format(Object item) {
|
||||
return item == null ? "" : String.valueOf(item);
|
||||
}
|
||||
|
||||
protected String asString(Set<Comparable<?>> items) {
|
||||
|
||||
Iterator<Comparable<?>> iter = items.iterator();
|
||||
if (items.size() == 1) return format(iter.next());
|
||||
|
||||
StringBuilder sb = new StringBuilder(format(iter.next()));
|
||||
while (iter.hasNext()) {
|
||||
sb.append(", ").append(format(iter.next()));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
25
pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/BasicValueFormatter.java
Executable file
25
pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/ui/preferences/br/BasicValueFormatter.java
Executable file
@ -0,0 +1,25 @@
|
||||
package net.sourceforge.pmd.eclipse.ui.preferences.br;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Brian Remedios
|
||||
*/
|
||||
public class BasicValueFormatter implements ValueFormatter {
|
||||
|
||||
/**
|
||||
* Override in subclasses
|
||||
*/
|
||||
public String format(Object value) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
format(value, sb);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Override in subclasses
|
||||
*/
|
||||
public void format(Object value, StringBuilder target) {
|
||||
target.append(value);
|
||||
}
|
||||
|
||||
}
|
@ -6,7 +6,7 @@ import java.util.Map;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Tree;
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Brian Remedios
|
||||
*/
|
||||
public interface CellPainterBuilder {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user