|
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 java.io.File; import java.io.FileNotFoundException; import javax.swing.JFileChooser; import org.openide.DialogDisplayer; import org.openide.NotifyDescriptor; import org.openide.util.NbBundle; import org.openide.ErrorManager; import org.netbeans.modules.tomcat5.config.Host; import org.netbeans.modules.tomcat5.config.Server; import org.netbeans.modules.tomcat5.config.Service; import org.netbeans.modules.tomcat5.util.TomcatInstallUtil; import org.netbeans.modules.tomcat5.TomcatFactory; import org.netbeans.modules.tomcat5.TomcatManager; import org.w3c.dom.Document; import org.xml.sax.*; import org.openide.xml.XMLUtil; import org.openide.xml.EntityCatalog; import java.io.FileInputStream; import java.io.InputStream; import java.io.BufferedInputStream; import java.io.IOException; import java.util.Properties; import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties; /** * * @author Martin Grebac */ public class TomcatInstall extends javax.swing.JPanel { public static final String OK_ENABLED = "ok_enabled"; //NOI18N private File homeDir; private File baseDir; private String homeDirName; private String baseDirName; private String displayName; private String url; private String username; private String password = ""; private final static String DEFAULT_PORT = TomcatManager.DEFAULT_SERVER_PORT.toString(); private final static String DEFAULT_ADMIN_PORT = TomcatManager.DEFAULT_ADMIN_PORT.toString(); private final static String DEFAULT_HOST = "localhost"; //NOI18N private String port = DEFAULT_PORT; private String adminport = DEFAULT_ADMIN_PORT; private String host = DEFAULT_HOST; private String managerContext = "/manager"; //NOI18N private boolean okEnabled = false; /** Creates new form JPanel */ public TomcatInstall() { okEnabled = false; initComponents(); int size = jLabelHomeDir.getFont().getSize(); setPreferredSize(new java.awt.Dimension(24*size+290,21*size+120)); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ private void initComponents() {//GEN-BEGIN:initComponents java.awt.GridBagConstraints gridBagConstraints; jLabelHomeDir = new javax.swing.JLabel(); jLabelBaseDir = new javax.swing.JLabel(); jTextFieldHomeDir = new javax.swing.JTextField(); jTextFieldBaseDir = new javax.swing.JTextField(); jButtonBaseBrowse = new javax.swing.JButton(); jButtonHomeBrowse = new javax.swing.JButton(); jCheckBoxMonitor = new javax.swing.JCheckBox(); jTextAreaBelow = new javax.swing.JTextArea(); jTextAreaAbove = new javax.swing.JTextArea(); jCheckBoxShared = new javax.swing.JCheckBox(); jLabelHint = new javax.swing.JLabel(); jTextAreaMonitor = new javax.swing.JTextArea(); jTextFieldUsername = new javax.swing.JTextField(); jTextFieldPassword = new javax.swing.JPasswordField(); jLabelUsername = new javax.swing.JLabel(); jLabelPassword = new javax.swing.JLabel(); jTextAreaDisplayName = new javax.swing.JTextArea(); jLabelDisplayName = new javax.swing.JLabel(); jTextFieldDisplayName = new javax.swing.JTextField(); setLayout(new java.awt.GridBagLayout()); getAccessibleContext().setAccessibleName(NbBundle.getMessage(TomcatInstall.class, "A11Y_NAME_panel")); getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(TomcatInstall.class, "A11Y_DESC_panel")); jLabelHomeDir.setDisplayedMnemonic(NbBundle.getMessage(TomcatInstall.class, "LBL_homeDir_Mnem").charAt(0)); jLabelHomeDir.setFont(new java.awt.Font("Dialog", 0, 12)); jLabelHomeDir.setLabelFor(jTextFieldHomeDir); jLabelHomeDir.setText(NbBundle.getMessage(TomcatInstall.class, "LBL_home_dir")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.insets = new java.awt.Insets(6, 12, 0, 0); gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; add(jLabelHomeDir, gridBagConstraints); jLabelHomeDir.getAccessibleContext().setAccessibleName(NbBundle.getMessage(TomcatInstall.class, "A11Y_NAME_labelHomeDir")); jLabelHomeDir.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(TomcatInstall.class, "A11Y_DESC_labelHomeDir")); jLabelBaseDir.setDisplayedMnemonic(NbBundle.getMessage(TomcatInstall.class, "LBL_baseDir_Mnem").charAt(0)); jLabelBaseDir.setFont(new java.awt.Font("Dialog", 0, 12)); jLabelBaseDir.setLabelFor(jTextFieldBaseDir); jLabelBaseDir.setText(NbBundle.getMessage(TomcatInstall.class, "LBL_base_dir")); jLabelBaseDir.setEnabled(false); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 3; gridBagConstraints.insets = new java.awt.Insets(0, 30, 0, 0); gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; add(jLabelBaseDir, gridBagConstraints); jLabelBaseDir.getAccessibleContext().setAccessibleName(NbBundle.getMessage(TomcatInstall.class, "A11Y_NAME_labelBaseDir")); jLabelBaseDir.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(TomcatInstall.class, "A11Y_DESC_labelBaseDir")); jTextFieldHomeDir.setColumns(20); jTextFieldHomeDir.addFocusListener(new java.awt.event.FocusAdapter() { public void focusGained(java.awt.event.FocusEvent evt) { jTextFieldHomeDirFocusGained(evt); } public void focusLost(java.awt.event.FocusEvent evt) { jTextFieldHomeDirFocusLost(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(6, 6, 0, 0); gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; add(jTextFieldHomeDir, gridBagConstraints); jTextFieldHomeDir.getAccessibleContext().setAccessibleName(NbBundle.getMessage(TomcatInstall.class, "A11Y_NAME_homeDir")); jTextFieldHomeDir.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(TomcatInstall.class, "A11Y_DESC_homeDir")); jTextFieldBaseDir.setEditable(false); jTextFieldBaseDir.setEnabled(false); jTextFieldBaseDir.addFocusListener(new java.awt.event.FocusAdapter() { public void focusGained(java.awt.event.FocusEvent evt) { jTextFieldBaseDirFocusGained(evt); } public void focusLost(java.awt.event.FocusEvent evt) { jTextFieldBaseDirFocusLost(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(0, 6, 0, 0); gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; add(jTextFieldBaseDir, gridBagConstraints); jTextFieldBaseDir.getAccessibleContext().setAccessibleName(NbBundle.getMessage(TomcatInstall.class, "A11Y_NAME_baseDir")); jTextFieldBaseDir.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(TomcatInstall.class, "A11Y_DESC_baseDir")); jButtonBaseBrowse.setFont(new java.awt.Font("Dialog", 0, 12)); jButtonBaseBrowse.setMnemonic(NbBundle.getMessage(TomcatInstall.class, "LBL_browseBase_Mnem").charAt(0)); jButtonBaseBrowse.setText(NbBundle.getMessage(TomcatInstall.class, "LBL_file_chooser_base")); jButtonBaseBrowse.setLabel(NbBundle.getMessage(TomcatInstall.class, "LBL_file_chooser_base")); jButtonBaseBrowse.setEnabled(false); jButtonBaseBrowse.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonBaseBrowseActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 3; gridBagConstraints.insets = new java.awt.Insets(0, 6, 0, 11); gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; add(jButtonBaseBrowse, gridBagConstraints); jButtonBaseBrowse.getAccessibleContext().setAccessibleName(NbBundle.getMessage(TomcatInstall.class, "A11Y_NAME_ButtonBaseBrowse")); jButtonBaseBrowse.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(TomcatInstall.class, "A11Y_DESC_ButtonBaseBrowse")); jButtonHomeBrowse.setFont(new java.awt.Font("Dialog", 0, 12)); jButtonHomeBrowse.setMnemonic(NbBundle.getMessage(TomcatInstall.class, "LBL_browseHome_Mnem").charAt(0)); jButtonHomeBrowse.setText(NbBundle.getMessage(TomcatInstall.class, "LBL_file_chooser_home")); jButtonHomeBrowse.setLabel(NbBundle.getMessage(TomcatInstall.class, "LBL_file_chooser_home")); jButtonHomeBrowse.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonHomeBrowseActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 1; gridBagConstraints.insets = new java.awt.Insets(6, 6, 0, 11); gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; add(jButtonHomeBrowse, gridBagConstraints); jButtonHomeBrowse.getAccessibleContext().setAccessibleName(NbBundle.getMessage(TomcatInstall.class, "A11Y_NAME_ButtonHomeBrowse")); jButtonHomeBrowse.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(TomcatInstall.class, "A11Y_DESC_ButtonHomeBrowse")); jCheckBoxMonitor.setFont(new java.awt.Font("Dialog", 0, 12)); jCheckBoxMonitor.setMnemonic(NbBundle.getMessage(TomcatInstall.class, "LBL_Monitor_Mnem").charAt(0)); jCheckBoxMonitor.setSelected(true); jCheckBoxMonitor.setText(NbBundle.getMessage(TomcatInstall.class, "LBL_Monitor")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 10; gridBagConstraints.gridwidth = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(23, 12, 0, 0); add(jCheckBoxMonitor, gridBagConstraints); jCheckBoxMonitor.getAccessibleContext().setAccessibleName(NbBundle.getMessage(TomcatInstall.class, "A11Y_NAME_monitor")); jCheckBoxMonitor.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(TomcatInstall.class, "A11Y_DESC_monitor")); jTextAreaBelow.setFont(new java.awt.Font("Dialog", 0, 12)); jTextAreaBelow.setBackground(jLabelHomeDir.getBackground()); jTextAreaBelow.setEditable(false); jTextAreaBelow.setLineWrap(true); jTextAreaBelow.setText(NbBundle.getMessage(TomcatInstall.class, "MSG_TextBelow")); jTextAreaBelow.setWrapStyleWord(true); jTextAreaBelow.setFocusable(false); jTextAreaBelow.setSelectionColor(new java.awt.Color(204, 204, 204)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 11; gridBagConstraints.gridwidth = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.insets = new java.awt.Insets(0, 30, 6, 12); add(jTextAreaBelow, gridBagConstraints); jTextAreaBelow.getAccessibleContext().setAccessibleName(NbBundle.getMessage(TomcatInstall.class, "A11Y_NAME_textAreaBelow")); jTextAreaBelow.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(TomcatInstall.class, "A11Y_DESC_textAreaBelow")); jTextAreaAbove.setFont(new java.awt.Font("Dialog", 0, 12)); jTextAreaAbove.setBackground(jLabelHomeDir.getBackground()); jTextAreaAbove.setEditable(false); jTextAreaAbove.setLineWrap(true); jTextAreaAbove.setText(NbBundle.getMessage(TomcatInstall.class, "MSG_TextAbove")); jTextAreaAbove.setWrapStyleWord(true); jTextAreaAbove.setDisabledTextColor(new java.awt.Color(255, 153, 153)); jTextAreaAbove.setFocusable(false); jTextAreaAbove.setSelectionColor(new java.awt.Color(204, 204, 204)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 12); add(jTextAreaAbove, gridBagConstraints); jTextAreaAbove.getAccessibleContext().setAccessibleName(NbBundle.getMessage(TomcatInstall.class, "A11Y_NAME_textAreaAbove")); jTextAreaAbove.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(TomcatInstall.class, "A11Y_DESC_textAreaAbove")); jCheckBoxShared.setFont(new java.awt.Font("Dialog", 0, 12)); jCheckBoxShared.setMnemonic(NbBundle.getMessage(TomcatInstall.class, "LBL_SharedInstall_Mnem").charAt(0)); jCheckBoxShared.setText(NbBundle.getMessage(TomcatInstall.class, "LBL_SharedInstall")); jCheckBoxShared.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jCheckBoxSharedActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; gridBagConstraints.gridwidth = 2; gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 0); gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; add(jCheckBoxShared, gridBagConstraints); jCheckBoxShared.getAccessibleContext().setAccessibleName(NbBundle.getMessage(TomcatInstall.class, "A11Y_NAME_shared")); jCheckBoxShared.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(TomcatInstall.class, "A11Y_DESC_shared")); jLabelHint.setFont(new java.awt.Font("Dialog", 0, 12)); jLabelHint.setForeground(new java.awt.Color(89, 79, 191)); jLabelHint.setText(NbBundle.getMessage(TomcatInstall.class, "MSG_SpecifyHomeDir")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 12; gridBagConstraints.gridwidth = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.ipady = 17; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; gridBagConstraints.weighty = 1.0; gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 12); add(jLabelHint, gridBagConstraints); jLabelHint.getAccessibleContext().setAccessibleName(NbBundle.getMessage(TomcatInstall.class, "A11Y_NAME_SpecifyHomeDir")); jLabelHint.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(TomcatInstall.class, "A11Y_DESC_SpecifyHomeDir")); jTextAreaMonitor.setFont(new java.awt.Font("Dialog", 0, 12)); jTextAreaMonitor.setBackground(jLabelHomeDir.getBackground()); jTextAreaMonitor.setEditable(false); jTextAreaMonitor.setLineWrap(true); jTextAreaMonitor.setText(NbBundle.getMessage(TomcatInstall.class, "MSG_TextMonitor")); jTextAreaMonitor.setWrapStyleWord(true); jTextAreaMonitor.setFocusable(false); jTextAreaMonitor.setSelectionColor(new java.awt.Color(204, 204, 204)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 6; gridBagConstraints.gridwidth = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 12); add(jTextAreaMonitor, gridBagConstraints); jTextAreaMonitor.getAccessibleContext().setAccessibleName(NbBundle.getMessage(TomcatInstall.class, "A11Y_NAME_textAreaMiddle")); jTextAreaMonitor.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(TomcatInstall.class, "A11Y_DESC_textAreaMiddle")); jTextFieldUsername.setColumns(20); jTextFieldUsername.addCaretListener(new javax.swing.event.CaretListener() { public void caretUpdate(javax.swing.event.CaretEvent evt) { jTextFieldUsernameCaretUpdate(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 8; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(6, 6, 0, 0); add(jTextFieldUsername, gridBagConstraints); jTextFieldUsername.getAccessibleContext().setAccessibleName(NbBundle.getMessage(TomcatInstall.class, "A11Y_NAME_username")); jTextFieldUsername.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(TomcatInstall.class, "A11Y_DESC_username")); jTextFieldPassword.setColumns(20); jTextFieldPassword.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { jTextFieldPasswordFocusLost(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 9; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(6, 6, 0, 0); add(jTextFieldPassword, gridBagConstraints); jTextFieldPassword.getAccessibleContext().setAccessibleName(NbBundle.getMessage(TomcatInstall.class, "A11Y_NAME_password")); jTextFieldPassword.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(TomcatInstall.class, "A11Y_DESC_password")); jLabelUsername.setDisplayedMnemonic(NbBundle.getMessage(TomcatInstall.class, "LBL_Username_Mnem").charAt(0)); jLabelUsername.setFont(new java.awt.Font("Dialog", 0, 12)); jLabelUsername.setLabelFor(jTextFieldUsername); jLabelUsername.setText(NbBundle.getMessage(TomcatInstall.class, "LBL_Username")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 8; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(6, 12, 0, 0); add(jLabelUsername, gridBagConstraints); jLabelUsername.getAccessibleContext().setAccessibleName(NbBundle.getMessage(TomcatInstall.class, "A11Y_NAME_labelUsername")); jLabelUsername.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(TomcatInstall.class, "A11Y_DESC_labelUsername")); jLabelPassword.setDisplayedMnemonic(NbBundle.getMessage(TomcatInstall.class, "LBL_Password_Mnem").charAt(0)); jLabelPassword.setFont(new java.awt.Font("Dialog", 0, 12)); jLabelPassword.setLabelFor(jTextFieldPassword); jLabelPassword.setText(NbBundle.getMessage(TomcatInstall.class, "LBL_Password")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 9; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(6, 12, 0, 0); add(jLabelPassword, gridBagConstraints); jLabelPassword.getAccessibleContext().setAccessibleName(NbBundle.getMessage(TomcatInstall.class, "A11Y_NAME_labelPassword")); jLabelPassword.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(TomcatInstall.class, "A11Y_DESC_labelPassword")); jTextAreaDisplayName.setFont(new java.awt.Font("Dialog", 0, 12)); jTextAreaDisplayName.setBackground(jLabelDisplayName.getBackground()); jTextAreaDisplayName.setEditable(false); jTextAreaDisplayName.setLineWrap(true); jTextAreaDisplayName.setText(NbBundle.getMessage (TomcatInstall.class, "MSG_DisplayName")); jTextAreaDisplayName.setWrapStyleWord(true); jTextAreaDisplayName.setFocusable(false); jTextAreaDisplayName.setSelectionColor(new java.awt.Color(204, 204, 204)); jTextAreaDisplayName.setSelectionEnd(11); jTextAreaDisplayName.setSelectionStart(11); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 4; gridBagConstraints.gridwidth = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 12); add(jTextAreaDisplayName, gridBagConstraints); jTextAreaDisplayName.getAccessibleContext().setAccessibleName(NbBundle.getMessage (TomcatInstall.class, "A11Y_NAME_MSG_DisplayName")); jTextAreaDisplayName.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage (TomcatInstall.class, "A11Y_DESC_MSG_DisplayName")); jLabelDisplayName.setDisplayedMnemonic(NbBundle.getMessage (TomcatInstall.class, "LBL_DisplayName_Mnem").charAt(0)); jLabelDisplayName.setFont(new java.awt.Font("Dialog", 0, 12)); jLabelDisplayName.setLabelFor(jTextFieldDisplayName); jLabelDisplayName.setText(NbBundle.getMessage (TomcatInstall.class, "LBL_DisplayName")); jLabelDisplayName.setMaximumSize(new java.awt.Dimension(90, 15)); jLabelDisplayName.setMinimumSize(new java.awt.Dimension(90, 15)); jLabelDisplayName.setPreferredSize(new java.awt.Dimension(90, 15)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 5; gridBagConstraints.insets = new java.awt.Insets(6, 12, 0, 0); gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; add(jLabelDisplayName, gridBagConstraints); jLabelDisplayName.getAccessibleContext().setAccessibleName(NbBundle.getMessage (TomcatInstall.class, "A11Y_NAME_DisplayName")); jLabelDisplayName.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage (TomcatInstall.class, "A11Y_DESC_DisplayName")); jTextFieldDisplayName.addCaretListener(new javax.swing.event.CaretListener() { public void caretUpdate(javax.swing.event.CaretEvent evt) { jTextFieldDisplayNameCaretUpdate(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 5; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(6, 6, 0, 0); gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; add(jTextFieldDisplayName, gridBagConstraints); jTextFieldDisplayName.getAccessibleContext().setAccessibleName(NbBundle.getMessage (TomcatInstall.class, "A11Y_NAME_DisplayName")); jTextFieldDisplayName.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage (TomcatInstall.class, "A11Y_DESC_DisplayName")); }//GEN-END:initComponents private void jTextFieldUsernameCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_jTextFieldUsernameCaretUpdate String uname = jTextFieldUsername.getText(); if (uname.equals(this.username) ) { return; } username = uname; updateHint(); }//GEN-LAST:event_jTextFieldUsernameCaretUpdate private void jTextFieldDisplayNameCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_jTextFieldDisplayNameCaretUpdate String aDisplayName = jTextFieldDisplayName.getText(); if (aDisplayName.equals(displayName) ) { return; } displayName = jTextFieldDisplayName.getText(); updateHint(); }//GEN-LAST:event_jTextFieldDisplayNameCaretUpdate private void jTextFieldPasswordFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldPasswordFocusLost String pwd = jTextFieldPassword.getText(); if (pwd.equals(this.password) ) { return; } password = pwd; updateHint(); }//GEN-LAST:event_jTextFieldPasswordFocusLost private void jTextFieldBaseDirFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldBaseDirFocusLost String path = jTextFieldBaseDir.getText(); if ( baseDirName.equals( path ) ) return; baseDirName = path; if ( path.length() > 0 ) baseDir = getValidDir( baseDirName, jTextFieldBaseDir); else baseDir = null; if ( baseDir != null ) if ( ! validateInput( false ) ) { jTextFieldBaseDir.setText( "" ); // NOI18N baseDir = null; jTextFieldBaseDir.requestFocus(); } updateUrl(); updateHint(); }//GEN-LAST:event_jTextFieldBaseDirFocusLost private void jTextFieldBaseDirFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldBaseDirFocusGained baseDirName = jTextFieldBaseDir.getText(); updateUrl(); updateHint(); }//GEN-LAST:event_jTextFieldBaseDirFocusGained private void jTextFieldHomeDirFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldHomeDirFocusGained homeDirName = jTextFieldHomeDir.getText(); updateUrl(); updateHint(); }//GEN-LAST:event_jTextFieldHomeDirFocusGained private void jTextFieldHomeDirFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldHomeDirFocusLost String path = jTextFieldHomeDir.getText(); if ( homeDirName.equals( path ) ) return; homeDirName = path; if ( path.length() > 0 ) homeDir = getValidDir( homeDirName, jTextFieldHomeDir); else homeDir = null; if ( homeDir != null ) if ( ! validateInput( true ) ) { jTextFieldHomeDir.setText( "" ); // NOI18N homeDir = null; jTextFieldHomeDir.requestFocus(); } updateUrl(); updateHint(); }//GEN-LAST:event_jTextFieldHomeDirFocusLost private void jButtonBaseBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBaseBrowseActionPerformed JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if ( baseDir != null ) chooser.setSelectedFile( baseDir ); boolean repeatchooser = true; while ( repeatchooser ) { repeatchooser = false; if ( chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION ) { baseDir = chooser.getSelectedFile(); if ( validateInput( false ) ) jTextFieldBaseDir.setText( baseDir.getAbsolutePath() ); else { jTextFieldBaseDir.setText( "" ); // NOI18N baseDir = null; repeatchooser = true; } } } updateUrl(); updateHint(); }//GEN-LAST:event_jButtonBaseBrowseActionPerformed private void jButtonHomeBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonHomeBrowseActionPerformed JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if ( homeDir != null ) chooser.setSelectedFile( homeDir ); boolean repeatchooser = true; while ( repeatchooser ) { repeatchooser = false; if ( chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION ) { homeDir = chooser.getSelectedFile(); if ( validateInput( true ) ) { jTextFieldHomeDir.setText(homeDir.getAbsolutePath()); } else { jTextFieldHomeDir.setText( "" ); // NOI18N homeDir = null; repeatchooser = true; } } } updateUrl(); updateHint(); }//GEN-LAST:event_jButtonHomeBrowseActionPerformed private void jCheckBoxSharedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxSharedActionPerformed boolean cbSelected; cbSelected = jCheckBoxShared.isSelected(); jLabelBaseDir.setEnabled(cbSelected); jTextFieldBaseDir.setEnabled(cbSelected); jTextFieldBaseDir.setEditable(cbSelected); jButtonBaseBrowse.setEnabled(cbSelected); updateUrl(); updateHint(); }//GEN-LAST:event_jCheckBoxSharedActionPerformed public String getPassword() { return password; } public java.util.Properties getProperties() { Properties p = new Properties(); p.put(TomcatManager.SERVER_PORT, port); //NOI18N p.put(TomcatManager.ADMIN_PORT, adminport); //NOI18N p.put(MonitorSupport.MONITOR_ENABLED_PROPERTY_NAME, new Boolean(jCheckBoxMonitor.isSelected()).toString ()); //NOI18N p.put(TomcatManager.HOST, "localhost"); //NOI18N return p; } /** * Return deployment manager URL (e.g. "tomcat:home=jakarta-tomcat-5.0.28:base=jakarta-tomcat-5.0.28_base"). * * @return deployment manager URL (e.g. "tomcat:home=jakarta-tomcat-5.0.28:base=jakarta-tomcat-5.0.28_base"). */ public String getUrl() { return url; } public String getUserName() { return username; } /** * Return Tomcat instance display name. * * @return Tomcat instance display name. */ public String getDisplayName() { return displayName; } // returns false if input have to be revoked public boolean validateInput(boolean homeEntered) { if ( homeEntered ) { if (TomcatInstallUtil.noServerXML(homeDir, baseDir) || TomcatInstallUtil.noBootStrapJar(homeDir)) { NotifyDescriptor.Confirmation nd = new NotifyDescriptor.Confirmation( NbBundle.getBundle (TomcatInstall.class).getString("MSG_no_server_xml"), NotifyDescriptor.OK_CANCEL_OPTION ); if (DialogDisplayer.getDefault().notify( nd ).equals( NotifyDescriptor.OK_OPTION )) { jCheckBoxShared.setSelected(true); jTextFieldBaseDir.setEnabled(true); jTextFieldBaseDir.setEditable(true); jButtonBaseBrowse.setEnabled(true); jLabelBaseDir.setEnabled(true); jTextFieldBaseDir.requestFocusInWindow(); jLabelHint.setText(NbBundle.getMessage(TomcatInstall.class, "MSG_SpecifyBaseDir")); return updateFields(); } else { return false; } } } /* if (TomcatInstallUtil.sameAsOtherTomcatInstallation(homeDir, baseDir)) { DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message (NbBundle.getBundle (TomcatInstall.class).getString("MSG_installation_exists"), NotifyDescriptor.ERROR_MESSAGE)); return true; } */ return updateFields(); } private boolean updateFields() { InputStream inputStream = null; try { if (jCheckBoxShared.isSelected()) { try { inputStream = new BufferedInputStream(new FileInputStream( new File(baseDir + "/conf/server.xml"))); } catch (FileNotFoundException fnfe) { // CATALINA_BASE dir is probably empty } } if (inputStream == null) { inputStream = new BufferedInputStream(new FileInputStream( new File(homeDir + "/conf/server.xml"))); } Document doc = XMLUtil.parse(new InputSource(inputStream), false, false, null, EntityCatalog.getDefault()); Server server = Server.createGraph(doc); host = TomcatInstallUtil.getHost(server); String p = TomcatInstallUtil.getPort(server); try { Integer i = Integer.valueOf(p); } catch (Exception e) { DialogDisplayer.getDefault().notify( new NotifyDescriptor.Message(NbBundle.getMessage(TomcatInstall.class, "MSG_ServerPortError", p), NotifyDescriptor.ERROR_MESSAGE)); return false; } port = p; String a = TomcatInstallUtil.getAdminPort(server); if (a == null) { // admin port is not set, use the default one adminport = DEFAULT_ADMIN_PORT; } else { try { Integer i = Integer.valueOf(a); adminport = a; } catch (Exception e) { DialogDisplayer.getDefault().notify( new NotifyDescriptor.Message( NbBundle.getMessage(TomcatInstall.class, "MSG_AdminPortError", a), NotifyDescriptor.ERROR_MESSAGE)); return false; } } return true; } catch (Exception e) { DialogDisplayer.getDefault().notify( new NotifyDescriptor.Message( NbBundle.getMessage(TomcatInstall.class, "MSG_ServerXmlError"), NotifyDescriptor.ERROR_MESSAGE)); return false; } finally { if (inputStream != null) { try { inputStream.close(); } catch(IOException ioe) { // ignore it } } } } private File getValidDir(String pathname, javax.swing.JTextField field) { if ( pathname != null/* && pathname.length() > 0*/ ) { try { File dir = new File( pathname ); if ( dir != null && dir.isDirectory() ) { if (dir.exists()) { return dir; } } } catch ( Exception e ) { } } DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message (NbBundle.getBundle (TomcatInstall.class).getString("MSG_no_valid_directory"), NotifyDescriptor.ERROR_MESSAGE)); field.requestFocus(); return null; } private void updateHint() { boolean cbSelected; boolean okEnabledNew = false; cbSelected = jCheckBoxShared.isSelected(); baseDirName = jTextFieldBaseDir.getText(); if (!isHomeDirValid()) { jLabelHint.setText(NbBundle.getMessage(TomcatInstall.class, "MSG_SpecifyHomeDir")); } else if (cbSelected && !isBaseDirValid()) { jLabelHint.setText(NbBundle.getMessage(TomcatInstall.class, "MSG_SpecifyBaseDir")); } else if (!isDisplayNameValid()) { jLabelHint.setText(NbBundle.getMessage(TomcatInstall.class, "MSG_SpecifyDisplayName")); } else if (!isUsernameValid()) { jLabelHint.setText(NbBundle.getMessage(TomcatInstall.class, "MSG_SpecifyUsername")); } else { jLabelHint.setText(null); okEnabledNew = true; } if (okEnabled != okEnabledNew) { firePropertyChange(OK_ENABLED, okEnabled, okEnabledNew); okEnabled = okEnabledNew; } } private boolean isHomeDirValid() { if (homeDir != null) {// && (homeDirName.length() > 0)) { return true; } return false; } private boolean isBaseDirValid() { if (baseDir != null) {// && (baseDirName.length() > 0)) { return true; } return false; } private boolean isDisplayNameValid() { if ((displayName != null) && (displayName.length() > 0)) { return true; } return false; } private boolean isUsernameValid() { if ((username != null) && (username.length() > 0)) { return true; } return false; } private void updateUrl() { url = TomcatFactory.tomcatUriPrefix + "home=" + homeDir; // NOI18N if (baseDir != null) { url += ":base=" + baseDir; // NOI18N } if (TomcatFactory.getEM ().isLoggable (ErrorManager.INFORMATIONAL)) { TomcatFactory.getEM ().log ("TInstall.updateUrl: " + url); // NOI18N } } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButtonBaseBrowse; private javax.swing.JButton jButtonHomeBrowse; private javax.swing.JCheckBox jCheckBoxMonitor; private javax.swing.JCheckBox jCheckBoxShared; private javax.swing.JLabel jLabelBaseDir; private javax.swing.JLabel jLabelDisplayName; private javax.swing.JLabel jLabelHint; private javax.swing.JLabel jLabelHomeDir; private javax.swing.JLabel jLabelPassword; private javax.swing.JLabel jLabelUsername; private javax.swing.JTextArea jTextAreaAbove; private javax.swing.JTextArea jTextAreaBelow; private javax.swing.JTextArea jTextAreaDisplayName; private javax.swing.JTextArea jTextAreaMonitor; private javax.swing.JTextField jTextFieldBaseDir; private javax.swing.JTextField jTextFieldDisplayName; private javax.swing.JTextField jTextFieldHomeDir; private javax.swing.JPasswordField jTextFieldPassword; private javax.swing.JTextField jTextFieldUsername; // End of variables declaration//GEN-END:variables } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 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.