741 |
10 Oct 06 |
olle |
1 |
/* |
1652 |
22 May 07 |
gregory |
$Id$ |
741 |
10 Oct 06 |
olle |
3 |
|
1916 |
31 Aug 07 |
jari |
Copyright (C) 2006 Olle Mansson |
1916 |
31 Aug 07 |
jari |
Copyright (C) 2007 Gregory Vincic |
741 |
10 Oct 06 |
olle |
6 |
|
1652 |
22 May 07 |
gregory |
This file is part of Proteios. |
1652 |
22 May 07 |
gregory |
Available at http://www.proteios.org/ |
741 |
10 Oct 06 |
olle |
9 |
|
1652 |
22 May 07 |
gregory |
Proteios is free software; you can redistribute it and/or modify it |
1652 |
22 May 07 |
gregory |
under the terms of the GNU General Public License as published by |
1652 |
22 May 07 |
gregory |
the Free Software Foundation; either version 2 of the License, or |
1652 |
22 May 07 |
gregory |
(at your option) any later version. |
741 |
10 Oct 06 |
olle |
14 |
|
1652 |
22 May 07 |
gregory |
Proteios is distributed in the hope that it will be useful, but |
1652 |
22 May 07 |
gregory |
WITHOUT ANY WARRANTY; without even the implied warranty of |
1652 |
22 May 07 |
gregory |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1652 |
22 May 07 |
gregory |
General Public License for more details. |
741 |
10 Oct 06 |
olle |
19 |
|
1652 |
22 May 07 |
gregory |
You should have received a copy of the GNU General Public License |
1652 |
22 May 07 |
gregory |
along with this program; if not, write to the Free Software |
1652 |
22 May 07 |
gregory |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
1652 |
22 May 07 |
gregory |
02111-1307, USA. |
1652 |
22 May 07 |
gregory |
24 |
*/ |
741 |
10 Oct 06 |
olle |
25 |
|
741 |
10 Oct 06 |
olle |
// Xerver Free Web Server |
741 |
10 Oct 06 |
olle |
// Copyright (C) 2002-2005 Omid Rouhani |
741 |
10 Oct 06 |
olle |
28 |
// |
741 |
10 Oct 06 |
olle |
29 |
// |
741 |
10 Oct 06 |
olle |
// This program is free software; you can redistribute it and/or |
741 |
10 Oct 06 |
olle |
// modify it under the terms of the GNU General Public License |
741 |
10 Oct 06 |
olle |
// as published by the Free Software Foundation; either version 2 |
741 |
10 Oct 06 |
olle |
// of the License, or (at your option) any later version. |
741 |
10 Oct 06 |
olle |
34 |
// |
741 |
10 Oct 06 |
olle |
// This program is distributed in the hope that it will be useful, |
741 |
10 Oct 06 |
olle |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
741 |
10 Oct 06 |
olle |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
741 |
10 Oct 06 |
olle |
// GNU General Public License for more details. |
741 |
10 Oct 06 |
olle |
39 |
// |
741 |
10 Oct 06 |
olle |
// You should have received a copy of the GNU General Public License |
741 |
10 Oct 06 |
olle |
// along with this program; if not, write to the Free Software |
741 |
10 Oct 06 |
olle |
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
741 |
10 Oct 06 |
olle |
43 |
// |
741 |
10 Oct 06 |
olle |
44 |
// |
741 |
10 Oct 06 |
olle |
45 |
// ############################################################# |
741 |
10 Oct 06 |
olle |
// ## YOU CAN CONTACT THE AUTHOR (OMID ROUHANI) AT: ## |
741 |
10 Oct 06 |
olle |
// ## HTTP://WWW.JAVASCRIPT.NU/XERVER/ ## |
741 |
10 Oct 06 |
olle |
48 |
// ## ## |
741 |
10 Oct 06 |
olle |
// ## IF YOUR SOFTWARE IS NOT RELEASED UNDER THE ## |
741 |
10 Oct 06 |
olle |
// ## GNU GENERAL PUBLIC LICENSE (GPL), ## |
741 |
10 Oct 06 |
olle |
// ## PLEASE DO NOT COPY ANYTHING FROM THIS SOURCE CODE!!! ## |
741 |
10 Oct 06 |
olle |
52 |
// ## ## |
741 |
10 Oct 06 |
olle |
// ## FOR FULL LICENSE, PLEASE READ "XERVER LICENSE". ## |
741 |
10 Oct 06 |
olle |
54 |
// ############################################################# |
741 |
10 Oct 06 |
olle |
55 |
|
1652 |
22 May 07 |
gregory |
56 |
package se.lu.thep.coreftpd.webserver; |
741 |
10 Oct 06 |
olle |
57 |
|
791 |
23 Oct 06 |
olle |
58 |
import se.lu.thep.coreftpd.common.GUIMethods; |
791 |
23 Oct 06 |
olle |
59 |
import se.lu.thep.coreftpd.common.HostInfo; |
791 |
23 Oct 06 |
olle |
60 |
import se.lu.thep.coreftpd.common.MyString; |
791 |
23 Oct 06 |
olle |
61 |
import se.lu.thep.coreftpd.ftp_server.FTPServerController; |
741 |
10 Oct 06 |
olle |
62 |
import java.awt.BorderLayout; |
741 |
10 Oct 06 |
olle |
63 |
import java.awt.Color; |
741 |
10 Oct 06 |
olle |
64 |
import java.awt.Container; |
741 |
10 Oct 06 |
olle |
65 |
import java.awt.Font; |
741 |
10 Oct 06 |
olle |
66 |
import java.awt.GridLayout; |
741 |
10 Oct 06 |
olle |
67 |
import java.awt.event.ActionEvent; |
741 |
10 Oct 06 |
olle |
68 |
import java.awt.event.ActionListener; |
741 |
10 Oct 06 |
olle |
69 |
import java.io.BufferedReader; |
741 |
10 Oct 06 |
olle |
70 |
import java.io.InputStreamReader; |
741 |
10 Oct 06 |
olle |
71 |
import java.net.URL; |
741 |
10 Oct 06 |
olle |
72 |
import javax.swing.BoxLayout; |
741 |
10 Oct 06 |
olle |
73 |
import javax.swing.DefaultListModel; |
741 |
10 Oct 06 |
olle |
74 |
import javax.swing.JCheckBox; |
741 |
10 Oct 06 |
olle |
75 |
import javax.swing.JLabel; |
741 |
10 Oct 06 |
olle |
76 |
import javax.swing.JList; |
741 |
10 Oct 06 |
olle |
77 |
import javax.swing.JPanel; |
741 |
10 Oct 06 |
olle |
78 |
import javax.swing.JScrollPane; |
741 |
10 Oct 06 |
olle |
79 |
import javax.swing.JTextField; |
741 |
10 Oct 06 |
olle |
80 |
import javax.swing.ListSelectionModel; |
741 |
10 Oct 06 |
olle |
81 |
import javax.swing.event.DocumentEvent; |
741 |
10 Oct 06 |
olle |
82 |
import javax.swing.event.DocumentListener; |
741 |
10 Oct 06 |
olle |
83 |
|
741 |
10 Oct 06 |
olle |
84 |
/** |
1652 |
22 May 07 |
gregory |
85 |
* |
1652 |
22 May 07 |
gregory |
* <B>About this class:</B> <BR> |
741 |
10 Oct 06 |
olle |
* This class has the members that are run when you do something in the <CODE>ProgramWindow</CODE>. |
741 |
10 Oct 06 |
olle |
* <BR> |
1652 |
22 May 07 |
gregory |
* When you for example choose something from the menu, a member of this class |
1652 |
22 May 07 |
gregory |
* is activated. <BR> |
741 |
10 Oct 06 |
olle |
* The constructor of this class needs a copy of <CODE>ProgramWindow</CODE>. |
1652 |
22 May 07 |
gregory |
92 |
* |
741 |
10 Oct 06 |
olle |
* @author <a href="http://www.JavaScript.nu/xerver/" TARGET="_top">Omid Rouhani</a> |
741 |
10 Oct 06 |
olle |
* @version 1.0 |
741 |
10 Oct 06 |
olle |
95 |
*/ |
741 |
10 Oct 06 |
olle |
96 |
|
1652 |
22 May 07 |
gregory |
97 |
final public class MenuOptions extends GUIMethods implements ActionListener, |
1652 |
22 May 07 |
gregory |
98 |
DocumentListener { |
1652 |
22 May 07 |
gregory |
99 |
private static final boolean b_showErrors = false; |
741 |
10 Oct 06 |
olle |
100 |
|
741 |
10 Oct 06 |
olle |
101 |
private static Font defaultFont; |
741 |
10 Oct 06 |
olle |
102 |
|
741 |
10 Oct 06 |
olle |
103 |
private XerverKernel xerverThread; |
1652 |
22 May 07 |
gregory |
104 |
|
1652 |
22 May 07 |
gregory |
105 |
public boolean xerverIsRunning = false, xerverSetupIsRunning = false; |
1652 |
22 May 07 |
gregory |
106 |
|
741 |
10 Oct 06 |
olle |
107 |
private ProgramWindow theProgramWindow; |
1652 |
22 May 07 |
gregory |
108 |
|
741 |
10 Oct 06 |
olle |
109 |
private SetupXerverKernel xerverSetupThread; |
1652 |
22 May 07 |
gregory |
110 |
|
741 |
10 Oct 06 |
olle |
111 |
public String s_egetIp; |
1652 |
22 May 07 |
gregory |
112 |
|
741 |
10 Oct 06 |
olle |
113 |
public int i_portNr; |
1652 |
22 May 07 |
gregory |
114 |
|
741 |
10 Oct 06 |
olle |
115 |
private JList JL_allIPConnected; |
1652 |
22 May 07 |
gregory |
116 |
|
1652 |
22 May 07 |
gregory |
117 |
private DefaultListModel DLM_listWithAllIPConnected; |
1652 |
22 May 07 |
gregory |
118 |
|
741 |
10 Oct 06 |
olle |
119 |
private JScrollPane JSP_IPScrollPane; |
1652 |
22 May 07 |
gregory |
120 |
|
741 |
10 Oct 06 |
olle |
121 |
private JPanel JP_IPPanel; |
1652 |
22 May 07 |
gregory |
122 |
|
1652 |
22 May 07 |
gregory |
123 |
private JCheckBox[] JCB_showWhatStatistic; |
1652 |
22 May 07 |
gregory |
124 |
|
1652 |
22 May 07 |
gregory |
125 |
private JTextFieldInt[] JTF_showStatisticFieldLength; |
1652 |
22 May 07 |
gregory |
126 |
|
741 |
10 Oct 06 |
olle |
127 |
private JTextField JTF_hitsField; |
1652 |
22 May 07 |
gregory |
128 |
|
741 |
10 Oct 06 |
olle |
129 |
private JTextField JTF_bytesField; |
1652 |
22 May 07 |
gregory |
130 |
|
741 |
10 Oct 06 |
olle |
131 |
private JTextField JTF_connectionsField; |
741 |
10 Oct 06 |
olle |
132 |
|
4415 |
20 Feb 13 |
olle |
133 |
@SuppressWarnings("unchecked") |
1652 |
22 May 07 |
gregory |
134 |
public MenuOptions(ProgramWindow argProgramWindow) { |
1652 |
22 May 07 |
gregory |
135 |
defaultFont = GUIMethods.defaultFont; |
1652 |
22 May 07 |
gregory |
136 |
xerverThread = new XerverKernel(this); |
741 |
10 Oct 06 |
olle |
137 |
initSwingButtons(); |
741 |
10 Oct 06 |
olle |
138 |
updateStatList(); |
741 |
10 Oct 06 |
olle |
139 |
DLM_listWithAllIPConnected.addElement(new HitStatistic()); |
741 |
10 Oct 06 |
olle |
140 |
|
1652 |
22 May 07 |
gregory |
141 |
theProgramWindow = argProgramWindow; |
741 |
10 Oct 06 |
olle |
142 |
xerverThread.stopXerver(); |
741 |
10 Oct 06 |
olle |
143 |
xerverThread.start(); |
1652 |
22 May 07 |
gregory |
144 |
xerverSetupThread = new SetupXerverKernel(this); |
741 |
10 Oct 06 |
olle |
145 |
xerverSetupThread.stopXerverSetup(); |
741 |
10 Oct 06 |
olle |
146 |
xerverSetupThread.start(); |
741 |
10 Oct 06 |
olle |
147 |
|
1652 |
22 May 07 |
gregory |
148 |
s_egetIp = XerverKernel.s_egetIp; |
1652 |
22 May 07 |
gregory |
149 |
i_portNr = XerverKernel.i_portNr; |
741 |
10 Oct 06 |
olle |
150 |
} |
741 |
10 Oct 06 |
olle |
151 |
|
1652 |
22 May 07 |
gregory |
152 |
public void statsHasBeenUpdated() { |
1652 |
22 May 07 |
gregory |
153 |
if (theProgramWindow.getCurrentMode() == ProgramWindow.STATS_MODE) { |
1652 |
22 May 07 |
gregory |
154 |
JTF_hitsField |
1652 |
22 May 07 |
gregory |
155 |
.setText(MyString |
1652 |
22 May 07 |
gregory |
156 |
.makeNumberToStringWithApostrophe(NewConnection.totalNumberOfHits |
1652 |
22 May 07 |
gregory |
157 |
+ "") |
1652 |
22 May 07 |
gregory |
158 |
+ " hits"); |
1652 |
22 May 07 |
gregory |
159 |
JTF_bytesField |
1652 |
22 May 07 |
gregory |
160 |
.setText(MyString |
1652 |
22 May 07 |
gregory |
161 |
.makeNumberToStringWithApostrophe(NewConnection.totalNumberOfBytesDownloaded |
1652 |
22 May 07 |
gregory |
162 |
+ "") |
1652 |
22 May 07 |
gregory |
163 |
+ " bytes"); |
1652 |
22 May 07 |
gregory |
164 |
JTF_connectionsField.setText(MyString |
1652 |
22 May 07 |
gregory |
165 |
.makeNumberToStringWithApostrophe(xerverThread |
1652 |
22 May 07 |
gregory |
166 |
.getNumberOfActiveConnections() |
1652 |
22 May 07 |
gregory |
167 |
+ "") |
1652 |
22 May 07 |
gregory |
168 |
+ " connections"); |
741 |
10 Oct 06 |
olle |
169 |
|
741 |
10 Oct 06 |
olle |
170 |
theProgramWindow.updateStatsContainer(); |
741 |
10 Oct 06 |
olle |
171 |
} |
741 |
10 Oct 06 |
olle |
172 |
} |
741 |
10 Oct 06 |
olle |
173 |
|
1652 |
22 May 07 |
gregory |
174 |
public void xerverSetupIsDone(boolean setupIsFinished) { |
741 |
10 Oct 06 |
olle |
175 |
xerverThread.getServerDefaults(); |
1652 |
22 May 07 |
gregory |
176 |
xerverThread.exchangeVariablesBetweenClasses(); // ALWAYS run this after |
1652 |
22 May 07 |
gregory |
// running |
1652 |
22 May 07 |
gregory |
// "getServerDefaults()" |
741 |
10 Oct 06 |
olle |
179 |
|
741 |
10 Oct 06 |
olle |
180 |
if (setupIsFinished) |
1652 |
22 May 07 |
gregory |
181 |
theProgramWindow.showAsMainFrame(GUIMethods |
1652 |
22 May 07 |
gregory |
182 |
.showAsNorthBorderLayout(showSettingsHaveBeenSaved())); // we |
1652 |
22 May 07 |
gregory |
// choose |
1652 |
22 May 07 |
gregory |
// to |
1652 |
22 May 07 |
gregory |
// only |
1652 |
22 May 07 |
gregory |
// show |
1652 |
22 May 07 |
gregory |
// this |
1652 |
22 May 07 |
gregory |
// message |
1652 |
22 May 07 |
gregory |
// when |
1652 |
22 May 07 |
gregory |
// the |
1652 |
22 May 07 |
gregory |
// setup |
1652 |
22 May 07 |
gregory |
// is |
1652 |
22 May 07 |
gregory |
// complete... |
1652 |
22 May 07 |
gregory |
// we |
1652 |
22 May 07 |
gregory |
// might |
1652 |
22 May 07 |
gregory |
// prefer |
1652 |
22 May 07 |
gregory |
// to |
1652 |
22 May 07 |
gregory |
// show |
1652 |
22 May 07 |
gregory |
// this |
1652 |
22 May 07 |
gregory |
// as |
1652 |
22 May 07 |
gregory |
// soon |
1652 |
22 May 07 |
gregory |
// as |
1652 |
22 May 07 |
gregory |
// something |
1652 |
22 May 07 |
gregory |
// has |
1652 |
22 May 07 |
gregory |
// been |
1652 |
22 May 07 |
gregory |
// updated |
1652 |
22 May 07 |
gregory |
// (in |
1652 |
22 May 07 |
gregory |
// this |
1652 |
22 May 07 |
gregory |
// case, |
1652 |
22 May 07 |
gregory |
// remove |
1652 |
22 May 07 |
gregory |
// the |
1652 |
22 May 07 |
gregory |
// if-case |
1652 |
22 May 07 |
gregory |
// above)... |
741 |
10 Oct 06 |
olle |
214 |
} |
741 |
10 Oct 06 |
olle |
215 |
|
1652 |
22 May 07 |
gregory |
216 |
public Container showSettingsHaveBeenSaved() { |
741 |
10 Oct 06 |
olle |
217 |
theProgramWindow.setCurrentMode(ProgramWindow.SETUPSAVED_MODE); |
741 |
10 Oct 06 |
olle |
218 |
|
1652 |
22 May 07 |
gregory |
219 |
String[] showThisText = new String[6]; |
1652 |
22 May 07 |
gregory |
220 |
showThisText[0] = "Xerver Setup has changed settings to Xerver!"; |
1652 |
22 May 07 |
gregory |
221 |
showThisText[1] = ""; |
1652 |
22 May 07 |
gregory |
222 |
if (xerverSetupIsRunning) { |
1652 |
22 May 07 |
gregory |
223 |
showThisText[2] = "If you feel that you are satisfied with your new settings,"; |
1652 |
22 May 07 |
gregory |
224 |
showThisText[3] = "please turn off the Xerver Remote Setup."; |
1652 |
22 May 07 |
gregory |
225 |
showThisText[4] = ""; |
1652 |
22 May 07 |
gregory |
226 |
showThisText[5] = "You don't need to restart Xerver!"; |
1652 |
22 May 07 |
gregory |
227 |
} else { |
1652 |
22 May 07 |
gregory |
228 |
showThisText[2] = "You don't need to restart Xerver!"; |
1652 |
22 May 07 |
gregory |
229 |
showThisText[3] = ""; |
1652 |
22 May 07 |
gregory |
230 |
showThisText[4] = ""; |
1652 |
22 May 07 |
gregory |
231 |
showThisText[5] = ""; |
741 |
10 Oct 06 |
olle |
232 |
} |
741 |
10 Oct 06 |
olle |
233 |
return giveContainerWithText(showThisText); |
741 |
10 Oct 06 |
olle |
234 |
} |
741 |
10 Oct 06 |
olle |
235 |
|
1652 |
22 May 07 |
gregory |
236 |
public void runXerverSetup() { |
1652 |
22 May 07 |
gregory |
237 |
if (!xerverSetupIsRunning) { |
1652 |
22 May 07 |
gregory |
238 |
xerverSetupIsRunning = true; |
741 |
10 Oct 06 |
olle |
239 |
xerverSetupThread.startXerverSetup(); |
741 |
10 Oct 06 |
olle |
240 |
theProgramWindow.setStatusText("Xerver Remote Setup is running"); |
741 |
10 Oct 06 |
olle |
241 |
}// else System.out.println("Xerver is already running!"); |
741 |
10 Oct 06 |
olle |
242 |
} |
741 |
10 Oct 06 |
olle |
243 |
|
1652 |
22 May 07 |
gregory |
244 |
public void stopXerverSetup() { |
1652 |
22 May 07 |
gregory |
245 |
if (xerverSetupIsRunning) { |
1652 |
22 May 07 |
gregory |
246 |
xerverSetupIsRunning = false; |
741 |
10 Oct 06 |
olle |
247 |
xerverSetupThread.stopXerverSetup(); |
1652 |
22 May 07 |
gregory |
248 |
theProgramWindow |
1652 |
22 May 07 |
gregory |
249 |
.setStatusText("Xerver Remote Setup is not running"); |
741 |
10 Oct 06 |
olle |
250 |
}// else System.out.println("Xerver is not running!"); |
741 |
10 Oct 06 |
olle |
251 |
} |
741 |
10 Oct 06 |
olle |
252 |
|
1652 |
22 May 07 |
gregory |
253 |
public void runXerver() { |
1652 |
22 May 07 |
gregory |
254 |
if (!xerverIsRunning) { |
1652 |
22 May 07 |
gregory |
255 |
xerverIsRunning = true; |
741 |
10 Oct 06 |
olle |
256 |
xerverThread.startXerver(); |
741 |
10 Oct 06 |
olle |
257 |
theProgramWindow.setStatusText("Xerver is running"); |
741 |
10 Oct 06 |
olle |
258 |
}// else System.out.println("Xerver is already running!"); |
741 |
10 Oct 06 |
olle |
259 |
} |
741 |
10 Oct 06 |
olle |
260 |
|
1652 |
22 May 07 |
gregory |
261 |
public void stopXerver() { |
1652 |
22 May 07 |
gregory |
262 |
if (xerverIsRunning) { |
1652 |
22 May 07 |
gregory |
263 |
xerverIsRunning = false; |
741 |
10 Oct 06 |
olle |
264 |
xerverThread.stopXerver(); |
741 |
10 Oct 06 |
olle |
265 |
theProgramWindow.setStatusText("Xerver is not running"); |
741 |
10 Oct 06 |
olle |
266 |
}// else System.out.println("Xerver is not running!"); |
741 |
10 Oct 06 |
olle |
267 |
} |
741 |
10 Oct 06 |
olle |
268 |
|
4415 |
20 Feb 13 |
olle |
269 |
@SuppressWarnings("unchecked") |
1652 |
22 May 07 |
gregory |
270 |
public void addIPToList(HitStatistic hit) { |
741 |
10 Oct 06 |
olle |
271 |
DLM_listWithAllIPConnected.addElement(hit); |
1652 |
22 May 07 |
gregory |
// JL_allIPConnected.setSelectedIndex(DLM_listWithAllIPConnected.getSize()-1);; |
741 |
10 Oct 06 |
olle |
273 |
} |
741 |
10 Oct 06 |
olle |
274 |
|
1652 |
22 May 07 |
gregory |
275 |
public Container showTurnOffSetup() { |
741 |
10 Oct 06 |
olle |
276 |
theProgramWindow.setCurrentMode(ProgramWindow.SETUPTURNEDOFF_MODE); |
741 |
10 Oct 06 |
olle |
277 |
|
1652 |
22 May 07 |
gregory |
278 |
String[] showThisText = new String[3]; |
1652 |
22 May 07 |
gregory |
279 |
showThisText[0] = "Xerver Remote Setup has been turned off!"; |
1652 |
22 May 07 |
gregory |
280 |
showThisText[1] = ""; |
1652 |
22 May 07 |
gregory |
281 |
showThisText[2] = "Settings can no longer be saved to Xerver from Internet."; |
741 |
10 Oct 06 |
olle |
282 |
return giveContainerWithText(showThisText); |
741 |
10 Oct 06 |
olle |
283 |
} |
741 |
10 Oct 06 |
olle |
284 |
|
1652 |
22 May 07 |
gregory |
285 |
public Container showTurnOnSetup() { |
741 |
10 Oct 06 |
olle |
286 |
theProgramWindow.setCurrentMode(ProgramWindow.SETUPTURNEDON_MODE); |
741 |
10 Oct 06 |
olle |
287 |
|
1652 |
22 May 07 |
gregory |
288 |
String[] showThisTextUp = new String[3], showThisTextDown = new String[2]; |
1652 |
22 May 07 |
gregory |
289 |
showThisTextUp[0] = "Xerver Remote Setup has been turned on!"; |
1652 |
22 May 07 |
gregory |
290 |
showThisTextUp[1] = ""; |
1652 |
22 May 07 |
gregory |
291 |
showThisTextUp[2] = "A remote administrator can now change settings to Xerver at:"; |
741 |
10 Oct 06 |
olle |
292 |
JTextField txtIPAdress; |
741 |
10 Oct 06 |
olle |
293 |
|
1652 |
22 May 07 |
gregory |
294 |
String s_outerIP = HostInfo.getIPFromInternet(); // Returns null if |
1652 |
22 May 07 |
gregory |
// not detected |
1652 |
22 May 07 |
gregory |
296 |
if (s_outerIP != null) { |
1652 |
22 May 07 |
gregory |
297 |
txtIPAdress = new JTextField("http://" + s_outerIP + ":32123/", 17); |
1652 |
22 May 07 |
gregory |
298 |
} else { |
1652 |
22 May 07 |
gregory |
299 |
txtIPAdress = new JTextField("IP could not be detected!", 17); |
741 |
10 Oct 06 |
olle |
300 |
} |
741 |
10 Oct 06 |
olle |
301 |
|
741 |
10 Oct 06 |
olle |
302 |
txtIPAdress.setBackground(Color.white); |
741 |
10 Oct 06 |
olle |
303 |
txtIPAdress.setEditable(false); |
741 |
10 Oct 06 |
olle |
304 |
txtIPAdress.setFont(defaultFont); |
1652 |
22 May 07 |
gregory |
305 |
showThisTextDown[0] = ""; |
1652 |
22 May 07 |
gregory |
306 |
showThisTextDown[1] = "Please turn off Xerver Remote Setup when you feel you are done!"; |
1652 |
22 May 07 |
gregory |
307 |
return make2ContainersTo1ContainerAbove( |
1652 |
22 May 07 |
gregory |
308 |
make2ContainersTo1ContainerAbove( |
1652 |
22 May 07 |
gregory |
309 |
giveContainerWithText(showThisTextUp), |
1652 |
22 May 07 |
gregory |
310 |
make2ContainersTo1ContainerBeside(txtIPAdress, |
1652 |
22 May 07 |
gregory |
311 |
new JLabel(""))), |
1652 |
22 May 07 |
gregory |
312 |
giveContainerWithText(showThisTextDown)); |
741 |
10 Oct 06 |
olle |
313 |
} |
741 |
10 Oct 06 |
olle |
314 |
|
1652 |
22 May 07 |
gregory |
315 |
public Container showHelp() { |
741 |
10 Oct 06 |
olle |
316 |
theProgramWindow.setCurrentMode(ProgramWindow.HELP_MODE); |
741 |
10 Oct 06 |
olle |
317 |
|
1652 |
22 May 07 |
gregory |
318 |
String[] showThisText = new String[8]; |
1652 |
22 May 07 |
gregory |
319 |
showThisText[0] = "Xerver help pages"; |
1652 |
22 May 07 |
gregory |
320 |
showThisText[1] = ""; |
1652 |
22 May 07 |
gregory |
321 |
showThisText[2] = "Xerver comes with a large number of help files"; |
1652 |
22 May 07 |
gregory |
322 |
showThisText[3] = "categorized by subject. However, the help files"; |
1652 |
22 May 07 |
gregory |
323 |
showThisText[4] = "are written in HTML and are available in the"; |
1652 |
22 May 07 |
gregory |
324 |
showThisText[5] = "help directory in the Xerver directory."; |
1652 |
22 May 07 |
gregory |
325 |
showThisText[6] = ""; |
1652 |
22 May 07 |
gregory |
326 |
showThisText[7] = "To start using help, start index.html in the help directory."; |
741 |
10 Oct 06 |
olle |
327 |
return giveContainerWithText(showThisText); |
741 |
10 Oct 06 |
olle |
328 |
} |
741 |
10 Oct 06 |
olle |
329 |
|
1652 |
22 May 07 |
gregory |
330 |
public Container showAbout() { |
741 |
10 Oct 06 |
olle |
331 |
theProgramWindow.setCurrentMode(ProgramWindow.ABOUT_MODE); |
741 |
10 Oct 06 |
olle |
332 |
|
1652 |
22 May 07 |
gregory |
333 |
String[] showThisText = new String[14]; |
1652 |
22 May 07 |
gregory |
334 |
showThisText[0] = "You are using Xerver " |
1652 |
22 May 07 |
gregory |
335 |
+ XerverKernel.getThisVersionString() + "."; |
1652 |
22 May 07 |
gregory |
336 |
showThisText[1] = ""; |
1652 |
22 May 07 |
gregory |
337 |
showThisText[2] = "This version of Xerver is bounded with"; |
1652 |
22 May 07 |
gregory |
338 |
showThisText[3] = "Xerver Free FTP Server " |
1652 |
22 May 07 |
gregory |
339 |
+ FTPServerController.getVersionString() + "."; |
1652 |
22 May 07 |
gregory |
340 |
showThisText[4] = ""; |
1652 |
22 May 07 |
gregory |
341 |
showThisText[5] = "Xerver is an open source project started in January 2002 by"; |
1652 |
22 May 07 |
gregory |
342 |
showThisText[6] = "Omid Rouhani at Chalmers University of Technology, Sweden."; |
1652 |
22 May 07 |
gregory |
343 |
showThisText[7] = "Xerver has actively been developed since then."; |
1652 |
22 May 07 |
gregory |
344 |
showThisText[8] = ""; |
1652 |
22 May 07 |
gregory |
345 |
showThisText[9] = "The official website is available at:"; |
1652 |
22 May 07 |
gregory |
346 |
showThisText[10] = "http://www.JavaScript.nu/xerver/"; |
1652 |
22 May 07 |
gregory |
347 |
showThisText[11] = ""; |
1652 |
22 May 07 |
gregory |
348 |
showThisText[12] = "For information about the license,"; |
1652 |
22 May 07 |
gregory |
349 |
showThisText[13] = "please read Xerver License (GNU GPL)."; |
741 |
10 Oct 06 |
olle |
350 |
return giveContainerWithText(showThisText); |
741 |
10 Oct 06 |
olle |
351 |
} |
741 |
10 Oct 06 |
olle |
352 |
|
1652 |
22 May 07 |
gregory |
353 |
public Container showXerverSetupInfo() { |
741 |
10 Oct 06 |
olle |
354 |
theProgramWindow.setCurrentMode(ProgramWindow.SETUP_MODE); |
741 |
10 Oct 06 |
olle |
355 |
|
741 |
10 Oct 06 |
olle |
356 |
if (xerverSetupIsRunning) |
741 |
10 Oct 06 |
olle |
357 |
theProgramWindow.setStatusText("Xerver Remote Setup is running"); |
741 |
10 Oct 06 |
olle |
358 |
else |
1652 |
22 May 07 |
gregory |
359 |
theProgramWindow |
1652 |
22 May 07 |
gregory |
360 |
.setStatusText("Xerver Remote Setup is not running"); |
741 |
10 Oct 06 |
olle |
361 |
|
741 |
10 Oct 06 |
olle |
362 |
theProgramWindow.setCurrentMode(ProgramWindow.SETUPTURNEDON_MODE); |
741 |
10 Oct 06 |
olle |
363 |
|
1652 |
22 May 07 |
gregory |
364 |
String[] showThisTextUp = new String[3], showThisTextDown = new String[14]; |
1652 |
22 May 07 |
gregory |
365 |
showThisTextUp[0] = "Welcome to \"Xerver Setup\"."; |
1652 |
22 May 07 |
gregory |
366 |
showThisTextUp[1] = ""; |
1652 |
22 May 07 |
gregory |
367 |
showThisTextUp[2] = "You can change settings to Xerver at this adress:"; |
1652 |
22 May 07 |
gregory |
368 |
JTextField txtIPAdress = new JTextField("http://" |
1652 |
22 May 07 |
gregory |
369 |
+ HostInfo.getLocalIPorLocalhost() + ":32123/", 17); |
741 |
10 Oct 06 |
olle |
370 |
txtIPAdress.setBackground(Color.white); |
741 |
10 Oct 06 |
olle |
371 |
txtIPAdress.setEditable(false); |
741 |
10 Oct 06 |
olle |
372 |
txtIPAdress.setFont(defaultFont); |
1652 |
22 May 07 |
gregory |
373 |
showThisTextDown[0] = ""; |
1652 |
22 May 07 |
gregory |
374 |
showThisTextDown[1] = "However, Xerver is also supporting remote administration."; |
1652 |
22 May 07 |
gregory |
375 |
showThisTextDown[2] = ""; |
1652 |
22 May 07 |
gregory |
376 |
showThisTextDown[3] = "Remote administartion means that someone on Internet can "; |
1652 |
22 May 07 |
gregory |
377 |
showThisTextDown[4] = "help you configure Xerver."; |
1652 |
22 May 07 |
gregory |
378 |
showThisTextDown[5] = ""; |
1652 |
22 May 07 |
gregory |
379 |
showThisTextDown[6] = "Only allow people you trust setup Xerver for you!"; |
1652 |
22 May 07 |
gregory |
380 |
showThisTextDown[7] = ""; |
1652 |
22 May 07 |
gregory |
381 |
showThisTextDown[8] = "For security reasons you must turn on remote administration"; |
1652 |
22 May 07 |
gregory |
382 |
showThisTextDown[9] = "before anyone from Internet can setup Xerver."; |
1652 |
22 May 07 |
gregory |
383 |
showThisTextDown[10] = ""; |
1652 |
22 May 07 |
gregory |
384 |
showThisTextDown[11] = "You (and only you) can always setup Xerver at the URL given above."; |
1652 |
22 May 07 |
gregory |
385 |
showThisTextDown[12] = ""; |
1652 |
22 May 07 |
gregory |
386 |
showThisTextDown[13] = "Don't turn on Xerver Remote Setup if you don't want use it!"; |
1652 |
22 May 07 |
gregory |
387 |
return make2ContainersTo1ContainerAbove( |
1652 |
22 May 07 |
gregory |
388 |
make2ContainersTo1ContainerAbove( |
1652 |
22 May 07 |
gregory |
389 |
giveContainerWithText(showThisTextUp), |
1652 |
22 May 07 |
gregory |
390 |
make2ContainersTo1ContainerBeside(txtIPAdress, |
741 |
10 Oct 06 |
olle |
391 |
new JLabel(""))), |
1652 |
22 May 07 |
gregory |
392 |
giveContainerWithText(showThisTextDown)); |
741 |
10 Oct 06 |
olle |
393 |
} |
741 |
10 Oct 06 |
olle |
394 |
|
1652 |
22 May 07 |
gregory |
395 |
public static Container showStatsText() { |
1652 |
22 May 07 |
gregory |
396 |
String[] showThisText = new String[4]; |
1652 |
22 May 07 |
gregory |
397 |
showThisText[0] = "Xerver Log"; |
1652 |
22 May 07 |
gregory |
398 |
showThisText[1] = "(Check what information you want to see and the size of each field in the list below)"; |
1652 |
22 May 07 |
gregory |
399 |
showThisText[2] = ""; |
741 |
10 Oct 06 |
olle |
400 |
return giveContainerWithText(showThisText); |
741 |
10 Oct 06 |
olle |
401 |
} |
741 |
10 Oct 06 |
olle |
402 |
|
1652 |
22 May 07 |
gregory |
403 |
public Container showStats() { |
741 |
10 Oct 06 |
olle |
404 |
theProgramWindow.setCurrentMode(ProgramWindow.STATS_MODE); |
741 |
10 Oct 06 |
olle |
405 |
|
1652 |
22 May 07 |
gregory |
406 |
Container statsCP = new Container(); |
741 |
10 Oct 06 |
olle |
407 |
statsCP.setLayout(new BorderLayout()); |
741 |
10 Oct 06 |
olle |
408 |
|
1652 |
22 May 07 |
gregory |
409 |
Container statsCP2 = new Container(); |
1652 |
22 May 07 |
gregory |
410 |
statsCP2.setLayout(new BorderLayout()); |
1652 |
22 May 07 |
gregory |
411 |
statsCP2.add(showButtonsAndTextStats(), BorderLayout.WEST); |
1652 |
22 May 07 |
gregory |
412 |
statsCP2.add(new JLabel(""), BorderLayout.CENTER); |
741 |
10 Oct 06 |
olle |
413 |
|
1652 |
22 May 07 |
gregory |
414 |
statsCP.add(statsCP2, BorderLayout.NORTH); |
1652 |
22 May 07 |
gregory |
415 |
statsCP.add(JP_IPPanel, BorderLayout.CENTER); |
1652 |
22 May 07 |
gregory |
416 |
statsCP.add(showBytesDownloaded(), BorderLayout.SOUTH); |
741 |
10 Oct 06 |
olle |
417 |
|
741 |
10 Oct 06 |
olle |
418 |
return statsCP; |
741 |
10 Oct 06 |
olle |
419 |
} |
741 |
10 Oct 06 |
olle |
420 |
|
1652 |
22 May 07 |
gregory |
421 |
public Container showBytesDownloaded() { |
1652 |
22 May 07 |
gregory |
422 |
JTF_hitsField |
1652 |
22 May 07 |
gregory |
423 |
.setText(MyString |
1652 |
22 May 07 |
gregory |
424 |
.makeNumberToStringWithApostrophe(NewConnection.totalNumberOfHits |
1652 |
22 May 07 |
gregory |
425 |
+ "") |
1652 |
22 May 07 |
gregory |
426 |
+ " hits"); |
1652 |
22 May 07 |
gregory |
427 |
JTF_bytesField |
1652 |
22 May 07 |
gregory |
428 |
.setText(MyString |
1652 |
22 May 07 |
gregory |
429 |
.makeNumberToStringWithApostrophe(NewConnection.totalNumberOfBytesDownloaded |
1652 |
22 May 07 |
gregory |
430 |
+ "") |
1652 |
22 May 07 |
gregory |
431 |
+ " bytes"); |
1652 |
22 May 07 |
gregory |
432 |
JTF_connectionsField.setText(MyString |
1652 |
22 May 07 |
gregory |
433 |
.makeNumberToStringWithApostrophe(xerverThread |
1652 |
22 May 07 |
gregory |
434 |
.getNumberOfActiveConnections() |
1652 |
22 May 07 |
gregory |
435 |
+ "") |
1652 |
22 May 07 |
gregory |
436 |
+ " connections"); |
741 |
10 Oct 06 |
olle |
437 |
JTF_hitsField.setBackground(Color.white); |
741 |
10 Oct 06 |
olle |
438 |
JTF_bytesField.setBackground(Color.white); |
741 |
10 Oct 06 |
olle |
439 |
JTF_connectionsField.setBackground(Color.white); |
741 |
10 Oct 06 |
olle |
440 |
JTF_hitsField.setEditable(false); |
741 |
10 Oct 06 |
olle |
441 |
JTF_bytesField.setEditable(false); |
741 |
10 Oct 06 |
olle |
442 |
JTF_connectionsField.setEditable(false); |
741 |
10 Oct 06 |
olle |
443 |
|
1652 |
22 May 07 |
gregory |
444 |
Container threeFields = new Container(); |
1652 |
22 May 07 |
gregory |
445 |
threeFields.setLayout(new GridLayout(1, 3)); |
741 |
10 Oct 06 |
olle |
446 |
threeFields.add(JTF_hitsField); |
741 |
10 Oct 06 |
olle |
447 |
threeFields.add(JTF_bytesField); |
741 |
10 Oct 06 |
olle |
448 |
threeFields.add(JTF_connectionsField); |
741 |
10 Oct 06 |
olle |
449 |
|
1652 |
22 May 07 |
gregory |
450 |
Container fieldsWithBlankAreas = new Container(); |
741 |
10 Oct 06 |
olle |
451 |
fieldsWithBlankAreas.setLayout(new BorderLayout()); |
1652 |
22 May 07 |
gregory |
452 |
fieldsWithBlankAreas.add(threeFields, BorderLayout.WEST); |
1652 |
22 May 07 |
gregory |
453 |
fieldsWithBlankAreas.add(ProgramWindow.EMPTY_JLABEL, |
1652 |
22 May 07 |
gregory |
454 |
BorderLayout.CENTER); |
741 |
10 Oct 06 |
olle |
455 |
return fieldsWithBlankAreas; |
1652 |
22 May 07 |
gregory |
// return |
1652 |
22 May 07 |
gregory |
// make2ContainersTo1ContainerBeside(make2ContainersTo1ContainerBeside(JTF_hitsField,JTF_bytesField),make2ContainersTo1ContainerBeside(JTF_connectionsField,ProgramWindow.EMPTY_JLABEL)); |
741 |
10 Oct 06 |
olle |
458 |
} |
741 |
10 Oct 06 |
olle |
459 |
|
1652 |
22 May 07 |
gregory |
460 |
public Container showButtonsAndTextStats() { |
1652 |
22 May 07 |
gregory |
461 |
Container statsCP = new Container(); |
741 |
10 Oct 06 |
olle |
462 |
statsCP.setLayout(new BorderLayout()); |
1652 |
22 May 07 |
gregory |
463 |
statsCP.add(showStatsText(), BorderLayout.CENTER); |
1652 |
22 May 07 |
gregory |
464 |
statsCP.add(showStatsButtons(), BorderLayout.SOUTH); |
741 |
10 Oct 06 |
olle |
465 |
|
741 |
10 Oct 06 |
olle |
466 |
return statsCP; |
741 |
10 Oct 06 |
olle |
467 |
} |
741 |
10 Oct 06 |
olle |
468 |
|
1652 |
22 May 07 |
gregory |
469 |
public Container showStatsButtons() { |
1652 |
22 May 07 |
gregory |
470 |
Container statsCP = new Container(); |
1652 |
22 May 07 |
gregory |
471 |
statsCP.setLayout(new GridLayout(2, 4)); |
741 |
10 Oct 06 |
olle |
472 |
|
1652 |
22 May 07 |
gregory |
473 |
for (int i = 0, showWhatStatisticLength = JCB_showWhatStatistic.length; i < showWhatStatisticLength; i++) // Optimization... |
741 |
10 Oct 06 |
olle |
474 |
{ |
1652 |
22 May 07 |
gregory |
475 |
statsCP.add(make2ContainersTo1ContainerBeside( |
1652 |
22 May 07 |
gregory |
476 |
JTF_showStatisticFieldLength[i], JCB_showWhatStatistic[i])); |
741 |
10 Oct 06 |
olle |
477 |
} |
1652 |
22 May 07 |
gregory |
478 |
statsCP.add(new JLabel("")); |
741 |
10 Oct 06 |
olle |
479 |
|
741 |
10 Oct 06 |
olle |
480 |
updateStatList(); |
741 |
10 Oct 06 |
olle |
481 |
return statsCP; |
741 |
10 Oct 06 |
olle |
482 |
} |
741 |
10 Oct 06 |
olle |
483 |
|
1652 |
22 May 07 |
gregory |
484 |
public Container checkForUpdates() { |
741 |
10 Oct 06 |
olle |
485 |
theProgramWindow.setCurrentMode(ProgramWindow.UPDATE_MODE); |
741 |
10 Oct 06 |
olle |
486 |
|
1652 |
22 May 07 |
gregory |
487 |
try { |
1652 |
22 May 07 |
gregory |
488 |
double latestVersionFromNet = getLatestVersion(); |
741 |
10 Oct 06 |
olle |
489 |
|
1652 |
22 May 07 |
gregory |
490 |
if (XerverKernel.getThisVersion() >= latestVersionFromNet) // If we |
1652 |
22 May 07 |
gregory |
// currently |
1652 |
22 May 07 |
gregory |
// are |
1652 |
22 May 07 |
gregory |
// running |
1652 |
22 May 07 |
gregory |
// a |
1652 |
22 May 07 |
gregory |
// newer |
1652 |
22 May 07 |
gregory |
// version |
1652 |
22 May 07 |
gregory |
// than |
1652 |
22 May 07 |
gregory |
// the |
1652 |
22 May 07 |
gregory |
// official |
1652 |
22 May 07 |
gregory |
// release |
1652 |
22 May 07 |
gregory |
// (=this |
1652 |
22 May 07 |
gregory |
// is a |
1652 |
22 May 07 |
gregory |
// BETA), |
1652 |
22 May 07 |
gregory |
// then |
1652 |
22 May 07 |
gregory |
// say |
1652 |
22 May 07 |
gregory |
// no |
1652 |
22 May 07 |
gregory |
// new |
1652 |
22 May 07 |
gregory |
// version |
1652 |
22 May 07 |
gregory |
// available |
741 |
10 Oct 06 |
olle |
510 |
{ |
1652 |
22 May 07 |
gregory |
511 |
String[] showThisText = new String[6]; |
1652 |
22 May 07 |
gregory |
512 |
showThisText[0] = "No new version available!"; |
1652 |
22 May 07 |
gregory |
513 |
showThisText[1] = ""; |
1652 |
22 May 07 |
gregory |
514 |
showThisText[2] = "You are currently using the latest version of Xerver (" |
1652 |
22 May 07 |
gregory |
515 |
+ XerverKernel.getThisVersionString() + ")."; |
1652 |
22 May 07 |
gregory |
516 |
showThisText[3] = ""; |
1652 |
22 May 07 |
gregory |
517 |
showThisText[4] = "The official Xerver website is available at:"; |
1652 |
22 May 07 |
gregory |
518 |
showThisText[5] = "http://www.javascript.nu/xerver/"; |
741 |
10 Oct 06 |
olle |
519 |
|
741 |
10 Oct 06 |
olle |
520 |
theProgramWindow.setStatusText("No New Version Available!"); |
1652 |
22 May 07 |
gregory |
521 |
return GUIMethods |
1652 |
22 May 07 |
gregory |
522 |
.showAsNorthBorderLayout(giveContainerWithText(showThisText)); |
1652 |
22 May 07 |
gregory |
523 |
} else // Regardless if getThisVersion() or latestVersionFromNet is |
1652 |
22 May 07 |
gregory |
// greatest, a new version has been released (as the two |
1652 |
22 May 07 |
gregory |
// versions are different) |
741 |
10 Oct 06 |
olle |
526 |
{ |
741 |
10 Oct 06 |
olle |
527 |
theProgramWindow.setStatusText("New Version Available!"); |
741 |
10 Oct 06 |
olle |
528 |
|
1652 |
22 May 07 |
gregory |
529 |
String[] showThisTextUp = new String[3], showThisTextDown = new String[14]; |
1652 |
22 May 07 |
gregory |
530 |
showThisTextUp[0] = "New version available!"; |
1652 |
22 May 07 |
gregory |
531 |
showThisTextUp[1] = ""; |
1652 |
22 May 07 |
gregory |
532 |
showThisTextUp[2] = "You can download Xerver " |
1652 |
22 May 07 |
gregory |
533 |
+ latestVersionFromNet + " for free at:"; |
1652 |
22 May 07 |
gregory |
534 |
showThisTextDown[0] = ""; |
1652 |
22 May 07 |
gregory |
535 |
showThisTextDown[1] = "You are strongly recommended to download the latest version."; |
1652 |
22 May 07 |
gregory |
536 |
JTextField txtIPAdress = new JTextField( |
1652 |
22 May 07 |
gregory |
537 |
"http://www.javascript.nu/xerver/", 17); |
741 |
10 Oct 06 |
olle |
538 |
txtIPAdress.setBackground(Color.white); |
741 |
10 Oct 06 |
olle |
539 |
txtIPAdress.setEditable(false); |
741 |
10 Oct 06 |
olle |
540 |
txtIPAdress.setFont(defaultFont); |
1652 |
22 May 07 |
gregory |
541 |
return make2ContainersTo1ContainerAbove( |
741 |
10 Oct 06 |
olle |
542 |
make2ContainersTo1ContainerAbove( |
1652 |
22 May 07 |
gregory |
543 |
giveContainerWithText(showThisTextUp), |
1652 |
22 May 07 |
gregory |
544 |
make2ContainersTo1ContainerBeside(txtIPAdress, |
1652 |
22 May 07 |
gregory |
545 |
new JLabel(""))), |
1652 |
22 May 07 |
gregory |
546 |
giveContainerWithText(showThisTextDown)); |
741 |
10 Oct 06 |
olle |
547 |
} |
741 |
10 Oct 06 |
olle |
548 |
|
1652 |
22 May 07 |
gregory |
549 |
} catch (Exception e) // java.net.ConnectException: Connection |
1652 |
22 May 07 |
gregory |
// refused: connect |
741 |
10 Oct 06 |
olle |
551 |
{ |
741 |
10 Oct 06 |
olle |
552 |
theProgramWindow.setStatusText("No Internet connection detected!"); |
741 |
10 Oct 06 |
olle |
553 |
|
1652 |
22 May 07 |
gregory |
554 |
JTextField txtIPAdress = new JTextField( |
1652 |
22 May 07 |
gregory |
555 |
"http://www.javascript.nu/xerver/", 17); |
741 |
10 Oct 06 |
olle |
556 |
txtIPAdress.setBackground(Color.white); |
741 |
10 Oct 06 |
olle |
557 |
txtIPAdress.setEditable(false); |
741 |
10 Oct 06 |
olle |
558 |
txtIPAdress.setFont(defaultFont); |
741 |
10 Oct 06 |
olle |
559 |
|
1652 |
22 May 07 |
gregory |
560 |
String[] showThisTextUp = new String[5]; |
1652 |
22 May 07 |
gregory |
561 |
showThisTextUp[0] = "No Internet connection detected!"; |
1652 |
22 May 07 |
gregory |
562 |
showThisTextUp[1] = ""; |
1652 |
22 May 07 |
gregory |
563 |
showThisTextUp[2] = "Xerver failed to connect to Internet."; |
1652 |
22 May 07 |
gregory |
564 |
showThisTextUp[3] = ""; |
1652 |
22 May 07 |
gregory |
565 |
showThisTextUp[4] = "You can find the latest version of Xerver at the official Xerver website:"; |
741 |
10 Oct 06 |
olle |
566 |
|
1652 |
22 May 07 |
gregory |
567 |
return GUIMethods |
1652 |
22 May 07 |
gregory |
568 |
.showAsNorthBorderLayout(make2ContainersTo1ContainerAbove( |
1652 |
22 May 07 |
gregory |
569 |
giveContainerWithText(showThisTextUp), |
1652 |
22 May 07 |
gregory |
570 |
make2ContainersTo1ContainerBeside(txtIPAdress, |
1652 |
22 May 07 |
gregory |
571 |
new JLabel("")))); |
741 |
10 Oct 06 |
olle |
572 |
} |
741 |
10 Oct 06 |
olle |
573 |
} |
741 |
10 Oct 06 |
olle |
574 |
|
1652 |
22 May 07 |
gregory |
575 |
public static double getLatestVersion() throws Exception { |
1652 |
22 May 07 |
gregory |
576 |
double versionNumber = -1; |
1652 |
22 May 07 |
gregory |
// try { |
1652 |
22 May 07 |
gregory |
578 |
URL updateFile = new URL( |
1652 |
22 May 07 |
gregory |
579 |
"http://www.javascript.nu/xerver/currentversion.js"); |
1652 |
22 May 07 |
gregory |
580 |
BufferedReader inStr = new BufferedReader(new InputStreamReader( |
1652 |
22 May 07 |
gregory |
581 |
updateFile.openStream())); |
1652 |
22 May 07 |
gregory |
582 |
String tmpStr; |
1652 |
22 May 07 |
gregory |
583 |
while ((tmpStr = inStr.readLine()) != null) { |
1652 |
22 May 07 |
gregory |
584 |
if (tmpStr.startsWith("newestVersion")) { |
1652 |
22 May 07 |
gregory |
585 |
String versionNumberStr = tmpStr.substring( |
1652 |
22 May 07 |
gregory |
586 |
tmpStr.indexOf("\"") + 1, tmpStr.lastIndexOf("\"")); |
1652 |
22 May 07 |
gregory |
587 |
versionNumber = (new Double(versionNumberStr)).doubleValue(); |
741 |
10 Oct 06 |
olle |
588 |
} |
1652 |
22 May 07 |
gregory |
589 |
} |
1652 |
22 May 07 |
gregory |
// } catch (Exception e) {System.out.println(e);} |
741 |
10 Oct 06 |
olle |
591 |
return versionNumber; |
741 |
10 Oct 06 |
olle |
592 |
} |
741 |
10 Oct 06 |
olle |
593 |
|
4415 |
20 Feb 13 |
olle |
594 |
@SuppressWarnings("unchecked") |
1652 |
22 May 07 |
gregory |
595 |
private void initSwingButtons() { |
741 |
10 Oct 06 |
olle |
596 |
DLM_listWithAllIPConnected = new DefaultListModel(); |
1652 |
22 May 07 |
gregory |
597 |
JL_allIPConnected = new JList(DLM_listWithAllIPConnected); |
741 |
10 Oct 06 |
olle |
598 |
JL_allIPConnected.setFont(new Font("Courier", Font.PLAIN, 12)); |
741 |
10 Oct 06 |
olle |
599 |
JL_allIPConnected.setVisibleRowCount(12); |
741 |
10 Oct 06 |
olle |
600 |
JL_allIPConnected.setFixedCellHeight(12); |
1652 |
22 May 07 |
gregory |
601 |
JL_allIPConnected |
1652 |
22 May 07 |
gregory |
602 |
.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); // SINGLE_SELECTION); |
741 |
10 Oct 06 |
olle |
603 |
JL_allIPConnected.setSelectedIndex(0); |
1652 |
22 May 07 |
gregory |
// JSP_IPScrollPane = new JScrollPane(JL_allIPConnected); |
741 |
10 Oct 06 |
olle |
605 |
|
741 |
10 Oct 06 |
olle |
606 |
JSP_IPScrollPane = new JScrollPane(); |
741 |
10 Oct 06 |
olle |
607 |
JSP_IPScrollPane.getViewport().add(JL_allIPConnected); |
741 |
10 Oct 06 |
olle |
608 |
|
1652 |
22 May 07 |
gregory |
609 |
JP_IPPanel = new JPanel(); |
741 |
10 Oct 06 |
olle |
610 |
JP_IPPanel.setLayout(new BoxLayout(JP_IPPanel, BoxLayout.X_AXIS)); |
741 |
10 Oct 06 |
olle |
611 |
JP_IPPanel.add(JSP_IPScrollPane); |
741 |
10 Oct 06 |
olle |
612 |
|
1652 |
22 May 07 |
gregory |
613 |
JCB_showWhatStatistic = new JCheckBox[7]; |
1652 |
22 May 07 |
gregory |
614 |
JCB_showWhatStatistic[0] = new JCheckBox("IP/Host", true); |
1652 |
22 May 07 |
gregory |
615 |
JCB_showWhatStatistic[1] = new JCheckBox("Status Code", false); |
1652 |
22 May 07 |
gregory |
616 |
JCB_showWhatStatistic[2] = new JCheckBox("Extension", false); |
1652 |
22 May 07 |
gregory |
617 |
JCB_showWhatStatistic[3] = new JCheckBox("Zone", false); |
1652 |
22 May 07 |
gregory |
618 |
JCB_showWhatStatistic[4] = new JCheckBox("UserName", false); |
1652 |
22 May 07 |
gregory |
619 |
JCB_showWhatStatistic[5] = new JCheckBox("Date", true); |
1652 |
22 May 07 |
gregory |
620 |
JCB_showWhatStatistic[6] = new JCheckBox("File", true); |
741 |
10 Oct 06 |
olle |
621 |
|
1652 |
22 May 07 |
gregory |
622 |
for (int i = 0, showWhatStatisticLength = JCB_showWhatStatistic.length; i < showWhatStatisticLength; i++) |
1652 |
22 May 07 |
gregory |
// Optimization... |
741 |
10 Oct 06 |
olle |
624 |
JCB_showWhatStatistic[i].setFont(defaultFont); |
741 |
10 Oct 06 |
olle |
625 |
|
1652 |
22 May 07 |
gregory |
626 |
for (int i = 0, showWhatStatisticLength = JCB_showWhatStatistic.length; i < showWhatStatisticLength; i++) |
1652 |
22 May 07 |
gregory |
// Optimization... |
741 |
10 Oct 06 |
olle |
628 |
JCB_showWhatStatistic[i].addActionListener(this); |
741 |
10 Oct 06 |
olle |
629 |
|
1652 |
22 May 07 |
gregory |
630 |
JTF_showStatisticFieldLength = new JTextFieldInt[7]; |
1652 |
22 May 07 |
gregory |
631 |
JTF_showStatisticFieldLength[0] = new JTextFieldInt(30, 3); |
1652 |
22 May 07 |
gregory |
632 |
JTF_showStatisticFieldLength[1] = new JTextFieldInt(14, 3); |
1652 |
22 May 07 |
gregory |
633 |
JTF_showStatisticFieldLength[2] = new JTextFieldInt(6, 3); |
1652 |
22 May 07 |
gregory |
634 |
JTF_showStatisticFieldLength[3] = new JTextFieldInt(10, 3); |
1652 |
22 May 07 |
gregory |
635 |
JTF_showStatisticFieldLength[4] = new JTextFieldInt(10, 3); |
1652 |
22 May 07 |
gregory |
636 |
JTF_showStatisticFieldLength[5] = new JTextFieldInt(15, 3); |
1652 |
22 May 07 |
gregory |
637 |
JTF_showStatisticFieldLength[6] = new JTextFieldInt("Inf", 3); // doesn't |
1652 |
22 May 07 |
gregory |
// matter, |
1652 |
22 May 07 |
gregory |
// this |
1652 |
22 May 07 |
gregory |
// isn't |
1652 |
22 May 07 |
gregory |
// used |
1652 |
22 May 07 |
gregory |
// anyway, |
1652 |
22 May 07 |
gregory |
// but |
1652 |
22 May 07 |
gregory |
// we |
1652 |
22 May 07 |
gregory |
// want |
1652 |
22 May 07 |
gregory |
// [JTF_showStatisticFieldLength.length==JCB_showWhatStatistic.length] |
741 |
10 Oct 06 |
olle |
647 |
JTF_showStatisticFieldLength[6].setEditable(false); |
741 |
10 Oct 06 |
olle |
648 |
JTF_showStatisticFieldLength[6].setEnabled(false); |
741 |
10 Oct 06 |
olle |
649 |
|
1652 |
22 May 07 |
gregory |
650 |
for (int i = 0, showStatisticFieldLengthLength = JTF_showStatisticFieldLength.length; i < showStatisticFieldLengthLength; i++) // Optimization... |
741 |
10 Oct 06 |
olle |
651 |
{ |
741 |
10 Oct 06 |
olle |
652 |
JTF_showStatisticFieldLength[i].setFont(defaultFont); |
741 |
10 Oct 06 |
olle |
653 |
JTF_showStatisticFieldLength[i].setColumns(3); |
741 |
10 Oct 06 |
olle |
654 |
JTF_showStatisticFieldLength[i].addActionListener(this); |
1652 |
22 May 07 |
gregory |
655 |
JTF_showStatisticFieldLength[i].getDocument().addDocumentListener( |
1652 |
22 May 07 |
gregory |
656 |
this); |
741 |
10 Oct 06 |
olle |
657 |
} |
741 |
10 Oct 06 |
olle |
658 |
|
1652 |
22 May 07 |
gregory |
659 |
JTF_hitsField = new JTextField( |
1652 |
22 May 07 |
gregory |
660 |
MyString |
1652 |
22 May 07 |
gregory |
661 |
.makeNumberToStringWithApostrophe(NewConnection.totalNumberOfHits |
1652 |
22 May 07 |
gregory |
662 |
+ "") |
1652 |
22 May 07 |
gregory |
663 |
+ " hits", 8); |
1652 |
22 May 07 |
gregory |
664 |
JTF_bytesField = new JTextField( |
1652 |
22 May 07 |
gregory |
665 |
MyString |
1652 |
22 May 07 |
gregory |
666 |
.makeNumberToStringWithApostrophe(NewConnection.totalNumberOfBytesDownloaded |
1652 |
22 May 07 |
gregory |
667 |
+ "") |
1652 |
22 May 07 |
gregory |
668 |
+ " bytes", 11); |
1652 |
22 May 07 |
gregory |
669 |
JTF_connectionsField = new JTextField(MyString |
1652 |
22 May 07 |
gregory |
670 |
.makeNumberToStringWithApostrophe(xerverThread |
1652 |
22 May 07 |
gregory |
671 |
.getNumberOfActiveConnections() |
1652 |
22 May 07 |
gregory |
672 |
+ "") |
1652 |
22 May 07 |
gregory |
673 |
+ " connections", 9); |
741 |
10 Oct 06 |
olle |
674 |
} |
741 |
10 Oct 06 |
olle |
675 |
|
1652 |
22 May 07 |
gregory |
676 |
private void updateStatList() { |
1652 |
22 May 07 |
gregory |
677 |
HitStatistic.showIP = JCB_showWhatStatistic[0].isSelected(); |
1652 |
22 May 07 |
gregory |
678 |
HitStatistic.showStatusCode = JCB_showWhatStatistic[1].isSelected(); |
1652 |
22 May 07 |
gregory |
679 |
HitStatistic.showFileExtension = JCB_showWhatStatistic[2].isSelected(); |
1652 |
22 May 07 |
gregory |
680 |
HitStatistic.showLoginRealm = JCB_showWhatStatistic[3].isSelected(); |
1652 |
22 May 07 |
gregory |
681 |
HitStatistic.showLoginUserName = JCB_showWhatStatistic[4].isSelected(); |
1652 |
22 May 07 |
gregory |
682 |
HitStatistic.showHitDate = JCB_showWhatStatistic[5].isSelected(); |
1652 |
22 May 07 |
gregory |
683 |
HitStatistic.showFileLocation = JCB_showWhatStatistic[6].isSelected(); |
1652 |
22 May 07 |
gregory |
684 |
/* |
1652 |
22 May 07 |
gregory |
* for (int i=0; i<JTF_showStatisticFieldLength.length; i++) if |
1652 |
22 May 07 |
gregory |
* (JTF_showStatisticFieldLength[i].getText().equals("")) |
1652 |
22 May 07 |
gregory |
* JTF_showStatisticFieldLength[i].setText("0"); |
1652 |
22 May 07 |
gregory |
688 |
*/ |
1652 |
22 May 07 |
gregory |
689 |
try { |
741 |
10 Oct 06 |
olle |
690 |
if (!JTF_showStatisticFieldLength[0].getText().equals("")) |
1652 |
22 May 07 |
gregory |
691 |
HitStatistic.showLengthIP = Integer |
1652 |
22 May 07 |
gregory |
692 |
.parseInt(JTF_showStatisticFieldLength[0].getText()); |
741 |
10 Oct 06 |
olle |
693 |
|
741 |
10 Oct 06 |
olle |
694 |
if (!JTF_showStatisticFieldLength[1].getText().equals("")) |
1652 |
22 May 07 |
gregory |
695 |
HitStatistic.showLengthStatusCode = Integer |
1652 |
22 May 07 |
gregory |
696 |
.parseInt(JTF_showStatisticFieldLength[1].getText()); |
741 |
10 Oct 06 |
olle |
697 |
|
741 |
10 Oct 06 |
olle |
698 |
if (!JTF_showStatisticFieldLength[2].getText().equals("")) |
1652 |
22 May 07 |
gregory |
699 |
HitStatistic.showLengthFileExtension = Integer |
1652 |
22 May 07 |
gregory |
700 |
.parseInt(JTF_showStatisticFieldLength[2].getText()); |
741 |
10 Oct 06 |
olle |
701 |
|
741 |
10 Oct 06 |
olle |
702 |
if (!JTF_showStatisticFieldLength[3].getText().equals("")) |
1652 |
22 May 07 |
gregory |
703 |
HitStatistic.showLengthLoginRealm = Integer |
1652 |
22 May 07 |
gregory |
704 |
.parseInt(JTF_showStatisticFieldLength[3].getText()); |
741 |
10 Oct 06 |
olle |
705 |
|
741 |
10 Oct 06 |
olle |
706 |
if (!JTF_showStatisticFieldLength[4].getText().equals("")) |
1652 |
22 May 07 |
gregory |
707 |
HitStatistic.showLengthLoginUserName = Integer |
1652 |
22 May 07 |
gregory |
708 |
.parseInt(JTF_showStatisticFieldLength[4].getText()); |
741 |
10 Oct 06 |
olle |
709 |
|
741 |
10 Oct 06 |
olle |
710 |
if (!JTF_showStatisticFieldLength[5].getText().equals("")) |
1652 |
22 May 07 |
gregory |
711 |
HitStatistic.showLengthHitDate = Integer |
1652 |
22 May 07 |
gregory |
712 |
.parseInt(JTF_showStatisticFieldLength[5].getText()); |
1652 |
22 May 07 |
gregory |
713 |
} catch (Exception e) // There is not an integer in the fields |
741 |
10 Oct 06 |
olle |
714 |
{ |
1652 |
22 May 07 |
gregory |
715 |
if (b_showErrors) |
1652 |
22 May 07 |
gregory |
716 |
System.out.println("An error has occured @ updateStatList:\n" |
1652 |
22 May 07 |
gregory |
717 |
+ e.getMessage()); |
741 |
10 Oct 06 |
olle |
718 |
} |
1652 |
22 May 07 |
gregory |
// JL_allIPConnected.repaint(); |
741 |
10 Oct 06 |
olle |
720 |
JSP_IPScrollPane.repaint(); |
741 |
10 Oct 06 |
olle |
721 |
} |
741 |
10 Oct 06 |
olle |
722 |
|
1652 |
22 May 07 |
gregory |
723 |
public void actionPerformed(ActionEvent event) { |
741 |
10 Oct 06 |
olle |
724 |
updateStatList(); |
741 |
10 Oct 06 |
olle |
725 |
} |
741 |
10 Oct 06 |
olle |
726 |
|
1652 |
22 May 07 |
gregory |
727 |
public void insertUpdate(DocumentEvent e) { |
741 |
10 Oct 06 |
olle |
728 |
updateStatList(); |
741 |
10 Oct 06 |
olle |
729 |
} |
741 |
10 Oct 06 |
olle |
730 |
|
1652 |
22 May 07 |
gregory |
731 |
public void removeUpdate(DocumentEvent e) { |
741 |
10 Oct 06 |
olle |
732 |
updateStatList(); |
741 |
10 Oct 06 |
olle |
733 |
} |
741 |
10 Oct 06 |
olle |
734 |
|
1652 |
22 May 07 |
gregory |
735 |
public void changedUpdate(DocumentEvent e) { |
741 |
10 Oct 06 |
olle |
736 |
updateStatList(); |
741 |
10 Oct 06 |
olle |
737 |
} |
741 |
10 Oct 06 |
olle |
738 |
} |