PageRenderTime 81ms CodeModel.GetById 40ms app.highlight 34ms RepoModel.GetById 2ms app.codeStats 0ms

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

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