Source Code Cross Referenced for CompilationMessage.java in  » IDE » tIDE » tide » editor » linemessages » 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 » IDE » tIDE » tide.editor.linemessages 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package tide.editor.linemessages;
002:
003:        import snow.html.HTMLUtils;
004:        import java.awt.Color;
005:        import snow.utils.storage.StorageVector;
006:        import tide.sources.TypeLocator;
007:        import tide.sources.FileItem;
008:        import java.util.*;
009:        import snow.utils.StringUtils;
010:        import java.awt.event.ActionEvent;
011:        import javax.swing.AbstractAction;
012:        import tide.editor.MainEditorFrame;
013:
014:        public final class CompilationMessage extends LineMessage {
015:            private String mess, shortMess, category = "";
016:            private int column = -1;
017:            private boolean error;
018:
019:            private CompilationMessage(boolean error, String javaName,
020:                    int line, int column, String mess, long created) {
021:                super (javaName, line, created);
022:                this .error = error;
023:                this .column = column;
024:                this .mess = mess;
025:                this .shortMess = mess.replace('\n', ' ').trim();
026:
027:                if (!error) {
028:                    // warning
029:                    if (shortMess.startsWith("warning: [")) {
030:                        int pos = shortMess.indexOf(']', 10);
031:                        if (pos > 0) {
032:                            category = shortMess.substring(10, pos);
033:                            shortMess = shortMess.substring(pos + 2);
034:                        }
035:                    } else if (shortMess.startsWith("warning:")) {
036:                        shortMess = shortMess.substring(9).trim();
037:                    }
038:                }
039:
040:                if (shortMess.endsWith("^")) {
041:                    shortMess = StringUtils.firstLine(shortMess); // [Feb2008]: nicer.
042:                    //shortMess = shortMess.substring(0,shortMess.length()-1).trim();
043:                }
044:            }
045:
046:            @Override
047:            public List<AbstractAction> lookForAvailableActions() {
048:                List<AbstractAction> actions = new ArrayList<AbstractAction>();
049:
050:                if (shortMess.startsWith("cannot find symbol")) {
051:                    String start = "symbol  : class ";
052:                    //int pos = shortMess.indexOf(start);
053:                    String clName = StringUtils
054:                            .extractFromFirstToNext_Excluded(shortMess, start,
055:                                    " "); // OK: line end have been replaced with spaces
056:                    if (clName != null) {
057:                        //System.out.println("clName="+clName);
058:                        final FileItem fi = TypeLocator.searchTypeForName(
059:                                clName, false, true); // respect case, but accept "ending with...". Todo: exact end
060:                        // TODO: like the editor popup !!
061:                        if (fi != null) {
062:                            AbstractAction al = new AbstractAction(
063:                                    "Add missing import for "
064:                                            + fi.getJavaName()) {
065:                                public void actionPerformed(ActionEvent ae) {
066:                                    MainEditorFrame.instance.editorPanel
067:                                            .addMissingImport(fi.getJavaName()
068:                                                    + ";");
069:                                }
070:                            };
071:                            actions.add(al);
072:                        }
073:                    }
074:                }
075:                return actions;
076:            }
077:
078:            public static void createAndAdd(String javaName, int line,
079:                    final String mess_) {
080:                String mess = mess_.trim();
081:
082:                boolean error = !mess.contains("warning: ");
083:
084:                // remove before ":<line>:"
085:                int pos = mess.indexOf(':');
086:                if (pos > 0) {
087:                    mess = mess.substring(pos + 1);
088:                    pos = mess.indexOf(':');
089:                    if (pos > 0) {
090:                        mess = mess.substring(pos + 1);
091:                    }
092:                }
093:
094:                // todo: detect column
095:                pos = mess.lastIndexOf("\n");
096:                int column = -1;
097:                if (pos > 0) {
098:                    String lastLine = mess.substring(pos);
099:                    column = lastLine.indexOf('^');
100:                    if (column >= 0) {
101:                        // remove the last line
102:                        //no, let its information be... mess = mess.substring(0, pos);
103:                        // TODO: underline or show error position.
104:                    }
105:
106:                }
107:
108:                CompilationMessage cm = new CompilationMessage(error, javaName,
109:                        line, column, mess, System.currentTimeMillis());
110:                LineMessagesManager.getInstance().add(cm);
111:
112:            }
113:
114:            // false for warnings
115:            public boolean isError() {
116:                return error;
117:            }
118:
119:            @Override
120:            public int getColumn() {
121:                return column;
122:            }
123:
124:            @Override
125:            public int getShiftX() {
126:                return 3;
127:            }
128:
129:            @Override
130:            public String getLetter() {
131:                return error ? "E" : "W";
132:            }
133:
134:            @Override
135:            public Color getColor() {
136:                return error ? Color.red : Color.orange;
137:            }
138:
139:            @Override
140:            public String getMessage() {
141:                return mess;
142:            }
143:
144:            @Override
145:            public String getMessageForTableColumn() {
146:                return shortMess;
147:            }
148:
149:            // todo: highlight last line at column position
150:            @Override
151:            public String toStringHTML() {
152:                return HTMLUtils.createCODEHTMLFromText(mess);
153:            }
154:
155:            @Override
156:            public String getMessageOriginator() {
157:                return "Compiler";
158:            }
159:
160:            @Override
161:            public String getCategory() {
162:                return error ? "Error" : (category.length() == 0 ? "Warning"
163:                        : category);
164:            }
165:
166:            @Override
167:            public StorageVector getStorageRepresentation() {
168:                StorageVector sv = new StorageVector();
169:                sv.add(1);
170:                sv.add("CompilationMessage");
171:                sv.add(javaName);
172:                sv.add(mess);
173:                sv.add(line);
174:                sv.add(column);
175:                sv.add(error);
176:                sv.add(created);
177:                return sv;
178:            }
179:
180:            public static CompilationMessage createFromStorageVector(
181:                    StorageVector sv) {
182:                long created = sv.size() > 7 ? (Long) sv.get(7) : System
183:                        .currentTimeMillis();
184:                return new CompilationMessage((Boolean) sv.get(6), (String) sv
185:                        .get(2), (Integer) sv.get(4), (Integer) sv.get(5),
186:                        (String) sv.get(3), created);
187:            }
188:
189:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.