1 package net.sourceforge.phpdt.internal.ui.dialogs;
3 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
5 import org.eclipse.core.runtime.IStatus;
7 //import org.eclipse.jface.text.Assert;
8 import org.eclipse.core.runtime.Assert;
11 * A settable IStatus. Can be an error, warning, info or ok. For error, info and
12 * warning states, a message describes the problem.
14 public class StatusInfo implements IStatus {
16 private String fStatusMessage;
18 private int fSeverity;
21 * Creates a status set to OK (no message)
31 * The status severity: ERROR, WARNING, INFO and OK.
33 * The message of the status. Applies only for ERROR, WARNING and
36 public StatusInfo(int severity, String message) {
37 fStatusMessage = message;
42 * Returns if the status' severity is OK.
44 public boolean isOK() {
45 return fSeverity == IStatus.OK;
49 * Returns if the status' severity is WARNING.
51 public boolean isWarning() {
52 return fSeverity == IStatus.WARNING;
56 * Returns if the status' severity is INFO.
58 public boolean isInfo() {
59 return fSeverity == IStatus.INFO;
63 * Returns if the status' severity is ERROR.
65 public boolean isError() {
66 return fSeverity == IStatus.ERROR;
70 * @see IStatus#getMessage
72 public String getMessage() {
73 return fStatusMessage;
77 * Sets the status to ERROR.
80 * error message (can be empty, but not null)
82 public void setError(String errorMessage) {
83 Assert.isNotNull(errorMessage);
84 fStatusMessage = errorMessage;
85 fSeverity = IStatus.ERROR;
89 * Sets the status to WARNING.
92 * warning message (can be empty, but not null)
94 public void setWarning(String warningMessage) {
95 Assert.isNotNull(warningMessage);
96 fStatusMessage = warningMessage;
97 fSeverity = IStatus.WARNING;
101 * Sets the status to INFO.
104 * info message (can be empty, but not null)
106 public void setInfo(String infoMessage) {
107 Assert.isNotNull(infoMessage);
108 fStatusMessage = infoMessage;
109 fSeverity = IStatus.INFO;
113 * Sets the status to OK.
115 public void setOK() {
116 fStatusMessage = null;
117 fSeverity = IStatus.OK;
121 * @see IStatus#matches(int)
123 public boolean matches(int severityMask) {
124 return (fSeverity & severityMask) != 0;
128 * Returns always <code>false</code>.
130 * @see IStatus#isMultiStatus()
132 public boolean isMultiStatus() {
137 * @see IStatus#getSeverity()
139 public int getSeverity() {
144 * @see IStatus#getPlugin()
146 public String getPlugin() {
147 return PHPeclipsePlugin.PLUGIN_ID;
151 * Returns always <code>null</code>.
153 * @see IStatus#getException()
155 public Throwable getException() {
160 * Returns always the error severity.
162 * @see IStatus#getCode()
164 public int getCode() {
169 * Returns always <code>null</code>.
171 * @see IStatus#getChildren()
173 public IStatus[] getChildren() {
174 return new IStatus[0];