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