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