1 package org.apache.ojb.tools.mapping.reversedb2.actions; 2 3 17 18 import org.apache.ojb.broker.metadata.DescriptorRepository; 19 20 24 public class ActionSaveOJBRepository extends javax.swing.AbstractAction 25 { 26 DescriptorRepository aRepository; 27 java.io.File theFile; 28 29 public ActionSaveOJBRepository(DescriptorRepository paRepository, java.io.File fileSaveTo) 30 { 31 super("Save"); 32 putValue(MNEMONIC_KEY, new Integer (java.awt.event.KeyEvent.VK_S)); 33 aRepository = paRepository; 34 theFile = fileSaveTo; 35 } 36 37 public void actionPerformed(java.awt.event.ActionEvent evt) 38 { 39 String xmlString = aRepository.toXML(); 40 try 41 { 42 if (!theFile.exists()) theFile.createNewFile(); 43 java.io.PrintWriter pw = new java.io.PrintWriter (new java.io.FileOutputStream ( theFile )); 44 pw.println(xmlString); 45 pw.close(); 46 } 47 catch (Throwable t) 49 { 50 javax.swing.JOptionPane.showMessageDialog((java.awt.Component )evt.getSource(), t.getMessage(), "Save repository.xml", javax.swing.JOptionPane.ERROR_MESSAGE); 51 } 52 } 53 } 54 | Popular Tags |