1 11 package org.eclipse.ui.internal.editors.text; 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 23 public class StatusUtil { 24 25 34 public static IStatus getMoreSevere(IStatus s1, IStatus s2) { 35 if (s1.getSeverity() > s2.getSeverity()) 36 return s1; 37 38 return s2; 39 } 40 41 49 public static IStatus getMostSevere(IStatus[] status) { 50 IStatus max= null; 51 for (int i= 0; i < status.length; i++) { 52 IStatus curr= status[i]; 53 if (curr.matches(IStatus.ERROR)) { 54 return curr; 55 } 56 if (max == null || curr.getSeverity() > max.getSeverity()) { 57 max= curr; 58 } 59 } 60 return max; 61 } 62 63 69 public static void applyToStatusLine(DialogPage page, IStatus status) { 70 String message= status.getMessage(); 71 switch (status.getSeverity()) { 72 case IStatus.OK: 73 page.setMessage(message, IMessageProvider.NONE); 74 page.setErrorMessage(null); 75 break; 76 case IStatus.WARNING: 77 page.setMessage(message, IMessageProvider.WARNING); 78 page.setErrorMessage(null); 79 break; 80 case IStatus.INFO: 81 page.setMessage(message, IMessageProvider.INFORMATION); 82 page.setErrorMessage(null); 83 break; 84 default: 85 if (message.length() == 0) { 86 message= null; 87 } 88 page.setMessage(null); 89 page.setErrorMessage(message); 90 break; 91 } 92 } 93 } 94 | Popular Tags |