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;
17 * Can be an error, warning, info or ok. For error, info and warning states,
18 * a message describes the problem.
20 public class StatusInfo implements IStatus {
22 private String fStatusMessage;
23 private int fSeverity;
26 * Creates a status set to OK (no message)
34 * @param severity The status severity: ERROR, WARNING, INFO and OK.
35 * @param message The message of the status. Applies only for ERROR,
38 public StatusInfo(int severity, String message) {
39 fStatusMessage= message;
44 * Returns if the status' severity is OK.
46 public boolean isOK() {
47 return fSeverity == IStatus.OK;
51 * Returns if the status' severity is WARNING.
53 public boolean isWarning() {
54 return fSeverity == IStatus.WARNING;
58 * Returns if the status' severity is INFO.
60 public boolean isInfo() {
61 return fSeverity == IStatus.INFO;
65 * Returns if the status' severity is ERROR.
67 public boolean isError() {
68 return fSeverity == IStatus.ERROR;
72 * @see IStatus#getMessage
74 public String getMessage() {
75 return fStatusMessage;
79 * Sets the status to ERROR.
80 * @param The error message (can be empty, but not null)
82 public void setError(String errorMessage) {
83 Assert.isNotNull(errorMessage);
84 fStatusMessage= errorMessage;
85 fSeverity= IStatus.ERROR;
89 * Sets the status to WARNING.
90 * @param The warning message (can be empty, but not null)
92 public void setWarning(String warningMessage) {
93 Assert.isNotNull(warningMessage);
94 fStatusMessage= warningMessage;
95 fSeverity= IStatus.WARNING;
99 * Sets the status to INFO.
100 * @param The info message (can be empty, but not null)
102 public void setInfo(String infoMessage) {
103 Assert.isNotNull(infoMessage);
104 fStatusMessage= infoMessage;
105 fSeverity= IStatus.INFO;
109 * Sets the status to OK.
111 public void setOK() {
112 fStatusMessage= null;
113 fSeverity= IStatus.OK;
117 * @see IStatus#matches(int)
119 public boolean matches(int severityMask) {
120 return (fSeverity & severityMask) != 0;
124 * Returns always <code>false</code>.
125 * @see IStatus#isMultiStatus()
127 public boolean isMultiStatus() {
132 * @see IStatus#getSeverity()
134 public int getSeverity() {
139 * @see IStatus#getPlugin()
141 public String getPlugin() {
142 return IExternalToolConstants.PLUGIN_ID;
146 * Returns always <code>null</code>.
147 * @see IStatus#getException()
149 public Throwable getException() {
154 * Returns always the error severity.
155 * @see IStatus#getCode()
157 public int getCode() {
162 * Returns always <code>null</code>.
163 * @see IStatus#getChildren()
165 public IStatus[] getChildren() {
166 return new IStatus[0];