1 package net.sourceforge.phpeclipse.ui;
3 /**********************************************************************
4 Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
5 This file is made available under the terms of the Common Public License v1.0
6 which accompanies this distribution, and is available at
7 http://www.eclipse.org/legal/cpl-v10.html
8 **********************************************************************/
11 //import net.sourceforge.phpdt.externaltools.model.IExternalToolConstants;
13 import org.eclipse.core.runtime.IStatus;
15 //import org.eclipse.jface.text.Assert;
16 import org.eclipse.core.runtime.Assert;
19 * A settable IStatus. Can be an error, warning, info or ok. For error, info and
20 * warning states, a message describes the problem.
22 public class StatusInfo implements IStatus {
24 private String fStatusMessage;
26 private int fSeverity;
29 * Creates a status set to OK (no message)
39 * The status severity: ERROR, WARNING, INFO and OK.
41 * The message of the status. Applies only for ERROR, WARNING and
44 public StatusInfo(int severity, String message) {
45 fStatusMessage = message;
50 * Returns if the status' severity is OK.
52 public boolean isOK() {
53 return fSeverity == IStatus.OK;
57 * Returns if the status' severity is WARNING.
59 public boolean isWarning() {
60 return fSeverity == IStatus.WARNING;
64 * Returns if the status' severity is INFO.
66 public boolean isInfo() {
67 return fSeverity == IStatus.INFO;
71 * Returns if the status' severity is ERROR.
73 public boolean isError() {
74 return fSeverity == IStatus.ERROR;
78 * @see IStatus#getMessage
80 public String getMessage() {
81 return fStatusMessage;
85 * Sets the status to ERROR.
88 * error message (can be empty, but not null)
90 public void setError(String errorMessage) {
91 Assert.isNotNull(errorMessage);
92 fStatusMessage = errorMessage;
93 fSeverity = IStatus.ERROR;
97 * Sets the status to WARNING.
100 * warning message (can be empty, but not null)
102 public void setWarning(String warningMessage) {
103 Assert.isNotNull(warningMessage);
104 fStatusMessage = warningMessage;
105 fSeverity = IStatus.WARNING;
109 * Sets the status to INFO.
112 * info message (can be empty, but not null)
114 public void setInfo(String infoMessage) {
115 Assert.isNotNull(infoMessage);
116 fStatusMessage = infoMessage;
117 fSeverity = IStatus.INFO;
121 * Sets the status to OK.
123 public void setOK() {
124 fStatusMessage = null;
125 fSeverity = IStatus.OK;
129 * @see IStatus#matches(int)
131 public boolean matches(int severityMask) {
132 return (fSeverity & severityMask) != 0;
136 * Returns always <code>false</code>.
138 * @see IStatus#isMultiStatus()
140 public boolean isMultiStatus() {
145 * @see IStatus#getSeverity()
147 public int getSeverity() {
152 * @see IStatus#getPlugin()
154 public String getPlugin() {
155 return WebUI.PLUGIN_ID/* IExternalToolConstants.PLUGIN_ID*/;
159 * Returns always <code>null</code>.
161 * @see IStatus#getException()
163 public Throwable getException() {
168 * Returns always the error severity.
170 * @see IStatus#getCode()
172 public int getCode() {
177 * Returns always <code>null</code>.
179 * @see IStatus#getChildren()
181 public IStatus[] getChildren() {
182 return new IStatus[0];