1 11 package org.eclipse.ui.texteditor.templates; 12 13 import org.eclipse.core.runtime.Assert; 14 import org.eclipse.core.runtime.IStatus; 15 16 17 import org.eclipse.ui.internal.texteditor.TextEditorPlugin; 18 19 26 class StatusInfo implements IStatus { 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 54 public boolean isOK() { 55 return fSeverity == IStatus.OK; 56 } 57 58 63 public boolean isWarning() { 64 return fSeverity == IStatus.WARNING; 65 } 66 67 72 public boolean isInfo() { 73 return fSeverity == IStatus.INFO; 74 } 75 76 81 public boolean isError() { 82 return fSeverity == IStatus.ERROR; 83 } 84 85 91 public String getMessage() { 92 return fStatusMessage; 93 } 94 95 99 public void setError(String errorMessage) { 100 Assert.isNotNull(errorMessage); 101 fStatusMessage= errorMessage; 102 fSeverity= IStatus.ERROR; 103 } 104 105 109 public void setWarning(String warningMessage) { 110 Assert.isNotNull(warningMessage); 111 fStatusMessage= warningMessage; 112 fSeverity= IStatus.WARNING; 113 } 114 115 119 public void setInfo(String infoMessage) { 120 Assert.isNotNull(infoMessage); 121 fStatusMessage= infoMessage; 122 fSeverity= IStatus.INFO; 123 } 124 125 128 public void setOK() { 129 fStatusMessage= null; 130 fSeverity= IStatus.OK; 131 } 132 133 136 public boolean matches(int severityMask) { 137 return (fSeverity & severityMask) != 0; 138 } 139 140 144 public boolean isMultiStatus() { 145 return false; 146 } 147 148 151 public int getSeverity() { 152 return fSeverity; 153 } 154 155 158 public String getPlugin() { 159 return TextEditorPlugin.PLUGIN_ID; 160 } 161 162 166 public Throwable getException() { 167 return null; 168 } 169 170 174 public int getCode() { 175 return fSeverity; 176 } 177 178 182 public IStatus[] getChildren() { 183 return new IStatus[0]; 184 } 185 186 } 187 | Popular Tags |