1 19 20 package org.netbeans.modules.scripting.php.dbginterface.models; 21 22 import java.text.MessageFormat ; 23 import org.netbeans.modules.scripting.php.dbginterface.DbgConstants; 24 import org.openide.ErrorManager; 25 import org.openide.filesystems.FileObject; 26 import org.openide.filesystems.FileStateInvalidException; 27 import org.openide.text.Line; 28 import org.openide.util.NbBundle; 29 30 34 public class DebugError { 35 private Line line; 36 private int type; 37 private String description; 38 39 40 public DebugError(Line line, int type, String desc) { 41 this.line = line; 42 this.type = type; 43 this.description = desc; 44 } 45 46 public boolean isError() { 47 return type == DbgConstants.ERR_CORE_ERROR || type == DbgConstants.ERR_ERROR || 48 type == DbgConstants.ERR_PARSE; 49 } 50 51 public boolean isWarning() { 52 return type == DbgConstants.ERR_CORE_WARNING || type == DbgConstants.ERR_WARNING; 53 } 54 55 public boolean isNotice() { 56 return type == DbgConstants.ERR_NOTICE; 57 } 58 59 public Line getLine() { 60 return line; 61 } 62 63 public FileObject getSourceFile() { 64 return (FileObject)line.getLookup().lookup(FileObject.class); 65 } 66 67 public String getDisplayName() { 68 String ret = ""; 69 70 try { 71 ret += getSourceFile().getURL().toString() + ":" + (line.getLineNumber() + 1); 72 } 73 catch (FileStateInvalidException fsie) { 74 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, fsie); 75 76 ret += getSourceFile().getPath() + ":" + (line.getLineNumber() + 1); 77 } 78 79 ret += " : " + getString(); 80 81 return ret; 82 } 83 84 public String getString() { 85 String ret; 86 String id = null; 87 88 switch (type) { 89 case DbgConstants.ERR_CORE_ERROR: 90 id = "ERR_coreError"; 91 break; 92 93 case DbgConstants.ERR_CORE_WARNING: 94 id = "ERR_coreWarning"; 95 break; 96 97 case DbgConstants.ERR_ERROR: 98 id = "ERR_error"; 99 break; 100 101 case DbgConstants.ERR_NOTICE: 102 id = "ERR_notice"; 103 break; 104 105 case DbgConstants.ERR_PARSE: 106 id = "ERR_parseError"; 107 break; 108 109 case DbgConstants.ERR_WARNING: 110 id = "ERR_warning"; 111 break; 112 } 113 114 if (id != null) { 115 ret = MessageFormat.format(NbBundle.getMessage(DebugError.class, id), description); 116 } 117 else { 118 ret = description; 119 } 120 121 return ret; 122 } 123 } 124 | Popular Tags |