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 org.eclipse.core.runtime.IStatus;
11 import org.eclipse.jface.util.Assert;
12 import net.sourceforge.phpdt.externaltools.model.IExternalToolConstants;
16 * Can be an error, warning, info or ok. For error, info and warning states,
17 * a message describes the problem.
19 public class StatusInfo implements IStatus {
21 private String fStatusMessage;
22 private int fSeverity;
25 * Creates a status set to OK (no message)
33 * @param severity The status severity: ERROR, WARNING, INFO and OK.
34 * @param message The message of the status. Applies only for ERROR,
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.
79 * @param The error message (can be empty, but not null)
81 public void setError(String errorMessage) {
82 Assert.isNotNull(errorMessage);
83 fStatusMessage= errorMessage;
84 fSeverity= IStatus.ERROR;
88 * Sets the status to WARNING.
89 * @param The warning message (can be empty, but not null)
91 public void setWarning(String warningMessage) {
92 Assert.isNotNull(warningMessage);
93 fStatusMessage= warningMessage;
94 fSeverity= IStatus.WARNING;
98 * Sets the status to INFO.
99 * @param The info message (can be empty, but not null)
101 public void setInfo(String infoMessage) {
102 Assert.isNotNull(infoMessage);
103 fStatusMessage= infoMessage;
104 fSeverity= IStatus.INFO;
108 * Sets the status to OK.
110 public void setOK() {
111 fStatusMessage= null;
112 fSeverity= IStatus.OK;
116 * @see IStatus#matches(int)
118 public boolean matches(int severityMask) {
119 return (fSeverity & severityMask) != 0;
123 * Returns always <code>false</code>.
124 * @see IStatus#isMultiStatus()
126 public boolean isMultiStatus() {
131 * @see IStatus#getSeverity()
133 public int getSeverity() {
138 * @see IStatus#getPlugin()
140 public String getPlugin() {
141 return IExternalToolConstants.PLUGIN_ID;
145 * Returns always <code>null</code>.
146 * @see IStatus#getException()
148 public Throwable getException() {
153 * Returns always the error severity.
154 * @see IStatus#getCode()
156 public int getCode() {
161 * Returns always <code>null</code>.
162 * @see IStatus#getChildren()
164 public IStatus[] getChildren() {
165 return new IStatus[0];