KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > deployment > devmodules > api > ServerManager


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.j2ee.deployment.devmodules.api;
20
21 import java.awt.Dialog JavaDoc;
22 import org.openide.DialogDescriptor;
23 import org.openide.DialogDisplayer;
24 import org.openide.util.HelpCtx;
25 import org.openide.util.NbBundle;
26 import javax.swing.JButton JavaDoc;
27 import org.netbeans.modules.j2ee.deployment.impl.ServerInstance;
28 import org.netbeans.modules.j2ee.deployment.impl.ServerRegistry;
29 import org.netbeans.modules.j2ee.deployment.impl.ui.ServersCustomizer;
30
31 /**
32  * ServerManager class provides access to the Server Manager dialog.
33  *
34  * @author sherold
35  * @since 1.7
36  */

37 public final class ServerManager {
38
39     /** Do not allow to create instances of this class */
40     private ServerManager() {
41     }
42     
43     /**
44      * Display the modal Server Manager dialog with the specified server instance
45      * preselected. This method should be called form the AWT event dispatch
46      * thread.
47      *
48      * @param serverInstanceID server instance which should be preselected, if
49      * null the first server instance will be preselected.
50      */

51     public static void showCustomizer(String JavaDoc serverInstanceID) {
52         ServerInstance instance = ServerRegistry.getInstance().getServerInstance(serverInstanceID);
53         ServersCustomizer customizer = new ServersCustomizer(instance);
54         JButton JavaDoc close = new JButton JavaDoc(NbBundle.getMessage(ServerManager.class,"CTL_Close"));
55         close.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ServerManager.class,"AD_Close"));
56         DialogDescriptor descriptor = new DialogDescriptor (
57                 customizer,
58                 NbBundle.getMessage(ServerManager.class, "TXT_ServerManager"),
59                 true,
60                 new Object JavaDoc[] {close},
61                 close,
62                 DialogDescriptor.DEFAULT_ALIGN,
63                 new HelpCtx(ServerManager.class),
64                 null);
65         Dialog JavaDoc dlg = null;
66         try {
67             dlg = DialogDisplayer.getDefault().createDialog(descriptor);
68             dlg.setVisible(true);
69         } finally {
70             if (dlg != null) {
71                 dlg.dispose();
72             }
73         }
74     }
75 }
76
Popular Tags