01: package org.apache.ojb.tools.mapping.reversedb2.actions;
02:
03: /* Copyright 2002-2005 The Apache Software Foundation
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * 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;
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
28: javax.swing.AbstractAction {
29: DescriptorRepository aRepository;
30:
31: /** Creates a new instance of ActionSaveOJBRepository */
32: public ActionSaveAsOJBRepository(DescriptorRepository paRepository) {
33: super ("Save As...");
34: putValue(MNEMONIC_KEY,
35: new Integer(java.awt.event.KeyEvent.VK_A));
36: aRepository = paRepository;
37: }
38:
39: public void actionPerformed(java.awt.event.ActionEvent evt) {
40: String lastPath = Main.getProperties().getProperty(
41: "lastFileChooserPosition");
42: javax.swing.JFileChooser fileChooser = new javax.swing.JFileChooser(
43: lastPath);
44: if (fileChooser.showSaveDialog((java.awt.Component) evt
45: .getSource()) == JFileChooser.APPROVE_OPTION) {
46: final java.io.File selectedFile = fileChooser
47: .getSelectedFile();
48: Main.getProperties().setProperty("lastFileChooserPosition",
49: selectedFile.getParentFile().getAbsolutePath());
50: Main.getProperties().storeProperties("");
51:
52: new ActionSaveOJBRepository(aRepository, selectedFile)
53: .actionPerformed(evt);
54:
55: /* javax.swing.SwingUtilities.invokeLater(new Runnable()
56: {
57: public void run()
58: {
59: try
60: {
61: RepositoryPersistor persistor = new RepositoryPersistor ();
62: DescriptorRepository repository = persistor.readFromFile(selectedFile.getCanonicalPath());
63: JIFrmOJBRepository frm = new JIFrmOJBRepository(repository);
64: containingFrame.getContentPane().add(frm);
65: frm.setVisible(true);
66: }
67: catch (Throwable t)
68: {
69: t.printStackTrace();
70: }
71: }
72: });
73: */
74: }
75: }
76: }
|