KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > tools > mapping > reversedb > gui > JDlgDBConnection


1 package org.apache.ojb.tools.mapping.reversedb.gui;
2
3 /* Copyright 2002-2005 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 /**
19  *
20  * @author <a HREF="mailto:bfl@florianbruckner.com">Florian Bruckner</a>
21  * @version $Id: JDlgDBConnection.java,v 1.1.2.1 2005/12/21 22:32:02 tomdz Exp $
22  */

23 public class JDlgDBConnection extends javax.swing.JDialog JavaDoc {
24
25     JFrmMainFrame mainFrame;
26     /** Creates new form JDlgDBConnection */
27     public JDlgDBConnection(java.awt.Frame JavaDoc parent, boolean modal,
28       JFrmMainFrame aMain)
29     {
30         super(parent, modal);
31         initComponents();
32         mainFrame = aMain;
33         this.tfJDBCDriver.setText(mainFrame.getProperty(JFrmMainFrame.JDBC_DRIVER, ""));
34         this.tfJDBCURL.setText(mainFrame.getProperty(JFrmMainFrame.JDBC_URL, ""));
35         this.tfUsername.setText(mainFrame.getProperty(JFrmMainFrame.JDBC_USER, ""));
36         this.tfPassword.setText(mainFrame.getProperty(JFrmMainFrame.JDBC_PASSWORD, ""));
37     }
38     
39     /** This method is called from within the constructor to
40      * initialize the form.
41      * WARNING: Do NOT modify this code. The content of this method is
42      * always regenerated by the Form Editor.
43      */

44     private void initComponents()//GEN-BEGIN:initComponents
45
{
46         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
47
48         lblJDBCDriver = new javax.swing.JLabel JavaDoc();
49         tfJDBCDriver = new javax.swing.JTextField JavaDoc();
50         lblJDBCURL = new javax.swing.JLabel JavaDoc();
51         tfJDBCURL = new javax.swing.JTextField JavaDoc();
52         lblUsername = new javax.swing.JLabel JavaDoc();
53         tfUsername = new javax.swing.JTextField JavaDoc();
54         lblPassword = new javax.swing.JLabel JavaDoc();
55         tfPassword = new javax.swing.JPasswordField JavaDoc();
56         jPanel1 = new javax.swing.JPanel JavaDoc();
57         pbCancel = new javax.swing.JButton JavaDoc();
58         pbConnect = new javax.swing.JButton JavaDoc();
59
60         getContentPane().setLayout(new java.awt.GridBagLayout JavaDoc());
61
62         addWindowListener(new java.awt.event.WindowAdapter JavaDoc()
63         {
64             public void windowClosing(java.awt.event.WindowEvent JavaDoc evt)
65             {
66                 closeDialog(evt);
67             }
68         });
69
70         lblJDBCDriver.setText("JDBC Driver Class:");
71         lblJDBCDriver.setLabelFor(tfJDBCDriver);
72         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
73         gridBagConstraints.gridx = 0;
74         gridBagConstraints.gridy = 0;
75         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
76         getContentPane().add(lblJDBCDriver, gridBagConstraints);
77
78         tfJDBCDriver.setText("jTextField1");
79         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
80         gridBagConstraints.gridx = 1;
81         gridBagConstraints.gridy = 0;
82         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
83         gridBagConstraints.weightx = 1.0;
84         getContentPane().add(tfJDBCDriver, gridBagConstraints);
85
86         lblJDBCURL.setText("JDBC URL:");
87         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
88         gridBagConstraints.gridx = 0;
89         gridBagConstraints.gridy = 1;
90         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
91         getContentPane().add(lblJDBCURL, gridBagConstraints);
92
93         tfJDBCURL.setColumns(40);
94         tfJDBCURL.setText("jTextField2");
95         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
96         gridBagConstraints.gridx = 1;
97         gridBagConstraints.gridy = 1;
98         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
99         gridBagConstraints.weightx = 1.0;
100         getContentPane().add(tfJDBCURL, gridBagConstraints);
101
102         lblUsername.setText("Username:");
103         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
104         gridBagConstraints.gridx = 0;
105         gridBagConstraints.gridy = 2;
106         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
107         getContentPane().add(lblUsername, gridBagConstraints);
108
109         tfUsername.setText("jTextField3");
110         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
111         gridBagConstraints.gridx = 1;
112         gridBagConstraints.gridy = 2;
113         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
114         gridBagConstraints.weightx = 1.0;
115         getContentPane().add(tfUsername, gridBagConstraints);
116
117         lblPassword.setText("Password:");
118         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
119         gridBagConstraints.gridx = 0;
120         gridBagConstraints.gridy = 3;
121         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
122         getContentPane().add(lblPassword, gridBagConstraints);
123
124         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
125         gridBagConstraints.gridx = 1;
126         gridBagConstraints.gridy = 3;
127         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
128         gridBagConstraints.weightx = 1.0;
129         getContentPane().add(tfPassword, gridBagConstraints);
130
131         pbCancel.setText("Cancel");
132         pbCancel.addActionListener(new java.awt.event.ActionListener JavaDoc()
133         {
134             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
135             {
136                 pbCancelActionPerformed(evt);
137             }
138         });
139
140         jPanel1.add(pbCancel);
141
142         pbConnect.setText("Connect");
143         pbConnect.addActionListener(new java.awt.event.ActionListener JavaDoc()
144         {
145             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
146             {
147                 pbConnectActionPerformed(evt);
148             }
149         });
150
151         jPanel1.add(pbConnect);
152
153         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
154         gridBagConstraints.gridx = 1;
155         gridBagConstraints.gridy = 4;
156         gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
157         getContentPane().add(jPanel1, gridBagConstraints);
158
159         pack();
160     }//GEN-END:initComponents
161

162   private void pbCancelActionPerformed (java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_pbCancelActionPerformed
163
{//GEN-HEADEREND:event_pbCancelActionPerformed
164
// Add your handling code here:
165
dispose();
166   }//GEN-LAST:event_pbCancelActionPerformed
167

168     private void pbConnectActionPerformed (java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_pbConnectActionPerformed
169
{//GEN-HEADEREND:event_pbConnectActionPerformed
170
// Add your handling code here:
171
mainFrame.setProperty(JFrmMainFrame.JDBC_DRIVER, tfJDBCDriver.getText());
172       mainFrame.setProperty(JFrmMainFrame.JDBC_URL, tfJDBCURL.getText());
173       mainFrame.setProperty(JFrmMainFrame.JDBC_USER, tfUsername.getText());
174       mainFrame.setProperty(JFrmMainFrame.JDBC_PASSWORD, new String JavaDoc(this.tfPassword.getPassword()));
175       new org.apache.ojb.tools.mapping.reversedb.gui.actions.DBConnectAction(mainFrame).actionPerformed(null);
176       dispose();
177     }//GEN-LAST:event_pbConnectActionPerformed
178

179     /** Closes the dialog */
180     private void closeDialog(java.awt.event.WindowEvent JavaDoc evt) {//GEN-FIRST:event_closeDialog
181
setVisible(false);
182         dispose();
183     }//GEN-LAST:event_closeDialog
184

185     /**
186      * @param args the command line arguments
187      */

188     public static void main(String JavaDoc args[]) {
189         // new JDlgDBConnection(new javax.swing.JFrame(), true).show();
190
}
191     
192     
193     // Variables declaration - do not modify//GEN-BEGIN:variables
194
private javax.swing.JLabel JavaDoc lblJDBCURL;
195     private javax.swing.JLabel JavaDoc lblJDBCDriver;
196     private javax.swing.JPanel JavaDoc jPanel1;
197     private javax.swing.JTextField JavaDoc tfJDBCDriver;
198     private javax.swing.JLabel JavaDoc lblPassword;
199     private javax.swing.JPasswordField JavaDoc tfPassword;
200     private javax.swing.JLabel JavaDoc lblUsername;
201     private javax.swing.JTextField JavaDoc tfUsername;
202     private javax.swing.JButton JavaDoc pbConnect;
203     private javax.swing.JButton JavaDoc pbCancel;
204     private javax.swing.JTextField JavaDoc tfJDBCURL;
205     // End of variables declaration//GEN-END:variables
206

207 }
208
209 /***************************** Changelog *****************************
210 // $Log: JDlgDBConnection.java,v $
211 // Revision 1.1.2.1 2005/12/21 22:32:02 tomdz
212 // Updated license
213 //
214 // Revision 1.1 2004/05/05 16:38:49 arminw
215 // fix fault
216 // wrong package structure used:
217 // org.apache.ojb.tools.reversdb
218 // org.apache.ojb.tools.reversdb2
219 //
220 // instead of
221 // org.apache.ojb.tools.mapping.reversdb
222 // org.apache.ojb.tools.mapping.reversdb2
223 //
224 // Revision 1.1 2004/05/04 13:44:59 arminw
225 // move reverseDB stuff
226 //
227 // Revision 1.6 2004/04/05 12:16:23 tomdz
228 // Fixed/updated license in files leftover from automatic license transition
229 //
230 // Revision 1.5 2004/04/04 23:53:42 brianm
231 // Fixed initial copyright dates to match cvs repository
232 //
233 // Revision 1.4 2004/03/11 18:16:22 brianm
234 // ASL 2.0
235 //
236 // Revision 1.3 2002/06/18 12:26:41 florianbruckner
237 // changes in Netbeans Form definitions after move to jakarta.
238 //
239 // Revision 1.2 2002/06/17 19:34:34 jvanzyl
240 // Correcting all the package references.
241 // PR:
242 // Obtained from:
243 // Submitted by:
244 // Reviewed by:
245 //
246 // Revision 1.1.1.1 2002/06/17 18:16:54 jvanzyl
247 // Initial OJB import
248 //
249 // Revision 1.2 2002/05/16 11:47:09 florianbruckner
250 // fix CR/LF issue, change license to ASL
251 //
252 // Revision 1.1 2002/04/18 11:44:16 mpoeschl
253 //
254 // move files to new location
255 //
256 // Revision 1.3 2002/04/07 09:05:17 thma
257 // *** empty log message ***
258 //
259 // Revision 1.2 2002/03/11 17:36:26 florianbruckner
260 // fix line break issue for these files that were previously checked in with -kb
261 //
262 // Revision 1.1 2002/03/04 17:19:32 thma
263 // initial checking for Florians Reverse engineering tool
264 //
265 // Revision 1.1.1.1 2002/02/20 13:35:25 Administrator
266 // initial import
267 //
268 /***************************** Changelog *****************************/

269
Popular Tags