done for now, prepping for release

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@250 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Tom Copeland
2002-07-09 17:41:12 +00:00
parent af3eac4e47
commit dd5e931533
4 changed files with 27 additions and 11 deletions

View File

@ -1,5 +1,6 @@
???? 2002 - 0.2:
Fixed bug - empty msg box is displayed if no errors are found.
Fixed bug - a message, not an empty box, is now displayed if no errors are found.
Added options pane so rulesets are selectable and selctions are persistant.
July 8 2002 - 0.1:
Initial release

View File

@ -46,18 +46,25 @@ public class PMDJEditPlugin extends EBPlugin {
PMD pmd = new PMD();
ReportFactory rf = new ReportFactory();
RuleContext ctx = new RuleContext();
RuleSetFactory ruleSetFactory = new RuleSetFactory();
RuleSet rules = ruleSetFactory.createRuleSet(pmd.getClass().getClassLoader().getResourceAsStream("rulesets/unusedcode.xml"));
SelectedRuleSetsMap selectedRuleSets = new SelectedRuleSetsMap();
RuleSet rules = new RuleSet();
for (Iterator i = selectedRuleSets.getSelectedRuleSetFileNames(); i.hasNext();) {
rules.addRuleSet(ruleSetFactory.createRuleSet(pmd.getClass().getClassLoader().getResourceAsStream((String)i.next())));
}
ctx.setReport(rf.createReport("xml"));
ctx.setSourceCodeFilename("this");
try {
// TODO switch to use StringReader once PMD 0.4 gets released
pmd.processFile(new StringBufferInputStream(view.getTextArea().getText()), rules, ctx);
// TODO put this in a list box or something
StringBuffer msg = new StringBuffer();
for (Iterator i = ctx.getReport().iterator(); i.hasNext();) {
RuleViolation rv = (RuleViolation)i.next();
msg.append(rv.getDescription() + " at line " + rv.getLine() + System.getProperty("line.separator"));
msg.append(rv.getDescription() + System.getProperty("line.separator"));
}
if (msg.length() == 0) {
msg.append("No errors found");

View File

@ -32,17 +32,16 @@ public class PMDOptionPane extends AbstractOptionPane implements OptionPane {
}
}
private static final String NAME = "PMD Options";
private SelectedRuleSetsMap selectedRuleSets = new SelectedRuleSetsMap();
private JDialog dialog;
public PMDOptionPane() {
super(NAME);
super(PMDJEditPlugin.NAME);
_init();
}
public String getName() {
return NAME;
return PMDJEditPlugin.NAME;
}
@ -70,8 +69,8 @@ public class PMDOptionPane extends AbstractOptionPane implements OptionPane {
closeButton.addActionListener(new CloseAL());
buttonPanel.add(closeButton);
dialog = new JDialog(jEdit.getFirstView(), "PMD", true);
dialog.setTitle("PMD");
dialog = new JDialog(jEdit.getFirstView(), PMDJEditPlugin.NAME, true);
dialog.setTitle(PMDJEditPlugin.NAME);
dialog.getContentPane().setLayout(new BorderLayout());
dialog.getContentPane().add(checkBoxPanel, BorderLayout.CENTER);
dialog.getContentPane().add(buttonPanel, BorderLayout.SOUTH);

View File

@ -8,9 +8,7 @@ package net.sourceforge.pmd.jedit;
import org.gjt.sp.jedit.jEdit;
import javax.swing.*;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.*;
public class SelectedRuleSetsMap {
private Map selections = new HashMap();
@ -40,6 +38,17 @@ public class SelectedRuleSetsMap {
}
}
public Iterator getSelectedRuleSetFileNames() {
List selected = new ArrayList();
for (Iterator i = keys(); i.hasNext();) {
String key = (String)i.next();
if (get(key).isSelected()) {
selected.add("rulesets/" + key + ".xml");
}
}
return selected.iterator();
}
private JCheckBox createCheckBox(String name) {
JCheckBox box = new JCheckBox();
box.setSelected(jEdit.getBooleanProperty(PMDJEditPlugin.OPTION_RULESETS_PREFIX + name, true));