Line | Hits | Source |
---|---|---|
1 | /******************************************************************************* | |
2 | * InternetCafe is a software solution that helps the management of Cybercafes | |
3 | * according with the ITALIAN DECREE LAW ON ANTI-TERROR MEASURES, 27 JULY 2005. | |
4 | * Copyright (C) 2006 Guido Angelo Ingenito | |
5 | ||
6 | * This program is free software; you can redistribute it and/or | |
7 | * modify it under the terms of the GNU General Public License | |
8 | * as published by the Free Software Foundation; either version 2 | |
9 | * of the License, or (at your option) any later version. | |
10 | ||
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
19 | *******************************************************************************/ | |
20 | package ui.command.information; | |
21 | ||
22 | import java.util.Date; | |
23 | ||
24 | import ui.Messages; | |
25 | import ui.command.Command; | |
26 | import ui.table.model.SessionTableModel; | |
27 | import ui.util.SortStrategy; | |
28 | import base.InternetCafe; | |
29 | import base.InternetCafeManager; | |
30 | import base.session.Session; | |
31 | ||
32 | public class SearchSessionCommand extends Command { | |
33 | ||
34 | private final SessionTableModel sessionTableModel; | |
35 | ||
36 | private final String text; | |
37 | ||
38 | private final Date date; | |
39 | ||
40 | /** | |
41 | * @param sessionTableModel | |
42 | * @param text | |
43 | * @param date | |
44 | */ | |
45 | public SearchSessionCommand(SessionTableModel sessionTableModel, | |
46 | 0 | String text, Date date) { |
47 | 0 | super(); |
48 | 0 | // TODO Auto-generated constructor stub |
49 | 0 | this.sessionTableModel = sessionTableModel; |
50 | 0 | this.text = text; |
51 | 0 | this.date = date; |
52 | 0 | } |
53 | ||
54 | /* | |
55 | * (non-Javadoc) | |
56 | * | |
57 | * @see ui.command.Command#prologo() | |
58 | */ | |
59 | @Override | |
60 | 0 | protected void prologo() { |
61 | 0 | String message = (text != null && date == null) ? Messages.getString("command.searchsessioncommand.search.byspecifiedtext") //$NON-NLS-1$ |
62 | 0 | : (text == null && date != null) ? Messages.getString("command.searchsessioncommand.search.byspecifieddateascending") //$NON-NLS-1$ |
63 | 0 | : Messages.getString("command.searchsessioncommand.search.byspecifiedtextanddateascending"); //$NON-NLS-1$ |
64 | 0 | InternetCafe |
65 | 0 | .setStatusBarMessage(Messages.getString("command.searchsessioncommand.searchingsession") + message + "..."); //$NON-NLS-1$ //$NON-NLS-2$ |
66 | 0 | setStatus(EXECUTE_STATUS); |
67 | 0 | } |
68 | ||
69 | /* | |
70 | * (non-Javadoc) | |
71 | * | |
72 | * @see ui.command.Command#execution() | |
73 | */ | |
74 | @Override | |
75 | 0 | protected void execution() throws Exception { |
76 | 0 | switch (getStatus()) { |
77 | 0 | case ABORT_STATUS: |
78 | 0 | break; |
79 | 0 | case VETOED_STATUS: |
80 | 0 | break; |
81 | 0 | case EXECUTE_STATUS: |
82 | 0 | if (text != null && date == null) { |
83 | 0 | sessionTableModel.setData(SortStrategy.searchSessionByText( |
84 | 0 | text, InternetCafeManager.getInstance().getSession())); |
85 | 0 | sessionTableModel.fireTableDataChanged(); |
86 | 0 | } else if (text == null && date != null) { |
87 | 0 | sessionTableModel.setData(SortStrategy.searchSessionByDate( |
88 | 0 | date, InternetCafeManager.getInstance().getSession())); |
89 | 0 | sessionTableModel.fireTableDataChanged(); |
90 | 0 | } else if (text != null && date != null) { |
91 | 0 | Session[] sByText = SortStrategy.searchSessionByText(text, |
92 | 0 | InternetCafeManager.getInstance().getSession()); |
93 | 0 | sessionTableModel.setData(SortStrategy.searchSessionByDate( |
94 | 0 | date, sByText)); |
95 | 0 | sessionTableModel.fireTableDataChanged(); |
96 | 0 | } |
97 | 0 | setStatus(SUCCESS_STATUS); |
98 | break; | |
99 | 0 | } |
100 | 0 | } |
101 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |