KickJava   Java API By Example, From Geeks To Geeks.

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


1 // {{{ copyright
2

3 /********************************************************************
4  *
5  * $Id: CommandOpenLogView.java,v 1.11 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.Frame JavaDoc;
35
36 import javax.swing.JTable JavaDoc;
37 import javax.swing.SwingUtilities JavaDoc;
38
39 import de.qfs.lib.command.Command;
40 import de.qfs.lib.command.CommandException;
41 import de.qfs.lib.command.Invokable;
42 import de.qfs.lib.gui.FilteredAndSortedTableModel;
43 import de.qfs.lib.log.Log;
44 import de.qfs.lib.log.Logger;
45
46 import de.qfs.apps.qflog.Model;
47
48 // }}}
49

50 /**
51  * This Command opens a view for the listener in the selected row of the
52  * listener table.
53  *
54  * @author Gregor Schmid
55  * @version $Revision: 1.11 $
56  */

57 public class CommandOpenLogView extends Command
58 implements Invokable
59 {
60     // {{{ variables
61

62     /**
63      * The Logger used for logging.
64      */

65     private final static Logger logger = new Logger (CommandOpenLogView.class);
66
67     /**
68      * The listener table.
69      */

70     private JTable JavaDoc table;
71
72     /**
73      * The row to take the listener from.
74      */

75     private int row = -1;
76
77     // }}}
78

79     // {{{ constructor
80

81     /**
82      * Create a new CommandOpenLogView.
83      *
84      * @param source The source of the Command.
85      * @param table The view table.
86      */

87     public CommandOpenLogView (Object JavaDoc source, JTable JavaDoc table)
88
89     {
90         super (source);
91         if (logger.level >= Log.MTD) {
92             logger.log(Log.MTD, "CommandOpenLogView(Object,ViewTable)",
93                        logger.level < Log.MTDDETAIL ? "" :
94                        "source: " + source + ", " +
95                        "table: " + table);
96         }
97         this.table = table;
98     }
99
100     /**
101      * Create a new CommandOpenLogView.
102      *
103      * @param source The source of the Command.
104      * @param table The view table.
105      * @param row The row of the view.
106      */

107     public CommandOpenLogView (Object JavaDoc source, JTable JavaDoc table, int row)
108
109     {
110         super (source);
111         if (logger.level >= Log.MTD) {
112             logger.log(Log.MTD, "CommandOpenLogView(Object,ViewTable)",
113                        logger.level < Log.MTDDETAIL ? "" :
114                        "source: " + source + ", " +
115                        "table: " + table);
116         }
117         this.table = table;
118         this.row = row;
119     }
120
121     // }}}
122

123     // {{{ invoke
124

125     /**
126      * Invoke the command.
127      *
128      * @return Always null.
129      *
130      * @throws CommandException Never.
131      */

132     public Object JavaDoc invoke()
133          throws CommandException
134     {
135         if (logger.level >= Log.MTD) {
136             logger.log(Log.MTD, "invoke()", "");
137         }
138
139         if (row == -1) {
140             row = table.getSelectedRow();
141         }
142         if (row >= 0) {
143             row = ((FilteredAndSortedTableModel) table.getModel())
144                 .getMappedRow(row);
145             final Frame JavaDoc frame =
146                 Model.instance().getFrameForRow(row);
147             frame.show();
148             frame.requestFocus();
149         }
150         return null;
151     }
152
153     // }}}
154
}
155
Popular Tags