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