From 4a60b812ecf09a9ae01d5b79b717a8ea42a5b91b Mon Sep 17 00:00:00 2001 From: Xavier Le Vourch Date: Fri, 26 Sep 2008 19:47:12 +0000 Subject: [PATCH] all rule examples displayed in Rule Configuration panel git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@6517 51baf565-9d33-0410-a72c-fc3788e3496d --- .../CHANGELOG.txt | 2 ++ .../RELNOTES.txt | 2 ++ .../messages.properties | 2 +- .../nl/fr/messages.properties | 2 +- .../sourceforge/pmd/ui/nls/StringKeys.java | 2 +- .../pmd/ui/preferences/RuleDialog.java | 27 ++++++++++++++++--- 6 files changed, 31 insertions(+), 6 deletions(-) diff --git a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/CHANGELOG.txt b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/CHANGELOG.txt index e5afde7edd..b80515d17f 100644 --- a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/CHANGELOG.txt +++ b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/CHANGELOG.txt @@ -4,6 +4,8 @@ v3.2.5 . PMD updated to v4.2.3 . plugin reorganization +. code cleanup +. all rule examples displayed in Rule Configuration panel ---------------------------------------------------------------------------------------- v3.2.4 - April 11 2008 diff --git a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/RELNOTES.txt b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/RELNOTES.txt index 10906c0beb..3ccc8dd99b 100644 --- a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/RELNOTES.txt +++ b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/RELNOTES.txt @@ -7,6 +7,8 @@ PMD to 4.2.3 plugin reorganization +code cleanup + v3.2.4 April 11 2008 ------------------ diff --git a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/messages.properties b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/messages.properties index 4c6aaeab37..46660465bf 100644 --- a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/messages.properties +++ b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/messages.properties @@ -81,7 +81,7 @@ preference.ruleedit.label.message = Message : preference.ruleedit.label.priority = Priority : preference.ruleedit.label.description = Description : preference.ruleedit.label.external_info_url = External Info URL : -preference.ruleedit.label.example = Example : +preference.ruleedit.label.examples = Examples : preference.ruleedit.label.xpath = XPath : preference.ruleedit.button.rule_reference = Rule Reference preference.ruleedit.button.xpath_rule = XPath rule diff --git a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/nl/fr/messages.properties b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/nl/fr/messages.properties index cc4d2c4d12..ed8c13a134 100644 --- a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/nl/fr/messages.properties +++ b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/nl/fr/messages.properties @@ -81,7 +81,7 @@ preference.ruleedit.label.message = Message : preference.ruleedit.label.priority = Priorité : preference.ruleedit.label.description = Description : preference.ruleedit.label.external_info_url = URL d'information externe : -preference.ruleedit.label.example = Exemple : +preference.ruleedit.label.examples = Exemples : preference.ruleedit.label.xpath = XPath : preference.ruleedit.button.rule_reference = Règle Reference preference.ruleedit.button.xpath_rule = Règle XPath diff --git a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/ui/nls/StringKeys.java b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/ui/nls/StringKeys.java index 03d033c015..6cf4d33924 100644 --- a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/ui/nls/StringKeys.java +++ b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/ui/nls/StringKeys.java @@ -190,7 +190,7 @@ public class StringKeys { 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"; - public static final String MSGKEY_PREF_RULEEDIT_LABEL_EXAMPLE = "preference.ruleedit.label.example"; + public static final String MSGKEY_PREF_RULEEDIT_LABEL_EXAMPLES = "preference.ruleedit.label.examples"; public static final String MSGKEY_PREF_RULEEDIT_LABEL_XPATH = "preference.ruleedit.label.xpath"; public static final String MSGKEY_PREF_RULEEDIT_BUTTON_RULE_REFERENCE = "preference.ruleedit.button.rule_reference"; public static final String MSGKEY_PREF_RULEEDIT_BUTTON_XPATH_RULE = "preference.ruleedit.button.xpath_rule"; diff --git a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/ui/preferences/RuleDialog.java b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/ui/preferences/RuleDialog.java index 23520145d8..8f5fe2642f 100644 --- a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/ui/preferences/RuleDialog.java +++ b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/ui/preferences/RuleDialog.java @@ -2,6 +2,7 @@ package net.sourceforge.pmd.ui.preferences; import java.net.MalformedURLException; import java.net.URL; +import java.util.Iterator; import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleReference; @@ -241,7 +242,7 @@ public class RuleDialog extends Dialog { data.grabExcessHorizontalSpace = true; externalInfoUrlText.setLayoutData(data); - Label exampleLabel = buildLabel(dlgArea, StringKeys.MSGKEY_PREF_RULEEDIT_LABEL_EXAMPLE); + Label exampleLabel = buildLabel(dlgArea, StringKeys.MSGKEY_PREF_RULEEDIT_LABEL_EXAMPLES); data = new GridData(); data.horizontalSpan = 4; exampleLabel.setLayoutData(data); @@ -604,6 +605,26 @@ public class RuleDialog extends Dialog { return button; } + /** + * Concatenate all the rule examples in one String. + * + * @return the concatenation of all example strings + */ + private String getExamplesString() { + StringBuffer buffer = new StringBuffer(); + Iterator i = this.editedRule.getExamples().iterator(); + boolean first = true; + while (i.hasNext()) { + if (first) { + first = false; + } else { + buffer.append("\n\n"); + } + buffer.append(((String)i.next()).trim()); + } + return buffer.toString(); + } + /** * Build the example text */ @@ -611,12 +632,12 @@ public class RuleDialog extends Dialog { Text text = new Text(parent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); text.setFont(courierFont); if (mode == MODE_EDIT) { - text.setText(this.editedRule.getExample().trim()); + text.setText(getExamplesString()); } if (mode == MODE_VIEW) { text.setEditable(false); - text.setText(this.editedRule.getExample().trim()); + text.setText(getExamplesString()); } return text;