This is an automated email from the ASF dual-hosted git repository.

thurka pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new ffe7c65bf2 added option to add the database connection while 
downloading Database Wallet
     new 348b0cd295 Merge pull request #6763 from thurka/GCN-3755
ffe7c65bf2 is described below

commit ffe7c65bf2136768d1e04d15dcfb3120d440ff4a
Author: Tomas Hurka <tomas.hu...@gmail.com>
AuthorDate: Wed Nov 29 10:39:41 2023 +0100

    added option to add the database connection while downloading Database 
Wallet
---
 .../modules/cloud/oracle/actions/Bundle.properties |  12 +-
 .../cloud/oracle/actions/DownloadWalletDialog.form |  94 +++++++------
 .../cloud/oracle/actions/DownloadWalletDialog.java | 152 ++++++++++++++-------
 3 files changed, 165 insertions(+), 93 deletions(-)

diff --git 
a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/Bundle.properties
 
b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/Bundle.properties
index d15c8ee33c..9a9166bac7 100644
--- 
a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/Bundle.properties
+++ 
b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/Bundle.properties
@@ -21,13 +21,15 @@ CreateAutonomousDBDialog.jLabel2.text=Password:
 CreateAutonomousDBDialog.jPasswordField1.text=
 CreateAutonomousDBDialog.jLabel3.text=Confirm Password:
 CreateAutonomousDBDialog.jPasswordField2.text=
-DownloadWalletDialog.jLabel2.text=Confirm Password:
-DownloadWalletDialog.jLabel1.text=Password:
-DownloadWalletDialog.jTextArea1.text=Database connections to your Autonomous 
Database use a secure connection. The wallet file will be required to configure 
your database clients and tools to access Autonomous Database.\n\nPlease create 
a password for this wallet. Some database clients will require that you provide 
both the wallet and password to connect to your database (other clients will 
auto-login using the wallet without a password).
+DownloadWalletDialog.jTextArea1.text=Database connections to your Autonomous 
Database use a secure connection. The wallet file will be required to configure 
your database clients and tools to access Autonomous Database.\n\nA password 
will be created for this wallet. Some database clients will require that you 
provide both the wallet and password to connect to your database (other clients 
will auto-login using the wallet without a password).
 DownloadWalletDialog.jButtonBrowse.text=Browse...
-DownloadWalletDialog.jPasswordField.text=
-DownloadWalletDialog.jPasswordFieldConfirm.text=
 DownloadWalletDialog.jTextFieldLocation.text=
 DownloadWalletDialog.jLabel3.text=Wallet Directory:
 CreateAutonomousDBDialog.jTextArea1.text=Creates a new Autonomous Database.
 CreateAutonomousDBDialog.jLabel4.text=Set the password for your Autonomous 
Database ADMIN user here.
+DownloadWalletDialog.dbUserField.text=
+DownloadWalletDialog.dbPasswordField.text=
+DownloadWalletDialog.dbUserLabel.text=DB Username:
+DownloadWalletDialog.dbPasswordLabel.text=DB Password:
+DownloadWalletDialog.addDBCheckbox.toolltip=In addition to downloading Wallet, 
it also adds this database connection to the database manager.
+DownloadWalletDialog.addDBCheckbox.text=Add As Database Connection
diff --git 
a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/DownloadWalletDialog.form
 
b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/DownloadWalletDialog.form
index fe0a4f2611..546029ac11 100644
--- 
a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/DownloadWalletDialog.form
+++ 
b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/DownloadWalletDialog.form
@@ -45,25 +45,29 @@
   <Layout>
     <DimensionLayout dim="0">
       <Group type="103" groupAlignment="0" attributes="0">
-          <Group type="102" alignment="0" attributes="0">
+          <Group type="102" attributes="0">
               <EmptySpace max="-2" attributes="0"/>
               <Group type="103" groupAlignment="0" attributes="0">
                   <Component id="jTextArea1" max="32767" attributes="0"/>
                   <Group type="102" attributes="0">
                       <Group type="103" groupAlignment="0" attributes="0">
-                          <Component id="jLabel2" alignment="0" min="-2" 
max="-2" attributes="0"/>
                           <Component id="jLabel3" alignment="0" min="-2" 
max="-2" attributes="0"/>
-                          <Component id="jLabel1" alignment="0" min="-2" 
max="-2" attributes="0"/>
+                          <Component id="dbUserLabel" alignment="0" min="-2" 
max="-2" attributes="0"/>
+                          <Component id="dbPasswordLabel" alignment="0" 
min="-2" max="-2" attributes="0"/>
                       </Group>
-                      <EmptySpace type="unrelated" max="-2" attributes="0"/>
-                      <Group type="103" groupAlignment="0" attributes="0">
-                          <Component id="jPasswordField" max="32767" 
attributes="0"/>
-                          <Component id="jTextFieldLocation" max="32767" 
attributes="0"/>
-                          <Component id="jPasswordFieldConfirm" max="32767" 
attributes="0"/>
+                      <EmptySpace min="-2" pref="27" max="-2" attributes="0"/>
+                      <Group type="103" groupAlignment="1" attributes="0">
+                          <Component id="jTextFieldLocation" alignment="0" 
max="32767" attributes="0"/>
+                          <Component id="dbPasswordField" max="32767" 
attributes="0"/>
+                          <Component id="dbUserField" max="32767" 
attributes="0"/>
                       </Group>
                       <EmptySpace max="-2" attributes="0"/>
                       <Component id="jButtonBrowse" min="-2" max="-2" 
attributes="0"/>
                   </Group>
+                  <Group type="102" alignment="0" attributes="0">
+                      <Component id="addDBCheckbox" min="-2" pref="344" 
max="-2" attributes="0"/>
+                      <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
+                  </Group>
               </Group>
               <EmptySpace max="-2" attributes="0"/>
           </Group>
@@ -74,23 +78,25 @@
           <Group type="102" alignment="0" attributes="0">
               <EmptySpace max="-2" attributes="0"/>
               <Component id="jTextArea1" min="-2" pref="113" max="-2" 
attributes="0"/>
-              <EmptySpace max="-2" attributes="0"/>
+              <EmptySpace type="separate" max="-2" attributes="0"/>
               <Group type="103" groupAlignment="3" attributes="0">
-                  <Component id="jLabel1" alignment="3" min="-2" max="-2" 
attributes="0"/>
-                  <Component id="jPasswordField" alignment="3" min="-2" 
max="-2" attributes="0"/>
+                  <Component id="jLabel3" alignment="3" min="-2" max="-2" 
attributes="0"/>
+                  <Component id="jTextFieldLocation" alignment="3" min="-2" 
max="-2" attributes="0"/>
+                  <Component id="jButtonBrowse" alignment="3" min="-2" 
max="-2" attributes="0"/>
               </Group>
               <EmptySpace max="-2" attributes="0"/>
+              <Component id="addDBCheckbox" min="-2" pref="17" max="-2" 
attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
               <Group type="103" groupAlignment="3" attributes="0">
-                  <Component id="jLabel2" alignment="3" min="-2" max="-2" 
attributes="0"/>
-                  <Component id="jPasswordFieldConfirm" alignment="3" min="-2" 
max="-2" attributes="0"/>
+                  <Component id="dbUserLabel" alignment="3" min="-2" max="-2" 
attributes="0"/>
+                  <Component id="dbUserField" alignment="3" min="-2" max="-2" 
attributes="0"/>
               </Group>
               <EmptySpace max="-2" attributes="0"/>
               <Group type="103" groupAlignment="3" attributes="0">
-                  <Component id="jLabel3" alignment="3" min="-2" max="-2" 
attributes="0"/>
-                  <Component id="jTextFieldLocation" alignment="3" min="-2" 
max="-2" attributes="0"/>
-                  <Component id="jButtonBrowse" alignment="3" min="-2" 
max="-2" attributes="0"/>
+                  <Component id="dbPasswordLabel" alignment="3" min="-2" 
max="-2" attributes="0"/>
+                  <Component id="dbPasswordField" alignment="3" min="-2" 
max="-2" attributes="0"/>
               </Group>
-              <EmptySpace pref="16" max="32767" attributes="0"/>
+              <EmptySpace max="32767" attributes="0"/>
           </Group>
       </Group>
     </DimensionLayout>
@@ -109,7 +115,6 @@
         <Property name="border" type="javax.swing.border.Border" 
editor="org.netbeans.modules.form.editors2.BorderEditor">
           <Border info="null"/>
         </Property>
-        <Property name="dragEnabled" type="boolean" value="false"/>
         <Property name="focusTraversalKeysEnabled" type="boolean" 
value="false"/>
         <Property name="focusable" type="boolean" value="false"/>
         <Property name="minimumSize" type="java.awt.Dimension" 
editor="org.netbeans.beaninfo.editors.DimensionEditor">
@@ -122,65 +127,76 @@
         <Property name="requestFocusEnabled" type="boolean" value="false"/>
       </Properties>
     </Component>
-    <Component class="javax.swing.JLabel" name="jLabel1">
+    <Component class="javax.swing.JLabel" name="jLabel3">
       <Properties>
         <Property name="labelFor" type="java.awt.Component" 
editor="org.netbeans.modules.form.ComponentChooserEditor">
-          <ComponentRef name="jPasswordField"/>
+          <ComponentRef name="jTextFieldLocation"/>
         </Property>
         <Property name="text" type="java.lang.String" 
editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
-          <ResourceString 
bundle="org/netbeans/modules/cloud/oracle/actions/Bundle.properties" 
key="DownloadWalletDialog.jLabel1.text" 
replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, 
&quot;{key}&quot;)"/>
+          <ResourceString 
bundle="org/netbeans/modules/cloud/oracle/actions/Bundle.properties" 
key="DownloadWalletDialog.jLabel3.text" 
replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, 
&quot;{key}&quot;)"/>
         </Property>
       </Properties>
     </Component>
-    <Component class="javax.swing.JLabel" name="jLabel2">
+    <Component class="javax.swing.JTextField" name="jTextFieldLocation">
       <Properties>
-        <Property name="labelFor" type="java.awt.Component" 
editor="org.netbeans.modules.form.ComponentChooserEditor">
-          <ComponentRef name="jPasswordFieldConfirm"/>
-        </Property>
         <Property name="text" type="java.lang.String" 
editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
-          <ResourceString 
bundle="org/netbeans/modules/cloud/oracle/actions/Bundle.properties" 
key="DownloadWalletDialog.jLabel2.text" 
replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, 
&quot;{key}&quot;)"/>
+          <ResourceString 
bundle="org/netbeans/modules/cloud/oracle/actions/Bundle.properties" 
key="DownloadWalletDialog.jTextFieldLocation.text" 
replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, 
&quot;{key}&quot;)"/>
         </Property>
       </Properties>
     </Component>
-    <Component class="javax.swing.JLabel" name="jLabel3">
+    <Component class="javax.swing.JButton" name="jButtonBrowse">
       <Properties>
-        <Property name="labelFor" type="java.awt.Component" 
editor="org.netbeans.modules.form.ComponentChooserEditor">
-          <ComponentRef name="jTextFieldLocation"/>
+        <Property name="text" type="java.lang.String" 
editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+          <ResourceString 
bundle="org/netbeans/modules/cloud/oracle/actions/Bundle.properties" 
key="DownloadWalletDialog.jButtonBrowse.text" 
replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, 
&quot;{key}&quot;)"/>
         </Property>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" 
listener="java.awt.event.ActionListener" 
parameters="java.awt.event.ActionEvent" handler="jButtonBrowseActionPerformed"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="dbUserLabel">
+      <Properties>
         <Property name="text" type="java.lang.String" 
editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
-          <ResourceString 
bundle="org/netbeans/modules/cloud/oracle/actions/Bundle.properties" 
key="DownloadWalletDialog.jLabel3.text" 
replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, 
&quot;{key}&quot;)"/>
+          <ResourceString 
bundle="org/netbeans/modules/cloud/oracle/actions/Bundle.properties" 
key="DownloadWalletDialog.dbUserLabel.text" 
replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, 
&quot;{key}&quot;)"/>
         </Property>
+        <Property name="enabled" type="boolean" value="false"/>
       </Properties>
     </Component>
-    <Component class="javax.swing.JTextField" name="jTextFieldLocation">
+    <Component class="javax.swing.JLabel" name="dbPasswordLabel">
       <Properties>
         <Property name="text" type="java.lang.String" 
editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
-          <ResourceString 
bundle="org/netbeans/modules/cloud/oracle/actions/Bundle.properties" 
key="DownloadWalletDialog.jTextFieldLocation.text" 
replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, 
&quot;{key}&quot;)"/>
+          <ResourceString 
bundle="org/netbeans/modules/cloud/oracle/actions/Bundle.properties" 
key="DownloadWalletDialog.dbPasswordLabel.text" 
replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, 
&quot;{key}&quot;)"/>
         </Property>
+        <Property name="enabled" type="boolean" value="false"/>
       </Properties>
     </Component>
-    <Component class="javax.swing.JPasswordField" name="jPasswordFieldConfirm">
+    <Component class="javax.swing.JPasswordField" name="dbPasswordField">
       <Properties>
         <Property name="text" type="java.lang.String" 
editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
-          <ResourceString 
bundle="org/netbeans/modules/cloud/oracle/actions/Bundle.properties" 
key="DownloadWalletDialog.jPasswordFieldConfirm.text" 
replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, 
&quot;{key}&quot;)"/>
+          <ResourceString 
bundle="org/netbeans/modules/cloud/oracle/actions/Bundle.properties" 
key="DownloadWalletDialog.dbPasswordField.text" 
replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, 
&quot;{key}&quot;)"/>
         </Property>
+        <Property name="enabled" type="boolean" value="false"/>
       </Properties>
     </Component>
-    <Component class="javax.swing.JPasswordField" name="jPasswordField">
+    <Component class="javax.swing.JTextField" name="dbUserField">
       <Properties>
         <Property name="text" type="java.lang.String" 
editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
-          <ResourceString 
bundle="org/netbeans/modules/cloud/oracle/actions/Bundle.properties" 
key="DownloadWalletDialog.jPasswordField.text" 
replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, 
&quot;{key}&quot;)"/>
+          <ResourceString 
bundle="org/netbeans/modules/cloud/oracle/actions/Bundle.properties" 
key="DownloadWalletDialog.dbUserField.text" 
replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, 
&quot;{key}&quot;)"/>
         </Property>
+        <Property name="enabled" type="boolean" value="false"/>
       </Properties>
     </Component>
-    <Component class="javax.swing.JButton" name="jButtonBrowse">
+    <Component class="javax.swing.JCheckBox" name="addDBCheckbox">
       <Properties>
         <Property name="text" type="java.lang.String" 
editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
-          <ResourceString 
bundle="org/netbeans/modules/cloud/oracle/actions/Bundle.properties" 
key="DownloadWalletDialog.jButtonBrowse.text" 
replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, 
&quot;{key}&quot;)"/>
+          <ResourceString 
bundle="org/netbeans/modules/cloud/oracle/actions/Bundle.properties" 
key="DownloadWalletDialog.addDBCheckbox.text" 
replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, 
&quot;{key}&quot;)"/>
+        </Property>
+        <Property name="toolTipText" type="java.lang.String" 
editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+          <ResourceString 
bundle="org/netbeans/modules/cloud/oracle/actions/Bundle.properties" 
key="DownloadWalletDialog.addDBCheckbox.toolltip" 
replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, 
&quot;{key}&quot;)"/>
         </Property>
       </Properties>
       <Events>
-        <EventHandler event="actionPerformed" 
listener="java.awt.event.ActionListener" 
parameters="java.awt.event.ActionEvent" handler="jButtonBrowseActionPerformed"/>
+        <EventHandler event="actionPerformed" 
listener="java.awt.event.ActionListener" 
parameters="java.awt.event.ActionEvent" handler="addDBCheckboxActionPerformed"/>
       </Events>
     </Component>
   </SubComponents>
diff --git 
a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/DownloadWalletDialog.java
 
b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/DownloadWalletDialog.java
index 051424b948..65602dbd14 100644
--- 
a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/DownloadWalletDialog.java
+++ 
b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/DownloadWalletDialog.java
@@ -23,9 +23,11 @@ import java.awt.Dialog;
 import java.awt.GraphicsEnvironment;
 import java.io.File;
 import java.io.IOException;
+import java.util.Arrays;
 import java.util.Locale;
 import java.util.Optional;
 import javax.swing.JFileChooser;
+import javax.swing.event.DocumentEvent;
 import javax.swing.event.DocumentListener;
 import org.openide.DialogDescriptor;
 import org.openide.DialogDisplayer;
@@ -53,8 +55,6 @@ import org.openide.windows.WindowManager;
     "OneNumber=The wallet download password should contain at least 1 number.",
     "OneSpecial=The wallet download password should contain at least 1 special 
character.",
     "OneLetter=The wallet download password should contain at least 1 letter.",
-    "WalletPassword=Enter the wallet password",
-    "WalletReEnterPassword=Re-enter the wallet password",
     "JDBCUsername=Enter the connection username",
     "JDBCPassword=Enter the conenction password"
 })
@@ -64,13 +64,14 @@ final class DownloadWalletDialog extends 
AbstractPasswordPanel {
     private static final String LAST_USED_DIR = "lastUsedDir";
     
     /**
-     * Creates new form NewJPanel
+     * Creates new DownloadWalletDialog form
      */
     DownloadWalletDialog() {
         initComponents();
-        DocumentListener docListener = new PasswordListener();
-        jPasswordField.getDocument().addDocumentListener(docListener);
-        jPasswordFieldConfirm.getDocument().addDocumentListener(docListener);
+        DocumentListener docListener = new TextFieldListener();
+        jTextFieldLocation.getDocument().addDocumentListener(docListener);
+        dbUserField.getDocument().addDocumentListener(docListener);
+        dbPasswordField.getDocument().addDocumentListener(docListener);
     }
     
     static Optional<WalletInfo> showDialog(OCIItem db) {
@@ -79,18 +80,19 @@ final class DownloadWalletDialog extends 
AbstractPasswordPanel {
                 
         if (!GraphicsEnvironment.isHeadless()) {
             DownloadWalletDialog dlgPanel = new DownloadWalletDialog();
-            dlgPanel.jTextFieldLocation.setText(lastUsedDir);
             DialogDescriptor descriptor = new DialogDescriptor(dlgPanel, 
Bundle.DownloadTitle()); //NOI18N
             dlgPanel.setDescriptor(descriptor);
             descriptor.createNotificationLineSupport();
             Dialog dialog = 
DialogDisplayer.getDefault().createDialog(descriptor);
             dialog.setMinimumSize(dlgPanel.getPreferredSize());
+            dlgPanel.jTextFieldLocation.setText(lastUsedDir);
             dialog.setVisible(true);
             if (DialogDescriptor.OK_OPTION == descriptor.getValue()) {
                 String path = dlgPanel.jTextFieldLocation.getText();
-                char[] passwd = dlgPanel.jPasswordField.getPassword();
+                String dbUser = dlgPanel.dbUserField.getText();
+                char[] dbPasswd = dlgPanel.dbPasswordField.getPassword();
                 
NbPreferences.forModule(DownloadWalletAction.class).put(LAST_USED_DIR, path); 
//NOI18N
-                return Optional.of(new WalletInfo(path, passwd, null, null, 
db.getKey().getValue()));
+                return Optional.of(new WalletInfo(path, generatePassword(), 
dbUser, dbPasswd, db.getKey().getValue()));
             }
         } else {
             try {
@@ -129,13 +131,14 @@ final class DownloadWalletDialog extends 
AbstractPasswordPanel {
     private void initComponents() {
 
         jTextArea1 = new javax.swing.JTextArea();
-        jLabel1 = new javax.swing.JLabel();
-        jLabel2 = new javax.swing.JLabel();
         jLabel3 = new javax.swing.JLabel();
         jTextFieldLocation = new javax.swing.JTextField();
-        jPasswordFieldConfirm = new javax.swing.JPasswordField();
-        jPasswordField = new javax.swing.JPasswordField();
         jButtonBrowse = new javax.swing.JButton();
+        dbUserLabel = new javax.swing.JLabel();
+        dbPasswordLabel = new javax.swing.JLabel();
+        dbPasswordField = new javax.swing.JPasswordField();
+        dbUserField = new javax.swing.JTextField();
+        addDBCheckbox = new javax.swing.JCheckBox();
 
         setMaximumSize(null);
         setMinimumSize(new java.awt.Dimension(714, 234));
@@ -147,7 +150,6 @@ final class DownloadWalletDialog extends 
AbstractPasswordPanel {
         
jTextArea1.setText(org.openide.util.NbBundle.getMessage(DownloadWalletDialog.class,
 "DownloadWalletDialog.jTextArea1.text")); // NOI18N
         jTextArea1.setWrapStyleWord(true);
         jTextArea1.setBorder(null);
-        jTextArea1.setDragEnabled(false);
         jTextArea1.setFocusTraversalKeysEnabled(false);
         jTextArea1.setFocusable(false);
         jTextArea1.setMinimumSize(new java.awt.Dimension(702, 113));
@@ -155,21 +157,11 @@ final class DownloadWalletDialog extends 
AbstractPasswordPanel {
         jTextArea1.setPreferredSize(new java.awt.Dimension(702, 113));
         jTextArea1.setRequestFocusEnabled(false);
 
-        jLabel1.setLabelFor(jPasswordField);
-        org.openide.awt.Mnemonics.setLocalizedText(jLabel1, 
org.openide.util.NbBundle.getMessage(DownloadWalletDialog.class, 
"DownloadWalletDialog.jLabel1.text")); // NOI18N
-
-        jLabel2.setLabelFor(jPasswordFieldConfirm);
-        org.openide.awt.Mnemonics.setLocalizedText(jLabel2, 
org.openide.util.NbBundle.getMessage(DownloadWalletDialog.class, 
"DownloadWalletDialog.jLabel2.text")); // NOI18N
-
         jLabel3.setLabelFor(jTextFieldLocation);
         org.openide.awt.Mnemonics.setLocalizedText(jLabel3, 
org.openide.util.NbBundle.getMessage(DownloadWalletDialog.class, 
"DownloadWalletDialog.jLabel3.text")); // NOI18N
 
         
jTextFieldLocation.setText(org.openide.util.NbBundle.getMessage(DownloadWalletDialog.class,
 "DownloadWalletDialog.jTextFieldLocation.text")); // NOI18N
 
-        
jPasswordFieldConfirm.setText(org.openide.util.NbBundle.getMessage(DownloadWalletDialog.class,
 "DownloadWalletDialog.jPasswordFieldConfirm.text")); // NOI18N
-
-        
jPasswordField.setText(org.openide.util.NbBundle.getMessage(DownloadWalletDialog.class,
 "DownloadWalletDialog.jPasswordField.text")); // NOI18N
-
         org.openide.awt.Mnemonics.setLocalizedText(jButtonBrowse, 
org.openide.util.NbBundle.getMessage(DownloadWalletDialog.class, 
"DownloadWalletDialog.jButtonBrowse.text")); // NOI18N
         jButtonBrowse.addActionListener(new java.awt.event.ActionListener() {
             public void actionPerformed(java.awt.event.ActionEvent evt) {
@@ -177,6 +169,26 @@ final class DownloadWalletDialog extends 
AbstractPasswordPanel {
             }
         });
 
+        org.openide.awt.Mnemonics.setLocalizedText(dbUserLabel, 
org.openide.util.NbBundle.getMessage(DownloadWalletDialog.class, 
"DownloadWalletDialog.dbUserLabel.text")); // NOI18N
+        dbUserLabel.setEnabled(false);
+
+        org.openide.awt.Mnemonics.setLocalizedText(dbPasswordLabel, 
org.openide.util.NbBundle.getMessage(DownloadWalletDialog.class, 
"DownloadWalletDialog.dbPasswordLabel.text")); // NOI18N
+        dbPasswordLabel.setEnabled(false);
+
+        
dbPasswordField.setText(org.openide.util.NbBundle.getMessage(DownloadWalletDialog.class,
 "DownloadWalletDialog.dbPasswordField.text")); // NOI18N
+        dbPasswordField.setEnabled(false);
+
+        
dbUserField.setText(org.openide.util.NbBundle.getMessage(DownloadWalletDialog.class,
 "DownloadWalletDialog.dbUserField.text")); // NOI18N
+        dbUserField.setEnabled(false);
+
+        org.openide.awt.Mnemonics.setLocalizedText(addDBCheckbox, 
org.openide.util.NbBundle.getMessage(DownloadWalletDialog.class, 
"DownloadWalletDialog.addDBCheckbox.text")); // NOI18N
+        
addDBCheckbox.setToolTipText(org.openide.util.NbBundle.getMessage(DownloadWalletDialog.class,
 "DownloadWalletDialog.addDBCheckbox.toolltip")); // NOI18N
+        addDBCheckbox.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                addDBCheckboxActionPerformed(evt);
+            }
+        });
+
         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
         this.setLayout(layout);
         layout.setHorizontalGroup(
@@ -187,16 +199,19 @@ final class DownloadWalletDialog extends 
AbstractPasswordPanel {
                     .addComponent(jTextArea1, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 
Short.MAX_VALUE)
                     .addGroup(layout.createSequentialGroup()
                         
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                            .addComponent(jLabel2)
                             .addComponent(jLabel3)
-                            .addComponent(jLabel1))
-                        
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
-                        
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                            .addComponent(jPasswordField)
-                            .addComponent(jTextFieldLocation)
-                            .addComponent(jPasswordFieldConfirm))
+                            .addComponent(dbUserLabel)
+                            .addComponent(dbPasswordLabel))
+                        .addGap(27, 27, 27)
+                        
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+                            .addComponent(jTextFieldLocation, 
javax.swing.GroupLayout.Alignment.LEADING)
+                            .addComponent(dbPasswordField)
+                            .addComponent(dbUserField))
                         
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                        .addComponent(jButtonBrowse)))
+                        .addComponent(jButtonBrowse))
+                    .addGroup(layout.createSequentialGroup()
+                        .addComponent(addDBCheckbox, 
javax.swing.GroupLayout.PREFERRED_SIZE, 344, 
javax.swing.GroupLayout.PREFERRED_SIZE)
+                        .addGap(0, 0, Short.MAX_VALUE)))
                 .addContainerGap())
         );
         layout.setVerticalGroup(
@@ -204,26 +219,28 @@ final class DownloadWalletDialog extends 
AbstractPasswordPanel {
             .addGroup(layout.createSequentialGroup()
                 .addContainerGap()
                 .addComponent(jTextArea1, 
javax.swing.GroupLayout.PREFERRED_SIZE, 113, 
javax.swing.GroupLayout.PREFERRED_SIZE)
-                
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                .addGap(18, 18, 18)
                 
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
-                    .addComponent(jLabel1)
-                    .addComponent(jPasswordField, 
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 
javax.swing.GroupLayout.PREFERRED_SIZE))
+                    .addComponent(jLabel3)
+                    .addComponent(jTextFieldLocation, 
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 
javax.swing.GroupLayout.PREFERRED_SIZE)
+                    .addComponent(jButtonBrowse))
+                
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                .addComponent(addDBCheckbox, 
javax.swing.GroupLayout.PREFERRED_SIZE, 17, 
javax.swing.GroupLayout.PREFERRED_SIZE)
                 
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                 
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
-                    .addComponent(jLabel2)
-                    .addComponent(jPasswordFieldConfirm, 
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 
javax.swing.GroupLayout.PREFERRED_SIZE))
+                    .addComponent(dbUserLabel)
+                    .addComponent(dbUserField, 
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 
javax.swing.GroupLayout.PREFERRED_SIZE))
                 
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                 
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
-                    .addComponent(jLabel3)
-                    .addComponent(jTextFieldLocation, 
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 
javax.swing.GroupLayout.PREFERRED_SIZE)
-                    .addComponent(jButtonBrowse))
-                .addContainerGap(16, Short.MAX_VALUE))
+                    .addComponent(dbPasswordLabel)
+                    .addComponent(dbPasswordField, 
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 
javax.swing.GroupLayout.PREFERRED_SIZE))
+                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, 
Short.MAX_VALUE))
         );
     }// </editor-fold>//GEN-END:initComponents
 
     private void jButtonBrowseActionPerformed(java.awt.event.ActionEvent evt) 
{//GEN-FIRST:event_jButtonBrowseActionPerformed
         JFileChooser chooser = new JFileChooser();
-        chooser.setDialogTitle(Bundle.LBL_SaveWallet()); //NOI18N
+        chooser.setDialogTitle(Bundle.LBL_SaveWallet());
         File folder = new File(jTextFieldLocation.getText());
         if (!folder.exists()) {
             folder = folder.getParentFile();
@@ -236,17 +253,53 @@ final class DownloadWalletDialog extends 
AbstractPasswordPanel {
         }
     }//GEN-LAST:event_jButtonBrowseActionPerformed
 
+    private void addDBCheckboxActionPerformed(java.awt.event.ActionEvent evt) 
{//GEN-FIRST:event_addDBCheckboxActionPerformed
+        boolean selected = addDBCheckbox.isSelected();
+        dbUserLabel.setEnabled(selected);
+        dbUserField.setEnabled(selected);
+        dbPasswordLabel.setEnabled(selected);
+        dbPasswordField.setEnabled(selected);
+        validateDialog();
+    }//GEN-LAST:event_addDBCheckboxActionPerformed
+
     @Override
     protected void checkPassword() {
-        char[] passwd1 = jPasswordField.getPassword();
-        char[] passwd2 = jPasswordFieldConfirm.getPassword();
-        checkPasswordLogic(passwd1, passwd2, (m) -> errorMessage(m));
     }
     
+    private boolean isValidDialog() {
+        if (jTextFieldLocation.getText().isEmpty()) return false;
+        if (!addDBCheckbox.isSelected()) return true;
+        if (dbUserField.getText().isEmpty()) return false;
+        if (dbPasswordField.getPassword() == null) return false;
+        if (dbPasswordField.getPassword().length == 0) return false;
+        return true;
+    }
+
+    private void validateDialog() {
+        descriptor.setValid(isValidDialog());
+    }
+
     static File getWalletsDir() throws IOException {
         FileObject fo = FileUtil.createFolder(FileUtil.getConfigRoot(), 
WALLETS_PATH);
         return FileUtil.toFile(fo);
     }
+
+    protected class TextFieldListener implements DocumentListener {
+        @Override
+        public void insertUpdate(DocumentEvent e) {
+            validateDialog();
+        }
+
+        @Override
+        public void removeUpdate(DocumentEvent e) {
+            validateDialog();
+        }
+
+        @Override
+        public void changedUpdate(DocumentEvent e) {
+            validateDialog();
+        }
+    }
     
     static class WalletInfo {
         private String path;
@@ -285,12 +338,13 @@ final class DownloadWalletDialog extends 
AbstractPasswordPanel {
     }
 
     // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JCheckBox addDBCheckbox;
+    private javax.swing.JPasswordField dbPasswordField;
+    private javax.swing.JLabel dbPasswordLabel;
+    private javax.swing.JTextField dbUserField;
+    private javax.swing.JLabel dbUserLabel;
     private javax.swing.JButton jButtonBrowse;
-    private javax.swing.JLabel jLabel1;
-    private javax.swing.JLabel jLabel2;
     private javax.swing.JLabel jLabel3;
-    private javax.swing.JPasswordField jPasswordField;
-    private javax.swing.JPasswordField jPasswordFieldConfirm;
     private javax.swing.JTextArea jTextArea1;
     private javax.swing.JTextField jTextFieldLocation;
     // End of variables declaration//GEN-END:variables


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to