New feature added to show a progressbar when working on large files

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@2550 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Jiger Patel
2004-02-18 11:38:25 +00:00
parent ee5ee831a2
commit 007e8e615c
6 changed files with 72 additions and 24 deletions

View File

@ -6,7 +6,7 @@
<property name="lib" value="lib"/>
<property name="build" value="build"/>
<property name="pmdjar" value="pmd-1.5.jar"/>
<property name="pluginversion" value="2.3"/>
<property name="pluginversion" value="2.4"/>
<property name="jedit.install.dir" value="../.."/>
<property name="jedit.jars.dir" value="${jedit.install.dir}\jars"/>
<property name="install.dir" value=".."/>

View File

@ -1,7 +1,9 @@
??? 2.4
- Optimized usage of ErrorSource for faster Error Highlighting.
- Fixed Run on save running when the buffer is non Java also.
- Updated to pmd 1.4
- Updated to pmd 1.5
- Added option to export PMD results to files in various formats such as HTML, XML, Text, CSV etc.
- Added a new feature to show Progressbar when working on Large file sets.
October 31st 2003 - 2.3
1. Updated to PMD 1.3

View File

@ -42,7 +42,10 @@ then 2) select the "PMD->Check directory recursively" menu option.</p>
<h3>2.4</h3>
<ol>
<li>Optimized usage of ErrorSource for faster Error Highlighting.</li>
<li>Updated to PMD 1.4</li>
<li>Updated to PMD 1.5</li>
<li>Fixed Run on save running when the buffer is non Java also.</li>
<li>Added option to export PMD results to a file in various formats such as HTML, XML, Text, CSV etc.</li>
<li>Added a new feature to show Progressbar when working on Large file sets.</li>
</ol>
<h3>2.3</h3>
<ol>

View File

@ -49,7 +49,7 @@ plugin.net.sourceforge.pmd.jedit.PMDJEditPlugin.browser-menu=pmd-check-file pmd-
#pmd properties
pmd.renderer=None
pmd.showprogress=true

View File

@ -5,7 +5,10 @@
*/
package net.sourceforge.pmd.jedit;
import javax.swing.JWindow;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Rectangle;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@ -50,6 +53,8 @@ import org.gjt.sp.util.Log;
import errorlist.DefaultErrorSource;
import errorlist.ErrorList;
import errorlist.ErrorSource;
import javax.swing.JDialog;
import javax.swing.border.EmptyBorder;
public class PMDJEditPlugin extends EBPlugin {
@ -60,8 +65,8 @@ public class PMDJEditPlugin extends EBPlugin {
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";
public static final String SHOW_PROGRESS = "pmd.showprogress";
//private static RE re = new UncheckedRE("Starting at line ([0-9]*) of (\\S*)");
private ProgressBar pbd;
private static PMDJEditPlugin instance;
@ -158,6 +163,12 @@ public class PMDJEditPlugin extends EBPlugin {
if(buffers != null)
{
ProgressBar pbd = null;
if(jEdit.getBooleanProperty(SHOW_PROGRESS))
{
pbd = startProgressBarDisplay(view,0,buffers.length);
}
for (int i=0; i<buffers.length; i++ )
{
if (buffers[i].getName().endsWith(".java"))
@ -166,7 +177,13 @@ public class PMDJEditPlugin extends EBPlugin {
Log.log(Log.DEBUG,this,"checking = " + buffers[i].getPath());
instanceCheck(buffers[i],view, false);
}
if(pbd != null)
{
pbd.increment(1);
}
}
endProgressBarDisplay(pbd);
}
//List files = new ArrayList();
@ -276,6 +293,12 @@ public class PMDJEditPlugin extends EBPlugin {
private void processFiles(List files, View view) {
unRegisterErrorSource();
errorSource.clear();
ProgressBar pbd = null;
if(jEdit.getBooleanProperty(SHOW_PROGRESS))
{
pbd = startProgressBarDisplay(view,0,files.size());
}
PMD pmd = new PMD();
SelectedRules selectedRuleSets = null;
try {
@ -304,11 +327,18 @@ public class PMDJEditPlugin extends EBPlugin {
pmde.printStackTrace();
JOptionPane.showMessageDialog(jEdit.getFirstView(), "Error while processing " + file.getAbsolutePath());
}
if(jEdit.getBooleanProperty(SHOW_PROGRESS))
{
pbd.increment(1);
}
for (Iterator j = ctx.getReport().iterator(); j.hasNext();) {
foundProblems = true;
RuleViolation rv = (RuleViolation)j.next();
errorSource.addError(new DefaultErrorSource.DefaultError(errorSource, ErrorSource.WARNING, file.getAbsolutePath(), rv.getLine()-1,0,0,rv.getDescription()));
}
}//End of for
if (!foundProblems)
@ -321,6 +351,9 @@ public class PMDJEditPlugin extends EBPlugin {
registerErrorSource();
exportErrorAsReport(view, ctx);
}
endProgressBarDisplay(pbd);
pbd = null;
}
private List findFiles(String dir, boolean recurse) {
@ -501,23 +534,20 @@ public class PMDJEditPlugin extends EBPlugin {
instance.process(instance.findFiles(de[0].path, recursive),view);
}
public void startProgressBarDisplay(View view, int min, int max)
public ProgressBar startProgressBarDisplay(View view, int min, int max)
{
ProgressBar pbd = new ProgressBar(view,min,max);
pbd.setVisible(true);
return pbd;
}
public void endProgressBarDisplay(ProgressBar pbd)
{
if(pbd != null)
{
view.getStatus().setMessage("Only one Progress Display tracked.");
return;
pbd.completeBar();
pbd.setVisible(false);
}
pbd = new ProgressBar(min,max);
pbd.setVisible(true);
Log.log(Log.DEBUG,this,"Showing PBD");
}
public void endProgressBarDisplay()
{
pbd.completeBar();
pbd = null;
Log.log(Log.DEBUG,this,"Comeplted display");
}
public void exportErrorAsReport(final View view, RuleContext ctx)
@ -562,7 +592,7 @@ public class PMDJEditPlugin extends EBPlugin {
}
});
}
}//End of exportErrorAsReport
@ -570,22 +600,31 @@ public class PMDJEditPlugin extends EBPlugin {
class ProgressBar extends JPanel
{
private JProgressBar pBar;
private View view;
public ProgressBar(int min,int max)
public ProgressBar(View view, int min,int max)
{
this.view = view;
setLayout(new BorderLayout());
pBar = new JProgressBar(min,max);
pBar.setBorder(new EmptyBorder(pBar.getInsets()));
pBar.setForeground(Color.orange);
pBar.setStringPainted(true);
add(pBar, BorderLayout.CENTER);
view.getStatus().add(pBar, BorderLayout.EAST);
}
public void increment(int num)
{
pBar.setValue(num);
pBar.setValue(pBar.getValue()+num);
}
public void completeBar()
{
pBar.setValue(pBar.getMaximum());
view.getStatus().remove(pBar);
view = null;
pBar = null;
}
}

View File

@ -32,6 +32,7 @@ import java.awt.event.MouseEvent;
public class PMDOptionPane extends AbstractOptionPane implements OptionPane {
public class CheckboxList extends JList {
private class MyMouseAdapter extends MouseAdapter {
@ -77,7 +78,7 @@ public class PMDOptionPane extends AbstractOptionPane implements OptionPane {
private SelectedRules rules;
private JTextArea exampleTextArea= new JTextArea(10, 50);
private JCheckBox directoryPopupBox, chkRunPMDOnSave;
private JCheckBox directoryPopupBox, chkRunPMDOnSave, chkShowProgressBar;
JTextField txtMinTileSize;
JTextField txtCustomRules;
JComboBox comboRenderer;
@ -119,6 +120,7 @@ public class PMDOptionPane extends AbstractOptionPane implements OptionPane {
directoryPopupBox = new JCheckBox("Ask for directory?", jEdit.getBooleanProperty(PMDJEditPlugin.OPTION_UI_DIRECTORY_POPUP));
chkRunPMDOnSave = new JCheckBox("Run PMD on Save", jEdit.getBooleanProperty(PMDJEditPlugin.RUN_PMD_ON_SAVE));
chkShowProgressBar = new JCheckBox("Show PMD Progress Bar", jEdit.getBooleanProperty(PMDJEditPlugin.SHOW_PROGRESS));
JPanel pnlSouth = new JPanel(new GridLayout(0,1));
@ -132,10 +134,11 @@ public class PMDOptionPane extends AbstractOptionPane implements OptionPane {
comboRenderer = new JComboBox(new String[] {"None", "Text", "Html", "XML", "CSV"});
comboRenderer.setSelectedItem(jEdit.getProperty(PMDJEditPlugin.RENDERER));
JLabel lblRenderer = new JLabel("Export Output as ");
pnlTileSize.add(lblRenderer);
pnlTileSize.add(comboRenderer);
pnlTileSize.add(chkShowProgressBar);
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());
mainPanel.add(rulesPanel, BorderLayout.NORTH);
@ -157,6 +160,7 @@ public class PMDOptionPane extends AbstractOptionPane implements OptionPane {
jEdit.setIntegerProperty(PMDJEditPlugin.DEFAULT_TILE_MINSIZE_PROPERTY,(txtMinTileSize.getText().length() == 0)?100:Integer.parseInt(txtMinTileSize.getText()));
jEdit.setBooleanProperty(PMDJEditPlugin.RUN_PMD_ON_SAVE,(chkRunPMDOnSave.isSelected()));
jEdit.setProperty(PMDJEditPlugin.RENDERER, (String)comboRenderer.getSelectedItem());
jEdit.setBooleanProperty(PMDJEditPlugin.SHOW_PROGRESS, chkShowProgressBar.isSelected());
if(txtCustomRules != null)
{