001: package tide.javadocgen;
002:
003: import snow.utils.StringUtils;
004: import snow.utils.storage.*;
005: import tide.editor.linemessages.*;
006: import tide.editor.MainEditorFrame;
007: import java.awt.Color;
008:
009: /** Parsed from the gobbler of the javadoc process output.
010: */
011: public class JavaDocLineMessage extends LineMessage {
012: final private String mess;
013: final private String shortMess;
014: final private String cat;
015: final private int priority;
016:
017: public JavaDocLineMessage(String javaName, String mess, int line,
018: long created) {
019: super (javaName, line, created);
020:
021: this .mess = mess;
022: if (mess.toLowerCase().startsWith("warning -")) {
023: this .cat = "Warning";
024: this .priority = 2;
025: shortMess = mess.substring(9).trim();
026: } else {
027: this .cat = "Error";
028: this .priority = 1;
029: shortMess = StringUtils.firstLine(mess); // multiline message with column marker "^" ...
030: }
031:
032: }
033:
034: public static void createAndAdd(final String line) {
035: int pos = line.indexOf(".java:");
036: if (pos == -1)
037: return;
038: String javaName = line.substring(0, pos);
039: String pa = MainEditorFrame.instance.getActualProject()
040: .getSources_Home().getAbsolutePath();
041: if (!pa.endsWith("\\"))
042: pa += "\\";
043: if (javaName.startsWith(pa)) {
044: javaName = javaName.substring(pa.length());
045: }
046:
047: javaName = javaName.replace('\\', '.');
048:
049: int posEnd = line.indexOf(':', pos + 6);
050: int lineNr = -1;
051: if (posEnd > 0) {
052: try {
053: lineNr = Integer.parseInt(line.substring(pos + 6,
054: posEnd));
055: } catch (Exception e) {
056: e.printStackTrace();
057: }
058: }
059:
060: String messLine = line.substring(posEnd + 1).trim();
061: JavaDocLineMessage lm = new JavaDocLineMessage(javaName,
062: messLine, lineNr, System.currentTimeMillis());
063: LineMessagesManager.getInstance().add(lm);
064: }
065:
066: @Override
067: public String toStringHTML() {
068: return "Javadoc: " + mess;
069: }
070:
071: @Override
072: public String getMessage() {
073: return mess;
074: }
075:
076: @Override
077: public String getMessageForTableColumn() {
078: return shortMess;
079: }
080:
081: @Override
082: public Color getColor() {
083: return Color.orange;
084: }
085:
086: @Override
087: public String getLetter() {
088: return "D";
089: }
090:
091: @Override
092: public int getShiftX() {
093: return 2;
094: }
095:
096: @Override
097: public String getMessageOriginator() {
098: return "Javadoc";
099: }
100:
101: @Override
102: public int getPriority() {
103: return priority;
104: }
105:
106: @Override
107: public String getCategory() {
108: return cat;
109: }
110:
111: @Override
112: public StorageVector getStorageRepresentation() {
113: StorageVector sv = new StorageVector();
114: sv.add(1);
115: sv.add("JavaDocLineMessage");
116: sv.add(javaName);
117: sv.add(mess);
118: sv.add(line);
119: sv.add(created);
120: return sv;
121: }
122:
123: public static JavaDocLineMessage createFromStorageVector(
124: StorageVector sv) {
125: long created = sv.size() > 5 ? (Long) sv.get(5) : System
126: .currentTimeMillis();
127:
128: return new JavaDocLineMessage((String) sv.get(2), (String) sv
129: .get(3), (Integer) sv.get(4), created);
130: }
131:
132: }
|