|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun * Microsystems, Inc. All Rights Reserved. */ /* * * */ package org.netbeans.modules.j2ee.deployment.impl.ui.actions; import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties; import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceCreationException; import org.netbeans.modules.j2ee.deployment.impl.ui.FindServerPanel; import org.openide.nodes.*; import org.openide.util.actions.*; import org.openide.*; import org.openide.util.HelpCtx; import org.netbeans.modules.j2ee.deployment.impl.*; import org.openide.util.NbBundle; import org.openide.filesystems.FileObject; import javax.swing.SwingUtilities; /** * @author George FinKlang */ public class FindServerAction extends CookieAction { public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; } public String getName() { return NbBundle.getMessage(FindServerAction.class, "LBL_Add_Server_Instance_NoUrl"); } protected void performAction(org.openide.nodes.Node[] node) { Server s = (Server) node[0].getCookie(Server.class); if (s == null) return; FindServerPanel panel = new FindServerPanel (); String title = NbBundle.getMessage(FindServerAction.class, "LBL_Add_Server_Instance_NoUrl"); DialogDescriptor dialogDescriptor = new DialogDescriptor(panel, title); //dialogDescriptor.setHelpCtx(new HelpCtx(helpId)); //dialogDescriptor.setClosingOptions (new Object [] { NotifyDescriptor.CANCEL_OPTION }); //dialogDescriptor.setValid(false); java.awt.Dialog dialog = DialogDisplayer.getDefault().createDialog(dialogDescriptor); dialog.setVisible(true); if (dialogDescriptor.getValue() == NotifyDescriptor.OK_OPTION ) { String url = panel.getUrl(); String username = panel.getUsername(); String password = panel.getPassword(); InstanceProperties ip = InstanceProperties.getInstanceProperties(url); try { if (ip == null) { ip = InstanceProperties.createInstanceProperties(url, username, password); } else { ip.setProperty(InstanceProperties.USERNAME_ATTR, username); ip.setProperty(InstanceProperties.PASSWORD_ATTR, username); ip.refreshServerInstance(); } } catch (InstanceCreationException icx) { DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(icx.getMessage(), NotifyDescriptor.ERROR_MESSAGE)); } catch (Exception ex) { ErrorManager.getDefault().log(ErrorManager.EXCEPTION, ex.getMessage()); } } } protected Class[] cookieClasses() { return new Class[] { Server.class }; } protected int mode() { return MODE_EXACTLY_ONE; } protected boolean enable(Node[] nodes) { if (nodes == null || nodes.length != 1) return false; Server s = (Server) nodes[0].getCookie(Server.class); if (s == null) return false; return true; } protected boolean asynchronous() { return false; } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.