Source Code Cross Referenced for PMDViewer.java in  » UML » jrefactory » org » acm » seguin » pmd » swingui » 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 » UML » jrefactory » org.acm.seguin.pmd.swingui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.acm.seguin.pmd.swingui;
002:
003:        import org.acm.seguin.pmd.PMDDirectory;
004:        import org.acm.seguin.pmd.PMDException;
005:        import org.acm.seguin.pmd.swingui.event.ListenerList;
006:        import org.acm.seguin.pmd.swingui.event.SetupFilesEvent;
007:        import org.acm.seguin.pmd.swingui.event.SetupFilesEventListener;
008:
009:        import javax.swing.ImageIcon;
010:        import javax.swing.JFrame;
011:        import javax.swing.JMenuBar;
012:        import javax.swing.JTabbedPane;
013:        import javax.swing.UIManager;
014:        import javax.swing.event.ChangeEvent;
015:        import javax.swing.event.ChangeListener;
016:        import java.awt.Component;
017:        import java.awt.Cursor;
018:        import java.awt.Dimension;
019:        import java.awt.Toolkit;
020:        import java.awt.event.MouseAdapter;
021:        import java.awt.event.MouseEvent;
022:        import java.io.File;
023:
024:        /**
025:         *
026:         * @author Donald A. Leckie
027:         * @since August 17, 2002
028:         * @version $Revision: 1.2 $, $Date: 2003/09/21 20:51:41 $
029:         */
030:        public class PMDViewer extends JFrame {
031:
032:            private int m_disabledCounter;
033:            private boolean m_firstLayout = true;
034:            private TabbedPane m_tabbedPane;
035:            private GlassPaneMouseListener m_glassPaneMouseListener;
036:            private static PMDViewer m_pmdViewer;
037:
038:            /**
039:             *******************************************************************************
040:             *
041:             */
042:            private PMDViewer() {
043:                super ("PMD Java Source Code Analyzer");
044:
045:                Dimension windowSize;
046:                Dimension screenSize;
047:
048:                m_pmdViewer = this ;
049:                windowSize = ComponentFactory.adjustWindowSize(1200, 1000);
050:                screenSize = Toolkit.getDefaultToolkit().getScreenSize();
051:
052:                if (windowSize.width >= screenSize.width) {
053:                    windowSize.width = screenSize.width - 10;
054:                }
055:
056:                if (windowSize.height >= screenSize.height) {
057:                    windowSize.height = screenSize.height - 20;
058:                }
059:
060:                int windowLocationX = (screenSize.width - windowSize.width) / 2;
061:                int windowLocationY = (screenSize.height - windowSize.height) / 2;
062:
063:                setSize(windowSize);
064:                setLocation(windowLocationX, windowLocationY);
065:                setResizable(true);
066:                setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
067:
068:                try {
069:                    PMDDirectory.open(Preferences.getPreferences()
070:                            .getCurrentPathToPMD());
071:                } catch (PMDException pmdException) {
072:                    String message = pmdException.getMessage();
073:                    Exception exception = pmdException.getReason();
074:                    MessageDialog.show(this , message, exception);
075:                }
076:
077:                m_tabbedPane = new TabbedPane();
078:                getContentPane().add(m_tabbedPane);
079:
080:                ImageIcon image = (ImageIcon) UIManager.get("pmdLogoImage");
081:                setIconImage(image.getImage());
082:
083:                m_glassPaneMouseListener = new GlassPaneMouseListener();
084:                ListenerList
085:                        .addListener((SetupFilesEventListener) new SetupFilesEventHandler());
086:            }
087:
088:            /**
089:             *********************************************************************************
090:             *
091:             */
092:            public void setVisible(boolean visible) {
093:                super .setVisible(visible);
094:
095:                if (visible && m_firstLayout) {
096:                    m_tabbedPane.adjustSplitPaneDividerLocation();
097:                    m_firstLayout = false;
098:                }
099:            }
100:
101:            /**
102:             *********************************************************************************
103:             *
104:             * @return
105:             */
106:            public static final PMDViewer getViewer() {
107:                return m_pmdViewer;
108:            }
109:
110:            /**
111:             *********************************************************************************
112:             *
113:             */
114:            public static final void run() {
115:                try {
116:                    //FIXME? MRA LoadRootDirectories loadRootDirectories = new LoadRootDirectories();
117:                    //FIXME? MRA loadRootDirectories.start();
118:
119:                    // Setup the User Interface based on this computer's operating system.
120:                    // This must be done before calling Java and Swing classes that call the GUI.
121:                    UIManager
122:                            .setLookAndFeel("org.acm.seguin.pmd.swingui.PMDLookAndFeel");
123:
124:                    PMDViewer pmdViewer = new PMDViewer();
125:                    pmdViewer.setVisible(true);
126:                    //FIXME? MRA SetupFilesEvent.notifySetFileList(pmdViewer, loadRootDirectories.getDirectories());
127:                    SetupFilesEvent.notifySetFileList(pmdViewer,
128:                            new File[] { new File("C:") });
129:
130:                } catch (Exception exception) {
131:                    exception.printStackTrace();
132:                } catch (Error error) {
133:                    error.printStackTrace();
134:                }
135:
136:                return;
137:            }
138:
139:            /**
140:             *********************************************************************************
141:             *
142:             * @param enable
143:             */
144:            protected void setEnableViewer(boolean enable) {
145:                if (enable) {
146:                    m_disabledCounter--;
147:
148:                    if (m_disabledCounter == 0) {
149:                        Component glassPane = getGlassPane();
150:                        glassPane.setVisible(false);
151:                        glassPane.setCursor(Cursor
152:                                .getPredefinedCursor(Cursor.DEFAULT_CURSOR));
153:                        glassPane.removeMouseListener(m_glassPaneMouseListener);
154:                        m_tabbedPane.setEnabled(true);
155:                        JMenuBar menuBar = getJMenuBar();
156:                        int menuCount = menuBar.getMenuCount();
157:
158:                        for (int n = 0; n < menuCount; n++) {
159:                            menuBar.getMenu(n).setEnabled(true);
160:                        }
161:                    }
162:                } else {
163:                    if (m_disabledCounter == 0) {
164:                        Component glassPane = getGlassPane();
165:                        glassPane.setVisible(true);
166:                        glassPane.setCursor(Cursor
167:                                .getPredefinedCursor(Cursor.WAIT_CURSOR));
168:                        glassPane.addMouseListener(m_glassPaneMouseListener);
169:                        m_tabbedPane.setEnabled(false);
170:                        JMenuBar menuBar = getJMenuBar();
171:                        int menuCount = menuBar.getMenuCount();
172:
173:                        for (int n = 0; n < menuCount; n++) {
174:                            menuBar.getMenu(n).setEnabled(false);
175:                        }
176:                    }
177:
178:                    m_disabledCounter++;
179:                }
180:            }
181:
182:            /**
183:             *********************************************************************************
184:             *
185:             * @param args
186:             */
187:            public static void main(String[] args) {
188:                run();
189:            }
190:
191:            /**
192:             *********************************************************************************
193:             *********************************************************************************
194:             *********************************************************************************
195:             */
196:            private class GlassPaneMouseListener extends MouseAdapter {
197:
198:                /**
199:                 *****************************************************************************
200:                 *
201:                 * Invoked when the mouse button has been clicked (pressed
202:                 * and released) on a component.
203:                 */
204:                public void mouseClicked(MouseEvent event) {
205:                    event.consume();
206:                }
207:
208:                /**
209:                 *****************************************************************************
210:                 *
211:                 * Invoked when a mouse button has been pressed on a component.
212:                 */
213:                public void mousePressed(MouseEvent event) {
214:                    event.consume();
215:                }
216:
217:                /**
218:                 *****************************************************************************
219:                 *
220:                 * Invoked when a mouse button has been released on a component.
221:                 */
222:                public void mouseReleased(MouseEvent event) {
223:                    event.consume();
224:                }
225:            }
226:
227:            /**
228:             *********************************************************************************
229:             *********************************************************************************
230:             *********************************************************************************
231:             */
232:            private class SetupFilesEventHandler implements 
233:                    SetupFilesEventListener {
234:
235:                /**
236:                 ****************************************************************************
237:                 *
238:                 * @param event
239:                 */
240:                public void startSetup(SetupFilesEvent event) {
241:                    PMDViewer.this .setEnableViewer(false);
242:                }
243:
244:                /**
245:                 ****************************************************************************
246:                 *
247:                 * @param event
248:                 */
249:                public void stopSetup(SetupFilesEvent event) {
250:                    PMDViewer.this .setEnableViewer(true);
251:                }
252:
253:                /**
254:                 ****************************************************************************
255:                 *
256:                 * @param event
257:                 */
258:                public void setFileList(SetupFilesEvent event) {
259:                }
260:            }
261:
262:            /**
263:             *********************************************************************************
264:             *********************************************************************************
265:             *********************************************************************************
266:             */
267:            private class TabbedPane extends JTabbedPane implements 
268:                    ChangeListener {
269:                private AnalysisViewer m_analysisViewer;
270:                private SearchViewer m_searchViewer;
271:                private RulesEditor m_rulesEditor;
272:                private PreferencesEditor m_preferencesEditor;
273:                private Component m_currentTab;
274:
275:                /**
276:                 *****************************************************************************
277:                 *
278:                 */
279:                private TabbedPane() {
280:                    super ();
281:
282:                    try {
283:                        m_analysisViewer = new AnalysisViewer();
284:                        m_searchViewer = new SearchViewer();
285:                        m_rulesEditor = new RulesEditor();
286:                        m_preferencesEditor = new PreferencesEditor();
287:
288:                        setFont(UIManager.getFont("tabFont"));
289:                        addTab("Analysis Viewer", m_analysisViewer);
290:                        addTab("Search Viewer", m_searchViewer);
291:                        addTab("Rules Editor", m_rulesEditor);
292:                        addTab("Preferences Editor", m_preferencesEditor);
293:                        addChangeListener(this );
294:                    } catch (PMDException pmdException) {
295:                        String message = pmdException.getMessage();
296:                        Exception exception = pmdException.getReason();
297:                        MessageDialog.show(m_pmdViewer, message, exception);
298:                    }
299:                }
300:
301:                /**
302:                 *****************************************************************************
303:                 *
304:                 */
305:                private void adjustSplitPaneDividerLocation() {
306:                    m_analysisViewer.adjustSplitPaneDividerLocation();
307:                    m_searchViewer.adjustSplitPaneDividerLocation();
308:                    m_rulesEditor.adjustSplitPaneDividerLocation();
309:                    m_preferencesEditor.adjustSplitPaneDividerLocation();
310:                }
311:
312:                /**
313:                 *******************************************************************************
314:                 *
315:                 * @param event
316:                 */
317:                public void stateChanged(ChangeEvent event) {
318:                    if (m_currentTab == m_rulesEditor) {
319:                        m_rulesEditor.saveData();
320:                    }
321:
322:                    m_currentTab = getSelectedComponent();
323:
324:                    if (m_currentTab == m_analysisViewer) {
325:                        m_analysisViewer.setMenuBar();
326:                        m_analysisViewer.analyze();
327:                    } else if (m_currentTab == m_searchViewer) {
328:                        m_searchViewer.setMenuBar();
329:                        m_searchViewer.analyze();
330:                    } else if (m_currentTab == m_rulesEditor) {
331:                        m_rulesEditor.setMenuBar();
332:                    } else if (m_currentTab == m_preferencesEditor) {
333:                        m_preferencesEditor.setMenuBar();
334:                    }
335:                }
336:            }
337:        }
338:
339:        /**
340:         *********************************************************************************
341:         *********************************************************************************
342:         *********************************************************************************
343:         */
344:        class LoadRootDirectories extends Thread {
345:            private File[] m_fileSystemRoots;
346:
347:            /**
348:             ************************************************************************
349:             *
350:             */
351:            protected LoadRootDirectories() {
352:                super ("Load Root Directories");
353:            }
354:
355:            /**
356:             ***************************************************************************
357:             *
358:             */
359:            public void run() {
360:                setup();
361:                process();
362:                cleanup();
363:            }
364:
365:            /**
366:             ************************************************************************
367:             *
368:             */
369:            protected void setup() {
370:            }
371:
372:            /**
373:             ************************************************************************
374:             *
375:             */
376:            protected void process() {
377:                m_fileSystemRoots = File.listRoots();
378:            }
379:
380:            /**
381:             ************************************************************************
382:             *
383:             */
384:            protected void cleanup() {
385:            }
386:
387:            /**
388:             ************************************************************************
389:             *
390:             * @return
391:             */
392:            protected File[] getDirectories() {
393:                return m_fileSystemRoots;
394:            }
395:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.