Source Code Cross Referenced for MainFrame.java in  » Code-Analyzer » pmd-4.2rc1 » net » sourceforge » pmd » util » viewer » gui » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Code Analyzer » pmd 4.2rc1 » net.sourceforge.pmd.util.viewer.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sourceforge.pmd.util.viewer.gui;
002:
003:        import net.sourceforge.pmd.PMD;
004:        import net.sourceforge.pmd.TargetJDK1_3;
005:        import net.sourceforge.pmd.TargetJDK1_4;
006:        import net.sourceforge.pmd.TargetJDK1_5;
007:        import net.sourceforge.pmd.TargetJDK1_6;
008:        import net.sourceforge.pmd.TargetJDK1_7;
009:        import net.sourceforge.pmd.TargetJDKVersion;
010:        import net.sourceforge.pmd.ast.ParseException;
011:        import net.sourceforge.pmd.util.viewer.model.ViewerModel;
012:        import net.sourceforge.pmd.util.viewer.model.ViewerModelEvent;
013:        import net.sourceforge.pmd.util.viewer.model.ViewerModelListener;
014:        import net.sourceforge.pmd.util.viewer.util.NLS;
015:
016:        import javax.swing.*;
017:        import java.awt.BorderLayout;
018:        import java.awt.FlowLayout;
019:        import java.awt.event.ActionEvent;
020:        import java.awt.event.ActionListener;
021:
022:        /**
023:         * viewer's main frame
024:         *
025:         * @author Boris Gruschko ( boris at gruschko.org )
026:         * @version $Id: MainFrame.java 5874 2008-03-07 01:59:30Z xlv $
027:         */
028:
029:        public class MainFrame extends JFrame implements  ActionListener,
030:                ActionCommands, ViewerModelListener {
031:            private ViewerModel model;
032:            private SourceCodePanel sourcePanel;
033:            private XPathPanel xPathPanel;
034:            private JButton evalBtn;
035:            private JLabel statusLbl;
036:            private JRadioButtonMenuItem jdk13MenuItem;
037:            private JRadioButtonMenuItem jdk14MenuItem;
038:            private JRadioButtonMenuItem jdk15MenuItem; //NOPMD
039:            private JRadioButtonMenuItem jdk16MenuItem;
040:            private JRadioButtonMenuItem jdk17MenuItem;
041:
042:            /**
043:             * constructs and shows the frame
044:             */
045:            public MainFrame() {
046:                super (NLS.nls("MAIN.FRAME.TITLE") + " (v " + PMD.VERSION + ')');
047:                init();
048:            }
049:
050:            private void init() {
051:                model = new ViewerModel();
052:                model.addViewerModelListener(this );
053:                sourcePanel = new SourceCodePanel(model);
054:                ASTPanel astPanel = new ASTPanel(model);
055:                xPathPanel = new XPathPanel(model);
056:                getContentPane().setLayout(new BorderLayout());
057:                JSplitPane editingPane = new JSplitPane(
058:                        JSplitPane.HORIZONTAL_SPLIT, sourcePanel, astPanel);
059:                editingPane.setResizeWeight(0.5d);
060:                JPanel interactionsPane = new JPanel(new BorderLayout());
061:                interactionsPane.add(xPathPanel, BorderLayout.SOUTH);
062:                interactionsPane.add(editingPane, BorderLayout.CENTER);
063:                getContentPane().add(interactionsPane, BorderLayout.CENTER);
064:                JButton compileBtn = new JButton(NLS
065:                        .nls("MAIN.FRAME.COMPILE_BUTTON.TITLE"));
066:                compileBtn.setActionCommand(COMPILE_ACTION);
067:                compileBtn.addActionListener(this );
068:                evalBtn = new JButton(NLS
069:                        .nls("MAIN.FRAME.EVALUATE_BUTTON.TITLE"));
070:                evalBtn.setActionCommand(EVALUATE_ACTION);
071:                evalBtn.addActionListener(this );
072:                evalBtn.setEnabled(false);
073:                statusLbl = new JLabel();
074:                statusLbl.setHorizontalAlignment(SwingConstants.RIGHT);
075:                JPanel btnPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
076:                btnPane.add(compileBtn);
077:                btnPane.add(evalBtn);
078:                btnPane.add(statusLbl);
079:                getContentPane().add(btnPane, BorderLayout.SOUTH);
080:
081:                JMenuBar menuBar = new JMenuBar();
082:                JMenu menu = new JMenu("JDK");
083:                ButtonGroup group = new ButtonGroup();
084:                jdk13MenuItem = new JRadioButtonMenuItem("JDK 1.3");
085:                jdk13MenuItem.setSelected(false);
086:                group.add(jdk13MenuItem);
087:                menu.add(jdk13MenuItem);
088:                jdk14MenuItem = new JRadioButtonMenuItem("JDK 1.4");
089:                jdk14MenuItem.setSelected(true);
090:                group.add(jdk14MenuItem);
091:                menu.add(jdk14MenuItem);
092:                jdk15MenuItem = new JRadioButtonMenuItem("JDK 1.5");
093:                jdk15MenuItem.setSelected(false);
094:                group.add(jdk15MenuItem);
095:                menu.add(jdk15MenuItem);
096:                jdk16MenuItem = new JRadioButtonMenuItem("JDK 1.6");
097:                jdk16MenuItem.setSelected(false);
098:                group.add(jdk16MenuItem);
099:                menu.add(jdk16MenuItem);
100:                jdk17MenuItem = new JRadioButtonMenuItem("JDK 1.7");
101:                jdk17MenuItem.setSelected(false);
102:                group.add(jdk17MenuItem);
103:                menu.add(jdk17MenuItem);
104:                menuBar.add(menu);
105:                setJMenuBar(menuBar);
106:
107:                setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
108:                pack();
109:                setSize(800, 600);
110:                setVisible(true);
111:            }
112:
113:            private TargetJDKVersion createJDKVersion() {
114:                if (jdk14MenuItem.isSelected()) {
115:                    return new TargetJDK1_4();
116:                } else if (jdk13MenuItem.isSelected()) {
117:                    return new TargetJDK1_3();
118:                } else if (jdk16MenuItem.isSelected()) {
119:                    return new TargetJDK1_6();
120:                } else if (jdk17MenuItem.isSelected()) {
121:                    return new TargetJDK1_7();
122:                }
123:                return new TargetJDK1_5();
124:            }
125:
126:            /**
127:             * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
128:             */
129:            public void actionPerformed(ActionEvent e) {
130:                String command = e.getActionCommand();
131:                long t0, t1;
132:                if (command.equals(COMPILE_ACTION)) {
133:                    try {
134:                        t0 = System.currentTimeMillis();
135:                        model.commitSource(sourcePanel.getSourceCode(),
136:                                createJDKVersion());
137:                        t1 = System.currentTimeMillis();
138:                        setStatus(NLS.nls("MAIN.FRAME.COMPILATION.TOOK") + " "
139:                                + (t1 - t0) + " ms");
140:                    } catch (ParseException exc) {
141:                        setStatus(NLS.nls("MAIN.FRAME.COMPILATION.PROBLEM")
142:                                + " " + exc.toString());
143:                        new ParseExceptionHandler(this , exc);
144:                    }
145:                } else if (command.equals(EVALUATE_ACTION)) {
146:                    try {
147:                        t0 = System.currentTimeMillis();
148:                        model.evaluateXPathExpression(xPathPanel
149:                                .getXPathExpression(), this );
150:                        t1 = System.currentTimeMillis();
151:                        setStatus(NLS.nls("MAIN.FRAME.EVALUATION.TOOK") + " "
152:                                + (t1 - t0) + " ms");
153:                    } catch (Exception exc) {
154:                        setStatus(NLS.nls("MAIN.FRAME.EVALUATION.PROBLEM")
155:                                + " " + exc.toString());
156:                        new ParseExceptionHandler(this , exc);
157:                    }
158:                }
159:            }
160:
161:            /**
162:             * Sets the status bar message
163:             *
164:             * @param string the new status, the empty string will be set if the value is <code>null</code>
165:             */
166:            private void setStatus(String string) {
167:                statusLbl.setText(string == null ? "" : string);
168:            }
169:
170:            /**
171:             * @see ViewerModelListener#viewerModelChanged(ViewerModelEvent)
172:             */
173:            public void viewerModelChanged(ViewerModelEvent e) {
174:                evalBtn.setEnabled(model.hasCompiledTree());
175:            }
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.