KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > tools > mapping > reversedb2 > actions > ActionSaveAsOJBRepository


1 package org.apache.ojb.tools.mapping.reversedb2.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 import javax.swing.JFileChooser JavaDoc;
19
20 import org.apache.ojb.broker.metadata.DescriptorRepository;
21 import org.apache.ojb.tools.mapping.reversedb2.Main;
22
23 /**
24  * Saves the given DescriptorRepository to a file selected by the use
25  * @author Administrator
26  */

27 public class ActionSaveAsOJBRepository extends javax.swing.AbstractAction JavaDoc
28 {
29     DescriptorRepository aRepository;
30
31     /** Creates a new instance of ActionSaveOJBRepository */
32     public ActionSaveAsOJBRepository(DescriptorRepository paRepository)
33     {
34         super("Save As...");
35         putValue(MNEMONIC_KEY, new Integer JavaDoc(java.awt.event.KeyEvent.VK_A));
36         aRepository = paRepository;
37     }
38     
39     public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
40     {
41         String JavaDoc lastPath = Main.getProperties().getProperty("lastFileChooserPosition");
42         javax.swing.JFileChooser JavaDoc fileChooser = new javax.swing.JFileChooser JavaDoc (lastPath);
43         if (fileChooser.showSaveDialog((java.awt.Component JavaDoc)evt.getSource())==JFileChooser.APPROVE_OPTION)
44         {
45             final java.io.File JavaDoc selectedFile = fileChooser.getSelectedFile();
46             Main.getProperties().setProperty("lastFileChooserPosition", selectedFile.getParentFile().getAbsolutePath());
47             Main.getProperties().storeProperties("");
48
49             new ActionSaveOJBRepository(aRepository, selectedFile).actionPerformed(evt);
50             
51 /* javax.swing.SwingUtilities.invokeLater(new Runnable()
52             {
53                 public void run()
54                 {
55                     try
56                     {
57                         RepositoryPersistor persistor = new RepositoryPersistor ();
58                         DescriptorRepository repository = persistor.readFromFile(selectedFile.getCanonicalPath());
59                         JIFrmOJBRepository frm = new JIFrmOJBRepository(repository);
60                         containingFrame.getContentPane().add(frm);
61                         frm.setVisible(true);
62                     }
63                     catch (Throwable t)
64                     {
65                         t.printStackTrace();
66                     }
67                 }
68             });
69  */

70         }
71     }
72 }
73
Popular Tags