KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.apache.ojb.tools.mapping.reversedb.gui.actions;
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: SaveXMLAction.java,v 1.1.2.1 2005/12/21 22:32:06 tomdz Exp $
22  */

23 public class SaveXMLAction extends javax.swing.AbstractAction JavaDoc
24 {
25   org.apache.ojb.tools.mapping.reversedb.gui.JFrmMainFrame mainFrame;
26   
27   /** Creates a new instance of SaveXMLAction */
28   public SaveXMLAction (org.apache.ojb.tools.mapping.reversedb.gui.JFrmMainFrame pmainFrame)
29   {
30     super();
31     mainFrame = pmainFrame;
32     this.putValue(NAME, "Save XML");
33   }
34   
35   public void actionPerformed (java.awt.event.ActionEvent JavaDoc actionEvent)
36   {
37     // 1. Open a Filechooser dialog to get the path for the XML file to
38
// generate
39
javax.swing.JFileChooser JavaDoc fileChooser = new javax.swing.JFileChooser JavaDoc();
40     int rc = fileChooser.showSaveDialog(mainFrame);
41     if (rc == javax.swing.JFileChooser.APPROVE_OPTION)
42     {
43       java.io.File JavaDoc f = fileChooser.getSelectedFile();
44       try
45       {
46         if (!f.exists()) f.createNewFile();
47         if (f.canWrite())
48         {
49           java.io.PrintWriter JavaDoc pw =
50             new java.io.PrintWriter JavaDoc(new java.io.FileOutputStream JavaDoc(f));
51           mainFrame.getDBMeta().writeXML(pw);
52           pw.close();
53         }
54       }
55       catch (java.io.FileNotFoundException JavaDoc fnfe)
56       {
57         fnfe.printStackTrace();
58       }
59       catch (java.io.IOException JavaDoc ioex)
60       {
61         ioex.printStackTrace();
62       }
63     }
64   }
65   
66 }
67
68 /***************************** Changelog *****************************
69 // $Log: SaveXMLAction.java,v $
70 // Revision 1.1.2.1 2005/12/21 22:32:06 tomdz
71 // Updated license
72 //
73 // Revision 1.1 2004/05/05 16:38:25 arminw
74 // fix fault
75 // wrong package structure used:
76 // org.apache.ojb.tools.reversdb
77 // org.apache.ojb.tools.reversdb2
78 //
79 // instead of
80 // org.apache.ojb.tools.mapping.reversdb
81 // org.apache.ojb.tools.mapping.reversdb2
82 //
83 // Revision 1.1 2004/05/04 13:44:59 arminw
84 // move reverseDB stuff
85 //
86 // Revision 1.7 2004/04/05 12:16:24 tomdz
87 // Fixed/updated license in files leftover from automatic license transition
88 //
89 // Revision 1.6 2004/04/04 23:53:42 brianm
90 // Fixed initial copyright dates to match cvs repository
91 //
92 // Revision 1.5 2004/03/11 18:16:23 brianm
93 // ASL 2.0
94 //
95 // Revision 1.4 2003/06/21 10:40:06 florianbruckner
96 // improve error reporting; use writeXML(PrintWriter) instead of getXML()
97 //
98 // Revision 1.3 2002/11/08 13:47:38 brj
99 // corrected some compiler warnings
100 //
101 // Revision 1.2 2002/06/17 19:34:34 jvanzyl
102 // Correcting all the package references.
103 // PR:
104 // Obtained from:
105 // Submitted by:
106 // Reviewed by:
107 //
108 // Revision 1.1.1.1 2002/06/17 18:16:54 jvanzyl
109 // Initial OJB import
110 //
111 // Revision 1.2 2002/05/16 11:47:09 florianbruckner
112 // fix CR/LF issue, change license to ASL
113 //
114 // Revision 1.1 2002/04/18 11:44:16 mpoeschl
115 //
116 // move files to new location
117 //
118 // Revision 1.1 2002/03/04 17:19:33 thma
119 // initial checking for Florians Reverse engineering tool
120 //
121 // Revision 1.1.1.1 2002/02/20 13:35:25 Administrator
122 // initial import
123 //
124 /***************************** Changelog *****************************/

125
Popular Tags