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;
10 * Can be an error, warning, info or ok. For error, info and warning states,
11 * a message describes the problem.
13 public class StatusInfo implements IStatus {
15 private String fStatusMessage;
16 private int fSeverity;
19 * Creates a status set to OK (no message)
27 * @param severity The status severity: ERROR, WARNING, INFO and OK.
28 * @param message The message of the status. Applies only for ERROR,
31 public StatusInfo(int severity, String message) {
32 fStatusMessage = message;
37 * Returns if the status' severity is OK.
39 public boolean isOK() {
40 return fSeverity == IStatus.OK;
44 * Returns if the status' severity is WARNING.
46 public boolean isWarning() {
47 return fSeverity == IStatus.WARNING;
51 * Returns if the status' severity is INFO.
53 public boolean isInfo() {
54 return fSeverity == IStatus.INFO;
58 * Returns if the status' severity is ERROR.
60 public boolean isError() {
61 return fSeverity == IStatus.ERROR;
65 * @see IStatus#getMessage
67 public String getMessage() {
68 return fStatusMessage;
72 * Sets the status to ERROR.
73 * @param The error message (can be empty, but not null)
75 public void setError(String errorMessage) {
76 Assert.isNotNull(errorMessage);
77 fStatusMessage = errorMessage;
78 fSeverity = IStatus.ERROR;
82 * Sets the status to WARNING.
83 * @param The warning message (can be empty, but not null)
85 public void setWarning(String warningMessage) {
86 Assert.isNotNull(warningMessage);
87 fStatusMessage = warningMessage;
88 fSeverity = IStatus.WARNING;
92 * Sets the status to INFO.
93 * @param The info message (can be empty, but not null)
95 public void setInfo(String infoMessage) {
96 Assert.isNotNull(infoMessage);
97 fStatusMessage = infoMessage;
98 fSeverity = IStatus.INFO;
102 * Sets the status to OK.
104 public void setOK() {
105 fStatusMessage = null;
106 fSeverity = IStatus.OK;
110 * @see IStatus#matches(int)
112 public boolean matches(int severityMask) {
113 return (fSeverity & severityMask) != 0;
117 * Returns always <code>false</code>.
118 * @see IStatus#isMultiStatus()
120 public boolean isMultiStatus() {
125 * @see IStatus#getSeverity()
127 public int getSeverity() {
132 * @see IStatus#getPlugin()
134 public String getPlugin() {
135 return PHPeclipsePlugin.PLUGIN_ID;
139 * Returns always <code>null</code>.
140 * @see IStatus#getException()
142 public Throwable getException() {
147 * Returns always the error severity.
148 * @see IStatus#getCode()
150 public int getCode() {
155 * Returns always <code>null</code>.
156 * @see IStatus#getChildren()
158 public IStatus[] getChildren() {
159 return new IStatus[0];