|
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-2004 Sun * Microsystems, Inc. All Rights Reserved. */ /* * * */ package org.netbeans.modules.tomcat5.ide; import org.openide.nodes.*; import org.openide.util.actions.*; import org.openide.*; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; import org.openide.filesystems.FileObject; import javax.swing.SwingUtilities; import org.netbeans.modules.tomcat5.TomcatManager; import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties; import java.beans.*; import java.util.*; /** * @author Martin Grebac */ public class AddServerAction extends NodeAction implements PropertyChangeListener { DialogDescriptor dialogDescriptor; public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; } public String getName() { return NbBundle.getMessage(AddServerAction.class, "LBL_Add_Server_Instance"); } protected void performAction(org.openide.nodes.Node[] node) { TomcatInstall panel = new TomcatInstall(); if (panel == null) return; panel.addPropertyChangeListener(this); String title = NbBundle.getMessage(AddServerAction.class, "LBL_Add_Server_Instance"); dialogDescriptor = new DialogDescriptor(panel, title); dialogDescriptor.setHelpCtx(new HelpCtx("tomcat_addinstall")); dialogDescriptor.setTitle(NbBundle.getMessage(AddServerAction.class, "LBL_Add_Server_Instance_Title")); //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 displayName = panel.getDisplayName(); String url = panel.getUrl(); String username = panel.getUserName(); String password = panel.getPassword(); try { InstanceProperties ip = InstanceProperties.createInstanceProperties( url, username, password, displayName); Properties prop = panel.getProperties (); Enumeration en = prop.propertyNames (); while (en.hasMoreElements ()) { String key = (String) en.nextElement (); ip.setProperty (key, prop.getProperty (key)); } } catch (Exception ex) { ErrorManager.getDefault().log(ErrorManager.EXCEPTION, ex.getMessage()); } } } public void propertyChange(PropertyChangeEvent evt) { if (evt == null) { return; } if (evt.getPropertyName().equals(TomcatInstall.OK_ENABLED)) { Object newvalue = evt.getNewValue(); if ((newvalue != null) && (newvalue instanceof Boolean)) { boolean valid = ((Boolean)newvalue).booleanValue(); dialogDescriptor.setValid(valid); } } } protected boolean enable(Node[] nodes) { 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.