PageRenderTime 270ms CodeModel.GetById 80ms app.highlight 133ms RepoModel.GetById 48ms app.codeStats 1ms

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

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