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.frame;
21
22 import java.awt.BorderLayout;
23 import java.awt.event.MouseEvent;
24 import java.awt.event.MouseListener;
25 import java.awt.event.WindowEvent;
26 import java.awt.event.WindowListener;
27 import java.util.Date;
28
29 import javax.swing.ImageIcon;
30 import javax.swing.JFrame;
31 import javax.swing.JPanel;
32 import javax.swing.JTabbedPane;
33
34 import org.apache.log4j.Logger;
35
36 import ui.ICMenuBar;
37 import ui.Messages;
38 import ui.command.CommandExecutor;
39 import ui.command.IO.ExitCommand;
40 import ui.panel.ICConfigurationPanel;
41 import ui.panel.ICInfoPanel;
42 import ui.panel.ICInventoryPanel;
43 import ui.panel.ICNetworkPanel;
44 import ui.panel.ICServicePanel;
45 import ui.panel.ICSessionPanel;
46 import ui.panel.ICStatisticPanel;
47 import ui.panel.ICUserPanel;
48 import base.ConfigurationManager;
49 import base.InternetCafe;
50
51 @SuppressWarnings("serial")
52 public class ICMainFrame extends JFrame {
53
54 private static final transient Logger logger = Logger
55 .getLogger(ICMainFrame.class.getName());
56
57 private JTabbedPane tabbedPane;
58
59 public ICMainFrame() {
60 initialize();
61 }
62
63 protected void initialize() {
64 this.setTitle(ConfigurationManager.getInstance().getInternetCafeName());
65 this.setJMenuBar(new ICMenuBar());
66 setDefaultCloseOperation(javax.swing.JFrame.DO_NOTHING_ON_CLOSE);
67 setSize(1024, 768);
68 setResizable(true);
69 JPanel panel = new JPanel();
70 panel.setLayout(new BorderLayout());
71 panel.add(InternetCafe.getToolBar(), BorderLayout.NORTH);
72 panel.add(getTabbedPane(), BorderLayout.CENTER);
73 panel.add(InternetCafe.getStatusBar(), BorderLayout.SOUTH);
74
75 this.setContentPane(panel);
76
77 this.addWindowListener(new WindowListener() {
78
79 public void windowOpened(WindowEvent arg0) {
80
81
82 }
83
84 public void windowClosing(WindowEvent arg0) {
85 CommandExecutor.getInstance().executeCommand(new ExitCommand(),
86 false);
87 }
88
89 public void windowClosed(WindowEvent arg0) {
90
91
92
93 }
94
95 public void windowIconified(WindowEvent arg0) {
96
97
98 }
99
100 public void windowDeiconified(WindowEvent arg0) {
101
102
103 }
104
105 public void windowActivated(WindowEvent arg0) {
106
107
108 }
109
110 public void windowDeactivated(WindowEvent arg0) {
111
112
113 }
114
115 });
116 }
117
118 /***
119 * @return Returns the tabbedPane.
120 */
121 protected JTabbedPane getTabbedPane() {
122 if (tabbedPane == null) {
123 tabbedPane = new JTabbedPane();
124 tabbedPane.addTab(Messages.getString("mainframe.info"), new ImageIcon(this.getClass()
125 .getResource("/icon/16x16/places/start-here.png")),
126 new ICInfoPanel(), ConfigurationManager.getInstance()
127 .getInternetCafeName()
128 + Messages.getString("mainframe.tooltip.infoof"));
129 tabbedPane.addTab(Messages.getString("mainframe.users"), new ImageIcon(this.getClass()
130 .getResource("/icon/16x16/apps/system-users.png")),
131 new ICUserPanel(), Messages.getString("mainframe.tooltip.manageusers"));
132 tabbedPane
133 .addTab(
134 Messages.getString("mainframe.sessions"),
135 new ImageIcon(
136 this
137 .getClass()
138 .getResource(
139 "/icon/16x16/apps/preferences-system-windows.png")),
140 new ICSessionPanel(), Messages.getString("mainframe.tooltip.managesessions"));
141 tabbedPane.addTab(Messages.getString("mainframe.services"), new ImageIcon(this.getClass()
142 .getResource("/icon/16x16/apps/internet-web-browser.png")),
143 new ICServicePanel(), Messages.getString("mainframe.tooltip.manageservices"));
144 tabbedPane.addTab(Messages.getString("mainframe.network"), new ImageIcon(this.getClass()
145 .getResource("/icon/16x16/places/network-workgroup.png")),
146 new ICNetworkPanel(), Messages.getString("mainframe.tooltip.managenetwork"));
147 tabbedPane.addTab(Messages.getString("mainframe.inventory"),
148 new ImageIcon(this.getClass().getResource(
149 "/icon/16x16/actions/format-justify-fill.png")),
150 new ICInventoryPanel(), Messages.getString("mainframe.tooltip.manageinventory"));
151 tabbedPane.addTab(Messages.getString("mainframe.statistics"), new ImageIcon(this.getClass()
152 .getResource(
153 "/icon/16x16/mimetypes/x-office-spreadsheet.png")),
154 new ICStatisticPanel(), Messages.getString("mainframe.tooltip.manageinventory"));
155 tabbedPane.addTab(Messages.getString("mainframe.configuration"), new ImageIcon(this.getClass()
156 .getResource(
157 "/icon/16x16/categories/preferences-desktop.png")),
158 new ICConfigurationPanel(),
159 Messages.getString("mainframe.tooltip.manageconfiguration"));
160 tabbedPane.addMouseListener(new MouseListener() {
161
162 public void mouseClicked(MouseEvent arg0) {
163 Date currentDate = new Date();
164 logger.debug("Last Seen User Working: " + currentDate);
165 ConfigurationManager.getInstance().setLastSeenUserWorking(
166 currentDate);
167 }
168
169 public void mousePressed(MouseEvent arg0) {
170
171
172 }
173
174 public void mouseReleased(MouseEvent arg0) {
175
176
177 }
178
179 public void mouseEntered(MouseEvent arg0) {
180
181
182 }
183
184 public void mouseExited(MouseEvent arg0) {
185
186
187 }
188
189 });
190 }
191 return tabbedPane;
192 }
193 }