1 package net.sourceforge.phpdt.internal.ui.dialogs;
3 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
5 import org.eclipse.core.runtime.IStatus;
6 import org.eclipse.jface.util.Assert;
9 * A settable IStatus. Can be an error, warning, info or ok. For error, info and
10 * warning states, a message describes the problem.
12 public class StatusInfo implements IStatus {
14 private String fStatusMessage;
16 private int fSeverity;
19 * Creates a status set to OK (no message)
29 * The status severity: ERROR, WARNING, INFO and OK.
31 * The message of the status. Applies only for ERROR, WARNING and
34 public StatusInfo(int severity, String message) {
35 fStatusMessage = message;
40 * Returns if the status' severity is OK.
42 public boolean isOK() {
43 return fSeverity == IStatus.OK;
47 * Returns if the status' severity is WARNING.
49 public boolean isWarning() {
50 return fSeverity == IStatus.WARNING;
54 * Returns if the status' severity is INFO.
56 public boolean isInfo() {
57 return fSeverity == IStatus.INFO;
61 * Returns if the status' severity is ERROR.
63 public boolean isError() {
64 return fSeverity == IStatus.ERROR;
68 * @see IStatus#getMessage
70 public String getMessage() {
71 return fStatusMessage;
75 * Sets the status to ERROR.
78 * error message (can be empty, but not null)
80 public void setError(String errorMessage) {
81 Assert.isNotNull(errorMessage);
82 fStatusMessage = errorMessage;
83 fSeverity = IStatus.ERROR;
87 * Sets the status to WARNING.
90 * warning message (can be empty, but not null)
92 public void setWarning(String warningMessage) {
93 Assert.isNotNull(warningMessage);
94 fStatusMessage = warningMessage;
95 fSeverity = IStatus.WARNING;
99 * Sets the status to INFO.
102 * info message (can be empty, but not null)
104 public void setInfo(String infoMessage) {
105 Assert.isNotNull(infoMessage);
106 fStatusMessage = infoMessage;
107 fSeverity = IStatus.INFO;
111 * Sets the status to OK.
113 public void setOK() {
114 fStatusMessage = null;
115 fSeverity = IStatus.OK;
119 * @see IStatus#matches(int)
121 public boolean matches(int severityMask) {
122 return (fSeverity & severityMask) != 0;
126 * Returns always <code>false</code>.
128 * @see IStatus#isMultiStatus()
130 public boolean isMultiStatus() {
135 * @see IStatus#getSeverity()
137 public int getSeverity() {
142 * @see IStatus#getPlugin()
144 public String getPlugin() {
145 return PHPeclipsePlugin.PLUGIN_ID;
149 * Returns always <code>null</code>.
151 * @see IStatus#getException()
153 public Throwable getException() {
158 * Returns always the error severity.
160 * @see IStatus#getCode()
162 public int getCode() {
167 * Returns always <code>null</code>.
169 * @see IStatus#getChildren()
171 public IStatus[] getChildren() {
172 return new IStatus[0];