1 package net.sourceforge.phpdt.internal.ui.dialog;
3 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
4 import org.eclipse.core.runtime.IStatus;
5 import org.eclipse.jface.util.Assert;
9 * Can be an error, warning, info or ok. For error, info and warning states,
10 * a message describes the problem.
12 public class StatusInfo implements IStatus {
14 private String fStatusMessage;
15 private int fSeverity;
18 * Creates a status set to OK (no message)
26 * @param severity The status severity: ERROR, WARNING, INFO and OK.
27 * @param message The message of the status. Applies only for ERROR,
30 public StatusInfo(int severity, String message) {
31 fStatusMessage = message;
36 * Returns if the status' severity is OK.
38 public boolean isOK() {
39 return fSeverity == IStatus.OK;
43 * Returns if the status' severity is WARNING.
45 public boolean isWarning() {
46 return fSeverity == IStatus.WARNING;
50 * Returns if the status' severity is INFO.
52 public boolean isInfo() {
53 return fSeverity == IStatus.INFO;
57 * Returns if the status' severity is ERROR.
59 public boolean isError() {
60 return fSeverity == IStatus.ERROR;
64 * @see IStatus#getMessage
66 public String getMessage() {
67 return fStatusMessage;
71 * Sets the status to ERROR.
72 * @param The error message (can be empty, but not null)
74 public void setError(String errorMessage) {
75 Assert.isNotNull(errorMessage);
76 fStatusMessage = errorMessage;
77 fSeverity = IStatus.ERROR;
81 * Sets the status to WARNING.
82 * @param The warning message (can be empty, but not null)
84 public void setWarning(String warningMessage) {
85 Assert.isNotNull(warningMessage);
86 fStatusMessage = warningMessage;
87 fSeverity = IStatus.WARNING;
91 * Sets the status to INFO.
92 * @param The info message (can be empty, but not null)
94 public void setInfo(String infoMessage) {
95 Assert.isNotNull(infoMessage);
96 fStatusMessage = infoMessage;
97 fSeverity = IStatus.INFO;
101 * Sets the status to OK.
103 public void setOK() {
104 fStatusMessage = null;
105 fSeverity = IStatus.OK;
109 * @see IStatus#matches(int)
111 public boolean matches(int severityMask) {
112 return (fSeverity & severityMask) != 0;
116 * Returns always <code>false</code>.
117 * @see IStatus#isMultiStatus()
119 public boolean isMultiStatus() {
124 * @see IStatus#getSeverity()
126 public int getSeverity() {
131 * @see IStatus#getPlugin()
133 public String getPlugin() {
134 return PHPeclipsePlugin.PLUGIN_ID;
138 * Returns always <code>null</code>.
139 * @see IStatus#getException()
141 public Throwable getException() {
146 * Returns always the error severity.
147 * @see IStatus#getCode()
149 public int getCode() {
154 * Returns always <code>null</code>.
155 * @see IStatus#getChildren()
157 public IStatus[] getChildren() {
158 return new IStatus[0];