| 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.panel; | |
| 21 | ||
| 22 | import java.awt.BorderLayout; | |
| 23 | import java.awt.GridLayout; | |
| 24 | import java.awt.event.ActionEvent; | |
| 25 | import java.awt.event.ActionListener; | |
| 26 | import java.util.Date; | |
| 27 | ||
| 28 | import javax.swing.ImageIcon; | |
| 29 | import javax.swing.JButton; | |
| 30 | import javax.swing.JCheckBox; | |
| 31 | import javax.swing.JOptionPane; | |
| 32 | import javax.swing.JPanel; | |
| 33 | import javax.swing.JTextField; | |
| 34 | import javax.swing.border.TitledBorder; | |
| 35 | ||
| 36 | import org.apache.log4j.Logger; | |
| 37 | ||
| 38 | import ui.Messages; | |
| 39 | import ui.command.CommandExecutor; | |
| 40 | import ui.command.information.SearchSessionCommand; | |
| 41 | import ui.table.model.SessionTableModel; | |
| 42 | ||
| 43 | import com.toedter.calendar.JDateChooser; | |
| 44 | ||
| 45 | 0 | @SuppressWarnings("serial") //$NON-NLS-1$ |
| 46 | 0 | public class SessionSearchPanel extends JPanel { |
| 47 | 0 | |
| 48 | 0 | private static final transient Logger logger = Logger |
| 49 | 0 | .getLogger(SessionSearchPanel.class.getName()); |
| 50 | ||
| 51 | private JPanel containedTextPanel; | |
| 52 | ||
| 53 | private JPanel datePanel; | |
| 54 | ||
| 55 | private JPanel buttonPanel; | |
| 56 | ||
| 57 | private JButton searchButton; | |
| 58 | ||
| 59 | private JButton stopButton; | |
| 60 | ||
| 61 | private JDateChooser dateChooser; | |
| 62 | ||
| 63 | private JTextField containedTextTextField; | |
| 64 | ||
| 65 | private JCheckBox sortByDateCheckBox; | |
| 66 | ||
| 67 | private JCheckBox sortByTextCheckBox; | |
| 68 | 0 | |
| 69 | 0 | private final SessionTableModel sessionTableModel; |
| 70 | 0 | |
| 71 | 0 | public SessionSearchPanel(SessionTableModel sessionTableModel) { |
| 72 | 0 | this.sessionTableModel = sessionTableModel; |
| 73 | 0 | initialize(); |
| 74 | 0 | } |
| 75 | ||
| 76 | 0 | protected void initialize() { |
| 77 | 0 | this.setLayout(new GridLayout(1, 3)); |
| 78 | 0 | TitledBorder titledBorder = new TitledBorder(Messages.getString("panel.sessionsearchpanel.searchsession")); //$NON-NLS-1$ |
| 79 | 0 | this.setBorder(titledBorder); |
| 80 | 0 | this.add(getContainedTextPanel(), null); |
| 81 | 0 | this.add(getDatePanel(), null); |
| 82 | 0 | this.add(getButtonPanel(), null); |
| 83 | 0 | } |
| 84 | ||
| 85 | /** | |
| 86 | * @return Returns the buttonPanel. | |
| 87 | */ | |
| 88 | 0 | protected JPanel getButtonPanel() { |
| 89 | 0 | if (buttonPanel == null) { |
| 90 | 0 | buttonPanel = new JPanel(); |
| 91 | 0 | TitledBorder titledBorder = new TitledBorder(Messages.getString("dialog.availableactions")); //$NON-NLS-1$ |
| 92 | 0 | buttonPanel.setBorder(titledBorder); |
| 93 | 0 | buttonPanel.setLayout(new GridLayout(1, 2)); |
| 94 | 0 | buttonPanel.add(getSearchButton()); |
| 95 | 0 | buttonPanel.add(getStopButton()); |
| 96 | ||
| 97 | 0 | } |
| 98 | 0 | return this.buttonPanel; |
| 99 | } | |
| 100 | ||
| 101 | /** | |
| 102 | * @return Returns the searchButton. | |
| 103 | */ | |
| 104 | 0 | protected JButton getSearchButton() { |
| 105 | 0 | if (searchButton == null) { |
| 106 | 0 | searchButton = new JButton(Messages.getString("button.search")); //$NON-NLS-1$ |
| 107 | 0 | searchButton.setIcon(new ImageIcon(this.getClass().getResource( |
| 108 | 0 | "/icon/22x22/actions/system-search.png"))); //$NON-NLS-1$ |
| 109 | 0 | searchButton.addActionListener(new ActionListener() { |
| 110 | public void actionPerformed(ActionEvent arg0) { | |
| 111 | logger.debug("actionPerformed searchButton"); //$NON-NLS-1$ | |
| 112 | if (getSortByTextCheckBox().isSelected() | |
| 113 | && getSortByDateCheckBox().isSelected()) { | |
| 114 | CommandExecutor.getInstance().executeCommand( | |
| 115 | new SearchSessionCommand(sessionTableModel, | |
| 116 | getContainedTextTextField().getText(), | |
| 117 | getDateChooser().getDate()), false); | |
| 118 | } else if (getSortByTextCheckBox().isSelected()) { | |
| 119 | CommandExecutor.getInstance().executeCommand( | |
| 120 | new SearchSessionCommand(sessionTableModel, | |
| 121 | getContainedTextTextField().getText(), | |
| 122 | null), false); | |
| 123 | } else if (getSortByDateCheckBox().isSelected()) { | |
| 124 | CommandExecutor.getInstance().executeCommand( | |
| 125 | new SearchSessionCommand(sessionTableModel, | |
| 126 | null, getDateChooser().getDate()), | |
| 127 | false); | |
| 128 | } else | |
| 129 | JOptionPane | |
| 130 | .showMessageDialog( | |
| 131 | null, | |
| 132 | Messages.getString("panel.sessionsearchpanel.message1")); //$NON-NLS-1$ | |
| 133 | } | |
| 134 | }); | |
| 135 | 0 | } |
| 136 | 0 | return searchButton; |
| 137 | } | |
| 138 | ||
| 139 | /** | |
| 140 | * @return Returns the stopButton. | |
| 141 | */ | |
| 142 | 0 | protected JButton getStopButton() { |
| 143 | 0 | if (stopButton == null) { |
| 144 | 0 | stopButton = new JButton(Messages.getString("button.refresh")); //$NON-NLS-1$ |
| 145 | 0 | stopButton.setIcon(new ImageIcon(this.getClass().getResource( |
| 146 | 0 | "/icon/22x22/actions/view-refresh.png"))); //$NON-NLS-1$ |
| 147 | 0 | |
| 148 | 0 | stopButton.addActionListener(new ActionListener() { |
| 149 | public void actionPerformed(ActionEvent arg0) { | |
| 150 | logger.debug("actionPerformed stopButton"); //$NON-NLS-1$ | |
| 151 | getContainedTextTextField().setText(""); //$NON-NLS-1$ | |
| 152 | getDateChooser().setDate(new Date()); | |
| 153 | getSortByDateCheckBox().setSelected(false); | |
| 154 | getSortByTextCheckBox().setSelected(false); | |
| 155 | sessionTableModel.setData(null); | |
| 156 | sessionTableModel.fireTableDataChanged(); | |
| 157 | } | |
| 158 | }); | |
| 159 | 0 | } |
| 160 | 0 | return stopButton; |
| 161 | } | |
| 162 | ||
| 163 | /** | |
| 164 | * @return Returns the datePanel. | |
| 165 | */ | |
| 166 | 0 | protected JPanel getDatePanel() { |
| 167 | 0 | if (datePanel == null) { |
| 168 | 0 | datePanel = new JPanel(); |
| 169 | 0 | TitledBorder titledBorder = new TitledBorder(Messages.getString("common.searchbydate")); //$NON-NLS-1$ |
| 170 | 0 | datePanel.setBorder(titledBorder); |
| 171 | 0 | datePanel.setLayout(new BorderLayout()); |
| 172 | 0 | datePanel.add(getDateChooser(), BorderLayout.CENTER); |
| 173 | 0 | datePanel.add(getSortByDateCheckBox(), BorderLayout.WEST); |
| 174 | 0 | } |
| 175 | 0 | return datePanel; |
| 176 | } | |
| 177 | ||
| 178 | /** | |
| 179 | * @return Returns the containedTextPanel. | |
| 180 | */ | |
| 181 | 0 | protected JPanel getContainedTextPanel() { |
| 182 | 0 | if (containedTextPanel == null) { |
| 183 | 0 | containedTextPanel = new JPanel(); |
| 184 | 0 | TitledBorder titledBorder = new TitledBorder(Messages.getString("common.searchbycontainedtext")); //$NON-NLS-1$ |
| 185 | 0 | containedTextPanel.setBorder(titledBorder); |
| 186 | 0 | containedTextPanel.setLayout(new BorderLayout()); |
| 187 | 0 | containedTextPanel.add(getContainedTextTextField(), |
| 188 | 0 | BorderLayout.CENTER); |
| 189 | 0 | containedTextPanel.add(getSortByTextCheckBox(), BorderLayout.WEST); |
| 190 | 0 | } |
| 191 | 0 | return containedTextPanel; |
| 192 | } | |
| 193 | ||
| 194 | /** | |
| 195 | * @return Returns the dateChooser. | |
| 196 | */ | |
| 197 | 0 | protected JDateChooser getDateChooser() { |
| 198 | 0 | if (dateChooser == null) { |
| 199 | 0 | dateChooser = new JDateChooser(); |
| 200 | 0 | dateChooser.setDate(new Date()); |
| 201 | 0 | } |
| 202 | 0 | return this.dateChooser; |
| 203 | } | |
| 204 | ||
| 205 | /** | |
| 206 | * @return Returns the containedTextTextField. | |
| 207 | */ | |
| 208 | 0 | protected JTextField getContainedTextTextField() { |
| 209 | 0 | if (containedTextTextField == null) { |
| 210 | 0 | containedTextTextField = new JTextField(); |
| 211 | 0 | } |
| 212 | 0 | return this.containedTextTextField; |
| 213 | } | |
| 214 | ||
| 215 | /** | |
| 216 | * @return Returns the sortByDateCheckBox. | |
| 217 | */ | |
| 218 | 0 | protected JCheckBox getSortByDateCheckBox() { |
| 219 | 0 | if (sortByDateCheckBox == null) { |
| 220 | 0 | sortByDateCheckBox = new JCheckBox(); |
| 221 | 0 | } |
| 222 | 0 | return sortByDateCheckBox; |
| 223 | } | |
| 224 | ||
| 225 | /** | |
| 226 | * @return Returns the sortByTextCheckBox. | |
| 227 | */ | |
| 228 | 0 | protected JCheckBox getSortByTextCheckBox() { |
| 229 | 0 | if (sortByTextCheckBox == null) { |
| 230 | 0 | sortByTextCheckBox = new JCheckBox(); |
| 231 | 0 | } |
| 232 | 0 | return sortByTextCheckBox; |
| 233 | } | |
| 234 | ||
| 235 | } |
|
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |