Initial revision

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@3778 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Tom Copeland 2005-08-15 19:51:41 +00:00
parent 417ae695a7
commit 3a0c157ae9
20 changed files with 1862 additions and 0 deletions

View File

@ -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
*
*/

View File

@ -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
*
*/

View File

@ -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
*
*/

View File

@ -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
*
*/

View File

@ -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
*
*/

View File

@ -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
*
*/

View File

@ -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
*
*/

View File

@ -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
*
*/

View File

@ -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
*
*/

View File

@ -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
*
*/

View File

@ -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
*
*/

View File

@ -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
*
*/

View File

@ -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
*
*/

View File

@ -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
*
*/

View File

@ -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
*
*/

View File

@ -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
*
*/

View File

@ -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
*
*/

View File

@ -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
*
*/

View File

@ -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

View File

@ -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
*
*/