git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@651 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Tom Copeland
2002-08-07 17:31:20 +00:00
parent 3e4799ffe9
commit 4f9251c3d1
3 changed files with 15 additions and 9 deletions

View File

@ -35,13 +35,14 @@ public class GUI implements CPDListener {
}
private JTextField rootDirectoryField= new JTextField("c:\\data\\pmd\\pmd\\src\\net\\sourceforge\\pmd\\cpd\\");
//private JTextField rootDirectoryField = new JTextField(System.getProperty("user.home"));
//private JTextField rootDirectoryField= new JTextField("c:\\data\\cougaar\\core\\src");
private JTextField minimumLengthField= new JTextField("50");
private JTextField minimumLengthField= new JTextField("20");
private JProgressBar tokenizingFilesBar = new JProgressBar();
private JProgressBar addingTokensBar = new JProgressBar();
private JTextArea resultsTextArea = new JTextArea(20,50);
private JTextArea resultsTextArea = new JTextArea();
private JTextField expandingTileField = new JTextField(50);
private JCheckBox recurseCheckbox = new JCheckBox("Recurse?", true);
@ -93,16 +94,19 @@ public class GUI implements CPDListener {
progressPanel.setBorder(BorderFactory.createTitledBorder("Progress"));
JPanel resultsPanel = new JPanel();
resultsPanel.add(new JScrollPane(resultsTextArea));
JScrollPane areaScrollPane = new JScrollPane(resultsTextArea);
areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
areaScrollPane.setPreferredSize(new Dimension(600,300));
resultsPanel.add(areaScrollPane);
resultsPanel.setBorder(BorderFactory.createTitledBorder("Results"));
frame.getContentPane().setLayout(new BorderLayout());
JPanel topPanel = new JPanel();
topPanel.setLayout(new BorderLayout());
topPanel.add(inputPanel, BorderLayout.NORTH);
topPanel.add(progressPanel, BorderLayout.SOUTH);
topPanel.add(progressPanel, BorderLayout.CENTER);
frame.getContentPane().add(topPanel, BorderLayout.NORTH);
frame.getContentPane().add(resultsPanel, BorderLayout.SOUTH);
frame.getContentPane().add(resultsPanel, BorderLayout.CENTER);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.show();
@ -121,7 +125,8 @@ public class GUI implements CPDListener {
}
cpd.go();
CPDRenderer renderer = new TextRenderer();
resultsTextArea.setText(renderer.render(cpd));
resultsTextArea.setText("");
resultsTextArea.append(renderer.render(cpd));
} catch (IOException ioe) {
ioe.printStackTrace();
}

View File

@ -15,11 +15,11 @@ public class TextRenderer implements CPDRenderer {
Tile tile = (Tile)i.next();
sb.append("=============================================================");
sb.append(System.getProperty("line.separator"));
sb.append("A " + cpd.getLineCountFor(tile) + " line (" + tile.getTokenCount() + " tokens) duplication in these files:");
sb.append("A " + cpd.getLineCountFor(tile) + " line (" + tile.getTokenCount() + " tokens) duplication:");
sb.append(System.getProperty("line.separator"));
for (Iterator j = cpd.getResults().getOccurrences(tile); j.hasNext();) {
TokenEntry tok = (TokenEntry)j.next();
sb.append(tok.getBeginLine() + "\t" + tok.getTokenSrcID());
sb.append("Starting at line " + tok.getBeginLine() + " in " + tok.getTokenSrcID());
sb.append(System.getProperty("line.separator"));
}
sb.append(cpd.getImage(tile));

View File

@ -10,7 +10,8 @@
<section name="Copied and pasted code is usually bad">
<p>But it can be hard to find, especially in a large project. So we wrote a utility - CPD - to find it for us.
CPD uses (more or less) Michael Wise's Greedy String Tiling algorithm to find duplicate code. Here's
a <a href="screenshot.jpg">screenshot</a>.</p>
a <a href="screenshot.jpg">screenshot</a> of CPD after running on itself. Looks like we've got
some refactoring to do....</p>
<p>To run CPD as a JNLP application, click <a href="cpd.jnlp">here</a>.</p>
<p>Future plans</p>
<ul>