A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse.externaltools / src / net / sourceforge / phpdt / externaltools / internal / ui / StatusInfo.java
1 package net.sourceforge.phpdt.externaltools.internal.ui;
2
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  **********************************************************************/
9
10 import net.sourceforge.phpdt.externaltools.model.IExternalToolConstants;
11
12 import org.eclipse.core.runtime.IStatus;
13 import org.eclipse.jface.util.Assert;
14
15 /**
16  * A settable IStatus. Can be an error, warning, info or ok. For error, info and
17  * warning states, a message describes the problem.
18  */
19 public class StatusInfo implements IStatus {
20
21         private String fStatusMessage;
22
23         private int fSeverity;
24
25         /**
26          * Creates a status set to OK (no message)
27          */
28         public StatusInfo() {
29                 this(OK, null);
30         }
31
32         /**
33          * Creates a status .
34          * 
35          * @param severity
36          *            The status severity: ERROR, WARNING, INFO and OK.
37          * @param message
38          *            The message of the status. Applies only for ERROR, WARNING and
39          *            INFO.
40          */
41         public StatusInfo(int severity, String message) {
42                 fStatusMessage = message;
43                 fSeverity = severity;
44         }
45
46         /**
47          * Returns if the status' severity is OK.
48          */
49         public boolean isOK() {
50                 return fSeverity == IStatus.OK;
51         }
52
53         /**
54          * Returns if the status' severity is WARNING.
55          */
56         public boolean isWarning() {
57                 return fSeverity == IStatus.WARNING;
58         }
59
60         /**
61          * Returns if the status' severity is INFO.
62          */
63         public boolean isInfo() {
64                 return fSeverity == IStatus.INFO;
65         }
66
67         /**
68          * Returns if the status' severity is ERROR.
69          */
70         public boolean isError() {
71                 return fSeverity == IStatus.ERROR;
72         }
73
74         /**
75          * @see IStatus#getMessage
76          */
77         public String getMessage() {
78                 return fStatusMessage;
79         }
80
81         /**
82          * Sets the status to ERROR.
83          * 
84          * @param The
85          *            error message (can be empty, but not null)
86          */
87         public void setError(String errorMessage) {
88                 Assert.isNotNull(errorMessage);
89                 fStatusMessage = errorMessage;
90                 fSeverity = IStatus.ERROR;
91         }
92
93         /**
94          * Sets the status to WARNING.
95          * 
96          * @param The
97          *            warning message (can be empty, but not null)
98          */
99         public void setWarning(String warningMessage) {
100                 Assert.isNotNull(warningMessage);
101                 fStatusMessage = warningMessage;
102                 fSeverity = IStatus.WARNING;
103         }
104
105         /**
106          * Sets the status to INFO.
107          * 
108          * @param The
109          *            info message (can be empty, but not null)
110          */
111         public void setInfo(String infoMessage) {
112                 Assert.isNotNull(infoMessage);
113                 fStatusMessage = infoMessage;
114                 fSeverity = IStatus.INFO;
115         }
116
117         /**
118          * Sets the status to OK.
119          */
120         public void setOK() {
121                 fStatusMessage = null;
122                 fSeverity = IStatus.OK;
123         }
124
125         /*
126          * @see IStatus#matches(int)
127          */
128         public boolean matches(int severityMask) {
129                 return (fSeverity & severityMask) != 0;
130         }
131
132         /**
133          * Returns always <code>false</code>.
134          * 
135          * @see IStatus#isMultiStatus()
136          */
137         public boolean isMultiStatus() {
138                 return false;
139         }
140
141         /*
142          * @see IStatus#getSeverity()
143          */
144         public int getSeverity() {
145                 return fSeverity;
146         }
147
148         /*
149          * @see IStatus#getPlugin()
150          */
151         public String getPlugin() {
152                 return IExternalToolConstants.PLUGIN_ID;
153         }
154
155         /**
156          * Returns always <code>null</code>.
157          * 
158          * @see IStatus#getException()
159          */
160         public Throwable getException() {
161                 return null;
162         }
163
164         /**
165          * Returns always the error severity.
166          * 
167          * @see IStatus#getCode()
168          */
169         public int getCode() {
170                 return fSeverity;
171         }
172
173         /**
174          * Returns always <code>null</code>.
175          * 
176          * @see IStatus#getChildren()
177          */
178         public IStatus[] getChildren() {
179                 return new IStatus[0];
180         }
181
182 }