various tweaks, slowly putting Options dialog together

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@246 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Tom Copeland
2002-07-08 21:43:30 +00:00
parent 410c3be298
commit 4cbbf643df
6 changed files with 67 additions and 30 deletions

View File

@ -6,4 +6,9 @@
net.sourceforge.pmd.jedit.PMDJEditPlugin.check(view);
</CODE>
</ACTION>
<ACTION NAME="pmd.options">
<CODE>
net.sourceforge.pmd.jedit.PMDJEditPlugin.displayPreferencesDialog(view);
</CODE>
</ACTION>
</ACTIONS>

View File

@ -12,6 +12,7 @@ plugin.net.sourceforge.pmd.jedit.PMDJEditPlugin.jars=pmd-0.3.jar
#
# Menu properties
#
pmd-menu=pmd.check
pmd-menu=pmd.check - pmd.options
pmd-menu.label=PMD
pmd.check.label=$Check active buffer
pmd.options.label=$Options

View File

@ -16,6 +16,7 @@
<target name="delete">
<delete file="${lib}/${ant.project.name}.jar"/>
<delete file="${jedit.install.dir}/${ant.project.name}.jar"/>
<delete dir="${build}"/>
<mkdir dir="${build}"/>
</target>
@ -42,7 +43,8 @@
</target>
<target name="dist" depends="jar">
<target name="dist" depends="clean">
<antcall target="jar"/>
<copy file="${lib}/${ant.project.name}.jar" todir="${jedit.install.dir}"/>
</target>

View File

@ -1,4 +1,5 @@
???? 2002 - 0.2:
Fixed bug - empty msg box is displayed if no errors are found.
July 8 2002 - 0.1:
Initial release

View File

@ -20,37 +20,34 @@ import net.sourceforge.pmd.reports.ReportFactory;
public class PMDJEditPlugin extends EBPlugin {
/*
private static class PMDJEditOptionPane extends AbstractOptionPane implements OptionPane {
public PMDJEditOptionPane() {
super("pmd.general");
}
public String getName() {
return "PMD Option Pane";
}
}
*/
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_PREFIX = "options.pmd.";
private static PMDJEditPlugin instance = new PMDJEditPlugin();
// boilerplate JEdit code
public static void check(View view) {
instance.instanceCheck(view);
}
public static void displayPreferencesDialog(View view) {
instance.instanceDisplayPreferencesDialog(view);
}
public void createMenuItems(Vector menuItems) {
menuItems.addElement(GUIUtilities.loadMenu(MENU));
}
/*
public void createOptionPanes(OptionsDialog dialog) {
dialog.addOptionPane(new PMDJEditOptionPane());
OptionGroup grp = new OptionGroup("PMD");
grp.addOptionPane(new PMDOptionPane());
dialog.addOptionGroup(grp);
}
*/
// boilerplate JEdit code
public void instanceCheck(View view) {
//view.getStatus().setMessage("HELLO PMD");
String text = view.getTextArea().getText();
PMD pmd = new PMD();
@ -66,27 +63,23 @@ public class PMDJEditPlugin extends EBPlugin {
// TODO switch to use StringReader once PMD 0.4 gets released
pmd.processFile(new StringBufferInputStream(text), rules, ctx);
String msg = "No errors found";
StringBuffer msg = new StringBuffer();
for (Iterator i = ctx.getReport().iterator(); i.hasNext();) {
RuleViolation rv = (RuleViolation)i.next();
msg += rv.getDescription() + " at line " + rv.getLine() + System.getProperty("line.separator");
msg.append(rv.getDescription() + " at line " + rv.getLine() + System.getProperty("line.separator"));
}
JOptionPane.showMessageDialog(view, msg, "PMD Results", JOptionPane.INFORMATION_MESSAGE);
if (msg.length() == 0) {
msg.append("No errors found");
}
JOptionPane.showMessageDialog(view, msg.toString(), "PMD Results", JOptionPane.INFORMATION_MESSAGE);
} catch (FileNotFoundException fnfe) {
fnfe.printStackTrace();
}
}
public void instanceDisplayPreferencesDialog(View view) {
//view.getStatus().setMessage("HELLO PMD DIALOG");
}
public static void check(View view) {
instance.instanceCheck(view);
}
public static void displayPreferencesDialog(View view) {
instance.instanceDisplayPreferencesDialog(view);
}
}

View File

@ -0,0 +1,35 @@
/*
* User: tom
* Date: Jul 8, 2002
* Time: 4:29:19 PM
*/
package net.sourceforge.pmd.jedit;
import org.gjt.sp.jedit.OptionPane;
import org.gjt.sp.jedit.AbstractOptionPane;
import org.gjt.sp.jedit.jEdit;
import org.gjt.sp.jedit.View;
public class PMDOptionPane extends AbstractOptionPane implements OptionPane {
private static final String NAME = "PMD Options";
public PMDOptionPane() {
super(NAME);
}
public String getName() {
return NAME;
}
public void _init() {
throw new RuntimeException("HI!!!!");
/*
for (int i = 0; i < jEdit.getViews().length; i++) {
View v = jEdit.getViews()[i];
v.getStatus().setMessage("HOWDY");
}
*/
}
}