1 19 20 package org.netbeans.modules.websvc.jaxwsmodel.project; 21 22 import java.io.IOException ; 23 import javax.swing.SwingUtilities ; 24 import org.openide.DialogDisplayer; 25 import org.openide.NotifyDescriptor; 26 import org.openide.util.NbBundle; 27 import org.openide.util.UserQuestionException; 28 29 34 public final class UserQuestionHandler { 35 36 private UserQuestionHandler() {} 37 38 44 public static void handle(final UserQuestionException e, final Callback callback) { 45 SwingUtilities.invokeLater(new Runnable () { 46 public void run() { 47 NotifyDescriptor.Confirmation desc = new NotifyDescriptor.Confirmation( 48 e.getLocalizedMessage(), 49 NbBundle.getMessage(UserQuestionHandler.class, "TITLE_CannotWriteFile"), 50 NotifyDescriptor.Confirmation.OK_CANCEL_OPTION); 51 if (DialogDisplayer.getDefault().notify(desc).equals(NotifyDescriptor.OK_OPTION)) { 52 try { 53 e.confirmed(); 54 callback.accepted(); 55 } catch (IOException x) { 56 callback.error(x); 57 } 58 } else { 59 callback.denied(); 60 } 61 } 62 }); 63 } 64 65 68 public interface Callback { 69 70 73 void accepted(); 74 75 78 void denied(); 79 80 83 void error(IOException e); 84 85 } 86 87 } 88 | Popular Tags |