KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > tools > mapping > reversedb2 > actions > ActionOpenDatabase


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

18
19
20
21 /** First opens a JDlgDBConnection to get a JDBC connection and if this
22  * was successful, a JIFrmDatabase is created with this connection and
23  * added to the parentFrame specified in the constructor.
24  * @author <a HREF="mailto:bfl@florianbruckner.com">Florian Bruckner</a>
25  * @version $Id: ActionOpenDatabase.java,v 1.1.2.1 2005/12/21 22:32:41 tomdz Exp $
26  */

27
28 public class ActionOpenDatabase extends javax.swing.AbstractAction JavaDoc
29 {
30     
31     javax.swing.JFrame JavaDoc containingFrame;
32     /** Creates a new instance of ActionOpenDatabase, pcontainingFrame
33      * is the parent frame for the dialog and the containing frame
34      * for the internal frame created.
35      * @param pcontainingFrame parent frame for the dialog, containing frame for the IFrame
36      */

37     public ActionOpenDatabase(javax.swing.JFrame JavaDoc pcontainingFrame)
38     {
39         this.containingFrame = pcontainingFrame;
40         putValue(NAME, "Open Database");
41         putValue(MNEMONIC_KEY, new Integer JavaDoc(java.awt.event.KeyEvent.VK_C));
42     }
43     
44     /** Called to execute this action.
45      * @param actionEvent
46      */

47     public void actionPerformed(java.awt.event.ActionEvent JavaDoc actionEvent)
48     {
49         new Thread JavaDoc()
50         {
51             public void run()
52             {
53                 final java.sql.Connection JavaDoc conn = new JDlgDBConnection(containingFrame, false).showAndReturnConnection();
54                 if (conn != null)
55                 {
56                     javax.swing.SwingUtilities.invokeLater(new Runnable JavaDoc()
57                     {
58                         public void run()
59                         {
60                             JIFrmDatabase frm = new JIFrmDatabase(conn);
61                             containingFrame.getContentPane().add(frm);
62                             frm.setVisible(true);
63                         }
64                     });
65                 }
66             }
67         }.start();
68     }
69 }
70
Popular Tags