Compare commits
264
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
242ea1065b | ||
|
|
9273d334ac | ||
|
|
d52db39846 | ||
|
|
6f61b41e20 | ||
|
|
d03f5a339c | ||
|
|
3b47b5d408 | ||
|
|
324f5707d2 | ||
|
|
b2b02a69a4 | ||
|
|
dcb7668c57 | ||
|
|
22647630b7 | ||
|
|
85d8660c6d | ||
|
|
f0346a9aee | ||
|
|
0796dad74e | ||
|
|
785f01b0fa | ||
|
|
dbddeb01f1 | ||
|
|
8694a26caf | ||
|
|
6eb8f84769 | ||
|
|
4bcef67b42 | ||
|
|
0f72ff41d9 | ||
|
|
24c9bb9de9 | ||
|
|
1fcc5ceeae | ||
|
|
db000f3ad0 | ||
|
|
5ad79006ab | ||
|
|
a12bc08c3b | ||
|
|
423ac78d91 | ||
|
|
9a61116259 | ||
|
|
2b11c5e1f2 | ||
|
|
06057f17ee | ||
|
|
1e3dbdb357 | ||
|
|
e42bc43287 | ||
|
|
1aa11e5ee7 | ||
|
|
e8e7420027 | ||
|
|
4dd18721c1 | ||
|
|
552acfd0c1 | ||
|
|
bc4f7cc1c2 | ||
|
|
36fc87c3c8 | ||
|
|
12adae6034 | ||
|
|
88ee9c47d8 | ||
|
|
e54b6dd22f | ||
|
|
e0ece8f82a | ||
|
|
7a806df932 | ||
|
|
87989b524a | ||
|
|
6e1927ee2a | ||
|
|
f0049c5946 | ||
|
|
21750b9bc4 | ||
|
|
4aee867fc2 | ||
|
|
79a9af14f2 | ||
|
|
c7bba5bf26 | ||
|
|
b970324b97 | ||
|
|
d36190ea7c | ||
|
|
83552fb843 | ||
|
|
f4343f6b19 | ||
|
|
c011fc6dd1 | ||
|
|
93a46d17e7 | ||
|
|
ec0471cebe | ||
|
|
8aa83291c0 | ||
|
|
08041af650 | ||
|
|
8482948518 | ||
|
|
a0a7f58dec | ||
|
|
29a139797c | ||
|
|
8607d02120 | ||
|
|
8e8cec667e | ||
|
|
5b52ba642c | ||
|
|
bbb36686b9 | ||
|
|
c0efb45c10 | ||
|
|
ab158fe19f | ||
|
|
86d9c1060c | ||
|
|
cc27363c97 | ||
|
|
aad969665f | ||
|
|
dff3d181f9 | ||
|
|
8cac431226 | ||
|
|
4e30abe315 | ||
|
|
964f6933e1 | ||
|
|
d9064e6956 | ||
|
|
1a48102d9a | ||
|
|
dc945f78b2 | ||
|
|
570d6cedc6 | ||
|
|
2624b6b3ea | ||
|
|
ee708b42ea | ||
|
|
6355c1f6f4 | ||
|
|
6dc3701cc8 | ||
|
|
9fbaf13bd9 | ||
|
|
64ab7b78e7 | ||
|
|
4de96d5dd2 | ||
|
|
5f9598815f | ||
|
|
bef23a8d2d | ||
|
|
bfa925a44f | ||
|
|
b3af64fa52 | ||
|
|
65864b6189 | ||
|
|
350d0c3cfc | ||
|
|
9ba87965ca | ||
|
|
e57eb66c55 | ||
|
|
a49391f3f5 | ||
|
|
88d766ee8b | ||
|
|
9b91690f21 | ||
|
|
8c0a4f6e4f | ||
|
|
5f02803d78 | ||
|
|
f7b61616ea | ||
|
|
28449e7f71 | ||
|
|
61c25b793e | ||
|
|
faa035b1c1 | ||
|
|
4d9b7b0f8b | ||
|
|
36224a5ef7 | ||
|
|
bc47a7109e | ||
|
|
9bf3895a48 | ||
|
|
7ec06b3adb | ||
|
|
4fe4b40279 | ||
|
|
cce09d0f64 | ||
|
|
388b1f5e65 | ||
|
|
687eadbb10 | ||
|
|
75addab584 | ||
|
|
0dd9ffb390 | ||
|
|
6fd188a2ab | ||
|
|
d8ec3bfd39 | ||
|
|
6a09146169 | ||
|
|
7d455c0064 | ||
|
|
5ed9bd8a0a | ||
|
|
93a5d77184 | ||
|
|
c1cb3bfb5e | ||
|
|
e2b5b3753e | ||
|
|
d4719914fa | ||
|
|
036cd3c143 | ||
|
|
eee76b0248 | ||
|
|
1354f6f1fa | ||
|
|
a10c7dc78e | ||
|
|
7f3a949935 | ||
|
|
dee9df77c6 | ||
|
|
8412e5eb62 | ||
|
|
aea2504b2b | ||
|
|
8ad4a6a375 | ||
|
|
eb31689e26 | ||
|
|
9c9ab97523 | ||
|
|
5c461b738d | ||
|
|
54f77b9ad4 | ||
|
|
d6b6afab23 | ||
|
|
e9d7dddfbd | ||
|
|
7ee2493593 | ||
|
|
3a96e8ada3 | ||
|
|
f5d9785625 | ||
|
|
3af86ec2aa | ||
|
|
f8e02bbd9f | ||
|
|
3df53c4e1b | ||
|
|
8e9bf2f321 | ||
|
|
2f21e2db42 | ||
|
|
b394464dcb | ||
|
|
916cdca56f | ||
|
|
d2bb244256 | ||
|
|
76beb2c48a | ||
|
|
d6df33915a | ||
|
|
24b19cfd55 | ||
|
|
cbba43c6a3 | ||
|
|
be4b6ecc5c | ||
|
|
c8d41ce3b3 | ||
|
|
67a4ed5b2e | ||
|
|
ddacf7ec44 | ||
|
|
a739794218 | ||
|
|
3aa04a8860 | ||
|
|
4781cdbcb5 | ||
|
|
391cf253ed | ||
|
|
5b3b8df945 | ||
|
|
cb5fea59ae | ||
|
|
782135b18a | ||
|
|
584743234c | ||
|
|
5e1f79148f | ||
|
|
ace4fa4b46 | ||
|
|
4034dbbe39 | ||
|
|
0d8b89aeeb | ||
|
|
c58ad5603c | ||
|
|
42193382a1 | ||
|
|
a8cb39b313 | ||
|
|
dfaca12bd3 | ||
|
|
9d302ed969 | ||
|
|
da68c9c6d3 | ||
|
|
9278e565aa | ||
|
|
cfd4a980bd | ||
|
|
718e918777 | ||
|
|
b27d17f064 | ||
|
|
78d5532b6f | ||
|
|
509cc2a9ab | ||
|
|
1c2fbb4c00 | ||
|
|
ec057aff19 | ||
|
|
78a8735615 | ||
|
|
72dc749ef4 | ||
|
|
f1ead3be52 | ||
|
|
f88bcf144a | ||
|
|
2d5e59ba73 | ||
|
|
cf1a1a2db9 | ||
|
|
4fb3a50df2 | ||
|
|
fa45557845 | ||
|
|
7a571b741e | ||
|
|
5d5b9e6a18 | ||
|
|
873d9f6f83 | ||
|
|
4013461794 | ||
|
|
20bd584634 | ||
|
|
17c9eadc61 | ||
|
|
526b5610f0 | ||
|
|
374c734a98 | ||
|
|
d41ade9d10 | ||
|
|
f5f4660b0a | ||
|
|
47ad0bbd7c | ||
|
|
ef23c93398 | ||
|
|
4a49e67caa | ||
|
|
4f50ec7bc7 | ||
|
|
21a1afb2df | ||
|
|
28f5d5d1ed | ||
|
|
aab003ea51 | ||
|
|
969b29c1c8 | ||
|
|
d21fdaf31d | ||
|
|
86f37b529c | ||
|
|
0f6ace560b | ||
|
|
2ab85d1c35 | ||
|
|
ab0c209e53 | ||
|
|
bfe1932037 | ||
|
|
93f5e8b2b4 | ||
|
|
77fa5b6d1d | ||
|
|
85f865e5e7 | ||
|
|
d157f8f869 | ||
|
|
3fb8fc1642 | ||
|
|
878596e15f | ||
|
|
03af9d4760 | ||
|
|
1491532ea2 | ||
|
|
66deb16cb1 | ||
|
|
84853e2099 | ||
|
|
f47e6b9813 | ||
|
|
06e0af2cfe | ||
|
|
037eaf9d2b | ||
|
|
8dbd3798f9 | ||
|
|
f0eafc912b | ||
|
|
6de746a359 | ||
|
|
cfa1b0c574 | ||
|
|
342b0848d1 | ||
|
|
6dd19418d8 | ||
|
|
f8b1ee358e | ||
|
|
6d4905335c | ||
|
|
4677cf8634 | ||
|
|
65edfe5e2f | ||
|
|
ca5a24edd5 | ||
|
|
d4a211087f | ||
|
|
fb74093d2a | ||
|
|
8c4fefe4a8 | ||
|
|
daf1f4c632 | ||
|
|
a9507e0ccd | ||
|
|
99c71ddcbd | ||
|
|
3b8d09cdd7 | ||
|
|
bf5bb5e2bb | ||
|
|
c482f7a81a | ||
|
|
10e1e8cdb3 | ||
|
|
3c3f811dff | ||
|
|
fe3f159255 | ||
|
|
501a4754f7 | ||
|
|
4580690ca9 | ||
|
|
56df618d60 | ||
|
|
f513a0cad0 | ||
|
|
66f31a2c9a | ||
|
|
d7037af36f | ||
|
|
ba84d1d9fa | ||
|
|
6f84da00a2 | ||
|
|
ec4d9f9af2 | ||
|
|
f7cdadc3a9 | ||
|
|
2e4e6b2231 | ||
|
|
0019f52074 | ||
|
|
7ac8edb6a1 | ||
|
|
1d2d04b3eb | ||
|
|
1cdbc0ca0a |
No files matched your search
@@ -1,41 +0,0 @@
|
||||
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
|
||||
*
|
||||
*/
|
||||
@@ -1,147 +0,0 @@
|
||||
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
|
||||
*
|
||||
*/
|
||||
@@ -1,35 +0,0 @@
|
||||
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
|
||||
*
|
||||
*/
|
||||
@@ -1,105 +0,0 @@
|
||||
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
|
||||
*
|
||||
*/
|
||||
@@ -1,172 +0,0 @@
|
||||
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
|
||||
*
|
||||
*/
|
||||
@@ -1,112 +0,0 @@
|
||||
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
|
||||
*
|
||||
*/
|
||||
@@ -1,119 +0,0 @@
|
||||
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
|
||||
*
|
||||
*/
|
||||
@@ -1,115 +0,0 @@
|
||||
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
|
||||
*
|
||||
*/
|
||||
@@ -1,63 +0,0 @@
|
||||
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
|
||||
*
|
||||
*/
|
||||
@@ -1,73 +0,0 @@
|
||||
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
|
||||
*
|
||||
*/
|
||||
@@ -1,76 +0,0 @@
|
||||
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
|
||||
*
|
||||
*/
|
||||
@@ -1,70 +0,0 @@
|
||||
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
|
||||
*
|
||||
*/
|
||||
@@ -1,125 +0,0 @@
|
||||
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
|
||||
*
|
||||
*/
|
||||
@@ -1,53 +0,0 @@
|
||||
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
|
||||
*
|
||||
*/
|
||||
@@ -1,142 +0,0 @@
|
||||
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
|
||||
*
|
||||
*/
|
||||
@@ -1,180 +0,0 @@
|
||||
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
|
||||
*
|
||||
*/
|
||||
@@ -1,112 +0,0 @@
|
||||
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
|
||||
*
|
||||
*/
|
||||
@@ -1,39 +0,0 @@
|
||||
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
|
||||
*
|
||||
*/
|
||||
@@ -1,34 +0,0 @@
|
||||
##########################################################################
|
||||
# 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
|
||||
@@ -1,49 +0,0 @@
|
||||
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
|
||||
*
|
||||
*/
|
||||
@@ -1,89 +0,0 @@
|
||||
<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>
|
||||
@@ -1,2 +0,0 @@
|
||||
November 10, 2005 - 1.0:
|
||||
Initial functionality - basic/unusedcode rules only, JDK 1.4 only, report is displayed in wonky JOptionPane.
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
ant deploy && ~/pmd/ides/bluej/bluej
|
||||
@@ -1,11 +0,0 @@
|
||||
Change the version number in PMDExtension.java
|
||||
|
||||
Check everything in
|
||||
|
||||
ant mergejars
|
||||
|
||||
ncftpput upload.sourceforge.net incoming/ ../PMDExtension.jar
|
||||
Create release on SF
|
||||
|
||||
Post news item on SF
|
||||
Post note to bluej-discuss
|
||||
@@ -1,11 +0,0 @@
|
||||
<?xml version = '1.0'?>
|
||||
<extensions-list>
|
||||
<extension>
|
||||
<name>PMD</name>
|
||||
<class>net.sourceforge.pmd.bluej.PMDExtension</class>
|
||||
<version>1.0</version>
|
||||
<size>924246</size>
|
||||
<jarUrl>PMDExtension.jar</jarUrl>
|
||||
<description>PMD extension - finds unused code, empty blocks, and more!</description>
|
||||
</extension>
|
||||
</extensions-list>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,91 +0,0 @@
|
||||
package net.sourceforge.pmd.bluej;
|
||||
|
||||
import bluej.extensions.BClass;
|
||||
import bluej.extensions.MenuGenerator;
|
||||
import bluej.extensions.BlueJ;
|
||||
import bluej.extensions.editor.TextLocation;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
import net.sourceforge.pmd.RuleContext;
|
||||
import net.sourceforge.pmd.RuleSet;
|
||||
import net.sourceforge.pmd.RuleSetFactory;
|
||||
import net.sourceforge.pmd.RuleViolation;
|
||||
import net.sourceforge.pmd.TargetJDK1_4;
|
||||
import net.sourceforge.pmd.RuleSetNotFoundException;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.Frame;
|
||||
import java.io.StringReader;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class MenuBuilder extends MenuGenerator {
|
||||
|
||||
private BClass curClass;
|
||||
private Frame frame;
|
||||
private RuleSet ruleSet = new RuleSet();
|
||||
|
||||
public MenuBuilder(Frame frame) {
|
||||
this.frame = frame;
|
||||
|
||||
try {
|
||||
RuleSetFactory rsf = new RuleSetFactory();
|
||||
ruleSet.addRuleSet(rsf.createRuleSet("rulesets/basic.xml"));
|
||||
ruleSet.addRuleSet(rsf.createRuleSet("rulesets/unusedcode.xml"));
|
||||
} catch (RuleSetNotFoundException rsnfe) {
|
||||
System.out.println("Hm, PMD couldn't find its rules");
|
||||
rsnfe.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public JMenuItem getClassMenuItem(BClass aClass) {
|
||||
JMenu jm = new JMenu("PMD");
|
||||
jm.add(new JMenuItem(new SimpleAction("Check code")));
|
||||
return jm;
|
||||
}
|
||||
|
||||
public void notifyPostClassMenu(BClass bc, JMenuItem jmi) {
|
||||
curClass = bc;
|
||||
}
|
||||
|
||||
// The nested class that instantiates the different (simple) menus.
|
||||
class SimpleAction extends AbstractAction {
|
||||
|
||||
public SimpleAction(String menuName) {
|
||||
putValue(AbstractAction.NAME, menuName);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent anEvent) {
|
||||
try {
|
||||
int textLen = curClass.getEditor().getTextLength();
|
||||
TextLocation lastLine = curClass.getEditor().getTextLocationFromOffset(textLen);
|
||||
String code = curClass.getEditor().getText(new TextLocation(0,0), lastLine);
|
||||
|
||||
RuleContext ctx = new RuleContext();
|
||||
ctx.setSourceCodeFilename(curClass.getJavaClass().getName());
|
||||
StringReader reader = new StringReader(code);
|
||||
new PMD(new TargetJDK1_4()).processFile(reader, ruleSet, ctx);
|
||||
|
||||
StringBuffer msg = new StringBuffer("");
|
||||
if (ctx.getReport().size() == 0) {
|
||||
msg.append("No problems found!");
|
||||
} else {
|
||||
if (ctx.getReport().size() == 1) {
|
||||
msg.append(" " + ctx.getReport().size() + " problem found");
|
||||
} else {
|
||||
msg.append(" " + ctx.getReport().size() + " problems found");
|
||||
}
|
||||
msg.append(System.getProperty("line.separator"));
|
||||
for (Iterator i = ctx.getReport().iterator(); i.hasNext();) {
|
||||
RuleViolation rv = (RuleViolation)i.next();
|
||||
msg.append("Line " + rv.getNode().getBeginLine() + ": " + rv.getDescription());
|
||||
msg.append(System.getProperty("line.separator"));
|
||||
}
|
||||
}
|
||||
JOptionPane.showMessageDialog(frame, msg);
|
||||
} catch (Exception exc) {
|
||||
exc.printStackTrace();
|
||||
JOptionPane.showMessageDialog(frame, "Couldn't run PMD: " + exc.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package net.sourceforge.pmd.bluej;
|
||||
|
||||
import bluej.extensions.BlueJ;
|
||||
import bluej.extensions.Extension;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
public class PMDExtension extends Extension {
|
||||
|
||||
public void startup (BlueJ bluej) {
|
||||
|
||||
bluej.setMenuGenerator(new MenuBuilder(bluej.getCurrentFrame()));
|
||||
/*
|
||||
Preferences myPreferences = new Preferences(bluej);
|
||||
bluej.setPreferenceGenerator(myPreferences);
|
||||
*/
|
||||
}
|
||||
|
||||
public boolean isCompatible () {
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getVersion () {
|
||||
return ("1.0");
|
||||
}
|
||||
|
||||
public String getName () {
|
||||
return ("PMD");
|
||||
}
|
||||
|
||||
public String getDescription () {
|
||||
return "PMD extension - finds unused code, empty blocks, and more!";
|
||||
}
|
||||
|
||||
public URL getURL () {
|
||||
try {
|
||||
return new URL("http://pmd.sf.net/");
|
||||
} catch ( Exception e ) {
|
||||
System.out.println ("Can't get PMD extension URL: "+e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loaded 30 of 2118 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user