Compare commits
109
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
030795ea95 | ||
|
|
1dc6d7e698 | ||
|
|
5c92fdd31a | ||
|
|
9a81bcf7dd | ||
|
|
fb426227e4 | ||
|
|
acf8db926d | ||
|
|
91f2137679 | ||
|
|
cc095674b0 | ||
|
|
0859285b8b | ||
|
|
d0c103ab62 | ||
|
|
e76947b297 | ||
|
|
a417f0003f | ||
|
|
dc64e2df77 | ||
|
|
829a939421 | ||
|
|
eb57fdc882 | ||
|
|
da1ee1fe72 | ||
|
|
ee39aa5f3c | ||
|
|
46573bb566 | ||
|
|
da08b0757e | ||
|
|
1c0badd429 | ||
|
|
e0a9e49560 | ||
|
|
dba46f2ebd | ||
|
|
5fb6daea58 | ||
|
|
2d655f4684 | ||
|
|
b77de63950 | ||
|
|
d347e38622 | ||
|
|
7494011999 | ||
|
|
3901ad7ddb | ||
|
|
2e85f1f935 | ||
|
|
a5efd66b73 | ||
|
|
a96ccf9741 | ||
|
|
f60128b142 | ||
|
|
89ebc32141 | ||
|
|
b501de3fba | ||
|
|
79fb7e359d | ||
|
|
6aa4897e21 | ||
|
|
ee05fa73cd | ||
|
|
0170a40dec | ||
|
|
4d7b4bb1bc | ||
|
|
a6c1c1f57c | ||
|
|
9f8246caac | ||
|
|
f51e41b05c | ||
|
|
ad66153a2d | ||
|
|
c8c6aa16dd | ||
|
|
b998e64819 | ||
|
|
62fc70e816 | ||
|
|
34b868ad14 | ||
|
|
26a862a51b | ||
|
|
4569842965 | ||
|
|
fddccb5030 | ||
|
|
00e27b4a37 | ||
|
|
b6c6899741 | ||
|
|
43ecf1e110 | ||
|
|
5f45a28621 | ||
|
|
41c44e5d8d | ||
|
|
040d465137 | ||
|
|
4e5ca16990 | ||
|
|
30af4f6381 | ||
|
|
cece698b04 | ||
|
|
13ef401a63 | ||
|
|
589ec3c6da | ||
|
|
c00ca9e44c | ||
|
|
31f6b9af1a | ||
|
|
8eac048c03 | ||
|
|
3b14b3f5cb | ||
|
|
adcbdc204f | ||
|
|
a1b1e3f31c | ||
|
|
3e8c42384b | ||
|
|
a00532595a | ||
|
|
3feda38cc3 | ||
|
|
3412d55fc6 | ||
|
|
436b7dcb50 | ||
|
|
d25dadc4b4 | ||
|
|
1c051674a0 | ||
|
|
3daca86045 | ||
|
|
d95d960de3 | ||
|
|
ef7478c350 | ||
|
|
c080fdda08 | ||
|
|
e603844a53 | ||
|
|
52b8be6601 | ||
|
|
7cbb385dbb | ||
|
|
61c0b4ea7f | ||
|
|
26fa85a9fa | ||
|
|
98b903897e | ||
|
|
55b5aa7f27 | ||
|
|
ffac9894c9 | ||
|
|
d557ed9c01 | ||
|
|
e0b7f6f17c | ||
|
|
cb9861dd1f | ||
|
|
7ee96a6b52 | ||
|
|
ac8e3314a3 | ||
|
|
7989ae1863 | ||
|
|
e3708b5030 | ||
|
|
85e493d55f | ||
|
|
6abbea51dd | ||
|
|
9162917346 | ||
|
|
637006674f | ||
|
|
63c1a8fe47 | ||
|
|
063c4228e3 | ||
|
|
4b0063dfc1 | ||
|
|
13e36974a5 | ||
|
|
33c7af965c | ||
|
|
a66bbf2193 | ||
|
|
38af8f2433 | ||
|
|
a6bcfe2b65 | ||
|
|
6474fde42d | ||
|
|
8dcde0edb5 | ||
|
|
70347aedd5 | ||
|
|
eaf1385595 |
No files matched your search
@@ -1,27 +1,8 @@
|
||||
[![PMD - Don't shoot the messenger][PMDLogo]][website]
|
||||
# PMD
|
||||
|
||||
PMD
|
||||
===
|
||||
PMD is a source code analyzer. It finds unused variables,
|
||||
empty catch blocks, unnecessary object creation, and so forth.
|
||||
|
||||
About
|
||||
-----
|
||||
PMD is a source code analyzer. It finds common programming flaws like unused variables, empty catch blocks,
|
||||
unnecessary object creation, and so forth. It supports Java, JavaScript, XML, XSL.
|
||||
Additionally it includes CPD, the copy-paste-detector. CPD finds duplicated code in
|
||||
Java, C, C++, C#, PHP, Ruby, Fortran, JavaScript.
|
||||
For more information, visit http://pmd.sourceforge.net
|
||||
|
||||
Source
|
||||
------
|
||||
Our latest source of PMD can be found on [GitHub]. Fork us!
|
||||
The current status of this repo can be seen at [BuildHive].
|
||||
|
||||
News and Website
|
||||
----------------
|
||||
More information can be found on our [Website] and on [SourceForge].
|
||||
|
||||
|
||||
[PMDLogo]: http://pmd.sourceforge.net/pmd_logo.png
|
||||
[GitHub]: https://github.com/pmd/pmd
|
||||
[BuildHive]: https://buildhive.cloudbees.com/job/pmd/
|
||||
[Website]: http://pmd.sourceforge.net
|
||||
[SourceForge]: https://sourceforge.net/projects/pmd/
|
||||
To see the current status of this repo, visit https://buildhive.cloudbees.com/job/pmd/
|
||||
@@ -0,0 +1,41 @@
|
||||
package net.sourceforge.pmd.util.viewer;
|
||||
|
||||
import net.sourceforge.pmd.util.viewer.gui.MainFrame;
|
||||
|
||||
|
||||
/**
|
||||
* viewer's starter
|
||||
*
|
||||
* @author Boris Gruschko ( boris at gruschko.org )
|
||||
* @version $Id$
|
||||
*/
|
||||
public class Viewer {
|
||||
/**
|
||||
* starts the viewer
|
||||
*
|
||||
* @param args arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
new MainFrame();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* $Log$
|
||||
* Revision 1.1 2005/08/15 19:51:41 tomcopeland
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.2 2004/09/27 19:42:52 tomcopeland
|
||||
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
|
||||
*
|
||||
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
|
||||
* Added Boris Gruschko's new AST/XPath viewer
|
||||
*
|
||||
* Revision 1.1 2003/09/24 01:33:03 bgr
|
||||
* moved to a new package
|
||||
*
|
||||
* Revision 1.1 2003/09/22 05:21:54 bgr
|
||||
* initial commit
|
||||
*
|
||||
*/
|
||||
@@ -0,0 +1,147 @@
|
||||
package net.sourceforge.pmd.util.viewer.gui;
|
||||
|
||||
import net.sourceforge.pmd.ast.Node;
|
||||
import net.sourceforge.pmd.ast.SimpleNode;
|
||||
import net.sourceforge.pmd.util.viewer.gui.menu.ASTNodePopupMenu;
|
||||
import net.sourceforge.pmd.util.viewer.model.ASTModel;
|
||||
import net.sourceforge.pmd.util.viewer.model.ViewerModel;
|
||||
import net.sourceforge.pmd.util.viewer.model.ViewerModelEvent;
|
||||
import net.sourceforge.pmd.util.viewer.model.ViewerModelListener;
|
||||
import net.sourceforge.pmd.util.viewer.util.NLS;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.TreeSelectionEvent;
|
||||
import javax.swing.event.TreeSelectionListener;
|
||||
import javax.swing.tree.TreeNode;
|
||||
import javax.swing.tree.TreePath;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.LinkedList;
|
||||
|
||||
|
||||
/**
|
||||
* tree panel GUI
|
||||
*
|
||||
* @author Boris Gruschko ( boris at gruschko.org )
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ASTPanel
|
||||
extends JPanel
|
||||
implements ViewerModelListener, TreeSelectionListener {
|
||||
private ViewerModel model;
|
||||
private JTree tree;
|
||||
|
||||
/**
|
||||
* constructs the panel
|
||||
*
|
||||
* @param model model to attach the panel to
|
||||
*/
|
||||
public ASTPanel(ViewerModel model) {
|
||||
this.model = model;
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
model.addViewerModelListener(this);
|
||||
|
||||
setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), NLS.nls("AST.PANEL.TITLE")));
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
tree = new JTree((TreeNode) null);
|
||||
|
||||
tree.addTreeSelectionListener(this);
|
||||
|
||||
tree.addMouseListener(new MouseAdapter() {
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
TreePath path =
|
||||
tree.getClosestPathForLocation(e.getX(), e.getY());
|
||||
tree.setSelectionPath(path);
|
||||
|
||||
JPopupMenu menu =
|
||||
new ASTNodePopupMenu(model, (SimpleNode) path.getLastPathComponent());
|
||||
|
||||
menu.show(tree, e.getX(), e.getY());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
add(new JScrollPane(tree), BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ViewerModelListener#viewerModelChanged(ViewerModelEvent)
|
||||
*/
|
||||
public void viewerModelChanged(ViewerModelEvent e) {
|
||||
switch (e.getReason()) {
|
||||
case ViewerModelEvent.CODE_RECOMPILED:
|
||||
tree.setModel(new ASTModel(model.getRootNode()));
|
||||
|
||||
break;
|
||||
|
||||
case ViewerModelEvent.NODE_SELECTED:
|
||||
|
||||
if (e.getSource() != this) {
|
||||
LinkedList list = new LinkedList();
|
||||
|
||||
for (
|
||||
Node node = (Node) e.getParameter(); node != null;
|
||||
node = node.jjtGetParent())
|
||||
list.addFirst(node);
|
||||
|
||||
TreePath path = new TreePath(list.toArray());
|
||||
|
||||
tree.setSelectionPath(path);
|
||||
|
||||
tree.scrollPathToVisible(path);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.swing.event.TreeSelectionListener#valueChanged(javax.swing.event.TreeSelectionEvent)
|
||||
*/
|
||||
public void valueChanged(TreeSelectionEvent e) {
|
||||
model.selectNode((SimpleNode) e.getNewLeadSelectionPath().getLastPathComponent(), this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* $Log$
|
||||
* Revision 1.1 2005/08/15 19:51:42 tomcopeland
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.5 2005/02/16 15:46:05 mikkey
|
||||
* javadoc fixes
|
||||
*
|
||||
* Revision 1.4 2004/09/27 19:42:52 tomcopeland
|
||||
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
|
||||
*
|
||||
* Revision 1.3 2004/04/15 18:21:58 tomcopeland
|
||||
* Cleaned up imports with new version of IDEA; fixed some deprecated Ant junx
|
||||
*
|
||||
* Revision 1.2 2003/09/23 20:51:06 tomcopeland
|
||||
* Cleaned up imports
|
||||
*
|
||||
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
|
||||
* Added Boris Gruschko's new AST/XPath viewer
|
||||
*
|
||||
* Revision 1.1 2003/09/24 01:33:03 bgr
|
||||
* moved to a new package
|
||||
*
|
||||
* Revision 1.3 2003/09/24 00:40:35 bgr
|
||||
* evaluation results browsing added
|
||||
*
|
||||
* Revision 1.2 2003/09/23 07:52:16 bgr
|
||||
* menus added
|
||||
*
|
||||
* Revision 1.1 2003/09/22 05:21:54 bgr
|
||||
* initial commit
|
||||
*
|
||||
*/
|
||||
@@ -0,0 +1,35 @@
|
||||
package net.sourceforge.pmd.util.viewer.gui;
|
||||
|
||||
/**
|
||||
* contains action command constants
|
||||
*
|
||||
* @author Boris Gruschko ( boris at gruschko.org )
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface ActionCommands {
|
||||
String COMPILE_ACTION = "Compile";
|
||||
String EVALUATE_ACTION = "Evaluate";
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* $Log$
|
||||
* Revision 1.1 2005/08/15 19:51:42 tomcopeland
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.3 2004/12/22 20:52:12 tomcopeland
|
||||
* Fixing some stuff PMD found
|
||||
*
|
||||
* Revision 1.2 2004/09/27 19:42:52 tomcopeland
|
||||
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
|
||||
*
|
||||
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
|
||||
* Added Boris Gruschko's new AST/XPath viewer
|
||||
*
|
||||
* Revision 1.1 2003/09/24 01:33:03 bgr
|
||||
* moved to a new package
|
||||
*
|
||||
* Revision 1.1 2003/09/22 05:21:54 bgr
|
||||
* initial commit
|
||||
*
|
||||
*/
|
||||
@@ -0,0 +1,105 @@
|
||||
package net.sourceforge.pmd.util.viewer.gui;
|
||||
|
||||
import net.sourceforge.pmd.ast.SimpleNode;
|
||||
import net.sourceforge.pmd.util.viewer.model.ViewerModel;
|
||||
import net.sourceforge.pmd.util.viewer.model.ViewerModelEvent;
|
||||
import net.sourceforge.pmd.util.viewer.model.ViewerModelListener;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import java.awt.BorderLayout;
|
||||
import java.util.Vector;
|
||||
|
||||
|
||||
/**
|
||||
* A panel showing XPath expression evaluation results
|
||||
*
|
||||
* @author Boris Gruschko ( boris at gruschko.org )
|
||||
* @version $Id$
|
||||
*/
|
||||
public class EvaluationResultsPanel
|
||||
extends JPanel
|
||||
implements ViewerModelListener {
|
||||
private ViewerModel model;
|
||||
private JList list;
|
||||
|
||||
/**
|
||||
* constructs the panel
|
||||
*
|
||||
* @param model model to refer to
|
||||
*/
|
||||
public EvaluationResultsPanel(ViewerModel model) {
|
||||
super(new BorderLayout());
|
||||
|
||||
this.model = model;
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
model.addViewerModelListener(this);
|
||||
|
||||
list = new JList();
|
||||
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
|
||||
list.addListSelectionListener(new ListSelectionListener() {
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
if (list.getSelectedValue() != null) {
|
||||
model.selectNode((SimpleNode) list.getSelectedValue(), EvaluationResultsPanel.this);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
add(new JScrollPane(list), BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ViewerModelListener#viewerModelChanged(ViewerModelEvent)
|
||||
*/
|
||||
public void viewerModelChanged(ViewerModelEvent e) {
|
||||
switch (e.getReason()) {
|
||||
case ViewerModelEvent.PATH_EXPRESSION_EVALUATED:
|
||||
|
||||
if (e.getSource() != this) {
|
||||
list.setListData(new Vector(model.getLastEvaluationResults()));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case ViewerModelEvent.CODE_RECOMPILED:
|
||||
list.setListData(new Vector(0));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* $Log$
|
||||
* Revision 1.1 2005/08/15 19:51:42 tomcopeland
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.5 2005/02/16 15:46:34 mikkey
|
||||
* javadoc fixes
|
||||
*
|
||||
* Revision 1.4 2004/09/27 19:42:52 tomcopeland
|
||||
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
|
||||
*
|
||||
* Revision 1.3 2004/04/15 18:21:58 tomcopeland
|
||||
* Cleaned up imports with new version of IDEA; fixed some deprecated Ant junx
|
||||
*
|
||||
* Revision 1.2 2003/09/23 20:51:06 tomcopeland
|
||||
* Cleaned up imports
|
||||
*
|
||||
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
|
||||
* Added Boris Gruschko's new AST/XPath viewer
|
||||
*
|
||||
* Revision 1.1 2003/09/24 01:33:03 bgr
|
||||
* moved to a new package
|
||||
*
|
||||
* Revision 1.1 2003/09/24 00:40:35 bgr
|
||||
* evaluation results browsing added
|
||||
*
|
||||
*/
|
||||
@@ -0,0 +1,172 @@
|
||||
package net.sourceforge.pmd.util.viewer.gui;
|
||||
|
||||
import net.sourceforge.pmd.ast.ParseException;
|
||||
import net.sourceforge.pmd.util.viewer.model.ViewerModel;
|
||||
import net.sourceforge.pmd.util.viewer.model.ViewerModelEvent;
|
||||
import net.sourceforge.pmd.util.viewer.model.ViewerModelListener;
|
||||
import net.sourceforge.pmd.util.viewer.util.NLS;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
|
||||
/**
|
||||
* viewer's main frame
|
||||
*
|
||||
* @author Boris Gruschko ( boris at gruschko.org )
|
||||
* @version $Id$
|
||||
*/
|
||||
public class MainFrame
|
||||
extends JFrame
|
||||
implements ActionListener, ActionCommands, ViewerModelListener {
|
||||
private ViewerModel model;
|
||||
private SourceCodePanel sourcePanel;
|
||||
private ASTPanel astPanel;
|
||||
private XPathPanel xPathPanel;
|
||||
private JButton compileBtn;
|
||||
private JButton evalBtn;
|
||||
private JLabel statusLbl;
|
||||
|
||||
/**
|
||||
* constructs and shows the frame
|
||||
*/
|
||||
public MainFrame() {
|
||||
super(NLS.nls("MAIN.FRAME.TITLE"));
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
model = new ViewerModel();
|
||||
|
||||
model.addViewerModelListener(this);
|
||||
|
||||
sourcePanel = new SourceCodePanel(model);
|
||||
astPanel = new ASTPanel(model);
|
||||
xPathPanel = new XPathPanel(model);
|
||||
|
||||
getContentPane().setLayout(new BorderLayout());
|
||||
|
||||
JSplitPane editingPane =
|
||||
new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sourcePanel, astPanel);
|
||||
editingPane.setResizeWeight(0.5d);
|
||||
|
||||
JPanel interactionsPane = new JPanel(new BorderLayout());
|
||||
|
||||
interactionsPane.add(xPathPanel, BorderLayout.SOUTH);
|
||||
interactionsPane.add(editingPane, BorderLayout.CENTER);
|
||||
|
||||
getContentPane().add(interactionsPane, BorderLayout.CENTER);
|
||||
|
||||
compileBtn = new JButton(NLS.nls("MAIN.FRAME.COMPILE_BUTTON.TITLE"));
|
||||
compileBtn.setActionCommand(COMPILE_ACTION);
|
||||
compileBtn.addActionListener(this);
|
||||
|
||||
evalBtn = new JButton(NLS.nls("MAIN.FRAME.EVALUATE_BUTTON.TITLE"));
|
||||
evalBtn.setActionCommand(EVALUATE_ACTION);
|
||||
evalBtn.addActionListener(this);
|
||||
evalBtn.setEnabled(false);
|
||||
|
||||
statusLbl = new JLabel();
|
||||
statusLbl.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||
|
||||
JPanel btnPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
|
||||
btnPane.add(compileBtn);
|
||||
btnPane.add(evalBtn);
|
||||
btnPane.add(statusLbl);
|
||||
|
||||
getContentPane().add(btnPane, BorderLayout.SOUTH);
|
||||
|
||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
|
||||
pack();
|
||||
setSize(800, 600);
|
||||
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
||||
*/
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String command = e.getActionCommand();
|
||||
long t0, t1;
|
||||
if (command.equals(COMPILE_ACTION)) {
|
||||
try {
|
||||
t0 = System.currentTimeMillis();
|
||||
model.commitSource(sourcePanel.getSourceCode());
|
||||
t1 = System.currentTimeMillis();
|
||||
setStatus(NLS.nls("MAIN.FRAME.COMPILATION.TOOK")+ " "+(t1-t0)+" ms");
|
||||
} catch (ParseException exc) {
|
||||
setStatus(NLS.nls("MAIN.FRAME.COMPILATION.PROBLEM")+ " "+exc.toString());
|
||||
new ParseExceptionHandler(this, exc);
|
||||
}
|
||||
} else if (command.equals(EVALUATE_ACTION)) {
|
||||
try {
|
||||
t0 = System.currentTimeMillis();
|
||||
model.evaluateXPathExpression(xPathPanel.getXPathExpression(), this);
|
||||
t1 = System.currentTimeMillis();
|
||||
setStatus(NLS.nls("MAIN.FRAME.EVALUATION.TOOK")+ " "+(t1-t0)+" ms");
|
||||
} catch (Exception exc) {
|
||||
setStatus(NLS.nls("MAIN.FRAME.EVALUATION.PROBLEM")+ " "+exc.toString());
|
||||
new ParseExceptionHandler(this, exc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the status bar message
|
||||
* @param string the new status, the empty string will be set if the value is <code>null</code>
|
||||
*/
|
||||
private void setStatus(String string) {
|
||||
if (string == null)
|
||||
string = "";
|
||||
statusLbl.setText(string);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ViewerModelListener#viewerModelChanged(ViewerModelEvent)
|
||||
*/
|
||||
public void viewerModelChanged(ViewerModelEvent e) {
|
||||
evalBtn.setEnabled(model.hasCompiledTree());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* $Log$
|
||||
* Revision 1.1 2005/08/15 19:51:42 tomcopeland
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.6 2005/02/16 15:47:01 mikkey
|
||||
* javadoc fixes
|
||||
*
|
||||
* Revision 1.5 2004/12/13 14:46:11 tomcopeland
|
||||
* Applied, thanks Miguel!
|
||||
*
|
||||
* Revision 1.4 2004/09/27 19:42:52 tomcopeland
|
||||
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
|
||||
*
|
||||
* Revision 1.3 2004/04/15 18:21:58 tomcopeland
|
||||
* Cleaned up imports with new version of IDEA; fixed some deprecated Ant junx
|
||||
*
|
||||
* Revision 1.2 2003/09/23 20:51:06 tomcopeland
|
||||
* Cleaned up imports
|
||||
*
|
||||
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
|
||||
* Added Boris Gruschko's new AST/XPath viewer
|
||||
*
|
||||
* Revision 1.1 2003/09/24 01:33:03 bgr
|
||||
* moved to a new package
|
||||
*
|
||||
* Revision 1.2 2003/09/24 00:40:35 bgr
|
||||
* evaluation results browsing added
|
||||
*
|
||||
* Revision 1.1 2003/09/22 05:21:54 bgr
|
||||
* initial commit
|
||||
*
|
||||
*/
|
||||
@@ -0,0 +1,112 @@
|
||||
package net.sourceforge.pmd.util.viewer.gui;
|
||||
|
||||
import net.sourceforge.pmd.util.viewer.util.NLS;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
|
||||
/**
|
||||
* handles parsing exceptions
|
||||
*
|
||||
* @author Boris Gruschko ( boris at gruschko.org )
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ParseExceptionHandler
|
||||
extends JDialog
|
||||
implements ActionListener {
|
||||
private Exception exc;
|
||||
private JTextArea errorArea;
|
||||
private JButton okBtn;
|
||||
|
||||
/**
|
||||
* creates the dialog
|
||||
*
|
||||
* @param parent dialog's parent
|
||||
* @param exc exception to be handled
|
||||
*/
|
||||
public ParseExceptionHandler(JFrame parent, Exception exc) {
|
||||
super(parent, NLS.nls("COMPILE_ERROR.DIALOG.TITLE"), true);
|
||||
|
||||
this.exc = exc;
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
errorArea = new JTextArea();
|
||||
errorArea.setEditable(false);
|
||||
errorArea.setText(exc.getMessage() + "\n");
|
||||
|
||||
getContentPane().setLayout(new BorderLayout());
|
||||
|
||||
JPanel messagePanel = new JPanel(new BorderLayout());
|
||||
|
||||
messagePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createRaisedBevelBorder(),
|
||||
BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
|
||||
NLS.nls("COMPILE_ERROR.PANEL.TITLE"))));
|
||||
|
||||
messagePanel.add(new JScrollPane(errorArea), BorderLayout.CENTER);
|
||||
|
||||
getContentPane().add(messagePanel, BorderLayout.CENTER);
|
||||
|
||||
JPanel btnPane = new JPanel(new FlowLayout(FlowLayout.RIGHT));
|
||||
|
||||
okBtn = new JButton(NLS.nls("COMPILE_ERROR.OK_BUTTON.CAPTION"));
|
||||
|
||||
okBtn.addActionListener(this);
|
||||
|
||||
btnPane.add(okBtn);
|
||||
|
||||
getRootPane().setDefaultButton(okBtn);
|
||||
|
||||
getContentPane().add(btnPane, BorderLayout.SOUTH);
|
||||
|
||||
pack();
|
||||
|
||||
setLocationRelativeTo(getParent());
|
||||
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
||||
*/
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource() == okBtn) {
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* $Log$
|
||||
* Revision 1.1 2005/08/15 19:51:42 tomcopeland
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.4 2004/09/27 19:42:52 tomcopeland
|
||||
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
|
||||
*
|
||||
* Revision 1.3 2004/04/15 18:21:58 tomcopeland
|
||||
* Cleaned up imports with new version of IDEA; fixed some deprecated Ant junx
|
||||
*
|
||||
* Revision 1.2 2003/09/23 20:51:06 tomcopeland
|
||||
* Cleaned up imports
|
||||
*
|
||||
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
|
||||
* Added Boris Gruschko's new AST/XPath viewer
|
||||
*
|
||||
* Revision 1.1 2003/09/24 01:33:03 bgr
|
||||
* moved to a new package
|
||||
*
|
||||
* Revision 1.2 2003/09/24 00:40:35 bgr
|
||||
* evaluation results browsing added
|
||||
*
|
||||
* Revision 1.1 2003/09/22 05:21:54 bgr
|
||||
* initial commit
|
||||
*
|
||||
*/
|
||||
@@ -0,0 +1,119 @@
|
||||
package net.sourceforge.pmd.util.viewer.gui;
|
||||
|
||||
import net.sourceforge.pmd.ast.SimpleNode;
|
||||
import net.sourceforge.pmd.util.viewer.model.ViewerModel;
|
||||
import net.sourceforge.pmd.util.viewer.model.ViewerModelEvent;
|
||||
import net.sourceforge.pmd.util.viewer.model.ViewerModelListener;
|
||||
import net.sourceforge.pmd.util.viewer.util.NLS;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.text.BadLocationException;
|
||||
import javax.swing.text.DefaultHighlighter;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
|
||||
|
||||
/**
|
||||
* source code panel
|
||||
*
|
||||
* @author Boris Gruschko ( boris at gruschko.org )
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SourceCodePanel
|
||||
extends JPanel
|
||||
implements ViewerModelListener {
|
||||
private ViewerModel model;
|
||||
private JTextArea sourceCodeArea;
|
||||
|
||||
public SourceCodePanel(ViewerModel model) {
|
||||
this.model = model;
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
model.addViewerModelListener(this);
|
||||
|
||||
setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), NLS.nls("SOURCE.PANEL.TITLE")));
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
sourceCodeArea = new JTextArea();
|
||||
|
||||
add(new JScrollPane(sourceCodeArea), BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
/**
|
||||
* retrieves the string representation of the source code
|
||||
*
|
||||
* @return source code's string representation
|
||||
*/
|
||||
public String getSourceCode() {
|
||||
return sourceCodeArea.getText();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ViewerModelListener#viewerModelChanged(ViewerModelEvent)
|
||||
*/
|
||||
public void viewerModelChanged(ViewerModelEvent e) {
|
||||
if (e.getReason() == ViewerModelEvent.NODE_SELECTED) {
|
||||
final SimpleNode node = (SimpleNode) e.getParameter();
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
sourceCodeArea.getHighlighter().removeAllHighlights();
|
||||
|
||||
if (node == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int startOffset =
|
||||
(sourceCodeArea.getLineStartOffset(node.getBeginLine() - 1) +
|
||||
node.getBeginColumn()) - 1;
|
||||
|
||||
int end =
|
||||
(sourceCodeArea.getLineStartOffset(node.getEndLine() - 1) +
|
||||
node.getEndColumn());
|
||||
|
||||
sourceCodeArea.getHighlighter().addHighlight(startOffset, end,
|
||||
new DefaultHighlighter.DefaultHighlightPainter(new Color(79, 237, 111)));
|
||||
|
||||
sourceCodeArea.moveCaretPosition(startOffset);
|
||||
} catch (BadLocationException exc) {
|
||||
throw new IllegalStateException(exc.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* $Log$
|
||||
* Revision 1.1 2005/08/15 19:51:42 tomcopeland
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.5 2005/02/16 15:47:27 mikkey
|
||||
* javadoc fixes
|
||||
*
|
||||
* Revision 1.4 2004/09/27 19:42:52 tomcopeland
|
||||
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
|
||||
*
|
||||
* Revision 1.3 2004/04/15 18:21:58 tomcopeland
|
||||
* Cleaned up imports with new version of IDEA; fixed some deprecated Ant junx
|
||||
*
|
||||
* Revision 1.2 2003/09/23 20:51:06 tomcopeland
|
||||
* Cleaned up imports
|
||||
*
|
||||
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
|
||||
* Added Boris Gruschko's new AST/XPath viewer
|
||||
*
|
||||
* Revision 1.1 2003/09/24 01:33:03 bgr
|
||||
* moved to a new package
|
||||
*
|
||||
* Revision 1.1 2003/09/22 05:21:54 bgr
|
||||
* initial commit
|
||||
*
|
||||
*/
|
||||
@@ -0,0 +1,115 @@
|
||||
package net.sourceforge.pmd.util.viewer.gui;
|
||||
|
||||
import net.sourceforge.pmd.util.viewer.model.ViewerModel;
|
||||
import net.sourceforge.pmd.util.viewer.model.ViewerModelEvent;
|
||||
import net.sourceforge.pmd.util.viewer.model.ViewerModelListener;
|
||||
import net.sourceforge.pmd.util.viewer.util.NLS;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.Dimension;
|
||||
|
||||
|
||||
/**
|
||||
* Panel for the XPath entry and editing
|
||||
*
|
||||
* @author Boris Gruschko ( boris at gruschko.org )
|
||||
* @version $Id$
|
||||
*/
|
||||
public class XPathPanel
|
||||
extends JTabbedPane
|
||||
implements ViewerModelListener {
|
||||
private ViewerModel model;
|
||||
private JTextArea xPathArea;
|
||||
|
||||
/**
|
||||
* Constructs the panel
|
||||
*
|
||||
* @param model model to refer to
|
||||
*/
|
||||
public XPathPanel(ViewerModel model) {
|
||||
super(JTabbedPane.BOTTOM);
|
||||
|
||||
this.model = model;
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
model.addViewerModelListener(this);
|
||||
|
||||
xPathArea = new JTextArea();
|
||||
|
||||
setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), NLS.nls("XPATH.PANEL.TITLE")));
|
||||
|
||||
add(new JScrollPane(xPathArea), NLS.nls("XPATH.PANEL.EXPRESSION"));
|
||||
add(new EvaluationResultsPanel(model), NLS.nls("XPATH.PANEL.RESULTS"));
|
||||
|
||||
setPreferredSize(new Dimension(-1, 200));
|
||||
}
|
||||
|
||||
/**
|
||||
* retrieves the XPath expression typed into the text area
|
||||
*
|
||||
* @return XPath expression
|
||||
*/
|
||||
public String getXPathExpression() {
|
||||
return xPathArea.getText();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ViewerModelListener#viewerModelChanged(ViewerModelEvent)
|
||||
*/
|
||||
public void viewerModelChanged(ViewerModelEvent e) {
|
||||
switch (e.getReason()) {
|
||||
case ViewerModelEvent.PATH_EXPRESSION_APPENDED:
|
||||
|
||||
if (e.getSource() != this) {
|
||||
xPathArea.append((String) e.getParameter());
|
||||
}
|
||||
|
||||
setSelectedIndex(0);
|
||||
|
||||
break;
|
||||
|
||||
case ViewerModelEvent.CODE_RECOMPILED:
|
||||
setSelectedIndex(0);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* $Log$
|
||||
* Revision 1.1 2005/08/15 19:51:42 tomcopeland
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.5 2005/02/16 15:47:48 mikkey
|
||||
* javadoc fixes
|
||||
*
|
||||
* Revision 1.4 2004/09/27 19:42:52 tomcopeland
|
||||
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
|
||||
*
|
||||
* Revision 1.3 2004/04/15 18:21:58 tomcopeland
|
||||
* Cleaned up imports with new version of IDEA; fixed some deprecated Ant junx
|
||||
*
|
||||
* Revision 1.2 2003/09/23 20:51:06 tomcopeland
|
||||
* Cleaned up imports
|
||||
*
|
||||
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
|
||||
* Added Boris Gruschko's new AST/XPath viewer
|
||||
*
|
||||
* Revision 1.1 2003/09/24 01:33:03 bgr
|
||||
* moved to a new package
|
||||
*
|
||||
* Revision 1.3 2003/09/24 00:40:35 bgr
|
||||
* evaluation results browsing added
|
||||
*
|
||||
* Revision 1.2 2003/09/23 07:52:16 bgr
|
||||
* menus added
|
||||
*
|
||||
* Revision 1.1 2003/09/22 05:21:54 bgr
|
||||
* initial commit
|
||||
*
|
||||
*/
|
||||
@@ -0,0 +1,63 @@
|
||||
package net.sourceforge.pmd.util.viewer.gui.menu;
|
||||
|
||||
import net.sourceforge.pmd.ast.SimpleNode;
|
||||
import net.sourceforge.pmd.util.viewer.model.ViewerModel;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
|
||||
/**
|
||||
* context sensetive menu for the AST Panel
|
||||
*
|
||||
* @author Boris Gruschko ( boris at gruschko.org )
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ASTNodePopupMenu
|
||||
extends JPopupMenu {
|
||||
private ViewerModel model;
|
||||
private SimpleNode node;
|
||||
|
||||
public ASTNodePopupMenu(ViewerModel model, SimpleNode node) {
|
||||
this.model = model;
|
||||
this.node = node;
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
add(new SimpleNodeSubMenu(model, node));
|
||||
|
||||
addSeparator();
|
||||
|
||||
add(new AttributesSubMenu(model, node));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* $Log$
|
||||
* Revision 1.1 2005/08/15 19:51:43 tomcopeland
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.5 2004/09/27 19:42:52 tomcopeland
|
||||
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
|
||||
*
|
||||
* Revision 1.4 2004/04/15 18:21:58 tomcopeland
|
||||
* Cleaned up imports with new version of IDEA; fixed some deprecated Ant junx
|
||||
*
|
||||
* Revision 1.3 2003/09/23 20:51:06 tomcopeland
|
||||
* Cleaned up imports
|
||||
*
|
||||
* Revision 1.2 2003/09/23 20:34:33 tomcopeland
|
||||
* Fixed some stuff PMD found
|
||||
*
|
||||
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
|
||||
* Added Boris Gruschko's new AST/XPath viewer
|
||||
*
|
||||
* Revision 1.1 2003/09/24 01:33:03 bgr
|
||||
* moved to a new package
|
||||
*
|
||||
* Revision 1.1 2003/09/23 07:52:16 bgr
|
||||
* menus added
|
||||
*
|
||||
*/
|
||||
@@ -0,0 +1,73 @@
|
||||
package net.sourceforge.pmd.util.viewer.gui.menu;
|
||||
|
||||
import net.sourceforge.pmd.ast.SimpleNode;
|
||||
import net.sourceforge.pmd.jaxen.Attribute;
|
||||
import net.sourceforge.pmd.jaxen.AttributeAxisIterator;
|
||||
import net.sourceforge.pmd.util.viewer.model.AttributeToolkit;
|
||||
import net.sourceforge.pmd.util.viewer.model.ViewerModel;
|
||||
import net.sourceforge.pmd.util.viewer.util.NLS;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.text.MessageFormat;
|
||||
|
||||
|
||||
/**
|
||||
* contains menu items for the predicate creation
|
||||
*
|
||||
* @author Boris Gruschko ( boris at gruschko.org )
|
||||
* @version $Id$
|
||||
*/
|
||||
public class AttributesSubMenu
|
||||
extends JMenu {
|
||||
private ViewerModel model;
|
||||
private SimpleNode node;
|
||||
|
||||
public AttributesSubMenu(ViewerModel model, SimpleNode node) {
|
||||
super(MessageFormat.format(NLS.nls("AST.MENU.ATTRIBUTES"), new Object[]{node.toString()}));
|
||||
|
||||
this.model = model;
|
||||
this.node = node;
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
AttributeAxisIterator i = new AttributeAxisIterator(node);
|
||||
|
||||
while (i.hasNext()) {
|
||||
Attribute attribute = (Attribute) i.next();
|
||||
|
||||
add(new XPathFragmentAddingItem(attribute.getName() + " = " + attribute.getValue(), model,
|
||||
AttributeToolkit.constructPredicate(attribute)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* $Log$
|
||||
* Revision 1.1 2005/08/15 19:51:43 tomcopeland
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.5 2004/09/27 19:42:52 tomcopeland
|
||||
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
|
||||
*
|
||||
* Revision 1.4 2004/04/15 18:21:58 tomcopeland
|
||||
* Cleaned up imports with new version of IDEA; fixed some deprecated Ant junx
|
||||
*
|
||||
* Revision 1.3 2003/09/23 20:51:06 tomcopeland
|
||||
* Cleaned up imports
|
||||
*
|
||||
* Revision 1.2 2003/09/23 20:34:34 tomcopeland
|
||||
* Fixed some stuff PMD found
|
||||
*
|
||||
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
|
||||
* Added Boris Gruschko's new AST/XPath viewer
|
||||
*
|
||||
* Revision 1.1 2003/09/24 01:33:03 bgr
|
||||
* moved to a new package
|
||||
*
|
||||
* Revision 1.1 2003/09/23 07:52:16 bgr
|
||||
* menus added
|
||||
*
|
||||
*/
|
||||
@@ -0,0 +1,76 @@
|
||||
package net.sourceforge.pmd.util.viewer.gui.menu;
|
||||
|
||||
import net.sourceforge.pmd.ast.Node;
|
||||
import net.sourceforge.pmd.ast.SimpleNode;
|
||||
import net.sourceforge.pmd.util.viewer.model.ViewerModel;
|
||||
import net.sourceforge.pmd.util.viewer.util.NLS;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.text.MessageFormat;
|
||||
|
||||
|
||||
/**
|
||||
* submenu for the simple node itself
|
||||
*
|
||||
* @author Boris Gruschko ( boris at gruschko.org )
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SimpleNodeSubMenu
|
||||
extends JMenu {
|
||||
private ViewerModel model;
|
||||
private SimpleNode node;
|
||||
|
||||
/**
|
||||
* constructs the submenu
|
||||
*
|
||||
* @param model model to which the actions will be forwarded
|
||||
* @param node menu's owner
|
||||
*/
|
||||
public SimpleNodeSubMenu(ViewerModel model, SimpleNode node) {
|
||||
super(MessageFormat.format(NLS.nls("AST.MENU.NODE.TITLE"), new Object[]{node.toString()}));
|
||||
|
||||
this.model = model;
|
||||
this.node = node;
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
StringBuffer buf = new StringBuffer(200);
|
||||
|
||||
for (Node temp = node; temp != null; temp = temp.jjtGetParent()) {
|
||||
buf.insert(0, "/" + temp.toString());
|
||||
}
|
||||
|
||||
add(new XPathFragmentAddingItem(NLS.nls("AST.MENU.NODE.ADD_ABSOLUTE_PATH"), model, buf.toString()));
|
||||
|
||||
add(new XPathFragmentAddingItem(NLS.nls("AST.MENU.NODE.ADD_ALLDESCENDANTS"), model,
|
||||
"//" + node.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* $Log$
|
||||
* Revision 1.1 2005/08/15 19:51:43 tomcopeland
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.4 2004/09/27 19:42:52 tomcopeland
|
||||
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
|
||||
*
|
||||
* Revision 1.3 2004/04/15 18:21:58 tomcopeland
|
||||
* Cleaned up imports with new version of IDEA; fixed some deprecated Ant junx
|
||||
*
|
||||
* Revision 1.2 2003/09/23 20:51:06 tomcopeland
|
||||
* Cleaned up imports
|
||||
*
|
||||
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
|
||||
* Added Boris Gruschko's new AST/XPath viewer
|
||||
*
|
||||
* Revision 1.1 2003/09/24 01:33:03 bgr
|
||||
* moved to a new package
|
||||
*
|
||||
* Revision 1.1 2003/09/23 07:52:16 bgr
|
||||
* menus added
|
||||
*
|
||||
*/
|
||||
@@ -0,0 +1,70 @@
|
||||
package net.sourceforge.pmd.util.viewer.gui.menu;
|
||||
|
||||
import net.sourceforge.pmd.util.viewer.model.ViewerModel;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
|
||||
/**
|
||||
* adds the given path fragment to the XPath expression upon action
|
||||
*
|
||||
* @author Boris Gruschko ( boris at gruschko.org )
|
||||
* @version $Id$
|
||||
*/
|
||||
public class XPathFragmentAddingItem
|
||||
extends JMenuItem
|
||||
implements ActionListener {
|
||||
private ViewerModel model;
|
||||
private String fragment;
|
||||
|
||||
/**
|
||||
* constructs the item
|
||||
*
|
||||
* @param caption menu item's caption
|
||||
* @param model model to refer to
|
||||
* @param fragment XPath expression fragment to be added upon action
|
||||
*/
|
||||
public XPathFragmentAddingItem(String caption, ViewerModel model, String fragment) {
|
||||
super(caption);
|
||||
|
||||
this.model = model;
|
||||
this.fragment = fragment;
|
||||
|
||||
addActionListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
||||
*/
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
model.appendToXPathExpression(fragment, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* $Log$
|
||||
* Revision 1.1 2005/08/15 19:51:42 tomcopeland
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.4 2004/09/27 19:42:52 tomcopeland
|
||||
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
|
||||
*
|
||||
* Revision 1.3 2004/04/15 18:21:58 tomcopeland
|
||||
* Cleaned up imports with new version of IDEA; fixed some deprecated Ant junx
|
||||
*
|
||||
* Revision 1.2 2003/09/23 20:51:06 tomcopeland
|
||||
* Cleaned up imports
|
||||
*
|
||||
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
|
||||
* Added Boris Gruschko's new AST/XPath viewer
|
||||
*
|
||||
* Revision 1.1 2003/09/24 01:33:03 bgr
|
||||
* moved to a new package
|
||||
*
|
||||
* Revision 1.1 2003/09/23 07:52:16 bgr
|
||||
* menus added
|
||||
*
|
||||
*/
|
||||
@@ -0,0 +1,125 @@
|
||||
package net.sourceforge.pmd.util.viewer.model;
|
||||
|
||||
import net.sourceforge.pmd.ast.SimpleNode;
|
||||
|
||||
import javax.swing.event.TreeModelEvent;
|
||||
import javax.swing.event.TreeModelListener;
|
||||
import javax.swing.tree.TreeModel;
|
||||
import javax.swing.tree.TreePath;
|
||||
import java.util.Vector;
|
||||
|
||||
|
||||
/**
|
||||
* Model for the AST Panel Tree component
|
||||
*
|
||||
* @author Boris Gruschko ( boris at gruschko.org )
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ASTModel
|
||||
implements TreeModel {
|
||||
private SimpleNode root;
|
||||
private Vector listeners = new Vector(1);
|
||||
|
||||
/**
|
||||
* creates the tree model
|
||||
*
|
||||
* @param root tree's root
|
||||
*/
|
||||
public ASTModel(SimpleNode root) {
|
||||
this.root = root;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.swing.tree.TreeModel#getChild(java.lang.Object, int)
|
||||
*/
|
||||
public Object getChild(Object parent, int index) {
|
||||
return ((SimpleNode) parent).jjtGetChild(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.swing.tree.TreeModel#getChildCount(java.lang.Object)
|
||||
*/
|
||||
public int getChildCount(Object parent) {
|
||||
return ((SimpleNode) parent).jjtGetNumChildren();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.swing.tree.TreeModel#getIndexOfChild(java.lang.Object,
|
||||
* java.lang.Object)
|
||||
*/
|
||||
public int getIndexOfChild(Object parent, Object child) {
|
||||
SimpleNode node = ((SimpleNode) parent);
|
||||
|
||||
for (int i = 0; i < node.jjtGetNumChildren(); i++)
|
||||
if (node.jjtGetChild(i).equals(child)) {
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.swing.tree.TreeModel#isLeaf(java.lang.Object)
|
||||
*/
|
||||
public boolean isLeaf(Object node) {
|
||||
return ((SimpleNode) node).jjtGetNumChildren() == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.swing.tree.TreeModel#getRoot()
|
||||
*/
|
||||
public Object getRoot() {
|
||||
return root;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.swing.tree.TreeModel#valueForPathChanged(javax.swing.tree.TreePath,
|
||||
* java.lang.Object)
|
||||
*/
|
||||
public void valueForPathChanged(TreePath path, Object newValue) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.swing.tree.TreeModel#addTreeModelListener(javax.swing.event.TreeModelListener)
|
||||
*/
|
||||
public void addTreeModelListener(TreeModelListener l) {
|
||||
listeners.add(l);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.swing.tree.TreeModel#removeTreeModelListener(javax.swing.event.TreeModelListener)
|
||||
*/
|
||||
public void removeTreeModelListener(TreeModelListener l) {
|
||||
listeners.remove(l);
|
||||
}
|
||||
|
||||
protected void fireTreeModelEvent(TreeModelEvent e) {
|
||||
for (int i = 0; i < listeners.size(); i++) {
|
||||
((TreeModelListener) listeners.elementAt(i)).treeNodesChanged(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* $Log$
|
||||
* Revision 1.1 2005/08/15 19:51:42 tomcopeland
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.3 2004/09/27 19:42:52 tomcopeland
|
||||
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
|
||||
*
|
||||
* Revision 1.2 2003/09/23 20:51:06 tomcopeland
|
||||
* Cleaned up imports
|
||||
*
|
||||
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
|
||||
* Added Boris Gruschko's new AST/XPath viewer
|
||||
*
|
||||
* Revision 1.1 2003/09/24 01:33:03 bgr
|
||||
* moved to a new package
|
||||
*
|
||||
* Revision 1.1 2003/09/24 00:40:35 bgr
|
||||
* evaluation results browsing added
|
||||
*
|
||||
*/
|
||||
@@ -0,0 +1,53 @@
|
||||
package net.sourceforge.pmd.util.viewer.model;
|
||||
|
||||
import net.sourceforge.pmd.jaxen.Attribute;
|
||||
|
||||
|
||||
/**
|
||||
* A toolkit for vaious attribute translations
|
||||
*
|
||||
* @author Boris Gruschko ( boris at gruschko.org )
|
||||
* @version $Id$
|
||||
*/
|
||||
public class AttributeToolkit {
|
||||
/**
|
||||
* formats a value for it's usage in XPath expressions
|
||||
*
|
||||
* @param attribute atribute which value should be formatted
|
||||
* @return formmated value
|
||||
*/
|
||||
public static String formatValueForXPath(Attribute attribute) {
|
||||
return "'" + attribute.getValue() + "'";
|
||||
}
|
||||
|
||||
/**
|
||||
* constructs a predicate from the given attribute
|
||||
*
|
||||
* @param attribute attribute to be formatted as predicate
|
||||
* @return predicate
|
||||
*/
|
||||
public static String constructPredicate(Attribute attribute) {
|
||||
return "[@" + attribute.getName() + "=" +
|
||||
formatValueForXPath(attribute) + "]";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* $Log$
|
||||
* Revision 1.1 2005/08/15 19:51:42 tomcopeland
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.2 2004/09/27 19:42:52 tomcopeland
|
||||
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
|
||||
*
|
||||
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
|
||||
* Added Boris Gruschko's new AST/XPath viewer
|
||||
*
|
||||
* Revision 1.1 2003/09/24 01:33:03 bgr
|
||||
* moved to a new package
|
||||
*
|
||||
* Revision 1.1 2003/09/23 07:52:16 bgr
|
||||
* menus added
|
||||
*
|
||||
*/
|
||||
@@ -0,0 +1,142 @@
|
||||
package net.sourceforge.pmd.util.viewer.model;
|
||||
|
||||
import net.sourceforge.pmd.ast.SimpleNode;
|
||||
|
||||
import javax.swing.tree.TreeNode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* provides the adapter for the tree model
|
||||
*
|
||||
* @author Boris Gruschko ( boris at gruschko.org )
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SimpleNodeTreeNodeAdapter
|
||||
implements TreeNode {
|
||||
private SimpleNode node;
|
||||
private List children;
|
||||
private SimpleNodeTreeNodeAdapter parent;
|
||||
|
||||
/**
|
||||
* constructs the node
|
||||
*
|
||||
* @param node underlying AST's node
|
||||
*/
|
||||
public SimpleNodeTreeNodeAdapter(SimpleNodeTreeNodeAdapter parent, SimpleNode node) {
|
||||
this.parent = parent;
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
/**
|
||||
* retrieves the underlying node
|
||||
*
|
||||
* @return AST node
|
||||
*/
|
||||
public SimpleNode getSimpleNode() {
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.swing.tree.TreeNode#getChildAt(int)
|
||||
*/
|
||||
public TreeNode getChildAt(int childIndex) {
|
||||
checkChildren();
|
||||
|
||||
return (TreeNode) children.get(childIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.swing.tree.TreeNode#getChildCount()
|
||||
*/
|
||||
public int getChildCount() {
|
||||
checkChildren();
|
||||
|
||||
return children.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.swing.tree.TreeNode#getParent()
|
||||
*/
|
||||
public TreeNode getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.swing.tree.TreeNode#getIndex(javax.swing.tree.TreeNode)
|
||||
*/
|
||||
public int getIndex(TreeNode node) {
|
||||
checkChildren();
|
||||
|
||||
return children.indexOf(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.swing.tree.TreeNode#getAllowsChildren()
|
||||
*/
|
||||
public boolean getAllowsChildren() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.swing.tree.TreeNode#isLeaf()
|
||||
*/
|
||||
public boolean isLeaf() {
|
||||
checkChildren();
|
||||
|
||||
return children.size() == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.swing.tree.TreeNode#children()
|
||||
*/
|
||||
public Enumeration children() {
|
||||
return Collections.enumeration(children);
|
||||
}
|
||||
|
||||
/**
|
||||
* checks the children and creates them if neccessary
|
||||
*/
|
||||
private void checkChildren() {
|
||||
if (children == null) {
|
||||
children = new ArrayList(node.jjtGetNumChildren());
|
||||
|
||||
for (int i = 0; i < node.jjtGetNumChildren(); i++) {
|
||||
children.add(new SimpleNodeTreeNodeAdapter(this, (SimpleNode) node.jjtGetChild(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
public String toString() {
|
||||
return node.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* $Log$
|
||||
* Revision 1.1 2005/08/15 19:51:41 tomcopeland
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.3 2004/09/27 19:42:52 tomcopeland
|
||||
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
|
||||
*
|
||||
* Revision 1.2 2003/09/23 20:51:06 tomcopeland
|
||||
* Cleaned up imports
|
||||
*
|
||||
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
|
||||
* Added Boris Gruschko's new AST/XPath viewer
|
||||
*
|
||||
* Revision 1.1 2003/09/24 01:33:03 bgr
|
||||
* moved to a new package
|
||||
*
|
||||
* Revision 1.1 2003/09/22 05:21:54 bgr
|
||||
* initial commit
|
||||
*
|
||||
*/
|
||||
@@ -0,0 +1,180 @@
|
||||
package net.sourceforge.pmd.util.viewer.model;
|
||||
|
||||
import net.sourceforge.pmd.TargetJDK1_4;
|
||||
import net.sourceforge.pmd.ast.ASTCompilationUnit;
|
||||
import net.sourceforge.pmd.ast.ParseException;
|
||||
import net.sourceforge.pmd.ast.SimpleNode;
|
||||
import net.sourceforge.pmd.jaxen.DocumentNavigator;
|
||||
import org.jaxen.BaseXPath;
|
||||
import org.jaxen.JaxenException;
|
||||
import org.jaxen.XPath;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
|
||||
/**
|
||||
* The model for the viewer gui
|
||||
* <p/>
|
||||
* <p/>
|
||||
* This is the model part of MVC
|
||||
* </p>
|
||||
*
|
||||
* @author Boris Gruschko ( boris at gruschko.org )
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ViewerModel {
|
||||
private Vector listeners;
|
||||
private SimpleNode rootNode;
|
||||
private List evaluationResults;
|
||||
|
||||
/**
|
||||
* constructs the model
|
||||
*/
|
||||
public ViewerModel() {
|
||||
listeners = new Vector(5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves AST's root node
|
||||
*
|
||||
* @return AST's root node
|
||||
*/
|
||||
public SimpleNode getRootNode() {
|
||||
return rootNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* commits source code to the model.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* all existing source will be replaced
|
||||
* </p>
|
||||
*
|
||||
* @param source source to be commited
|
||||
*/
|
||||
public void commitSource(String source) {
|
||||
ASTCompilationUnit compilationUnit = new TargetJDK1_4().createParser(new StringReader(source)).CompilationUnit();
|
||||
rootNode = compilationUnit;
|
||||
fireViewerModelEvent(new ViewerModelEvent(this, ViewerModelEvent.CODE_RECOMPILED));
|
||||
}
|
||||
|
||||
/**
|
||||
* determines wheteher the model has a compiled tree at it's disposal
|
||||
*
|
||||
* @return true if there is an AST, false otherwise
|
||||
*/
|
||||
public boolean hasCompiledTree() {
|
||||
return rootNode != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* evaluates the given XPath expression against the current tree
|
||||
*
|
||||
* @param xPath XPath expression to be evaluated
|
||||
* @param evaluator object which requests the evaluation
|
||||
*/
|
||||
public void evaluateXPathExpression(String xPath, Object evaluator)
|
||||
throws ParseException, JaxenException {
|
||||
XPath xpath = new BaseXPath(xPath, new DocumentNavigator());
|
||||
|
||||
evaluationResults = xpath.selectNodes(rootNode);
|
||||
|
||||
fireViewerModelEvent(new ViewerModelEvent(evaluator, ViewerModelEvent.PATH_EXPRESSION_EVALUATED));
|
||||
}
|
||||
|
||||
/**
|
||||
* retrieves the results of last evaluation
|
||||
*
|
||||
* @return a list containing the nodes selected by the last XPath expression
|
||||
* evaluation
|
||||
*/
|
||||
public List getLastEvaluationResults() {
|
||||
return evaluationResults;
|
||||
}
|
||||
|
||||
/**
|
||||
* selects the given node in the AST
|
||||
*
|
||||
* @param node node to be selected
|
||||
* @param selector object which requests the selection
|
||||
*/
|
||||
public void selectNode(SimpleNode node, Object selector) {
|
||||
fireViewerModelEvent(new ViewerModelEvent(selector, ViewerModelEvent.NODE_SELECTED, node));
|
||||
}
|
||||
|
||||
/**
|
||||
* appends the given fragment to the XPath expression
|
||||
*
|
||||
* @param pathFragment fragment to be added
|
||||
* @param appender object that is trying to append the fragment
|
||||
*/
|
||||
public void appendToXPathExpression(String pathFragment, Object appender) {
|
||||
fireViewerModelEvent(new ViewerModelEvent(appender, ViewerModelEvent.PATH_EXPRESSION_APPENDED, pathFragment));
|
||||
}
|
||||
|
||||
/**
|
||||
* adds a listener to the model
|
||||
*
|
||||
* @param l listener to be added
|
||||
*/
|
||||
public void addViewerModelListener(ViewerModelListener l) {
|
||||
listeners.add(l);
|
||||
}
|
||||
|
||||
/**
|
||||
* removes the lisetener from the model
|
||||
*
|
||||
* @param l listener to be removed
|
||||
*/
|
||||
public void removeViewerModelListener(ViewerModelListener l) {
|
||||
listeners.remove(l);
|
||||
}
|
||||
|
||||
/**
|
||||
* notifes all listener of a change in the model
|
||||
*
|
||||
* @param e change's reason
|
||||
*/
|
||||
protected void fireViewerModelEvent(ViewerModelEvent e) {
|
||||
for (int i = 0; i < listeners.size(); i++) {
|
||||
((ViewerModelListener) listeners.elementAt(i)).viewerModelChanged(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* $Log$
|
||||
* Revision 1.1 2005/08/15 19:51:42 tomcopeland
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.5 2004/09/27 19:42:52 tomcopeland
|
||||
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
|
||||
*
|
||||
* Revision 1.4 2004/04/12 17:35:09 tomcopeland
|
||||
* Cleaned up imports
|
||||
*
|
||||
* Revision 1.3 2004/04/12 17:23:29 tomcopeland
|
||||
* Moving all explicit JavaParser creations over to a factory-ish sort of thing. This makes the version of the parser explicit rather than assumed.
|
||||
*
|
||||
* Revision 1.2 2003/09/23 20:51:06 tomcopeland
|
||||
* Cleaned up imports
|
||||
*
|
||||
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
|
||||
* Added Boris Gruschko's new AST/XPath viewer
|
||||
*
|
||||
* Revision 1.1 2003/09/24 01:33:03 bgr
|
||||
* moved to a new package
|
||||
*
|
||||
* Revision 1.3 2003/09/24 00:40:35 bgr
|
||||
* evaluation results browsing added
|
||||
*
|
||||
* Revision 1.2 2003/09/23 07:52:16 bgr
|
||||
* menus added
|
||||
*
|
||||
* Revision 1.1 2003/09/22 05:21:54 bgr
|
||||
* initial commit
|
||||
*
|
||||
*/
|
||||
@@ -0,0 +1,112 @@
|
||||
package net.sourceforge.pmd.util.viewer.model;
|
||||
|
||||
/**
|
||||
* The event which will be sent every time the model changes
|
||||
* <p/>
|
||||
* <p/>
|
||||
* Note: the instances will be immutable
|
||||
* </p>
|
||||
*
|
||||
* @author Boris Gruschko ( boris at gruschko.org )
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ViewerModelEvent {
|
||||
/**
|
||||
* reason in the case of code recompilation
|
||||
*/
|
||||
public static final int CODE_RECOMPILED = 1;
|
||||
|
||||
/**
|
||||
* reason in the case of node selection
|
||||
*/
|
||||
public static final int NODE_SELECTED = 2;
|
||||
|
||||
/**
|
||||
* reason in the case of path extension
|
||||
*/
|
||||
public static final int PATH_EXPRESSION_APPENDED = 3;
|
||||
|
||||
/**
|
||||
* reason in the case of path expression evaluation
|
||||
*/
|
||||
public static final int PATH_EXPRESSION_EVALUATED = 4;
|
||||
private Object source;
|
||||
private int reason;
|
||||
private Object parameter;
|
||||
|
||||
/**
|
||||
* Creates an event
|
||||
*
|
||||
* @param source event's source
|
||||
* @param reason event's reason
|
||||
*/
|
||||
public ViewerModelEvent(Object source, int reason) {
|
||||
this(source, reason, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an event
|
||||
*
|
||||
* @param source event's source
|
||||
* @param reason event's reason
|
||||
* @param parameter parameter object
|
||||
*/
|
||||
public ViewerModelEvent(Object source, int reason, Object parameter) {
|
||||
this.source = source;
|
||||
this.reason = reason;
|
||||
this.parameter = parameter;
|
||||
}
|
||||
|
||||
/**
|
||||
* retrieves the reason for event's occurance
|
||||
*
|
||||
* @return event's reason
|
||||
*/
|
||||
public int getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* retrieves the object which caused the event
|
||||
*
|
||||
* @return object that casused the event
|
||||
*/
|
||||
public Object getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
/**
|
||||
* retrieves event's parameter
|
||||
*
|
||||
* @return event's parameter
|
||||
*/
|
||||
public Object getParameter() {
|
||||
return parameter;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* $Log$
|
||||
* Revision 1.1 2005/08/15 19:51:42 tomcopeland
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.2 2004/09/27 19:42:52 tomcopeland
|
||||
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
|
||||
*
|
||||
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
|
||||
* Added Boris Gruschko's new AST/XPath viewer
|
||||
*
|
||||
* Revision 1.1 2003/09/24 01:33:03 bgr
|
||||
* moved to a new package
|
||||
*
|
||||
* Revision 1.3 2003/09/24 00:40:35 bgr
|
||||
* evaluation results browsing added
|
||||
*
|
||||
* Revision 1.2 2003/09/23 07:52:16 bgr
|
||||
* menus added
|
||||
*
|
||||
* Revision 1.1 2003/09/22 05:21:54 bgr
|
||||
* initial commit
|
||||
*
|
||||
*/
|
||||
@@ -0,0 +1,39 @@
|
||||
package net.sourceforge.pmd.util.viewer.model;
|
||||
|
||||
/**
|
||||
* identiefie a listener of the ViewerModel
|
||||
*
|
||||
* @author Boris Gruschko ( boris at gruschko.org )
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface ViewerModelListener {
|
||||
/**
|
||||
* DOCUMENT ME!
|
||||
*
|
||||
* @param e DOCUMENT ME!
|
||||
*/
|
||||
void viewerModelChanged(ViewerModelEvent e);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* $Log$
|
||||
* Revision 1.1 2005/08/15 19:51:42 tomcopeland
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.3 2004/12/22 20:52:12 tomcopeland
|
||||
* Fixing some stuff PMD found
|
||||
*
|
||||
* Revision 1.2 2004/09/27 19:42:52 tomcopeland
|
||||
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
|
||||
*
|
||||
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
|
||||
* Added Boris Gruschko's new AST/XPath viewer
|
||||
*
|
||||
* Revision 1.1 2003/09/24 01:33:03 bgr
|
||||
* moved to a new package
|
||||
*
|
||||
* Revision 1.1 2003/09/22 05:21:54 bgr
|
||||
* initial commit
|
||||
*
|
||||
*/
|
||||
@@ -0,0 +1,34 @@
|
||||
##########################################################################
|
||||
# english string translations for the viewer
|
||||
#
|
||||
##########################################################################
|
||||
|
||||
# Main Frame
|
||||
MAIN.FRAME.TITLE = AST Viewer
|
||||
MAIN.FRAME.COMPILE_BUTTON.TITLE = Compile
|
||||
MAIN.FRAME.EVALUATE_BUTTON.TITLE = Evaluate XPath Expression
|
||||
MAIN.FRAME.COMPILATION.TOOK = Compilation took
|
||||
MAIN.FRAME.COMPILATION.PROBLEM = Compilation problem:
|
||||
MAIN.FRAME.EVALUATION.TOOK = Evaluation took
|
||||
MAIN.FRAME.EVALUATION.PROBLEM = Evaluation problem:
|
||||
|
||||
|
||||
# Source Panel
|
||||
SOURCE.PANEL.TITLE = Source code
|
||||
|
||||
# Tree Panel
|
||||
AST.PANEL.TITLE = Abstract Syntax Tree
|
||||
AST.MENU.ATTRIBUTES = Add predicate from {0}'a attributes
|
||||
AST.MENU.NODE.TITLE = Add {0} to the XPath expression
|
||||
AST.MENU.NODE.ADD_ABSOLUTE_PATH = Add with absolute path
|
||||
AST.MENU.NODE.ADD_ALLDESCENDANTS = Add all descentands of this type
|
||||
|
||||
# XPath Panel
|
||||
XPATH.PANEL.TITLE = XPath
|
||||
XPATH.PANEL.EXPRESSION = Expression
|
||||
XPATH.PANEL.RESULTS = Results
|
||||
|
||||
# Compile Error dialog
|
||||
COMPILE_ERROR.DIALOG.TITLE = Compilation error
|
||||
COMPILE_ERROR.PANEL.TITLE = Error message
|
||||
COMPILE_ERROR.OK_BUTTON.CAPTION = Ok
|
||||
@@ -0,0 +1,49 @@
|
||||
package net.sourceforge.pmd.util.viewer.util;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
|
||||
/**
|
||||
* helps with internationalization
|
||||
*
|
||||
* @author Boris Gruschko ( boris at gruschko.org )
|
||||
* @version $Id$
|
||||
*/
|
||||
public class NLS {
|
||||
private final static ResourceBundle bundle;
|
||||
|
||||
static {
|
||||
bundle =
|
||||
ResourceBundle.getBundle("net.sourceforge.pmd.util.viewer.resources.viewer_strings");
|
||||
}
|
||||
|
||||
/**
|
||||
* translates the given key to the message
|
||||
*
|
||||
* @param key key to be translated
|
||||
* @return translated string
|
||||
*/
|
||||
public static String nls(String key) {
|
||||
return bundle.getString(key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* $Log$
|
||||
* Revision 1.1 2005/08/15 19:51:42 tomcopeland
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.2 2004/09/27 19:42:52 tomcopeland
|
||||
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
|
||||
*
|
||||
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
|
||||
* Added Boris Gruschko's new AST/XPath viewer
|
||||
*
|
||||
* Revision 1.1 2003/09/24 01:33:03 bgr
|
||||
* moved to a new package
|
||||
*
|
||||
* Revision 1.1 2003/09/22 05:21:54 bgr
|
||||
* initial commit
|
||||
*
|
||||
*/
|
||||
@@ -6,13 +6,12 @@
|
||||
<groupId>org.sonatype.oss</groupId>
|
||||
<artifactId>oss-parent</artifactId>
|
||||
<version>7</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
<groupId>net.sourceforge.pmd</groupId>
|
||||
<artifactId>pmd-build</artifactId>
|
||||
<name>PMD Build Plugin</name>
|
||||
<version>0.9-SNAPSHOT</version>
|
||||
<version>0.8-SNAPSHOT</version>
|
||||
<packaging>maven-plugin</packaging>
|
||||
<description>
|
||||
<![CDATA[
|
||||
|
||||
+1
-12
@@ -7,7 +7,6 @@ import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -23,7 +22,6 @@ public class RuntimeRulePropertiesAnalyzer {
|
||||
private Class<?> propertyDesc;
|
||||
private Method nameMethod;
|
||||
private Method descMethod;
|
||||
private Method defaultValueMethod;
|
||||
private Field propertiesField;
|
||||
private Field propertiesValues;
|
||||
|
||||
@@ -38,7 +36,6 @@ public class RuntimeRulePropertiesAnalyzer {
|
||||
propertyDesc = cl.loadClass("net.sourceforge.pmd.PropertyDescriptor");
|
||||
nameMethod = propertyDesc.getDeclaredMethod("name");
|
||||
descMethod = propertyDesc.getDeclaredMethod("description");
|
||||
defaultValueMethod = propertyDesc.getDeclaredMethod("defaultValue");
|
||||
propertiesField = propertySource.getDeclaredField("propertyDescriptors");
|
||||
propertiesValues = propertySource.getDeclaredField("propertyValuesByDescriptor");
|
||||
propertiesField.setAccessible(true);
|
||||
@@ -90,19 +87,11 @@ public class RuntimeRulePropertiesAnalyzer {
|
||||
|
||||
for (Object o : properties) {
|
||||
Object value = values.get(o);
|
||||
if (value == null) {
|
||||
value = defaultValueMethod.invoke(o);
|
||||
}
|
||||
|
||||
Element propElem = document.createElement("property");
|
||||
propElem.setAttribute("name", (String)nameMethod.invoke(o));
|
||||
propElem.setAttribute("description", (String)descMethod.invoke(o));
|
||||
if (value != null) {
|
||||
String valueString = String.valueOf(value);
|
||||
if (value.getClass().isArray()) {
|
||||
valueString = Arrays.toString((Object[])value);
|
||||
}
|
||||
propElem.setAttribute("value", valueString);
|
||||
propElem.setAttribute("value", String.valueOf(value));
|
||||
}
|
||||
propsElem.appendChild(propElem);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
-->
|
||||
<xsl:stylesheet
|
||||
version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
|
||||
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
|
||||
|
||||
<xsl:template match="root">
|
||||
<xsl:comment>
|
||||
THIS FILE HAS BEEN AUTOMATICLY GENERATED.
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
<xsl:with-param name="classname" select="$classname"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<p><xsl:value-of select="$definedByJavaClass"/>: <a><xsl:attribute name="href"><xsl:value-of select="concat(concat('../../xref/',$classfile),'.html')"/></xsl:attribute><xsl:value-of select="@class"/></a>
|
||||
<p><xsl:value-of select="$definedByJavaClass"/>:<a><xsl:attribute name="href"><xsl:value-of select="concat(concat('../../xref/',$classfile),'.html')"/></xsl:attribute><xsl:value-of select="@class"/></a>
|
||||
</p>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
@@ -29,9 +29,6 @@
|
||||
</li>
|
||||
</xsl:for-each>
|
||||
</ul>
|
||||
|
||||
<xsl:variable name="urlPrefixLength"><xsl:value-of select="string-length('${pmd.website.baseurl}/rules/')"/></xsl:variable>
|
||||
|
||||
<xsl:for-each select="language">
|
||||
<xsl:variable name="language"><xsl:value-of select="@name"/></xsl:variable>
|
||||
<xsl:for-each select="ruleset">
|
||||
@@ -44,11 +41,7 @@
|
||||
<xsl:attribute name="name"><xsl:value-of select="@name"/> (<xsl:value-of select="$language"/>)</xsl:attribute>
|
||||
<ul>
|
||||
<xsl:for-each select="./rule[@name]">
|
||||
<li>
|
||||
<a>
|
||||
<xsl:attribute name="href"><xsl:value-of select="substring(@externalInfoUrl,$urlPrefixLength + 1)"/></xsl:attribute>
|
||||
<xsl:value-of select="@name"/>
|
||||
</a>: <xsl:value-of select="description"/></li>
|
||||
<li> <xsl:value-of select="@name"/>: <xsl:value-of select="description"/></li>
|
||||
</xsl:for-each>
|
||||
</ul>
|
||||
</subsection>
|
||||
|
||||
@@ -29,11 +29,6 @@ public class AbstractPropertySource {
|
||||
public String description() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object defaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
};
|
||||
propertyDescriptors.add(descriptor);
|
||||
propertyValuesByDescriptor.put(descriptor, defaultValue);
|
||||
|
||||
@@ -11,5 +11,4 @@ public interface PropertyDescriptor {
|
||||
|
||||
String name();
|
||||
String description();
|
||||
Object defaultValue();
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<project name="pmd-jbuilder" default="compile" basedir="../">
|
||||
|
||||
<property name="dir.lib" value="lib\"/>
|
||||
<property name="dir.src" value="src\"/>
|
||||
<property name="dir.build" value="build\"/>
|
||||
<property name="version" value="1.0"/>
|
||||
<property name="pmd.version" value="3.3"/>
|
||||
|
||||
<path id="dependencies.path">
|
||||
<pathelement location="${dir.build}"/>
|
||||
<fileset dir="${dir.lib}">
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
</path>
|
||||
|
||||
<target name="delete">
|
||||
<delete dir="${dir.build}"/>
|
||||
<delete file="${dir.lib}\PMDExtension.jar"/>
|
||||
<mkdir dir="${dir.build}"/>
|
||||
</target>
|
||||
|
||||
<target name="compile" description="Compiles the code">
|
||||
<mkdir dir="${dir.build}"/>
|
||||
<javac deprecation="false"
|
||||
debug="true"
|
||||
optimize="false"
|
||||
srcdir="${dir.src}"
|
||||
destdir="${dir.build}">
|
||||
<classpath>
|
||||
|
||||
<path refid="dependencies.path"/>
|
||||
</classpath>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<target name="clean" depends="delete,compile" description="Does a complete recompile"/>
|
||||
|
||||
<target name="jar" depends="clean" description="Jars up the classes and rulesets">
|
||||
<jar
|
||||
jarfile="${dir.lib}\PMDExtension.jar"
|
||||
includes="net/sourceforge/pmd/bluej/*.class"
|
||||
basedir="${dir.build}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="net.sourceforge.pmd.bluej.PMDExtension"/>
|
||||
<attribute name="Class-Path" value="pmd/pmd-${pmd.version}.jar pmd/jaxen-1.1-beta-7.jar"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
<target name="mergejars" depends="jar" description="Creates one uber-jar for easier deployment">
|
||||
<unjar src="${dir.lib}/jaxen-1.1-beta-7.jar" dest="lib" overwrite="true"/>
|
||||
<unjar src="${dir.lib}/pmd-${pmd.version}.jar" dest="lib" overwrite="true"/>
|
||||
<unjar src="${dir.lib}/PMDExtension.jar" dest="lib" overwrite="true"/>
|
||||
<delete file="${dir.lib}\PMDExtension.jar"/>
|
||||
<jar
|
||||
jarfile="${dir.lib}\PMDExtension.jar"
|
||||
includes="net/**/*.*,org/**/*.*,META-INF/**/*.*,rulesets/**/*.*,"
|
||||
basedir="${dir.lib}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="net.sourceforge.pmd.bluej.PMDExtension"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
<delete dir="${dir.lib}/net"/>
|
||||
<delete dir="${dir.lib}/rulesets"/>
|
||||
<delete dir="${dir.lib}/org"/>
|
||||
<delete dir="${dir.lib}/test"/>
|
||||
<delete dir="${dir.lib}/META-INF"/>
|
||||
</target>
|
||||
|
||||
<target name="deploy" depends="mergejars" description="Deploys new jar file to my BlueJ install">
|
||||
<copy todir="/home/tom/pmd/ides/bluej/lib/extensions">
|
||||
<fileset dir="${dir.lib}">
|
||||
<include name="PMDExtension.jar"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="deploysfserver" depends="mergejars" description="Deploys new jar file to my BlueJ install">
|
||||
<echo message="Uploading jar file to SourceForge"/>
|
||||
<exec executable="scp" os="Linux">
|
||||
<arg line=" /home/tom/pmd/pmd-bluej/lib/PMDExtension.jar tomcopeland@pmd.sf.net:/home/groups/p/pm/pmd/htdocs/"/>
|
||||
</exec>
|
||||
<echo message="Uploading extensions.xml to SourceForge"/>
|
||||
<exec executable="scp" os="Linux">
|
||||
<arg line=" /home/tom/pmd/pmd-bluej/bin/extensions.xml tomcopeland@pmd.sf.net:/home/groups/p/pm/pmd/htdocs/"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,2 @@
|
||||
November 10, 2005 - 1.0:
|
||||
Initial functionality - basic/unusedcode rules only, JDK 1.4 only, report is displayed in wonky JOptionPane.
|
||||
Loaded 30 of 2137 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user