1 19 20 package org.netbeans.modules.j2ee.common.ui; 21 22 import java.awt.Dialog ; 23 import javax.swing.JButton ; 24 import javax.swing.SwingUtilities ; 25 import org.netbeans.modules.j2ee.common.*; 26 import org.netbeans.modules.j2ee.common.ui.NoSelectedServerWarning; 27 import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment; 28 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule; 29 import org.openide.DialogDescriptor; 30 import org.openide.DialogDisplayer; 31 import org.openide.util.NbBundle; 32 33 41 public class BrokenServerSupport { 42 43 44 private static long brokenAlertLastTime = 0; 45 46 47 private static boolean brokenAlertShown = false; 48 49 50 private static int BROKEN_ALERT_TIMEOUT = 1000; 51 52 private BrokenServerSupport() {} 53 54 61 public static boolean isBroken(String serverInstanceID) { 62 return Deployment.getDefault().getServerID(serverInstanceID) == null; 63 } 64 65 73 public static String selectServer(final String j2eeSpec, final Object moduleType) { 74 return NoSelectedServerWarning.selectServerDialog( 75 new Object [] { moduleType }, j2eeSpec, 76 NbBundle.getMessage(BrokenServerSupport.class, "LBL_Resolve_Missing_Server_Title"), 77 NbBundle.getMessage(BrokenServerSupport.class, "ACSD_Resolve_Missing_Server")); } 79 80 87 public static synchronized void showAlert() { 88 if (Boolean.getBoolean("j2eeserver.no.server.instance.check")) { 89 return; 90 } 91 if (brokenAlertShown 94 || brokenAlertLastTime+BROKEN_ALERT_TIMEOUT > System.currentTimeMillis() 95 || !J2EEUISettings.getDefault().isShowAgainBrokenServerAlert()) { 96 return; 97 } 98 brokenAlertShown = true; 99 SwingUtilities.invokeLater(new Runnable () { 100 public void run() { 101 try { 102 BrokenServerAlertPanel alert = new BrokenServerAlertPanel(); 103 JButton close = new JButton ( 104 NbBundle.getMessage(BrokenServerSupport.class, "LBL_BrokenServerCustomizer_Close")); 105 close.getAccessibleContext().setAccessibleDescription( 106 NbBundle.getMessage(BrokenServerSupport.class, "ACSD_BrokenServerCustomizer_Close")); 107 DialogDescriptor dd = new DialogDescriptor( 108 alert, 109 NbBundle.getMessage(BrokenServerAlertPanel.class, "MSG_Broken_Server_Title"), 110 true, 111 new Object [] {close}, 112 close, 113 DialogDescriptor.DEFAULT_ALIGN, 114 null, 115 null); 116 dd.setMessageType(DialogDescriptor.WARNING_MESSAGE); 117 Dialog dlg = DialogDisplayer.getDefault().createDialog(dd); 118 dlg.setVisible(true); 119 } finally { 120 synchronized (BrokenServerSupport.class) { 121 brokenAlertLastTime = System.currentTimeMillis(); 122 brokenAlertShown = false; 123 } 124 } 125 } 126 }); 127 } 128 } 129 | Popular Tags |