1 11 package org.eclipse.jdt.internal.ui.dialogs; 12 13 import org.eclipse.core.runtime.Assert; 14 import org.eclipse.core.runtime.IStatus; 15 16 17 import org.eclipse.jdt.ui.JavaUI; 18 19 24 public class StatusInfo implements IStatus { 25 26 public static final IStatus OK_STATUS= new StatusInfo(); 27 28 private String fStatusMessage; 29 private int fSeverity; 30 31 34 public StatusInfo() { 35 this(OK, null); 36 } 37 38 44 public StatusInfo(int severity, String message) { 45 fStatusMessage= message; 46 fSeverity= severity; 47 } 48 49 52 public boolean isOK() { 53 return fSeverity == IStatus.OK; 54 } 55 56 59 public boolean isWarning() { 60 return fSeverity == IStatus.WARNING; 61 } 62 63 66 public boolean isInfo() { 67 return fSeverity == IStatus.INFO; 68 } 69 70 73 public boolean isError() { 74 return fSeverity == IStatus.ERROR; 75 } 76 77 80 public String getMessage() { 81 return fStatusMessage; 82 } 83 84 88 public void setError(String errorMessage) { 89 Assert.isNotNull(errorMessage); 90 fStatusMessage= errorMessage; 91 fSeverity= IStatus.ERROR; 92 } 93 94 98 public void setWarning(String warningMessage) { 99 Assert.isNotNull(warningMessage); 100 fStatusMessage= warningMessage; 101 fSeverity= IStatus.WARNING; 102 } 103 104 108 public void setInfo(String infoMessage) { 109 Assert.isNotNull(infoMessage); 110 fStatusMessage= infoMessage; 111 fSeverity= IStatus.INFO; 112 } 113 114 117 public void setOK() { 118 fStatusMessage= null; 119 fSeverity= IStatus.OK; 120 } 121 122 125 public boolean matches(int severityMask) { 126 return (fSeverity & severityMask) != 0; 127 } 128 129 133 public boolean isMultiStatus() { 134 return false; 135 } 136 137 140 public int getSeverity() { 141 return fSeverity; 142 } 143 144 147 public String getPlugin() { 148 return JavaUI.ID_PLUGIN; 149 } 150 151 155 public Throwable getException() { 156 return null; 157 } 158 159 163 public int getCode() { 164 return fSeverity; 165 } 166 167 171 public IStatus[] getChildren() { 172 return new IStatus[0]; 173 } 174 175 179 public String toString() { 180 StringBuffer buf = new StringBuffer (); 181 buf.append("StatusInfo "); if (fSeverity == OK) { 183 buf.append("OK"); } else if (fSeverity == ERROR) { 185 buf.append("ERROR"); } else if (fSeverity == WARNING) { 187 buf.append("WARNING"); } else if (fSeverity == INFO) { 189 buf.append("INFO"); } else { 191 buf.append("severity="); buf.append(fSeverity); 193 } 194 buf.append(": "); buf.append(fStatusMessage); 196 return buf.toString(); 197 } 198 } 199 | Popular Tags |