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


001:        /*
002:            FindBugs - Find bugs in Java programs
003:            Copyright (C) 2003, University of Maryland
004:            This library is free software; you can redistribute it and/or
005:            modify it under the terms of the GNU Lesser General Public
006:            License as published by the Free Software Foundation; either
007:            version 2.1 of the License, or (at your option) any later version.
008:            This library is distributed in the hope that it will be useful,
009:            but WITHOUT ANY WARRANTY; without even the implied warranty of
010:            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
011:            Lesser General Public License for more details.
012:            You should have received a copy of the GNU Lesser General Public
013:            License along with this library; if not, write to the Free Software
014:            Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
015:         */
016:        /*
017:         FindBugsFrame.java
018:         Created on March 30, 2003, 12:05 PM
019:         */
020:        package org.acm.seguin.findbugs;
021:
022:        import java.awt.CardLayout;
023:        import java.awt.Color;
024:        import java.awt.Component;
025:        import java.awt.Cursor;
026:
027:        import java.awt.Frame;
028:        import java.awt.Graphics;
029:        import java.awt.Point;
030:        import java.awt.Rectangle;
031:        import java.awt.Shape;
032:        import java.io.BufferedReader;
033:        import java.io.File;
034:        import java.io.File;
035:        import java.io.FileInputStream;
036:        import java.io.FileOutputStream;
037:        import java.io.IOException;
038:        import java.io.InputStream;
039:        import java.io.InputStreamReader;
040:        import java.io.StringReader;
041:        import java.io.StringWriter;
042:        import java.util.*;
043:        import javax.swing.*;
044:        import javax.swing.event.*;
045:        import javax.swing.filechooser.*;
046:        import javax.swing.text.*;
047:        import javax.swing.tree.*;
048:        import edu.umd.cs.findbugs.ba.SourceFile;
049:        import edu.umd.cs.findbugs.ba.SourceFinder;
050:        import edu.umd.cs.findbugs.*;
051:        import edu.umd.cs.findbugs.gui.*;
052:        import org.acm.seguin.ide.common.IDEInterface;
053:
054:        import org.acm.seguin.ide.common.IDEPlugin;
055:
056:        /**
057:         *  The main GUI frame for FindBugs.
058:         *
059:         *@author    David Hovemeyer
060:         */
061:        public class FindBugsFrame extends
062:                edu.umd.cs.findbugs.gui.FindBugsFrame {
063:            private static Frame view = null;
064:
065:            private static ConsoleLogger consoleLogger = null;
066:
067:            /**
068:             *  Gets the Logger attribute of the FindBugsFrame object
069:             *
070:             *@return    The Logger value
071:             */
072:            public edu.umd.cs.findbugs.gui.ConsoleLogger getLogger() {
073:                return consoleLogger;
074:            }
075:
076:            /**
077:             *  Write a message to the console window.
078:             *
079:             *@param  message  Description of Parameter
080:             */
081:            public void writeToConsole(String message) {
082:                System.out.println(message);
083:                super .writeToConsole(message);
084:            }
085:
086:            /**
087:             *  Show an error dialog.
088:             *
089:             *@param  message  Description of Parameter
090:             */
091:            public void error(String message) {
092:                JOptionPane.showMessageDialog(view, message, "Error",
093:                        JOptionPane.ERROR_MESSAGE);
094:            }
095:
096:            /**
097:             *  Gets the AWTFrame attribute of the FindBugsFrame object
098:             *
099:             *@return    The AWTFrame value
100:             */
101:            protected Frame getAWTFrame() {
102:                return view;
103:            }
104:
105:            /**
106:             *  Update the source view window.
107:             *
108:             *@param  project          the project (containing the source directories to search)
109:             *@param  analysisRun      the analysis run (containing the mapping of classes to source files)
110:             *@param  srcLine          the source line annotation (specifying source file to load and which lines to highlight)
111:             *@param  selected         Description of Parameter
112:             *@return                  true if the source was shown successfully, false otherwise
113:             *@exception  IOException  Description of Exception
114:             */
115:            //protected boolean viewSource(Project project, AnalysisRun analysisRun, final SourceLineAnnotation srcLine, BugInstance selected) throws IOException {
116:            public boolean viewSource(Project project, AnalysisRun analysisRun,
117:                    final SourceLineAnnotation srcLine) throws IOException {
118:                IDEPlugin.log(IDEInterface.DEBUG, this , "srcLine=" + srcLine);
119:                //IDEPlugin.log(IDEInterface.DEBUG, this, "selected=" + selected);
120:                SourceFinder sourceFinder = new SourceFinder();
121:                sourceFinder.setSourceBaseList(project.getSourceDirList());
122:                String sourceFileName = null;
123:                String packageName = (srcLine == null) ? "" : srcLine
124:                        .getPackageName();
125:                IDEPlugin.log(IDEInterface.DEBUG, this , "packageName="
126:                        + packageName);
127:                if (srcLine != null) {
128:                    sourceFileName = srcLine.getSourceFile();
129:                    /*
130:                     } else if (selected != null) {
131:                     ClassAnnotation primaryClass = selected.getPrimaryClass();
132:                     sourceFileName = primaryClass.getClassName();
133:                     sourceFileName = srcLine.getSourceFile();
134:                     IDEPlugin.log(IDEInterface.DEBUG, this, "sourceFileName=" + sourceFileName);
135:                     sourceFileName = sourceFileName.replace('.', File.separatorChar);
136:                     int x = sourceFileName.indexOf("$");
137:                     IDEPlugin.log(IDEInterface.DEBUG, this, "sourceFileName=" + sourceFileName + ", x=" + x);
138:                     if (x > 0) {
139:                     sourceFileName = sourceFileName.substring(0, x);
140:                     }
141:                     x = sourceFileName.lastIndexOf("java") - 1;
142:                     IDEPlugin.log(IDEInterface.DEBUG, this, "sourceFileName=" + sourceFileName + ", x=" + x);
143:                     if (x > 0) {
144:                     sourceFileName = sourceFileName.substring(0, x);
145:                     }
146:                     IDEPlugin.log(IDEInterface.DEBUG, this, "sourceFileName=" + sourceFileName);
147:                     sourceFileName = sourceFileName + ".java";
148:                     IDEPlugin.log(IDEInterface.DEBUG, this, "sourceFileName=" + sourceFileName);
149:                     */
150:                } else {
151:                    return super .viewSource(project, analysisRun, srcLine); //, selected);
152:                }
153:
154:                IDEPlugin.log(IDEInterface.DEBUG, this , "sourceFileName="
155:                        + sourceFileName);
156:                if (sourceFileName == null
157:                        || sourceFileName.equals("<Unknown>")) {
158:                    getLogger().logMessage(
159:                            ConsoleLogger.WARNING,
160:                            "No source file for class "
161:                                    + srcLine.getClassName());
162:                    return super .viewSource(project, analysisRun, srcLine); //, selected);
163:                }
164:
165:                SourceFile sourceFile = sourceFinder.findSourceFile(
166:                        packageName, sourceFileName);
167:                IDEPlugin.log(IDEInterface.DEBUG, this , "sourceFile="
168:                        + sourceFile);
169:                // Try to open the source file and display its contents
170:                // in the source text area.
171:                if (sourceFile != null) {
172:                    //Buffer buffer = jEdit.openFile(view, sourceFile.getAbsolutePath());
173:                    Object buffer = IDEPlugin.openFile(view, sourceFile
174:                            .getFullFileName());
175:                    IDEPlugin.goToBuffer(view, buffer);
176:
177:                    if (!srcLine.isUnknown()) {
178:                        int start = 0;
179:                        int end = 0;
180:
181:                        int lineNo = srcLine.getStartLine() - 1;
182:                        int endLine = srcLine.getEndLine();
183:                        IDEPlugin.log(IDEInterface.DEBUG, this , "startLine="
184:                                + lineNo + ", endLine=" + endLine);
185:                        if (lineNo >= 0
186:                                && lineNo < IDEPlugin.getLineCount(buffer)) {
187:                            start += IDEPlugin.getLineStartOffset(buffer,
188:                                    lineNo);
189:                        }
190:                        if (endLine >= 0
191:                                && endLine < IDEPlugin.getLineCount(buffer)) {
192:                            if (end == 0) {
193:                                end = IDEPlugin.getLineEndOffset(buffer,
194:                                        endLine) - 1;
195:                            } else {
196:                                end += IDEPlugin.getLineStartOffset(buffer,
197:                                        endLine);
198:                            }
199:                        }
200:
201:                        IDEPlugin.log(IDEInterface.DEBUG, this , "start="
202:                                + start + ", end=" + end);
203:                        IDEPlugin.setSelection(view, buffer, start, end);
204:
205:                        IDEPlugin.moveCaretPosition(view, buffer, end);
206:                    }
207:                }
208:
209:                return super .viewSource(project, analysisRun, srcLine); //, selected);
210:            }
211:
212:            /**
213:             *  Description of the Method
214:             *
215:             *@param  aView  Description of Parameter
216:             *@return        Description of the Returned Value
217:             */
218:            public static JRootPane createFindBugsPanel(Frame aView) {
219:                view = aView;
220:                // Load plugins!
221:
222:                System.setProperty("findbugs.debug", "true");
223:                System.setProperty("findbugs.home", "true");
224:                FindBugsFrame frame = new FindBugsFrame();
225:                //frame.setSize(800, 600);
226:                //frame.show();
227:                //frame.hide();
228:                consoleLogger = new ConsoleLogger(frame);
229:                return frame.getRootPane();
230:            }
231:
232:            /**
233:             *  Description of the Class
234:             *
235:             *@author    Mike Atkinson
236:             */
237:            public static class ConsoleLogger extends
238:                    edu.umd.cs.findbugs.gui.ConsoleLogger {
239:
240:                private edu.umd.cs.findbugs.gui.FindBugsFrame frame;
241:
242:                /**
243:                 *  Creates a new instance of ConsoleLogger
244:                 *
245:                 *@param  frame  Description of Parameter
246:                 */
247:                public ConsoleLogger(edu.umd.cs.findbugs.gui.FindBugsFrame frame) {
248:                    super (frame);
249:                    this .frame = frame;
250:                }
251:
252:                /**
253:                 *  Description of the Method
254:                 *
255:                 *@param  severity  Description of Parameter
256:                 *@param  message   Description of Parameter
257:                 */
258:                public void logMessage(int severity, String message) {
259:                    switch (severity) {
260:                    case INFO:
261:                        IDEPlugin.log(IDEInterface.DEBUG, frame, message);
262:                        break;
263:                    case WARNING:
264:                        IDEPlugin.log(IDEInterface.WARNING, frame, message);
265:                        break;
266:                    case ERROR:
267:                        IDEPlugin.log(IDEInterface.ERROR, frame, message);
268:                        break;
269:                    default:
270:                        IDEPlugin.log(IDEInterface.ERROR, frame, message);
271:                        break;
272:                    }
273:                }
274:
275:            }
276:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.