1 19 20 package org.netbeans.modules.projectimport.j2seimport.ui; 21 import java.util.Iterator ; 22 import org.netbeans.modules.projectimport.j2seimport.WarningContainer; 23 import org.netbeans.modules.projectimport.j2seimport.ImportProcess; 24 import org.netbeans.modules.projectimport.j2seimport.WarningContainer.Warning; 25 import org.openide.DialogDescriptor; 26 import org.openide.DialogDisplayer; 27 import org.openide.NotifyDescriptor; 28 import org.openide.util.NbBundle; 29 30 31 35 public class WarningMessage { 36 public static void showMessages(final ImportProcess iProcess) { 37 WarningContainer warnings = iProcess.getWarnings(); 38 39 if (warnings != null) { 40 Iterator it = iProcess.getWarnings().getIterator(); 41 String message = createHtmlString(NbBundle.getMessage(WarningMessage.class, "MSG_ProblemsOccured"), it, true, 10); if (message != null) { 43 NotifyDescriptor d = new DialogDescriptor.Message(message, NotifyDescriptor.WARNING_MESSAGE); 44 DialogDisplayer.getDefault().notify(d); 45 } 46 } 47 } 48 49 public static String createHtmlString(String msg, Iterator it, boolean userNotificationOnly, int itemsLimit) { 50 StringBuffer sb = new StringBuffer (); 51 int items = 0; 52 sb.append("<html><b>").append(msg).append("</b><ul>"); while (it.hasNext()) { 54 WarningContainer.Warning warning = (Warning)it.next(); 55 boolean add = (userNotificationOnly && !warning.isUserNotification()) ? false : true; 56 if (items < itemsLimit) { 57 if (add) { 58 items++; 59 sb.append("<li>").append(warning.getMessage()).append("</li>"); } 61 } else { 62 break; 63 } 64 } 65 66 sb.append("</ul>"); 67 sb.append("</html>"); return (items > 0) ? sb.toString() : null; 69 } 70 71 72 private WarningMessage() { 73 } 74 75 } 76 | Popular Tags |