1 package org.apache.ojb.tools.mapping.reversedb.gui.actions; 2 3 17 18 23 public class SaveXMLAction extends javax.swing.AbstractAction 24 { 25 org.apache.ojb.tools.mapping.reversedb.gui.JFrmMainFrame mainFrame; 26 27 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 actionEvent) 36 { 37 javax.swing.JFileChooser fileChooser = new javax.swing.JFileChooser (); 40 int rc = fileChooser.showSaveDialog(mainFrame); 41 if (rc == javax.swing.JFileChooser.APPROVE_OPTION) 42 { 43 java.io.File f = fileChooser.getSelectedFile(); 44 try 45 { 46 if (!f.exists()) f.createNewFile(); 47 if (f.canWrite()) 48 { 49 java.io.PrintWriter pw = 50 new java.io.PrintWriter (new java.io.FileOutputStream (f)); 51 mainFrame.getDBMeta().writeXML(pw); 52 pw.close(); 53 } 54 } 55 catch (java.io.FileNotFoundException fnfe) 56 { 57 fnfe.printStackTrace(); 58 } 59 catch (java.io.IOException ioex) 60 { 61 ioex.printStackTrace(); 62 } 63 } 64 } 65 66 } 67 68 125 | Popular Tags |