KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > qfs > apps > qflog > command > CommandFileSaveAs


1 // {{{ copyright
2

3 /********************************************************************
4  *
5  * $Id: CommandFileSaveAs.java,v 1.10 2000/07/05 14:07:44 gs Exp $
6  *
7  * The contents of this file are subject to the Mozilla Public
8  * License Version 1.1 (the "License"); you may not use this file
9  * except in compliance with the License. You may obtain a copy of
10  * the License at http://www.mozilla.org/MPL/
11  *
12  * Software distributed under the License is distributed on an "AS
13  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
14  * implied. See the License for the specific language governing
15  * rights and limitations under the License.
16  *
17  * The Original Code is qfs.de code.
18  *
19  * The Initial Developer of the Original Code is Gregor Schmid.
20  * Portions created by Gregor Schmid are
21  * Copyright (C) 1999 Quality First Software, Gregor Schmid.
22  * All Rights Reserved.
23  *
24  * Contributor(s):
25  *
26  *******************************************************************/

27
28 // }}}
29

30 package de.qfs.apps.qflog.command;
31
32 // {{{ imports
33

34 import java.awt.Component JavaDoc;
35 import java.awt.Frame JavaDoc;
36
37 import java.io.File JavaDoc;
38 import java.io.FileOutputStream JavaDoc;
39 import java.io.IOException JavaDoc;
40 import java.io.ObjectOutputStream JavaDoc;
41
42 import javax.swing.JTable JavaDoc;
43
44 import de.qfs.lib.command.CancelCommandException;
45 import de.qfs.lib.command.Command;
46 import de.qfs.lib.command.CommandException;
47 import de.qfs.lib.command.MessageCommandException;
48 import de.qfs.lib.command.Invokable;
49 import de.qfs.lib.gui.FilteredAndSortedTableModel;
50 import de.qfs.lib.log.Log;
51 import de.qfs.lib.log.Logger;
52
53 import de.qfs.apps.qflog.App;
54 import de.qfs.apps.qflog.FileChooser;
55 import de.qfs.apps.qflog.LogListenerImpl;
56 import de.qfs.apps.qflog.Model;
57
58 import de.qfs.apps.qflog.logview.LogView;
59 import de.qfs.apps.qflog.logview.command.CommandSaveLog;
60
61 // }}}
62

63 /**
64  * This Command saves the log entries from the listener in the selected row of
65  * the listener table into a log file.
66  *
67  * @author Gregor Schmid
68  * @version $Revision: 1.10 $
69  */

70 public class CommandFileSaveAs extends Command
71 implements Invokable
72 {
73     // {{{ variables
74

75     /**
76      * The Logger used for logging.
77      */

78     private final static Logger logger = new Logger (CommandFileSaveAs.class);
79
80     /**
81      * The parent Frame for the FileChooser.
82      */

83     private Frame JavaDoc parent;
84
85     /**
86      * The listener table.
87      */

88     private JTable JavaDoc table;
89
90     // }}}
91

92     // {{{ constructor
93

94     /**
95      * Create a new CommandFileSaveAs.
96      *
97      * @param source The source of the Command.
98      * @param parent The parent Frame for the FileChooser.
99      * @param table The listener table.
100      */

101     public CommandFileSaveAs (Object JavaDoc source, Frame JavaDoc parent, JTable JavaDoc table)
102     {
103         super (source);
104         this.parent = parent;
105         this.table = table;
106     }
107
108     // }}}
109

110     // {{{ invoke
111

112     /**
113      * Invoke the command.
114      *
115      * @return Always null.
116      *
117      * @throws CommandException Never.
118      */

119     public Object JavaDoc invoke()
120          throws CommandException
121     {
122         if (logger.level >= Log.MTD) {
123             logger.log(Log.MTD, "invoke()", "");
124         }
125
126         int row = table.getSelectedRow();
127         if (row == -1) {
128             return null;
129         }
130         row = ((FilteredAndSortedTableModel) table.getModel())
131             .getMappedRow(row);
132
133         LogView view = Model.instance().getViewForRow(row);
134
135         App.getCommandDistributor().assignCommandSilently
136             (new CommandSaveLog (this, parent, view, null, true, true));
137         return null;
138     }
139
140     // }}}
141
}
142
Popular Tags