2  * (c) Copyright IBM Corp. 2000, 2001.
 
   5 package net.sourceforge.phpdt.internal.ui.dialogs;
 
   7 import org.eclipse.core.runtime.IStatus;
 
   8 import org.eclipse.jface.dialogs.DialogPage;
 
  11  * A utility class to work with IStatus.
 
  13 public class StatusUtil {
 
  16          * Compares two instances of <code>IStatus</code>. The more severe is returned:
 
  17          * An error is more severe than a warning, and a warning is more severe
 
  18          * than ok. If the two stati have the same severity, the second is returned.
 
  20         public static IStatus getMoreSevere(IStatus s1, IStatus s2) {
 
  21                 if (s1.getSeverity() > s2.getSeverity()) {
 
  29          * Finds the most severe status from a array of stati.
 
  30          * An error is more severe than a warning, and a warning is more severe
 
  33         public static IStatus getMostSevere(IStatus[] status) {
 
  35                 for (int i= 0; i < status.length; i++) {
 
  36                         IStatus curr= status[i];
 
  37                         if (curr.matches(IStatus.ERROR)) {
 
  40                         if (max == null || curr.getSeverity() > max.getSeverity()) {
 
  48          * Applies the status to the status line of a dialog page.
 
  50         public static void applyToStatusLine(DialogPage page, IStatus status) {
 
  51                 String message= status.getMessage();
 
  52                 switch (status.getSeverity()) {
 
  54                                 page.setMessage(message, DialogPage.NONE);
 
  55                                 page.setErrorMessage(null);
 
  58                                 page.setMessage(message, DialogPage.WARNING);
 
  59                                 page.setErrorMessage(null);
 
  62                                 page.setMessage(message, DialogPage.INFORMATION);
 
  63                                 page.setErrorMessage(null);
 
  66                                 if (message.length() == 0) {
 
  69                                 page.setMessage(null);
 
  70                                 page.setErrorMessage(message);