KickJava   Java API By Example, From Geeks To Geeks.

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


1 // {{{ copyright
2

3 /********************************************************************
4  *
5  * $Id: CommandFileOpen.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
39 import de.qfs.lib.command.CancelCommandException;
40 import de.qfs.lib.command.Command;
41 import de.qfs.lib.command.CommandException;
42 import de.qfs.lib.command.Invokable;
43 import de.qfs.lib.log.Log;
44 import de.qfs.lib.log.Logger;
45
46 import de.qfs.apps.qflog.App;
47 import de.qfs.apps.qflog.Model;
48
49 import de.qfs.apps.qflog.logview.LogView;
50 import de.qfs.apps.qflog.logview.command.CommandSaveLog;
51
52 // }}}
53

54 /**
55  * This Command creates a new view for a LogFile.
56  *
57  * @author Gregor Schmid
58  * @version $Revision: 1.10 $
59  */

60 public class CommandFileOpen extends Command
61 implements Invokable
62 {
63     // {{{ variables
64

65     /**
66      * The Logger used for logging.
67      */

68     private final static Logger logger = new Logger (CommandFileOpen.class);
69
70     /**
71      * The parent Frame for the FileChooser.
72      */

73     private Frame JavaDoc parent;
74
75     /**
76      * The file to open.
77      */

78     private File JavaDoc file;
79
80     // }}}
81

82     // {{{ constructors
83

84     /**
85      * Create a new CommandFileOpen.
86      *
87      * @param source The source of the Command.
88      * @param parent The parent Frame for the FileChooser.
89      */

90     public CommandFileOpen (Object JavaDoc source, Frame JavaDoc parent)
91     {
92         super (source);
93         this.parent = parent;
94     }
95
96     /**
97      * Create a new CommandFileOpen.
98      *
99      * @param source The source of the Command.
100      * @param parent The parent Frame for the FileChooser - ignored.
101      * @param file The file to open.
102      */

103     public CommandFileOpen (Object JavaDoc source, Frame JavaDoc parent, File JavaDoc file)
104     {
105         super (source);
106         this.parent = parent;
107         this.file = file;
108     }
109
110     // }}}
111

112     // {{{ invoke
113

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

121     public Object JavaDoc invoke()
122          throws CommandException
123     {
124         if (logger.level >= Log.MTD) {
125             logger.log(Log.MTD, "invoke()", "");
126         }
127
128         LogView view = new LogView ();
129         view.setLoggingEnabled(true);
130         // view.getConfigurator().register();
131
App.getCommandDistributor().assignCommandSilently
132             (new CommandSaveLog (this, parent, view, file, false, false));
133
134         Model.instance().addView(view);
135
136         // String name = view.getClientName();
137
// if (name == null) {
138
// name = "unknown";
139
// }
140
// int id = Model.instance().getNewId(name);
141

142         // try {
143
// LogListenerImpl listener =
144
// new LogListenerImpl (name, id, true, view);
145
// } catch (RemoteException ex) {
146
// // shouldn't happen
147
// if (logger.level >= Log.ERR) {
148
// logger.log("invoke()", ex);
149
// }
150
// return null;
151
// }
152

153         // if (file == null) {
154
// file = FileChooser.openLog(parent);
155
// if (file == null) {
156
// throw new CancelCommandException();
157
// }
158
// }
159

160         // String name = "unknown";
161
// try {
162
// ObjectInputStream ois = new ObjectInputStream
163
// (new FileInputStream (file));
164
// int version = ois.readInt();
165
// name = (String) ((Object[]) ois.readObject())[0];
166
// ois.close();
167
// } catch (Exception ex) {
168
// if (logger.level >= Log.MSG) {
169
// logger.log(Log.MSG, "invoke()", ex);
170
// }
171
// }
172
// int id = Model.instance().getNewId(name);
173
// try {
174
// LogListenerImpl listener =
175
// new LogListenerImpl (name, id, true);
176
// } catch (RemoteException ex) {
177
// if (logger.level >= Log.ERR) {
178
// logger.log("invoke()", ex);
179
// }
180
// return null;
181
// }
182
// App.getCommandDistributor().assignCommandSilently
183
// (new CommandSaveLog (this, parent,
184
// Model.instance().getTableModel()
185
// .getViewForListener(0), file,
186
// false, false));
187
return null;
188     }
189
190     // }}}
191
}
192
Popular Tags