PageRenderTime 270ms CodeModel.GetById 61ms app.highlight 148ms RepoModel.GetById 53ms app.codeStats 0ms

/src/mpv5/ui/dialogs/subcomponents/wizard_DBSettings_manage_1.java

http://mp-rechnungs-und-kundenverwaltung.googlecode.com/
Java | 542 lines | 465 code | 63 blank | 14 comment | 33 complexity | 2447efb825a70c10fc3b219b3a7238b7 MD5 | raw file
  1/*
  2 * SearchPanel.java
  3 *
  4 * Created on Nov 30, 2008, 6:16:09 PM
  5 */
  6package mpv5.ui.dialogs.subcomponents;
  7
  8import java.awt.Cursor;
  9import java.awt.Desktop;
 10import java.io.File;
 11import java.io.IOException;
 12import java.util.List;
 13import java.util.Random;
 14import javax.swing.DefaultComboBoxModel;
 15import javax.swing.JFileChooser;
 16import mpv5.Main;
 17import mpv5.db.common.ConnectionTypeHandler;
 18import mpv5.db.common.DatabaseConnection;
 19import mpv5.db.common.DatabaseInstallation;
 20import mpv5.globals.Constants;
 21import mpv5.globals.LocalSettings;
 22import mpv5.globals.Messages;
 23
 24import mpv5.i18n.LanguageManager;
 25import mpv5.logging.Log;
 26import mpv5.logging.YConsole;
 27import mpv5.ui.dialogs.Popup;
 28import mpv5.ui.dialogs.Wizard;
 29import mpv5.ui.dialogs.WizardMaster;
 30import mpv5.ui.dialogs.Wizardable;
 31
 32/**
 33 *
 34 * 
 35 */
 36public class wizard_DBSettings_manage_1 extends javax.swing.JPanel implements Wizardable {
 37
 38    private static final long serialVersionUID = 1L;
 39    private WizardMaster master;
 40    private Integer forConnId = null;
 41    private java.util.ResourceBundle bundle = mpv5.i18n.LanguageManager.getBundle();
 42
 43    public wizard_DBSettings_manage_1(Wizard w) {
 44        this.master = w;
 45        initComponents();
 46        labeledTextChooser2.setMode(JFileChooser.DIRECTORIES_ONLY);
 47        jComboBox1.setModel(new DefaultComboBoxModel(ConnectionTypeHandler.DRIVERS));
 48
 49        forConnId = getNextConnID();
 50
 51        load();
 52    }
 53
 54    private boolean DBVerification() {
 55        DatabaseConnection conn;
 56        this.master.setCursor(new Cursor(Cursor.WAIT_CURSOR));
 57
 58        if (labeledTextChooser1.get_Text(false) != null && labeledTextChooser1.get_Text(false).length() > 0) {
 59            master.getStore().changeProperty("driver", jComboBox1.getSelectedItem().toString());
 60            master.getStore().changeProperty("url", labeledTextChooser1.get_Text(false));
 61            master.getStore().changeProperty("user", labeledTextField4.get_Text());
 62            master.getStore().changeProperty("password", labeledTextField5.get_Text());
 63            master.getStore().changeProperty("dbname", labeledTextField3.get_Text());
 64            master.getStore().changeProperty("dbprefix", prefix.get_Text());
 65            master.setMessage(Messages.CONNECTION_PROBE + master.getStore().getProperty("driver"));
 66            conn = new DatabaseConnection();
 67            try {
 68                LocalSettings.setProperty(LocalSettings.DBPATH, master.getStore().getProperty("url"));
 69                LocalSettings.setProperty(LocalSettings.DBDRIVER, master.getStore().getProperty("driver"));
 70                LocalSettings.setProperty(LocalSettings.DBUSER, master.getStore().getProperty("user"));
 71                LocalSettings.setProperty(LocalSettings.DBPASSWORD, master.getStore().getProperty("password"));
 72                LocalSettings.setProperty(LocalSettings.DBNAME, master.getStore().getProperty("dbname"));
 73                LocalSettings.setProperty(LocalSettings.DBPREFIX, master.getStore().getProperty("dbprefix"));
 74                if (!jCheckBox3.isSelected() && labeledTextChooser2.hasText()) {
 75                    LocalSettings.setProperty(LocalSettings.OFFICE_HOME, labeledTextChooser2.get_Text(true));
 76                    LocalSettings.setProperty(LocalSettings.OFFICE_USE, "true");
 77                    LocalSettings.setProperty(LocalSettings.OFFICE_REMOTE, "false");
 78                } else if (labeledTextField1.getText().length() > 0 && labeledTextField2.getText().length() > 0) {
 79                    LocalSettings.setProperty(LocalSettings.OFFICE_HOST, labeledTextField1.getText());
 80                    LocalSettings.setProperty(LocalSettings.OFFICE_PORT, labeledTextField2.getText());
 81                    LocalSettings.setProperty(LocalSettings.OFFICE_USE, "true");
 82                    LocalSettings.setProperty(LocalSettings.OFFICE_REMOTE, "true");
 83                } else {
 84                    LocalSettings.setProperty(LocalSettings.OFFICE_USE, "false");
 85                }
 86                if (jCheckBox2.isSelected()) {
 87                    LocalSettings.setProperty(LocalSettings.DBTYPE, "network");
 88                } else {
 89                    LocalSettings.setProperty(LocalSettings.DBTYPE, "single");
 90                }
 91
 92                if (conn.connect(master.getStore().getProperty("driver"),
 93                        master.getStore().getProperty("user"),
 94                        master.getStore().getProperty("password"),
 95                        master.getStore().getProperty("url"),
 96                        master.getStore().getProperty("dbname"),
 97                        master.getStore().getProperty("dbprefix"),
 98                        !jCheckBox1.isSelected())) {
 99                    master.setMessage(Messages.CONNECTION_VERIFIED.toString());
100                    LocalSettings.save(forConnId);
101                    LocalSettings.apply();
102
103                    if (ConnectionTypeHandler.getDriverType() != ConnectionTypeHandler.DERBY) {
104                        Popup.notice("Please run the MySQL/SQL install script manually BEFORE clicking ok now!");
105                    }
106
107                    if (!jCheckBox1.isSelected()) {
108                        master.setMessage(Messages.CREATING_DATABASE.toString());
109                        conn.setProgressbar(master.getProgressbar());
110                        if (conn.runQueries(new DatabaseInstallation().getStructure())
111                                && conn.runQueries(new DatabaseInstallation().getInitialData())) {
112                            try {
113                                File f = new File(this.getClass().getResource("languages").toURI());
114                                Log.Debug(this, "Importing languages from: " + f.getCanonicalPath());
115                                File[] langfiles = f.listFiles();
116                                for (int i = 0; i < langfiles.length; i++) {
117                                    File file = langfiles[i];
118                                    LanguageManager.importLanguage(file.getName(), file);
119                                }
120                            } catch (Exception uRISyntaxException) {
121                                Log.Debug(this, uRISyntaxException.getMessage());
122                            }
123                            master.setMessage(Messages.CONNECTION_VERIFIED.toString());
124                        } else {
125                            master.setMessage(Messages.CREATING_DATABASE_FAILED.toString());
126                            return false;
127                        }
128                    }
129                    master.isEnd(true);
130                } else {
131                    master.setMessage(Messages.CONNECTION_FAILED.toString());
132                }
133
134            } catch (Exception ex) {
135                master.setMessage(Messages.CONNECTION_FAILED.toString());
136                this.master.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
137                Log.Debug(ex);
138                if (Popup.Y_N_dialog(this, Messages.ERROR_OCCURED + "\n" + Messages.SEE_LOG + "?", Messages.CONNECTION_FAILED)) {
139                    try {
140                        Desktop.getDesktop().open(YConsole.getLogfile());
141                    } catch (IOException ex1) {
142                        Popup.error(ex1);
143                    }
144                }
145                return false;
146            }
147            this.master.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
148            return true;
149        } else {
150            this.master.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
151            return false;
152        }
153    }
154
155    private boolean DirectoryCreate() {
156        ////////////// The cache dir //////////////////////
157        LocalSettings.setProperty(LocalSettings.CACHE_DIR, Main.MPPATH + File.separator + "Cache");
158        LocalSettings.save(forConnId);
159        File file1 = new File(LocalSettings.getProperty(LocalSettings.CACHE_DIR));
160        file1.mkdirs();
161        ///////////////////////////////////////////////////////////
162
163        return file1.exists();
164    }
165
166    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
167    private void initComponents() {
168
169        jPanel1 = new javax.swing.JPanel();
170        labeledTextChooser2 = new mpv5.ui.beans.LabeledTextChooser();
171        jCheckBox3 = new javax.swing.JCheckBox();
172        labeledTextField1 = new mpv5.ui.beans.LabeledTextField();
173        labeledTextField2 = new mpv5.ui.beans.LabeledTextField();
174        jLabel3 = new javax.swing.JLabel();
175        jPanel2 = new javax.swing.JPanel();
176        jLabel1 = new javax.swing.JLabel();
177        jComboBox1 = new javax.swing.JComboBox();
178        labeledTextChooser1 = new mpv5.ui.beans.LabeledTextChooser();
179        labeledTextField3 = new mpv5.ui.beans.LabeledTextField();
180        jCheckBox1 = new javax.swing.JCheckBox();
181        jLabel2 = new javax.swing.JLabel();
182        jCheckBox2 = new javax.swing.JCheckBox();
183        jPanel4 = new javax.swing.JPanel();
184        labeledTextField4 = new mpv5.ui.beans.LabeledTextField();
185        labeledTextField5 = new mpv5.ui.beans.LabeledTextField();
186        jButton2 = new javax.swing.JButton();
187        prefix = new mpv5.ui.beans.LabeledTextField();
188        jButton3 = new javax.swing.JButton();
189        jLabel4 = new javax.swing.JLabel();
190        jButton1 = new javax.swing.JButton();
191        jPanel3 = new javax.swing.JPanel();
192        jScrollPane1 = new javax.swing.JScrollPane();
193        jTextArea1 = new javax.swing.JTextArea();
194
195        setBackground(new java.awt.Color(255, 255, 255));
196        mpv5.i18n.LanguageManager.getBundle();
197        setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("wizard_DBSettings_manage_1.border.title"))); // NOI18N
198        setName("Form"); // NOI18N
199        setLayout(new java.awt.BorderLayout());
200
201        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("wizard_DBSettings_manage_1.jPanel1.border.title"))); // NOI18N
202        jPanel1.setName("jPanel1"); // NOI18N
203
204        labeledTextChooser2.set_Label(bundle.getString("wizard_DBSettings_manage_1.labeledTextChooser2._Label")); // NOI18N
205        labeledTextChooser2.setName("labeledTextChooser2"); // NOI18N
206
207        jCheckBox3.setText(bundle.getString("wizard_DBSettings_manage_1.jCheckBox3.text")); // NOI18N
208        jCheckBox3.setName("jCheckBox3"); // NOI18N
209        jCheckBox3.addItemListener(new java.awt.event.ItemListener() {
210            public void itemStateChanged(java.awt.event.ItemEvent evt) {
211                jCheckBox3ItemStateChanged(evt);
212            }
213        });
214
215        labeledTextField1.set_Label(bundle.getString("wizard_DBSettings_manage_1.labeledTextField1._Label")); // NOI18N
216        labeledTextField1.set_Text(bundle.getString("wizard_DBSettings_manage_1.labeledTextField1._Text")); // NOI18N
217        labeledTextField1.setEnabled(false);
218        labeledTextField1.setName("labeledTextField1"); // NOI18N
219
220        labeledTextField2.set_Label(bundle.getString("wizard_DBSettings_manage_1.labeledTextField2._Label")); // NOI18N
221        labeledTextField2.setEnabled(false);
222        labeledTextField2.setName("labeledTextField2"); // NOI18N
223
224        jLabel3.setText(bundle.getString("wizard_DBSettings_manage_1.jLabel3.text")); // NOI18N
225        jLabel3.setName("jLabel3"); // NOI18N
226
227        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
228        jPanel1.setLayout(jPanel1Layout);
229        jPanel1Layout.setHorizontalGroup(
230            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
231            .addGroup(jPanel1Layout.createSequentialGroup()
232                .addContainerGap()
233                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
234                    .addComponent(labeledTextChooser2, javax.swing.GroupLayout.DEFAULT_SIZE, 584, Short.MAX_VALUE)
235                    .addGroup(jPanel1Layout.createSequentialGroup()
236                        .addComponent(jCheckBox3, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
237                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
238                        .addComponent(labeledTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 285, Short.MAX_VALUE)
239                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
240                        .addComponent(labeledTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE))
241                    .addComponent(jLabel3))
242                .addContainerGap())
243        );
244        jPanel1Layout.setVerticalGroup(
245            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
246            .addGroup(jPanel1Layout.createSequentialGroup()
247                .addComponent(labeledTextChooser2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
248                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
249                .addComponent(jLabel3)
250                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
251                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
252                    .addComponent(labeledTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
253                    .addComponent(jCheckBox3)
254                    .addComponent(labeledTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
255                .addContainerGap())
256        );
257
258        add(jPanel1, java.awt.BorderLayout.CENTER);
259
260        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("wizard_DBSettings_manage_1.jPanel2.border.title"))); // NOI18N
261        jPanel2.setName("jPanel2"); // NOI18N
262
263        jLabel1.setText(bundle.getString("wizard_DBSettings_manage_1.jLabel1.text")); // NOI18N
264        jLabel1.setName("jLabel1"); // NOI18N
265
266        jComboBox1.setEditable(true);
267        jComboBox1.setFont(new java.awt.Font("Dialog", 0, 11));
268        jComboBox1.setName("jComboBox1"); // NOI18N
269        jComboBox1.addActionListener(new java.awt.event.ActionListener() {
270            public void actionPerformed(java.awt.event.ActionEvent evt) {
271                jComboBox1ActionPerformed(evt);
272            }
273        });
274
275        labeledTextChooser1.set_Label(bundle.getString("wizard_DBSettings_manage_1.labeledTextChooser1._Label")); // NOI18N
276        labeledTextChooser1.setFocusCycleRoot(true);
277        labeledTextChooser1.setFocusTraversalPolicyProvider(true);
278        labeledTextChooser1.setName("labeledTextChooser1"); // NOI18N
279
280        labeledTextField3.set_Label(bundle.getString("wizard_DBSettings_manage_1.labeledTextField3._Label")); // NOI18N
281        labeledTextField3.setName("labeledTextField3"); // NOI18N
282
283        jCheckBox1.setFont(new java.awt.Font("Dialog", 0, 12));
284        jCheckBox1.setText(bundle.getString("wizard_DBSettings_manage_1.jCheckBox1.text")); // NOI18N
285        jCheckBox1.setName("jCheckBox1"); // NOI18N
286
287        jLabel2.setText(bundle.getString("wizard_DBSettings_manage_1.jLabel2.text")); // NOI18N
288        jLabel2.setName("jLabel2"); // NOI18N
289
290        jCheckBox2.setFont(new java.awt.Font("Dialog", 0, 12));
291        jCheckBox2.setText(bundle.getString("wizard_DBSettings_manage_1.jCheckBox2.text")); // NOI18N
292        jCheckBox2.setName("jCheckBox2"); // NOI18N
293
294        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("wizard_DBSettings_manage_1.jPanel4.border.title"))); // NOI18N
295        jPanel4.setName("jPanel4"); // NOI18N
296
297        labeledTextField4.set_Label(bundle.getString("wizard_DBSettings_manage_1.labeledTextField4._Label")); // NOI18N
298        labeledTextField4.setEnabled(false);
299        labeledTextField4.setName("labeledTextField4"); // NOI18N
300        jPanel4.add(labeledTextField4);
301
302        labeledTextField5.set_Label(bundle.getString("wizard_DBSettings_manage_1.labeledTextField5._Label")); // NOI18N
303        labeledTextField5.setEnabled(false);
304        labeledTextField5.setName("labeledTextField5"); // NOI18N
305        jPanel4.add(labeledTextField5);
306
307        jButton2.setFont(new java.awt.Font("Dialog", 0, 12));
308        jButton2.setText(bundle.getString("wizard_DBSettings_manage_1.jButton2.text")); // NOI18N
309        jButton2.setName("jButton2"); // NOI18N
310        jButton2.addActionListener(new java.awt.event.ActionListener() {
311            public void actionPerformed(java.awt.event.ActionEvent evt) {
312                jButton2ActionPerformed(evt);
313            }
314        });
315        jPanel4.add(jButton2);
316
317        prefix.set_Label(bundle.getString("wizard_DBSettings_manage_1.prefix._Label")); // NOI18N
318        prefix.setEnabled(false);
319        prefix.setName("prefix"); // NOI18N
320
321        jButton3.setFont(new java.awt.Font("Dialog", 0, 12));
322        jButton3.setText(bundle.getString("wizard_DBSettings_manage_1.jButton3.text")); // NOI18N
323        jButton3.setName("jButton3"); // NOI18N
324        jButton3.addActionListener(new java.awt.event.ActionListener() {
325            public void actionPerformed(java.awt.event.ActionEvent evt) {
326                jButton3ActionPerformed(evt);
327            }
328        });
329
330        jLabel4.setFont(new java.awt.Font("Dialog", 0, 12));
331        jLabel4.setText(bundle.getString("wizard_DBSettings_manage_1.jLabel4.text")); // NOI18N
332        jLabel4.setName("jLabel4"); // NOI18N
333
334        jButton1.setText(bundle.getString("wizard_DBSettings_manage_1.jButton1.text")); // NOI18N
335        jButton1.setName("jButton1"); // NOI18N
336        jButton1.addActionListener(new java.awt.event.ActionListener() {
337            public void actionPerformed(java.awt.event.ActionEvent evt) {
338                jButton1ActionPerformed(evt);
339            }
340        });
341
342        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
343        jPanel2.setLayout(jPanel2Layout);
344        jPanel2Layout.setHorizontalGroup(
345            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
346            .addGroup(jPanel2Layout.createSequentialGroup()
347                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
348                    .addComponent(labeledTextChooser1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 594, Short.MAX_VALUE)
349                    .addGroup(jPanel2Layout.createSequentialGroup()
350                        .addComponent(labeledTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
351                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
352                        .addComponent(jCheckBox1, javax.swing.GroupLayout.DEFAULT_SIZE, 399, Short.MAX_VALUE))
353                    .addGroup(jPanel2Layout.createSequentialGroup()
354                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
355                            .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
356                            .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 183, Short.MAX_VALUE))
357                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
358                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
359                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
360                                .addComponent(jComboBox1, 0, 344, Short.MAX_VALUE)
361                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
362                                .addComponent(jButton1))
363                            .addComponent(jCheckBox2, javax.swing.GroupLayout.DEFAULT_SIZE, 407, Short.MAX_VALUE)))
364                    .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, 594, Short.MAX_VALUE)
365                    .addGroup(jPanel2Layout.createSequentialGroup()
366                        .addComponent(prefix, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
367                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
368                        .addComponent(jButton3)
369                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
370                        .addComponent(jLabel4)))
371                .addContainerGap())
372        );
373        jPanel2Layout.setVerticalGroup(
374            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
375            .addGroup(jPanel2Layout.createSequentialGroup()
376                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE, false)
377                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
378                    .addComponent(jLabel1)
379                    .addComponent(jButton1))
380                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
381                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
382                    .addComponent(jLabel2)
383                    .addComponent(jCheckBox2))
384                .addGap(7, 7, 7)
385                .addComponent(labeledTextChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
386                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
387                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
388                    .addGroup(jPanel2Layout.createSequentialGroup()
389                        .addGap(1, 1, 1)
390                        .addComponent(jCheckBox1, 0, 0, Short.MAX_VALUE))
391                    .addComponent(labeledTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
392                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
393                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
394                    .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
395                    .addComponent(prefix, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
396                    .addComponent(jLabel4))
397                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
398                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE))
399        );
400
401        add(jPanel2, java.awt.BorderLayout.PAGE_START);
402
403        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("wizard_DBSettings_manage_1.jPanel3.border.title"))); // NOI18N
404        jPanel3.setName("jPanel3"); // NOI18N
405
406        jScrollPane1.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
407        jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
408        jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
409        jScrollPane1.setName("jScrollPane1"); // NOI18N
410
411        jTextArea1.setBackground(new java.awt.Color(236, 233, 216));
412        jTextArea1.setColumns(20);
413        jTextArea1.setEditable(false);
414        jTextArea1.setFont(new java.awt.Font("Tahoma", 0, 12));
415        jTextArea1.setLineWrap(true);
416        jTextArea1.setRows(5);
417        jTextArea1.setText(bundle.getString("wizard_DBSettings_manage_1.jTextArea1.text")); // NOI18N
418        jTextArea1.setWrapStyleWord(true);
419        jTextArea1.setName("jTextArea1"); // NOI18N
420        jScrollPane1.setViewportView(jTextArea1);
421
422        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
423        jPanel3.setLayout(jPanel3Layout);
424        jPanel3Layout.setHorizontalGroup(
425            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
426            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 604, Short.MAX_VALUE)
427        );
428        jPanel3Layout.setVerticalGroup(
429            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
430            .addGroup(jPanel3Layout.createSequentialGroup()
431                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
432                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
433        );
434
435        add(jPanel3, java.awt.BorderLayout.PAGE_END);
436    }// </editor-fold>//GEN-END:initComponents
437
438    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
439        if (jComboBox1.getSelectedItem().toString().contains("mysql")) {
440            labeledTextChooser1.set_Text("localhost:3306");
441        } else if (jComboBox1.getSelectedItem().toString().contains("custom")) {
442            labeledTextChooser1.set_Text("jdbc:sql://<path>:port");
443        } else if (jComboBox1.getSelectedItem().toString().contains("derby")) {
444            labeledTextChooser1.set_Text(Main.MPPATH);
445        }
446
447    }//GEN-LAST:event_jComboBox1ActionPerformed
448
449    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
450
451        labeledTextField4.setEnabled(true);
452        labeledTextField5.setEnabled(true);
453
454    }//GEN-LAST:event_jButton2ActionPerformed
455
456    private void jCheckBox3ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jCheckBox3ItemStateChanged
457        labeledTextField1.setEnabled(jCheckBox3.isSelected());
458        labeledTextField2.setEnabled(jCheckBox3.isSelected());
459        labeledTextChooser2.setEnabled(!jCheckBox3.isSelected());
460    }//GEN-LAST:event_jCheckBox3ItemStateChanged
461
462    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
463
464        prefix.setEnabled(true);
465    }//GEN-LAST:event_jButton3ActionPerformed
466
467    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
468
469        try {
470            ConnectionTypeHandler.testDriver(jComboBox1.getSelectedItem().toString());
471            Popup.notice("OK!");
472        } catch (ClassNotFoundException ex) {
473            Popup.error(ex);
474        }
475    }//GEN-LAST:event_jButton1ActionPerformed
476    // Variables declaration - do not modify//GEN-BEGIN:variables
477    private javax.swing.JButton jButton1;
478    private javax.swing.JButton jButton2;
479    private javax.swing.JButton jButton3;
480    private javax.swing.JCheckBox jCheckBox1;
481    private javax.swing.JCheckBox jCheckBox2;
482    private javax.swing.JCheckBox jCheckBox3;
483    private javax.swing.JComboBox jComboBox1;
484    private javax.swing.JLabel jLabel1;
485    private javax.swing.JLabel jLabel2;
486    private javax.swing.JLabel jLabel3;
487    private javax.swing.JLabel jLabel4;
488    private javax.swing.JPanel jPanel1;
489    private javax.swing.JPanel jPanel2;
490    private javax.swing.JPanel jPanel3;
491    private javax.swing.JPanel jPanel4;
492    private javax.swing.JScrollPane jScrollPane1;
493    private javax.swing.JTextArea jTextArea1;
494    private mpv5.ui.beans.LabeledTextChooser labeledTextChooser1;
495    private mpv5.ui.beans.LabeledTextChooser labeledTextChooser2;
496    private mpv5.ui.beans.LabeledTextField labeledTextField1;
497    private mpv5.ui.beans.LabeledTextField labeledTextField2;
498    private mpv5.ui.beans.LabeledTextField labeledTextField3;
499    private mpv5.ui.beans.LabeledTextField labeledTextField4;
500    private mpv5.ui.beans.LabeledTextField labeledTextField5;
501    private mpv5.ui.beans.LabeledTextField prefix;
502    // End of variables declaration//GEN-END:variables
503
504    public boolean next() {
505        if (DBVerification() & DirectoryCreate()) {
506            this.master.dispose();
507            return true;
508        } else {
509            this.master.setCursor(Cursor.DEFAULT_CURSOR);
510            return false;
511        }
512    }
513
514    public boolean back() {
515        return false;
516    }
517
518    public void load() {
519        String dbn = Constants.DATABASENAME;
520        if (forConnId != null) {
521            dbn += forConnId;
522        }
523        labeledTextChooser1.set_Text(Main.MPPATH);
524        labeledTextField3.set_Text(dbn);
525        labeledTextField1.requestFocusInWindow();
526    }
527
528    private Integer getNextConnID() {
529        try {
530            List<Integer> ids = LocalSettings.getConnectionIDs();
531            Integer random = new Random().nextInt();
532            if (!ids.contains(random)) {
533                return random;
534            } else {
535                return getNextConnID();
536            }
537        } catch (Exception ex) {
538            Log.Debug(ex);
539            return -1;
540        }
541    }
542}