diff --git a/pmd-jedit/PMDPlugin/actions.xml b/pmd-jedit/PMDPlugin/actions.xml
index b7c9059e3d..11e6ff2228 100644
--- a/pmd-jedit/PMDPlugin/actions.xml
+++ b/pmd-jedit/PMDPlugin/actions.xml
@@ -14,11 +14,6 @@
net.sourceforge.pmd.jedit.PMDJEditPlugin.checkDirectory(view);
-
-
-
-
- net.sourceforge.pmd.jedit.PMDJEditPlugin.checkDirectoryRecursively(view);
@@ -33,17 +28,7 @@
- net.sourceforge.pmd.jedit.PMDJEditPlugin.cpdDir(view,false);
-
-
-
-
- net.sourceforge.pmd.jedit.PMDJEditPlugin.cpdDir(view,true);
-
-
-
-
- net.sourceforge.pmd.jedit.PMDJEditPlugin.checkFile(view,browser);
-
+ net.sourceforge.pmd.jedit.PMDJEditPlugin.cpdDir(view);
+
diff --git a/pmd-jedit/PMDPlugin/browser.actions.xml b/pmd-jedit/PMDPlugin/browser.actions.xml
index 869896c502..5a5f1e9ddb 100644
--- a/pmd-jedit/PMDPlugin/browser.actions.xml
+++ b/pmd-jedit/PMDPlugin/browser.actions.xml
@@ -1,19 +1,24 @@
-
-
- net.sourceforge.pmd.jedit.PMDJEditPlugin.checkFile(view,browser);
-
-
-
-
- net.sourceforge.pmd.jedit.PMDJEditPlugin.checkDirectory(view, browser,false);
-
-
-
-
- net.sourceforge.pmd.jedit.PMDJEditPlugin.checkDirectory(view, browser,true);
-
-
+
+ net.sourceforge.pmd.jedit.PMDJEditPlugin.checkFile(view,browser);
+
+
+ net.sourceforge.pmd.jedit.PMDJEditPlugin.checkDirectory(view, browser,false);
+
+
+ net.sourceforge.pmd.jedit.PMDJEditPlugin.checkDirectory(view, browser,true);
+
+
+ net.sourceforge.pmd.jedit.PMDJEditPlugin.cpdCurrentFile(view, browser);
+
+
+ net.sourceforge.pmd.jedit.PMDJEditPlugin.cpdDir(view,browser, false);
+
+
+
+ net.sourceforge.pmd.jedit.PMDJEditPlugin.cpdDir(view,browser, true);
+
+
diff --git a/pmd-jedit/PMDPlugin/etc/changelog.txt b/pmd-jedit/PMDPlugin/etc/changelog.txt
index 1b0d59933d..3511c77e0c 100644
--- a/pmd-jedit/PMDPlugin/etc/changelog.txt
+++ b/pmd-jedit/PMDPlugin/etc/changelog.txt
@@ -1,5 +1,8 @@
??? - 2.5
- Updated to PMD 1.8
+- Removed Recursive Directory options and integrated them into FileChooser itself.
+- Complete redesign of the way PMD Rules and Copy/Paste Detector are used.
+- Lots of code cleanup.
22 March 2004- 2.4
- Optimized usage of ErrorSource for faster Error Highlighting.
diff --git a/pmd-jedit/PMDPlugin/jedit.html b/pmd-jedit/PMDPlugin/jedit.html
index 90a5b51d92..ab08869626 100644
--- a/pmd-jedit/PMDPlugin/jedit.html
+++ b/pmd-jedit/PMDPlugin/jedit.html
@@ -45,7 +45,10 @@ Take a look at the Release Notes and Changelog for m
Release Notes & Changelog
2.5
- - Updated to PMD 1.7
+ - Updated to PMD 1.8
+ - Removed Recursive Directory options and integrated them into FileChooser itself.
+ - Complete redesign of the way PMD Rules and Copy/Paste Detector are used.
+ - Lots of code cleanup.
2.4
diff --git a/pmd-jedit/PMDPlugin/lib/pmd-swingui-0.1.jar b/pmd-jedit/PMDPlugin/lib/pmd-swingui-0.1.jar
index aee124da82..28ec61b8b4 100644
Binary files a/pmd-jedit/PMDPlugin/lib/pmd-swingui-0.1.jar and b/pmd-jedit/PMDPlugin/lib/pmd-swingui-0.1.jar differ
diff --git a/pmd-jedit/PMDPlugin/pmd.props b/pmd-jedit/PMDPlugin/pmd.props
index 6ab869f8c5..7dc636346c 100644
--- a/pmd-jedit/PMDPlugin/pmd.props
+++ b/pmd-jedit/PMDPlugin/pmd.props
@@ -19,16 +19,18 @@ plugin.net.sourceforge.pmd.jedit.PMDJEditPlugin.activate=defer
plugin.net.sourceforge.pmd.jedit.PMDJEditPlugin.menu.label=$PMD
-plugin.net.sourceforge.pmd.jedit.PMDJEditPlugin.menu=pmd-check-current-buffer pmd-check-all-open-buffers pmd-check-directory pmd-check-directory-recursively pmd-clear-errorlist %pmd-cpd
-pmd-cpd=cpd-currentfile cpd-dir cpd-dir-recursively
+plugin.net.sourceforge.pmd.jedit.PMDJEditPlugin.menu=pmd-check-current-buffer pmd-check-all-open-buffers pmd-check-directory pmd-clear-errorlist %pmd-cpd
+pmd-cpd=cpd-currentfile cpd-dir
+browser-pmd-cpd=cpd-currentfile cpd-dir cpd-dir-recursively
#Dockables and Menu Labels
pmd-check-current-buffer.label=Check current buffer
pmd-check-all-open-buffers.label=Check all open buffers
pmd-check-directory.label=Check all files in directory
-pmd-check-directory-recursively.label=Check directory recursively
+pmd-check-directory-recursively.label=Check all files in directory recursively
pmd-clear-errorlist.label=Clear ErrorList
pmd-cpd.label=Detect Duplicate Code
+browser-pmd-cpd.label=Detect Duplicate Code
cpd-currentfile.label=In Current File
cpd-dir.label=In Directory
cpd-dir-recursively.label=In Directory Recursively
@@ -49,7 +51,7 @@ cpd-viewer.title=Copy/Paste Detector
#FS Browser properties
-plugin.net.sourceforge.pmd.jedit.PMDJEditPlugin.browser-menu=pmd-check-file pmd-check-directory pmd-check-directory-recursively
+plugin.net.sourceforge.pmd.jedit.PMDJEditPlugin.browser-menu=pmd-check-file pmd-check-directory pmd-check-directory-recursively %browser-pmd-cpd
#pmd properties
pmd.renderer=None
diff --git a/pmd-jedit/PMDPlugin/src/net/sourceforge/pmd/jedit/PMDJEditPlugin.java b/pmd-jedit/PMDPlugin/src/net/sourceforge/pmd/jedit/PMDJEditPlugin.java
index f2e2428fc4..73fc50edd5 100644
--- a/pmd-jedit/PMDPlugin/src/net/sourceforge/pmd/jedit/PMDJEditPlugin.java
+++ b/pmd-jedit/PMDPlugin/src/net/sourceforge/pmd/jedit/PMDJEditPlugin.java
@@ -50,13 +50,18 @@ import org.gjt.sp.jedit.jEdit;
import org.gjt.sp.jedit.msg.BufferUpdate;
import org.gjt.sp.jedit.View;
import org.gjt.sp.util.Log;
+import javax.swing.JCheckBox;
+import java.awt.GridLayout;
+import javax.swing.BoxLayout;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
-public class PMDJEditPlugin extends EBPlugin {
+public class PMDJEditPlugin extends EBPlugin
+{
public static final String NAME = "PMD";
public static final String OPTION_RULES_PREFIX = "options.pmd.rules.";
- public static final String OPTION_UI_DIRECTORY_POPUP = "options.pmd.ui.directorypopup";
public static final String DEFAULT_TILE_MINSIZE_PROPERTY = "pmd.cpd.defMinTileSize";
public static final String RUN_PMD_ON_SAVE = "pmd.runPMDOnSave";
public static final String CUSTOM_RULES_PATH_KEY = "pmd.customRulesPath";
@@ -98,35 +103,11 @@ public class PMDJEditPlugin extends EBPlugin {
} */
// boilerplate JEdit code
- public static void checkDirectory(View view) {
+ public static void checkDirectory(View view)
+ {
instance.instanceCheckDirectory(view);
}
- public void instanceCheckDirectory(View view) {
- if (jEdit.getBooleanProperty(PMDJEditPlugin.OPTION_UI_DIRECTORY_POPUP))
- {
- String dir = (String)JOptionPane.showInputDialog(jEdit.getFirstView(), "Please type in a directory to scan", NAME, JOptionPane.QUESTION_MESSAGE, null, null, MiscUtilities.getParentOfPath(view.getBuffer().getPath()));
- if (dir != null)
- {
- if (!(new File(dir)).exists() || !(new File(dir)).isDirectory() )
- {
- JOptionPane.showMessageDialog(jEdit.getFirstView(), dir + " is not a valid directory name", NAME, JOptionPane.ERROR_MESSAGE);
- return;
- }
- process(findFiles(dir, false), view);
- }
- }
- else
- {
- VFSBrowser browser = (VFSBrowser)view.getDockableWindowManager().getDockable("vfs.browser");
- if(browser == null) {
- JOptionPane.showMessageDialog(jEdit.getFirstView(), "Can't run PMD on a directory unless the file browser is open", NAME, JOptionPane.ERROR_MESSAGE);
- return;
- }
- process(findFiles(browser.getDirectory(), false), view);
- }
- }
-
public void handleMessage(EBMessage ebmess)
{
if (ebmess instanceof BufferUpdate)
@@ -134,6 +115,7 @@ public class PMDJEditPlugin extends EBPlugin {
if(jEdit.getBooleanProperty(PMDJEditPlugin.RUN_PMD_ON_SAVE))
{
BufferUpdate bu = (BufferUpdate)ebmess;
+
if (bu.getWhat() == BufferUpdate.SAVED)
{
if(bu.getBuffer().getMode().getName().equals("java"))
@@ -146,11 +128,64 @@ public class PMDJEditPlugin extends EBPlugin {
}
// check all open buffers
- public static void checkAllOpenBuffers(View view) {
+ public static void checkAllOpenBuffers(View view)
+ {
instance.instanceCheckAllOpenBuffers(view);
}
- public void instanceCheckAllOpenBuffers(View view) {
+ public static void clearErrorList()
+ {
+ instance.instanceClearErrorList();
+ }
+
+ public void instanceClearErrorList()
+ {
+ errorSource.clear();
+ }
+
+ public void instanceCheckDirectory(View view)
+ {
+ JFileChooser chooser = new JFileChooser(jEdit.getProperty("pmd.cpd.lastDirectory"));
+ chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+
+ JPanel pnlAccessory = new JPanel();
+ JCheckBox chkRecursive = new JCheckBox("Recursive", false);
+ pnlAccessory.add(chkRecursive);
+ chooser.setAccessory(pnlAccessory);
+
+ int returnVal = chooser.showOpenDialog(view);
+
+ try
+ {
+ File selectedFile = null;
+
+ if(returnVal == JFileChooser.APPROVE_OPTION)
+ {
+ selectedFile = chooser.getSelectedFile();
+
+ if(!selectedFile.isDirectory())
+ {
+ JOptionPane.showMessageDialog(view,"Selection not a directory.","PMD",JOptionPane.ERROR_MESSAGE);
+ return;
+ }
+
+ jEdit.setProperty("pmd.cpd.lastDirectory",selectedFile.getCanonicalPath());
+ process(findFiles(selectedFile.getCanonicalPath(), chkRecursive.isSelected()), view);
+ }
+ else
+ {
+ return; //Incase the user presses cancel or escape.
+ }
+
+ }
+ catch(IOException e)
+ {
+ Log.log(Log.DEBUG,this,e);
+ }
+ }//End of instanceCheckDirectory
+
+ public void instanceCheckAllOpenBuffers(View view)
+ {
// I'm putting the files in a Set to work around some
// odd behavior in jEdit - the buffer.getNext()
// seems to iterate over the files twice.
@@ -159,9 +194,10 @@ public class PMDJEditPlugin extends EBPlugin {
if(buffers != null)
{
ProgressBar pbd = null;
+
if(jEdit.getBooleanProperty(SHOW_PROGRESS))
{
- pbd = startProgressBarDisplay(view,0,buffers.length);
+ pbd = startProgressBarDisplay(view,0,buffers.length);
}
for (int i=0; i