1 11 package org.eclipse.jdt.internal.ui.dialogs; 12 13 import org.eclipse.core.runtime.IStatus; 14 15 import org.eclipse.jface.dialogs.DialogPage; 16 import org.eclipse.jface.dialogs.IMessageProvider; 17 18 21 public class StatusUtil { 22 23 28 public static IStatus getMoreSevere(IStatus s1, IStatus s2) { 29 if (s1.getSeverity() > s2.getSeverity()) { 30 return s1; 31 } else { 32 return s2; 33 } 34 } 35 36 41 public static IStatus getMostSevere(IStatus[] status) { 42 IStatus max= null; 43 for (int i= 0; i < status.length; i++) { 44 IStatus curr= status[i]; 45 if (curr.matches(IStatus.ERROR)) { 46 return curr; 47 } 48 if (max == null || curr.getSeverity() > max.getSeverity()) { 49 max= curr; 50 } 51 } 52 return max; 53 } 54 55 58 public static void applyToStatusLine(DialogPage page, IStatus status) { 59 String message= status.getMessage(); 60 switch (status.getSeverity()) { 61 case IStatus.OK: 62 page.setMessage(message, IMessageProvider.NONE); 63 page.setErrorMessage(null); 64 break; 65 case IStatus.WARNING: 66 page.setMessage(message, IMessageProvider.WARNING); 67 page.setErrorMessage(null); 68 break; 69 case IStatus.INFO: 70 page.setMessage(message, IMessageProvider.INFORMATION); 71 page.setErrorMessage(null); 72 break; 73 default: 74 if (message.length() == 0) { 75 message= null; 76 } 77 page.setMessage(null); 78 page.setErrorMessage(message); 79 break; 80 } 81 } 82 } 83 | Popular Tags |