1 package org.apache.ojb.tools.mapping.reversedb2.actions; 2 import javax.swing.JFileChooser ; 3 4 import org.apache.ojb.broker.metadata.DescriptorRepository; 5 import org.apache.ojb.broker.metadata.RepositoryPersistor; 6 import org.apache.ojb.tools.mapping.reversedb2.Main; 7 import org.apache.ojb.tools.mapping.reversedb2.gui.JIFrmOJBRepository; 8 22 23 27 public class ActionOpenOJBRepository extends javax.swing.AbstractAction 28 { 29 private javax.swing.JFrame containingFrame; 30 31 public ActionOpenOJBRepository(javax.swing.JFrame pcontainingFrame) 32 { 33 this.containingFrame = pcontainingFrame; 34 putValue(NAME, "Open OJB Repository"); 35 putValue(MNEMONIC_KEY, new Integer (java.awt.event.KeyEvent.VK_O)); 36 } 37 38 public void actionPerformed (java.awt.event.ActionEvent actionEvent) 39 { 40 String lastPath = Main.getProperties().getProperty("lastFileChooserPosition"); 41 javax.swing.JFileChooser fileChooser = new javax.swing.JFileChooser (lastPath); 42 if (fileChooser.showOpenDialog(containingFrame)==JFileChooser.APPROVE_OPTION) 43 { 44 final java.io.File selectedFile = fileChooser.getSelectedFile(); 45 Main.getProperties().setProperty("lastFileChooserPosition", selectedFile.getParentFile().getAbsolutePath()); 46 Main.getProperties().storeProperties(""); 47 javax.swing.SwingUtilities.invokeLater(new Runnable () 48 { 49 public void run() 50 { 51 try 52 { 53 RepositoryPersistor persistor = new RepositoryPersistor (); 54 DescriptorRepository repository = persistor.readDescriptorRepository(selectedFile.getCanonicalPath()); 55 JIFrmOJBRepository frm = new JIFrmOJBRepository(repository); 56 containingFrame.getContentPane().add(frm); 57 frm.setVisible(true); 58 } 59 catch (Throwable t) 60 { 61 t.printStackTrace(); 62 } 63 } 64 }); 65 } 66 } 67 } 68 | Popular Tags |