01: package org.apache.ojb.tools.mapping.reversedb2.actions;
02:
03: import org.apache.ojb.tools.mapping.reversedb2.gui.JDlgDBConnection;
04: import org.apache.ojb.tools.mapping.reversedb2.gui.JIFrmDatabase;
05:
06: /* Copyright 2002-2005 The Apache Software Foundation
07: *
08: * Licensed under the Apache License, Version 2.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
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 {
29:
30: javax.swing.JFrame containingFrame;
31:
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 pcontainingFrame) {
38: this .containingFrame = pcontainingFrame;
39: putValue(NAME, "Open Database");
40: putValue(MNEMONIC_KEY,
41: new Integer(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 actionEvent) {
48: new Thread() {
49: public void run() {
50: final java.sql.Connection conn = new JDlgDBConnection(
51: containingFrame, false)
52: .showAndReturnConnection();
53: if (conn != null) {
54: javax.swing.SwingUtilities
55: .invokeLater(new Runnable() {
56: public void run() {
57: JIFrmDatabase frm = new JIFrmDatabase(
58: conn);
59: containingFrame.getContentPane()
60: .add(frm);
61: frm.setVisible(true);
62: }
63: });
64: }
65: }
66: }.start();
67: }
68: }
|