2 * (c) Copyright IBM Corp. 2000, 2001.
5 package net.sourceforge.phpdt.internal.ui.dialog;
7 import org.eclipse.core.runtime.IStatus;
9 import org.eclipse.jface.dialogs.DialogPage;
12 * A utility class to work with IStatus.
14 public class StatusUtil {
17 * Compares two instances of <code>IStatus</code>. The more severe is returned:
18 * An error is more severe than a warning, and a warning is more severe
19 * than ok. If the two stati have the same severity, the second is returned.
21 public static IStatus getMoreSevere(IStatus s1, IStatus s2) {
22 if (s1.getSeverity() > s2.getSeverity()) {
30 * Finds the most severe status from a array of stati.
31 * An error is more severe than a warning, and a warning is more severe
34 public static IStatus getMostSevere(IStatus[] status) {
36 for (int i= 0; i < status.length; i++) {
37 IStatus curr= status[i];
38 if (curr.matches(IStatus.ERROR)) {
41 if (max == null || curr.getSeverity() > max.getSeverity()) {
49 * Applies the status to the status line of a dialog page.
51 public static void applyToStatusLine(DialogPage page, IStatus status) {
52 String message= status.getMessage();
53 switch (status.getSeverity()) {
55 page.setMessage(message, DialogPage.NONE);
56 page.setErrorMessage(null);
59 page.setMessage(message, DialogPage.WARNING);
60 page.setErrorMessage(null);
63 page.setMessage(message, DialogPage.INFORMATION);
64 page.setErrorMessage(null);
67 if (message.length() == 0) {
70 page.setMessage(null);
71 page.setErrorMessage(message);