moved options into JEdit config area

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@462 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Tom Copeland
2002-07-22 19:57:18 +00:00
parent 002bb4a596
commit 6b9a60a895
8 changed files with 53 additions and 119 deletions

View File

@ -1,14 +1,9 @@
<?xml version="1.0"?>
<!DOCTYPE ACTIONS SYSTEM "actions.dtd">
<ACTIONS>
<ACTION NAME="pmd.check">
<ACTION NAME="PMD">
<CODE>
net.sourceforge.pmd.jedit.PMDJEditPlugin.check(buffer, view);
</CODE>
</ACTION>
<ACTION NAME="pmd.options">
<CODE>
net.sourceforge.pmd.jedit.PMDJEditPlugin.displayPreferencesDialog(view);
</CODE>
</ACTION>
</ACTIONS>
</ACTIONS>

View File

@ -1,32 +1,23 @@
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>
PMD JEdit Plug-in Users' Guide
PMD-JEdit Plug-in Users' Guide
</title>
<body>
<h1>PMD JEdit Plug-in Users' Guide</h1>
<h1>PMD-JEdit Plug-in Users' Guide</h1>
<hr>
<h2>Installation</h2>
<h3>System requirements</h3>
<p>PMD is a Java source code analyzer. The PMD JEdit Plugin requires at least JEdit 4.0final. <a href="http://pmd.sf.net/" target="_blank">Here's</a> the PMD web site.</p>
<p>PMD is a Java source code analyzer - it finds unused variables, questionable design decisions, empty catch blocks, and so forth.
You can read much more about PMD here - http://pmd.sf.net/.</p>
<h3>Installation</h3>
<p>First, you may have to delete old version of the PMD plugin from your jars directory... you can pretty much just delete any jar file starting with "pmd" to be on the safe side. Then, unzip the PMD-Jedit .zip file.
Just unzip it into your JEdit directory and it'll put a couple of jar files into your jars directory, restart JEdit,
and you'll be ready to go. </p>
<h2>Integration</h2>
<p>The software adds a new menu item group into the <b>Plugins</b> menu of the editor view. There are several menu items:</p>
<ul>
<li>
<b>Plugins</b>-&gt;<b>PMD</b>-&gt;<b>Check code</b> - checks your currently displayed Java code pops up a window with the results.</p>
</li>
<li>
<b>Plugins</b>-&gt;<b>PMD</b>-&gt;<b>Options</b> - here's where you can choose what rulesets you want to use to check your code.</p>
</li>
<li>Uninstall any old PMD-JEdit plugins
<li>Unzip the PMD-JEdit-bin-0.5.zip file into your JEdit directory; it'll put a couple of jar files into your jars directory.
<li>Restart JEdit and you'll be ready to go.
</ul>
<h2>License</h2>
<p>The JEdit Plug-in is free software, released under the Apache license.</p>
<h3>Integration</h3>
<p>There's a new 'PMD' menu item in the Plugins menu. This checks your currently displayed Java code and puts the results in the ErrorList.</p>
<p>There's also a new section in the Global Options configuration panel that lets you pick rule sets.</p>
<h3>License</h3>
<p>The PMD-JEdit plugin is free software released under the Apache license.</p>
</body>
</html>

View File

@ -12,10 +12,11 @@ plugin.net.sourceforge.pmd.jedit.PMDJEditPlugin.jars=pmd-0.6.jar
#
# Menu properties
#
pmd-menu=pmd.check - pmd.options
pmd-menu.label=PMD
pmd.check.label=$Check code
pmd.options.label=$Options
PMD.label=$PMD
#
# Option pane properties
#
options.pmd.title=PMD
options.pmd.label=PMD

View File

@ -35,7 +35,7 @@
</target>
<target name="jar">
<jar jarfile="${lib}/${ant.project.name}.jar">
<jar jarfile="${lib}/${ant.project.name}-${pluginversion}.jar">
<fileset dir="${build}"/>
<fileset dir="${config}">
<include name="*.props"/>
@ -48,7 +48,7 @@
<target name="dist" depends="clean">
<antcall target="jar"/>
<copy file="${lib}/${ant.project.name}.jar" todir="${jedit.install.dir}"/>
<copy file="${lib}/${ant.project.name}-${pluginversion}.jar" todir="${jedit.install.dir}"/>
</target>
<target name="release">

View File

@ -1,4 +1,7 @@
???? 2002 - 0.5:
July 22 2002 - 0.5:
Moved options into Global Options area and made them look nicer.
Cleaned up menus.
Cleaned up help text.
July 18 2002 - 0.4:
Updated to use pmd-0.6

View File

@ -18,21 +18,20 @@ import java.io.StringReader;
import net.sourceforge.pmd.*;
public class PMDJEditPlugin extends EBPlugin {
public class PMDJEditPlugin extends EditPlugin {
public static final String NAME = "PMD";
public static final String MENU = "pmd-menu";
public static final String PROPERTY_PREFIX = "plugin.net.sourceforge.pmd.jedit.";
public static final String OPTION_PREFIX = "options.pmd.";
public static final String OPTION_RULESETS_PREFIX = "options.pmd.rulesets.";
private static PMDJEditPlugin instance;
static {
instance = new PMDJEditPlugin();
instance.start();
}
private DefaultErrorSource errorSource;
// boilerplate JEdit code
@ -41,19 +40,19 @@ public class PMDJEditPlugin extends EBPlugin {
ErrorSource.registerErrorSource(errorSource);
}
public void createMenuItems(Vector menuItems) {
menuItems.addElement(GUIUtilities.loadMenuItem(NAME));
}
public void createOptionPanes(OptionsDialog optionsDialog) {
optionsDialog.addOptionPane(new PMDOptionPane());
}
// boilerplate JEdit code
public static void check(Buffer buffer, View view) {
instance.instanceCheck(buffer, view);
}
public static void displayPreferencesDialog(View view) {
instance.instanceDisplayPreferencesDialog(view);
}
public void createMenuItems(Vector menuItems) {
menuItems.addElement(GUIUtilities.loadMenu(MENU));
}
// boilerplate JEdit code
public void instanceCheck(Buffer buffer, View view) {
try {
errorSource.clear();
@ -68,18 +67,18 @@ public class PMDJEditPlugin extends EBPlugin {
ctx.setReport(new Report());
ctx.setSourceCodeFilename(buffer.getPath());
pmd.processFile(new StringReader(view.getTextArea().getText()), rules, ctx);
for (Iterator i = ctx.getReport().iterator(); i.hasNext();) {
RuleViolation rv = (RuleViolation)i.next();
if (ctx.getReport().isEmpty()) {
JOptionPane.showMessageDialog(jEdit.getFirstView(), "No problems found");
errorSource.clear();
} else {
String path = buffer.getPath();
DefaultErrorSource.DefaultError err = new DefaultErrorSource.DefaultError(errorSource, ErrorSource.WARNING, path, rv.getLine()-1,0,0,rv.getDescription());
errorSource.addError(err);
for (Iterator i = ctx.getReport().iterator(); i.hasNext();) {
RuleViolation rv = (RuleViolation)i.next();
errorSource.addError(new DefaultErrorSource.DefaultError(errorSource, ErrorSource.WARNING, path, rv.getLine()-1,0,0,rv.getDescription()));
}
}
} catch (RuleSetNotFoundException rsne) {
rsne.printStackTrace();
}
}
public void instanceDisplayPreferencesDialog(View view) {
new PMDOptionPane();
}
}

View File

@ -23,82 +23,28 @@ import net.sourceforge.pmd.RuleSet;
public class PMDOptionPane extends AbstractOptionPane implements OptionPane {
private class SaveAL implements ActionListener {
public void actionPerformed(ActionEvent e) {
selectedRuleSets.save();
}
}
private class CloseAL implements ActionListener {
public void actionPerformed(ActionEvent e) {
dialog.dispose();
}
}
private SelectedRuleSetsMap selectedRuleSets;
private JDialog dialog;
public PMDOptionPane() {
super(PMDJEditPlugin.NAME);
_init();
}
public String getName() {
return PMDJEditPlugin.NAME;
}
public void _init() {
super._init();
if (this.selectedRuleSets == null) {
if (selectedRuleSets == null) {
try {
selectedRuleSets = new SelectedRuleSetsMap();
} catch (RuleSetNotFoundException rsne) {
rsne.printStackTrace();
}
}
JPanel textPanel = new JPanel();
textPanel.setBackground(Color.white);
textPanel.setLayout(new BorderLayout());
textPanel.add(new JLabel("Select the rulesets you want to use and click 'Save'."), BorderLayout.NORTH);
textPanel.add(new JLabel("Please see http://pmd.sourceforge.net/ for more information on what's in each rule set."), BorderLayout.SOUTH);
JPanel checkBoxPanel = new JPanel();
checkBoxPanel.setBackground(Color.white);
checkBoxPanel.setBackground(Color.white);
checkBoxPanel.setLayout(new GridLayout(selectedRuleSets.size(), 2));
addComponent(new JLabel("Please see http://pmd.sourceforge.net/ for more information on what's in each rule set."));
for (Iterator i = selectedRuleSets.keys(); i.hasNext();) {
RuleSet rs = (RuleSet)i.next();
JPanel oneBoxPanel = new JPanel();
oneBoxPanel.setBackground(Color.white);
oneBoxPanel.add(new JLabel(rs.getName(), JLabel.LEFT));
oneBoxPanel.add((JCheckBox)selectedRuleSets.get(rs));
checkBoxPanel.add(oneBoxPanel);
addComponent((JCheckBox)selectedRuleSets.get(rs));
}
JButton saveButton = new JButton("Save");
saveButton.setMnemonic('s');
saveButton.addActionListener(new SaveAL());
JButton closeButton = new JButton("Close");
closeButton.setMnemonic('c');
closeButton.addActionListener(new CloseAL());
JPanel buttonPanel = new JPanel();
buttonPanel.setBackground(Color.white);
buttonPanel.add(saveButton);
buttonPanel.add(closeButton);
dialog = new JDialog(jEdit.getFirstView(), PMDJEditPlugin.NAME, true);
dialog.setTitle(PMDJEditPlugin.NAME);
dialog.getContentPane().setLayout(new BorderLayout());
dialog.getContentPane().add(textPanel, BorderLayout.NORTH);
dialog.getContentPane().add(checkBoxPanel, BorderLayout.CENTER);
dialog.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
dialog.setSize(new Dimension(500,300));
dialog.pack();
dialog.setLocationRelativeTo(jEdit.getFirstView());
dialog.setVisible(true);
}
public void save() {
selectedRuleSets.save();
}
}

View File

@ -58,8 +58,7 @@ public class SelectedRuleSetsMap {
}
private JCheckBox createCheckBox(String name) {
JCheckBox box = new JCheckBox();
box.setBackground(Color.white);
JCheckBox box = new JCheckBox(name);
box.setSelected(jEdit.getBooleanProperty(PMDJEditPlugin.OPTION_RULESETS_PREFIX + name, true));
return box;
}