1 package net.sourceforge.phpdt.externaltools.internal.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 **********************************************************************/
10 import net.sourceforge.phpdt.externaltools.model.IExternalToolConstants;
12 import org.eclipse.core.runtime.IStatus;
13 import org.eclipse.jface.util.Assert;
16 * A settable IStatus. Can be an error, warning, info or ok. For error, info and
17 * warning states, a message describes the problem.
19 public class StatusInfo implements IStatus {
21 private String fStatusMessage;
23 private int fSeverity;
26 * Creates a status set to OK (no message)
36 * The status severity: ERROR, WARNING, INFO and OK.
38 * The message of the status. Applies only for ERROR, WARNING and
41 public StatusInfo(int severity, String message) {
42 fStatusMessage = message;
47 * Returns if the status' severity is OK.
49 public boolean isOK() {
50 return fSeverity == IStatus.OK;
54 * Returns if the status' severity is WARNING.
56 public boolean isWarning() {
57 return fSeverity == IStatus.WARNING;
61 * Returns if the status' severity is INFO.
63 public boolean isInfo() {
64 return fSeverity == IStatus.INFO;
68 * Returns if the status' severity is ERROR.
70 public boolean isError() {
71 return fSeverity == IStatus.ERROR;
75 * @see IStatus#getMessage
77 public String getMessage() {
78 return fStatusMessage;
82 * Sets the status to ERROR.
85 * error message (can be empty, but not null)
87 public void setError(String errorMessage) {
88 Assert.isNotNull(errorMessage);
89 fStatusMessage = errorMessage;
90 fSeverity = IStatus.ERROR;
94 * Sets the status to WARNING.
97 * warning message (can be empty, but not null)
99 public void setWarning(String warningMessage) {
100 Assert.isNotNull(warningMessage);
101 fStatusMessage = warningMessage;
102 fSeverity = IStatus.WARNING;
106 * Sets the status to INFO.
109 * info message (can be empty, but not null)
111 public void setInfo(String infoMessage) {
112 Assert.isNotNull(infoMessage);
113 fStatusMessage = infoMessage;
114 fSeverity = IStatus.INFO;
118 * Sets the status to OK.
120 public void setOK() {
121 fStatusMessage = null;
122 fSeverity = IStatus.OK;
126 * @see IStatus#matches(int)
128 public boolean matches(int severityMask) {
129 return (fSeverity & severityMask) != 0;
133 * Returns always <code>false</code>.
135 * @see IStatus#isMultiStatus()
137 public boolean isMultiStatus() {
142 * @see IStatus#getSeverity()
144 public int getSeverity() {
149 * @see IStatus#getPlugin()
151 public String getPlugin() {
152 return IExternalToolConstants.PLUGIN_ID;
156 * Returns always <code>null</code>.
158 * @see IStatus#getException()
160 public Throwable getException() {
165 * Returns always the error severity.
167 * @see IStatus#getCode()
169 public int getCode() {
174 * Returns always <code>null</code>.
176 * @see IStatus#getChildren()
178 public IStatus[] getChildren() {
179 return new IStatus[0];