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;
8 //import org.eclipse.jface.text.Assert;
9 import org.eclipse.core.runtime.Assert;
12 * A settable IStatus. Can be an error, warning, info or ok. For error, info and
13 * warning states, a message describes the problem.
15 public class StatusInfo implements IStatus {
17 private String fStatusMessage;
19 private int fSeverity;
22 * Creates a status set to OK (no message)
32 * The status severity: ERROR, WARNING, INFO and OK.
34 * The message of the status. Applies only for ERROR, WARNING and
37 public StatusInfo(int severity, String message) {
38 fStatusMessage = message;
43 * Returns if the status' severity is OK.
45 public boolean isOK() {
46 return fSeverity == IStatus.OK;
50 * Returns if the status' severity is WARNING.
52 public boolean isWarning() {
53 return fSeverity == IStatus.WARNING;
57 * Returns if the status' severity is INFO.
59 public boolean isInfo() {
60 return fSeverity == IStatus.INFO;
64 * Returns if the status' severity is ERROR.
66 public boolean isError() {
67 return fSeverity == IStatus.ERROR;
71 * @see IStatus#getMessage
73 public String getMessage() {
74 return fStatusMessage;
78 * Sets the status to ERROR.
81 * error message (can be empty, but not null)
83 public void setError(String errorMessage) {
84 Assert.isNotNull(errorMessage);
85 fStatusMessage = errorMessage;
86 fSeverity = IStatus.ERROR;
90 * Sets the status to WARNING.
93 * warning message (can be empty, but not null)
95 public void setWarning(String warningMessage) {
96 Assert.isNotNull(warningMessage);
97 fStatusMessage = warningMessage;
98 fSeverity = IStatus.WARNING;
102 * Sets the status to INFO.
105 * info message (can be empty, but not null)
107 public void setInfo(String infoMessage) {
108 Assert.isNotNull(infoMessage);
109 fStatusMessage = infoMessage;
110 fSeverity = IStatus.INFO;
114 * Sets the status to OK.
116 public void setOK() {
117 fStatusMessage = null;
118 fSeverity = IStatus.OK;
122 * @see IStatus#matches(int)
124 public boolean matches(int severityMask) {
125 return (fSeverity & severityMask) != 0;
129 * Returns always <code>false</code>.
131 * @see IStatus#isMultiStatus()
133 public boolean isMultiStatus() {
138 * @see IStatus#getSeverity()
140 public int getSeverity() {
145 * @see IStatus#getPlugin()
147 public String getPlugin() {
148 return WebUI.PLUGIN_ID;
152 * Returns always <code>null</code>.
154 * @see IStatus#getException()
156 public Throwable getException() {
161 * Returns always the error severity.
163 * @see IStatus#getCode()
165 public int getCode() {
170 * Returns always <code>null</code>.
172 * @see IStatus#getChildren()
174 public IStatus[] getChildren() {
175 return new IStatus[0];