Add Legal Notice functionality
[habeas.git] / src / habeas / DatabaseSettingsDialog.java
1 /*
2 * To change this license header, choose License Headers in Project Properties.
3 * To change this template file, choose Tools | Templates
4 * and open the template in the editor.
5 */
6 package habeas;
7
8 import javax.swing.JFileChooser;
9
10 /**
11 *
12 * @author hari
13 */
14 public class DatabaseSettingsDialog extends javax.swing.JDialog {
15
16 /**
17 * Creates new form DatabaseSettings
18 */
19 public DatabaseSettingsDialog(java.awt.Frame parent, boolean modal) {
20 super(parent, modal);
21 initComponents();
22 txtDatabaseURL.setText(Utility.connectionURL);
23 }
24
25 /**
26 * This method is called from within the constructor to initialize the form.
27 * WARNING: Do NOT modify this code. The content of this method is always
28 * regenerated by the Form Editor.
29 */
30 @SuppressWarnings("unchecked")
31 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
32 private void initComponents() {
33
34 jLabel1 = new javax.swing.JLabel();
35 txtDatabaseURL = new javax.swing.JTextField();
36 buttonChooseFile = new javax.swing.JButton();
37 buttonClose = new javax.swing.JButton();
38 buttonApply = new javax.swing.JButton();
39
40 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
41 setTitle("Connection");
42 setLocationByPlatform(true);
43 setResizable(false);
44
45 jLabel1.setText("Path to Database");
46
47 buttonChooseFile.setText("Choose...");
48 buttonChooseFile.addActionListener(new java.awt.event.ActionListener() {
49 public void actionPerformed(java.awt.event.ActionEvent evt) {
50 buttonChooseFileActionPerformed(evt);
51 }
52 });
53
54 buttonClose.setText("Close");
55 buttonClose.addActionListener(new java.awt.event.ActionListener() {
56 public void actionPerformed(java.awt.event.ActionEvent evt) {
57 buttonCloseActionPerformed(evt);
58 }
59 });
60
61 buttonApply.setText("Apply");
62 buttonApply.addActionListener(new java.awt.event.ActionListener() {
63 public void actionPerformed(java.awt.event.ActionEvent evt) {
64 buttonApplyActionPerformed(evt);
65 }
66 });
67
68 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
69 getContentPane().setLayout(layout);
70 layout.setHorizontalGroup(
71 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
72 .addGroup(layout.createSequentialGroup()
73 .addContainerGap()
74 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
75 .addGroup(layout.createSequentialGroup()
76 .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
77 .addGap(0, 0, Short.MAX_VALUE))
78 .addGroup(layout.createSequentialGroup()
79 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
80 .addComponent(txtDatabaseURL, javax.swing.GroupLayout.PREFERRED_SIZE, 231, javax.swing.GroupLayout.PREFERRED_SIZE)
81 .addComponent(buttonApply, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE))
82 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
83 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
84 .addComponent(buttonClose, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
85 .addComponent(buttonChooseFile, javax.swing.GroupLayout.DEFAULT_SIZE, 93, Short.MAX_VALUE))))
86 .addContainerGap())
87 );
88 layout.setVerticalGroup(
89 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
90 .addGroup(layout.createSequentialGroup()
91 .addContainerGap()
92 .addComponent(jLabel1)
93 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
94 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
95 .addComponent(txtDatabaseURL, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
96 .addComponent(buttonChooseFile))
97 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 29, Short.MAX_VALUE)
98 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
99 .addComponent(buttonClose)
100 .addComponent(buttonApply))
101 .addContainerGap())
102 );
103
104 pack();
105 }// </editor-fold>//GEN-END:initComponents
106
107 private void buttonApplyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonApplyActionPerformed
108 // TODO add your handling code here
109 Utility.setConnectionURL (txtDatabaseURL.getText());
110 }//GEN-LAST:event_buttonApplyActionPerformed
111
112 private void buttonCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCloseActionPerformed
113 // TODO add your handling code here:
114 dispose();
115 }//GEN-LAST:event_buttonCloseActionPerformed
116
117 private void buttonChooseFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonChooseFileActionPerformed
118 // TODO add your handling code here:
119 JFileChooser chooser = new JFileChooser ();
120 int i = chooser.showOpenDialog(this);
121 if (i == JFileChooser.APPROVE_OPTION) {
122 txtDatabaseURL.setText(chooser.getSelectedFile().getAbsolutePath());
123 }
124 }//GEN-LAST:event_buttonChooseFileActionPerformed
125
126 /**
127 * @param args the command line arguments
128 */
129 public static void main(String args[]) {
130 /* Set the Nimbus look and feel */
131 //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
132 /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
133 * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
134 */
135 try {
136 for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
137 if ("Nimbus".equals(info.getName())) {
138 javax.swing.UIManager.setLookAndFeel(info.getClassName());
139 break;
140 }
141 }
142 } catch (ClassNotFoundException ex) {
143 java.util.logging.Logger.getLogger(DatabaseSettingsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
144 } catch (InstantiationException ex) {
145 java.util.logging.Logger.getLogger(DatabaseSettingsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
146 } catch (IllegalAccessException ex) {
147 java.util.logging.Logger.getLogger(DatabaseSettingsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
148 } catch (javax.swing.UnsupportedLookAndFeelException ex) {
149 java.util.logging.Logger.getLogger(DatabaseSettingsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
150 }
151 //</editor-fold>
152 //</editor-fold>
153
154 /* Create and display the dialog */
155 java.awt.EventQueue.invokeLater(new Runnable() {
156 public void run() {
157 DatabaseSettingsDialog dialog = new DatabaseSettingsDialog(new javax.swing.JFrame(), true);
158 dialog.addWindowListener(new java.awt.event.WindowAdapter() {
159 @Override
160 public void windowClosing(java.awt.event.WindowEvent e) {
161 System.exit(0);
162 }
163 });
164 dialog.setVisible(true);
165 }
166 });
167 }
168
169 // Variables declaration - do not modify//GEN-BEGIN:variables
170 private javax.swing.JButton buttonApply;
171 private javax.swing.JButton buttonChooseFile;
172 private javax.swing.JButton buttonClose;
173 private javax.swing.JLabel jLabel1;
174 private javax.swing.JTextField txtDatabaseURL;
175 // End of variables declaration//GEN-END:variables
176 }