1 package net.sourceforge.phpdt.internal.ui.dialogs;
3 //import net.sourceforge.phpeclipse.PHPeclipsePlugin;
4 import net.sourceforge.phpeclipse.ui.WebUI;
6 import org.eclipse.core.runtime.IStatus;
7 import org.eclipse.jface.util.Assert;
10 * A settable IStatus. Can be an error, warning, info or ok. For error, info and
11 * warning states, a message describes the problem.
13 public class StatusInfo implements IStatus {
15 private String fStatusMessage;
17 private int fSeverity;
20 * Creates a status set to OK (no message)
30 * The status severity: ERROR, WARNING, INFO and OK.
32 * The message of the status. Applies only for ERROR, WARNING and
35 public StatusInfo(int severity, String message) {
36 fStatusMessage = message;
41 * Returns if the status' severity is OK.
43 public boolean isOK() {
44 return fSeverity == IStatus.OK;
48 * Returns if the status' severity is WARNING.
50 public boolean isWarning() {
51 return fSeverity == IStatus.WARNING;
55 * Returns if the status' severity is INFO.
57 public boolean isInfo() {
58 return fSeverity == IStatus.INFO;
62 * Returns if the status' severity is ERROR.
64 public boolean isError() {
65 return fSeverity == IStatus.ERROR;
69 * @see IStatus#getMessage
71 public String getMessage() {
72 return fStatusMessage;
76 * Sets the status to ERROR.
79 * error message (can be empty, but not null)
81 public void setError(String errorMessage) {
82 Assert.isNotNull(errorMessage);
83 fStatusMessage = errorMessage;
84 fSeverity = IStatus.ERROR;
88 * Sets the status to WARNING.
91 * warning message (can be empty, but not null)
93 public void setWarning(String warningMessage) {
94 Assert.isNotNull(warningMessage);
95 fStatusMessage = warningMessage;
96 fSeverity = IStatus.WARNING;
100 * Sets the status to INFO.
103 * info message (can be empty, but not null)
105 public void setInfo(String infoMessage) {
106 Assert.isNotNull(infoMessage);
107 fStatusMessage = infoMessage;
108 fSeverity = IStatus.INFO;
112 * Sets the status to OK.
114 public void setOK() {
115 fStatusMessage = null;
116 fSeverity = IStatus.OK;
120 * @see IStatus#matches(int)
122 public boolean matches(int severityMask) {
123 return (fSeverity & severityMask) != 0;
127 * Returns always <code>false</code>.
129 * @see IStatus#isMultiStatus()
131 public boolean isMultiStatus() {
136 * @see IStatus#getSeverity()
138 public int getSeverity() {
143 * @see IStatus#getPlugin()
145 public String getPlugin() {
146 return WebUI.PLUGIN_ID;
150 * Returns always <code>null</code>.
152 * @see IStatus#getException()
154 public Throwable getException() {
159 * Returns always the error severity.
161 * @see IStatus#getCode()
163 public int getCode() {
168 * Returns always <code>null</code>.
170 * @see IStatus#getChildren()
172 public IStatus[] getChildren() {
173 return new IStatus[0];