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.ftp_server.FTPMessages; |
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.event.ActionEvent; |
741 |
10 Oct 06 |
olle |
67 |
import java.awt.event.ActionListener; |
741 |
10 Oct 06 |
olle |
68 |
import java.awt.event.WindowAdapter; |
741 |
10 Oct 06 |
olle |
69 |
import java.awt.event.WindowEvent; |
741 |
10 Oct 06 |
olle |
70 |
import java.io.File; |
741 |
10 Oct 06 |
olle |
71 |
import javax.swing.BoxLayout; |
741 |
10 Oct 06 |
olle |
72 |
import javax.swing.ImageIcon; |
741 |
10 Oct 06 |
olle |
73 |
import javax.swing.JButton; |
741 |
10 Oct 06 |
olle |
74 |
import javax.swing.JFrame; |
741 |
10 Oct 06 |
olle |
75 |
import javax.swing.JLabel; |
741 |
10 Oct 06 |
olle |
76 |
import javax.swing.JMenu; |
741 |
10 Oct 06 |
olle |
77 |
import javax.swing.JMenuBar; |
741 |
10 Oct 06 |
olle |
78 |
import javax.swing.JMenuItem; |
741 |
10 Oct 06 |
olle |
79 |
import javax.swing.JOptionPane; |
741 |
10 Oct 06 |
olle |
80 |
import javax.swing.JTextField; |
741 |
10 Oct 06 |
olle |
81 |
|
741 |
10 Oct 06 |
olle |
82 |
/** |
1652 |
22 May 07 |
gregory |
83 |
* |
1652 |
22 May 07 |
gregory |
* <B>About this class:</B> <BR> |
1652 |
22 May 07 |
gregory |
* This is the graphical layout of Xerver. However, to start an advanced |
1652 |
22 May 07 |
gregory |
* graphical layout requires system resources. That's why you actually don't |
1652 |
22 May 07 |
gregory |
* need this if you want to run the pure Xerver web server. If you want to run |
1652 |
22 May 07 |
gregory |
* the pure web server, use setup and choose to run Xerver with now window and |
1652 |
22 May 07 |
gregory |
* then start Start.class. <BR> |
1652 |
22 May 07 |
gregory |
* Start Xerver in one of these ways: <BR> |
1652 |
22 May 07 |
gregory |
* <CODE>(new Thread(new XerverKernel(true,null))).start(); //no window</CODE> |
741 |
10 Oct 06 |
olle |
* <BR> |
1652 |
22 May 07 |
gregory |
* <CODE>(new Thread(new XerverKernel(false,null))).start(); //awt-window</CODE> |
741 |
10 Oct 06 |
olle |
* <BR> |
1652 |
22 May 07 |
gregory |
* <CODE>new ProgramWindow(); //swing-window</CODE> <BR> |
741 |
10 Oct 06 |
olle |
* <BR> |
741 |
10 Oct 06 |
olle |
* One of the lines above are executed when you run "Start.class". |
1652 |
22 May 07 |
gregory |
98 |
* |
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 |
101 |
*/ |
741 |
10 Oct 06 |
olle |
102 |
|
1652 |
22 May 07 |
gregory |
103 |
@SuppressWarnings("serial") |
1652 |
22 May 07 |
gregory |
104 |
final public class ProgramWindow extends JFrame implements ActionListener { |
1652 |
22 May 07 |
gregory |
105 |
public final static int STARTUP_MODE = 0; |
741 |
10 Oct 06 |
olle |
106 |
|
1652 |
22 May 07 |
gregory |
107 |
public final static int STATS_MODE = 1; |
741 |
10 Oct 06 |
olle |
108 |
|
1652 |
22 May 07 |
gregory |
109 |
public final static int SETUP_MODE = 2; |
741 |
10 Oct 06 |
olle |
110 |
|
1652 |
22 May 07 |
gregory |
111 |
public final static int SETUPSAVED_MODE = 3; |
741 |
10 Oct 06 |
olle |
112 |
|
1652 |
22 May 07 |
gregory |
113 |
public final static int UPDATE_MODE = 4; |
1652 |
22 May 07 |
gregory |
114 |
|
1652 |
22 May 07 |
gregory |
115 |
public final static int SETUPTURNEDON_MODE = 5; |
1652 |
22 May 07 |
gregory |
116 |
|
1652 |
22 May 07 |
gregory |
117 |
public final static int SETUPTURNEDOFF_MODE = 6; |
1652 |
22 May 07 |
gregory |
118 |
|
1652 |
22 May 07 |
gregory |
119 |
public final static int HELP_MODE = 7; |
1652 |
22 May 07 |
gregory |
120 |
|
1652 |
22 May 07 |
gregory |
121 |
public final static int ABOUT_MODE = 8; |
1652 |
22 May 07 |
gregory |
122 |
|
1652 |
22 May 07 |
gregory |
123 |
public final static Font defaultFont = GUIMethods.defaultFont; |
1652 |
22 May 07 |
gregory |
124 |
|
1652 |
22 May 07 |
gregory |
125 |
public final static JLabel EMPTY_JLABEL = new JLabel(" "); // Optimization... |
1652 |
22 May 07 |
gregory |
126 |
|
1652 |
22 May 07 |
gregory |
127 |
private final static Font f_defaultStatusFont = new Font("arial", |
1652 |
22 May 07 |
gregory |
128 |
Font.ITALIC, 11); |
1652 |
22 May 07 |
gregory |
129 |
|
1652 |
22 May 07 |
gregory |
130 |
public final static JButton aboutOuterIPButton = new JButton("?");; // So |
1652 |
22 May 07 |
gregory |
// that |
1652 |
22 May 07 |
gregory |
// actionPerformed |
1652 |
22 May 07 |
gregory |
// can |
1652 |
22 May 07 |
gregory |
// recognize |
1652 |
22 May 07 |
gregory |
// this |
1652 |
22 May 07 |
gregory |
// button |
1652 |
22 May 07 |
gregory |
137 |
|
1652 |
22 May 07 |
gregory |
138 |
public final static JButton aboutLocalIPButton = new JButton("?");; // So |
1652 |
22 May 07 |
gregory |
// that |
1652 |
22 May 07 |
gregory |
// actionPerformed |
1652 |
22 May 07 |
gregory |
// can |
1652 |
22 May 07 |
gregory |
// recognize |
1652 |
22 May 07 |
gregory |
// this |
1652 |
22 May 07 |
gregory |
// button |
1652 |
22 May 07 |
gregory |
145 |
|
1652 |
22 May 07 |
gregory |
146 |
private final static JButton turnOffButton = new JButton(new ImageIcon( |
1652 |
22 May 07 |
gregory |
147 |
"data" + File.separator + "imagestopbutton.gif"));; // So that |
1652 |
22 May 07 |
gregory |
// actionPerformed |
1652 |
22 May 07 |
gregory |
// can recognize |
1652 |
22 May 07 |
gregory |
// this button |
1652 |
22 May 07 |
gregory |
151 |
|
1652 |
22 May 07 |
gregory |
152 |
private final static JButton turnOnButton = new JButton(new ImageIcon( |
1652 |
22 May 07 |
gregory |
153 |
"data" + File.separator + "imagestartbutton.gif"));; // So that |
1652 |
22 May 07 |
gregory |
// actionPerformed |
1652 |
22 May 07 |
gregory |
// can |
1652 |
22 May 07 |
gregory |
// recognize |
1652 |
22 May 07 |
gregory |
// this |
1652 |
22 May 07 |
gregory |
// button |
1652 |
22 May 07 |
gregory |
159 |
|
1652 |
22 May 07 |
gregory |
160 |
private final static JButton turnOnSetupButton = new JButton(new ImageIcon( |
1652 |
22 May 07 |
gregory |
161 |
"data" + File.separator + "imagestartsetupbutton.gif")); // So |
1652 |
22 May 07 |
gregory |
// that |
1652 |
22 May 07 |
gregory |
// actionPerformed |
1652 |
22 May 07 |
gregory |
// can |
1652 |
22 May 07 |
gregory |
// recognize |
1652 |
22 May 07 |
gregory |
// this |
1652 |
22 May 07 |
gregory |
// button |
1652 |
22 May 07 |
gregory |
168 |
|
1652 |
22 May 07 |
gregory |
169 |
private final static JButton turnOffSetupButton = new JButton( |
1652 |
22 May 07 |
gregory |
170 |
new ImageIcon("data" + File.separator + "imagestopsetupbutton.gif")); // So |
1652 |
22 May 07 |
gregory |
// that |
1652 |
22 May 07 |
gregory |
// actionPerformed |
1652 |
22 May 07 |
gregory |
// can |
1652 |
22 May 07 |
gregory |
// recognize |
1652 |
22 May 07 |
gregory |
// this |
1652 |
22 May 07 |
gregory |
// button |
1652 |
22 May 07 |
gregory |
177 |
|
1652 |
22 May 07 |
gregory |
178 |
private final static String turnOnFTPText = "Start FTP Server"; |
1652 |
22 May 07 |
gregory |
179 |
|
1652 |
22 May 07 |
gregory |
180 |
private final static String turnOffFTPText = "Stop FTP Server"; |
1652 |
22 May 07 |
gregory |
181 |
|
1652 |
22 May 07 |
gregory |
182 |
private final static String turnOnFTPSetupText = "Start FTP Remote Setup"; |
1652 |
22 May 07 |
gregory |
183 |
|
1652 |
22 May 07 |
gregory |
184 |
private static String turnOffFTPSetupText = "Start FTP Local Setup"; |
1652 |
22 May 07 |
gregory |
185 |
|
1652 |
22 May 07 |
gregory |
186 |
private final static JMenuItem turnOnFTPRadio = new JMenuItem(turnOnFTPText); |
1652 |
22 May 07 |
gregory |
187 |
|
1652 |
22 May 07 |
gregory |
188 |
private final static JMenuItem turnOffFTPRadio = new JMenuItem( |
1652 |
22 May 07 |
gregory |
189 |
turnOffFTPText); |
1652 |
22 May 07 |
gregory |
190 |
|
1652 |
22 May 07 |
gregory |
191 |
private final static JMenuItem turnOnFTPRemoteSetupRadio = new JMenuItem( |
1652 |
22 May 07 |
gregory |
192 |
turnOnFTPSetupText); |
1652 |
22 May 07 |
gregory |
193 |
|
1652 |
22 May 07 |
gregory |
194 |
private static JMenuItem turnOnFTPLocalSetupRadio = new JMenuItem( |
1652 |
22 May 07 |
gregory |
195 |
turnOffFTPSetupText); |
1652 |
22 May 07 |
gregory |
196 |
|
1652 |
22 May 07 |
gregory |
// private final static JButton turnOffFTPSetupRadio=new JButton("Stop FTP |
1652 |
22 May 07 |
gregory |
// Setup",true); |
1652 |
22 May 07 |
gregory |
199 |
|
1652 |
22 May 07 |
gregory |
200 |
private Container CP; // The whole layout (including the menu) |
1652 |
22 May 07 |
gregory |
201 |
|
1652 |
22 May 07 |
gregory |
202 |
private Container CPlarge; // Everything except the menu |
1652 |
22 May 07 |
gregory |
203 |
|
1652 |
22 May 07 |
gregory |
204 |
private Container CPintoCPlarge; // Everything except the menu and the |
1652 |
22 May 07 |
gregory |
// bottom Container (statusbar, buttons |
1652 |
22 May 07 |
gregory |
// etc.) |
1652 |
22 May 07 |
gregory |
207 |
|
1652 |
22 May 07 |
gregory |
208 |
private Container bottomCP; // Buttons and statusbar |
1652 |
22 May 07 |
gregory |
209 |
|
741 |
10 Oct 06 |
olle |
210 |
private JMenuBar theMenu; |
1652 |
22 May 07 |
gregory |
211 |
|
741 |
10 Oct 06 |
olle |
212 |
private MenuOptions myOptions; |
1652 |
22 May 07 |
gregory |
213 |
|
1652 |
22 May 07 |
gregory |
214 |
private final static String statusBarText = "Welcome to Xerver [Xerver is not running. To start Xerver, press the \"Start Xerver\" button]"; |
1652 |
22 May 07 |
gregory |
215 |
|
1652 |
22 May 07 |
gregory |
216 |
private int currentMode = STARTUP_MODE; |
1652 |
22 May 07 |
gregory |
217 |
|
741 |
10 Oct 06 |
olle |
218 |
private JLabel JL_statusBar; |
741 |
10 Oct 06 |
olle |
219 |
|
1652 |
22 May 07 |
gregory |
220 |
public static void main(String[] s) { |
741 |
10 Oct 06 |
olle |
221 |
new ProgramWindow(); |
741 |
10 Oct 06 |
olle |
222 |
} |
741 |
10 Oct 06 |
olle |
223 |
|
1652 |
22 May 07 |
gregory |
224 |
public ProgramWindow(boolean gotoMinimizedMode) // By default |
1652 |
22 May 07 |
gregory |
// gotoMinimizedMode is |
1652 |
22 May 07 |
gregory |
// false, that is we don't |
1652 |
22 May 07 |
gregory |
// start with a minimized |
1652 |
22 May 07 |
gregory |
// mode |
741 |
10 Oct 06 |
olle |
229 |
{ |
1652 |
22 May 07 |
gregory |
230 |
myOptions = new MenuOptions(this); |
1652 |
22 May 07 |
gregory |
231 |
CP = getContentPane(); |
741 |
10 Oct 06 |
olle |
232 |
|
741 |
10 Oct 06 |
olle |
233 |
initComponents(); |
741 |
10 Oct 06 |
olle |
234 |
setIsRunningButton(); |
741 |
10 Oct 06 |
olle |
235 |
setSetupIsRunningButton(); |
741 |
10 Oct 06 |
olle |
236 |
|
741 |
10 Oct 06 |
olle |
237 |
addWindowListener(MyWindowListener); |
1652 |
22 May 07 |
gregory |
238 |
CPintoCPlarge = GUIMethods |
1652 |
22 May 07 |
gregory |
239 |
.showAsNorthBorderLayout(giveStartupContainer()); |
741 |
10 Oct 06 |
olle |
240 |
showAsMainFrame(CPintoCPlarge); |
741 |
10 Oct 06 |
olle |
241 |
|
741 |
10 Oct 06 |
olle |
242 |
try { |
1652 |
22 May 07 |
gregory |
243 |
if (XerverKernel.getThisVersion() < MenuOptions.getLatestVersion()) // If a |
1652 |
22 May 07 |
gregory |
// new |
1652 |
22 May 07 |
gregory |
// version |
1652 |
22 May 07 |
gregory |
// is |
1652 |
22 May 07 |
gregory |
// available... |
1652 |
22 May 07 |
gregory |
248 |
showAsMainFrame(myOptions.checkForUpdates()); // Let the user |
1652 |
22 May 07 |
gregory |
// know... |
1652 |
22 May 07 |
gregory |
250 |
} catch (Exception e) {/* No internetconnection might be the reason. */ |
1652 |
22 May 07 |
gregory |
251 |
} |
1652 |
22 May 07 |
gregory |
252 |
; |
741 |
10 Oct 06 |
olle |
253 |
|
741 |
10 Oct 06 |
olle |
254 |
setTitle("Xerver"); |
1652 |
22 May 07 |
gregory |
255 |
setSize(530, 440); |
1652 |
22 May 07 |
gregory |
256 |
setIconImage((new ImageIcon("data" + File.separator |
1652 |
22 May 07 |
gregory |
257 |
+ "imagexervericon.gif")).getImage()); |
741 |
10 Oct 06 |
olle |
258 |
|
1652 |
22 May 07 |
gregory |
259 |
if (gotoMinimizedMode) { |
1652 |
22 May 07 |
gregory |
260 |
goToMinimizedMode(); // Minimize... |
1652 |
22 May 07 |
gregory |
261 |
myOptions.runXerver(); // Start Xerver automatically... |
1652 |
22 May 07 |
gregory |
262 |
} else { |
741 |
10 Oct 06 |
olle |
263 |
setVisible(true); |
741 |
10 Oct 06 |
olle |
264 |
toFront(); |
741 |
10 Oct 06 |
olle |
265 |
} |
741 |
10 Oct 06 |
olle |
266 |
} |
741 |
10 Oct 06 |
olle |
267 |
|
1652 |
22 May 07 |
gregory |
268 |
public void initComponents() { |
1652 |
22 May 07 |
gregory |
// These lines at the very top, as the methods that are called later on |
1652 |
22 May 07 |
gregory |
// requires these to have been set |
1652 |
22 May 07 |
gregory |
// turnOffButton=new JButton(new |
1652 |
22 May 07 |
gregory |
// ImageIcon("data"+File.separator+"imagestopbutton.gif")); |
741 |
10 Oct 06 |
olle |
273 |
aboutOuterIPButton.addActionListener(this); |
741 |
10 Oct 06 |
olle |
274 |
aboutLocalIPButton.addActionListener(this); |
741 |
10 Oct 06 |
olle |
275 |
turnOffButton.addActionListener(this); |
1652 |
22 May 07 |
gregory |
// turnOffButton.setBackground(Color.white); |
741 |
10 Oct 06 |
olle |
277 |
turnOffButton.setOpaque(true); |
741 |
10 Oct 06 |
olle |
278 |
turnOnButton.addActionListener(this); |
1652 |
22 May 07 |
gregory |
// turnOnButton.setBackground(Color.white); |
741 |
10 Oct 06 |
olle |
280 |
turnOnButton.setOpaque(true); |
741 |
10 Oct 06 |
olle |
281 |
turnOffSetupButton.addActionListener(this); |
1652 |
22 May 07 |
gregory |
// turnOffSetupButton.setBackground(Color.white); |
741 |
10 Oct 06 |
olle |
283 |
turnOffSetupButton.setOpaque(true); |
741 |
10 Oct 06 |
olle |
284 |
turnOnSetupButton.addActionListener(this); |
1652 |
22 May 07 |
gregory |
// turnOnSetupButton.setBackground(Color.white); |
741 |
10 Oct 06 |
olle |
286 |
turnOnSetupButton.setOpaque(true); |
741 |
10 Oct 06 |
olle |
287 |
|
741 |
10 Oct 06 |
olle |
288 |
turnOffFTPRadio.setEnabled(false); |
741 |
10 Oct 06 |
olle |
289 |
|
1652 |
22 May 07 |
gregory |
290 |
theMenu = giveTheMenu(); |
741 |
10 Oct 06 |
olle |
291 |
|
1652 |
22 May 07 |
gregory |
292 |
JL_statusBar = new JLabel(statusBarText); |
741 |
10 Oct 06 |
olle |
293 |
JL_statusBar.setFont(f_defaultStatusFont); |
741 |
10 Oct 06 |
olle |
294 |
JL_statusBar.setForeground(Color.black); |
741 |
10 Oct 06 |
olle |
295 |
|
1652 |
22 May 07 |
gregory |
296 |
bottomCP = new Container(); |
741 |
10 Oct 06 |
olle |
297 |
bottomCP.setLayout(new BorderLayout()); |
1652 |
22 May 07 |
gregory |
298 |
bottomCP.add(JL_statusBar, BorderLayout.SOUTH); |
741 |
10 Oct 06 |
olle |
299 |
|
1652 |
22 May 07 |
gregory |
300 |
CPlarge = new Container(); |
741 |
10 Oct 06 |
olle |
301 |
CPlarge.setLayout(new BorderLayout()); |
1652 |
22 May 07 |
gregory |
302 |
CPlarge.add(bottomCP, BorderLayout.SOUTH); |
741 |
10 Oct 06 |
olle |
303 |
|
1652 |
22 May 07 |
gregory |
304 |
CP.add(theMenu, BorderLayout.NORTH); |
1652 |
22 May 07 |
gregory |
305 |
CP.add(CPlarge, BorderLayout.CENTER); |
741 |
10 Oct 06 |
olle |
306 |
} |
741 |
10 Oct 06 |
olle |
307 |
|
1652 |
22 May 07 |
gregory |
308 |
public ProgramWindow() { |
1652 |
22 May 07 |
gregory |
309 |
this(false);// By default don't use minimized mode |
741 |
10 Oct 06 |
olle |
310 |
} |
741 |
10 Oct 06 |
olle |
311 |
|
1652 |
22 May 07 |
gregory |
312 |
private Container giveStartupContainer() { |
1652 |
22 May 07 |
gregory |
313 |
Container Cont = new Container(); |
741 |
10 Oct 06 |
olle |
314 |
Cont.setLayout(new BorderLayout()); |
1652 |
22 May 07 |
gregory |
315 |
Cont.add(new JLabel(new ImageIcon("data" + File.separator |
1652 |
22 May 07 |
gregory |
316 |
+ "imagelogo.gif")), BorderLayout.NORTH); |
741 |
10 Oct 06 |
olle |
317 |
|
741 |
10 Oct 06 |
olle |
318 |
JTextField addressInfo; |
741 |
10 Oct 06 |
olle |
319 |
JTextField addressInfo2; |
741 |
10 Oct 06 |
olle |
320 |
JLabel txtAboveIP; |
741 |
10 Oct 06 |
olle |
321 |
JLabel txtAboveIP2; |
741 |
10 Oct 06 |
olle |
322 |
|
1652 |
22 May 07 |
gregory |
323 |
Container theFields = new Container(); |
741 |
10 Oct 06 |
olle |
324 |
theFields.setLayout(new BoxLayout(theFields, BoxLayout.Y_AXIS)); |
741 |
10 Oct 06 |
olle |
325 |
|
1652 |
22 May 07 |
gregory |
326 |
txtAboveIP = new JLabel("Your server's outer IP is:"); |
1652 |
22 May 07 |
gregory |
327 |
String s_outerIP = HostInfo.getIPFromInternet(); // Returns null if |
1652 |
22 May 07 |
gregory |
// not detected |
1652 |
22 May 07 |
gregory |
329 |
if (s_outerIP != null) { |
1652 |
22 May 07 |
gregory |
330 |
if (myOptions.i_portNr == 80) |
1652 |
22 May 07 |
gregory |
331 |
addressInfo = new JTextField("http://" + s_outerIP + "/", 17); |
741 |
10 Oct 06 |
olle |
332 |
else |
1652 |
22 May 07 |
gregory |
333 |
addressInfo = new JTextField("http://" + s_outerIP + ":" |
1652 |
22 May 07 |
gregory |
334 |
+ myOptions.i_portNr + "/", 17); |
1652 |
22 May 07 |
gregory |
335 |
} else { |
1652 |
22 May 07 |
gregory |
336 |
addressInfo = new JTextField("IP could not be detected!", 17); |
741 |
10 Oct 06 |
olle |
337 |
} |
741 |
10 Oct 06 |
olle |
338 |
|
1652 |
22 May 07 |
gregory |
339 |
txtAboveIP2 = new JLabel("Your server's local IP is: "); |
741 |
10 Oct 06 |
olle |
340 |
|
1652 |
22 May 07 |
gregory |
341 |
if (myOptions.i_portNr == 80) |
1652 |
22 May 07 |
gregory |
342 |
addressInfo2 = new JTextField("http://" |
1652 |
22 May 07 |
gregory |
343 |
+ HostInfo.getLocalIPorLocalhost() + "/", 17); |
741 |
10 Oct 06 |
olle |
344 |
else |
1652 |
22 May 07 |
gregory |
345 |
addressInfo2 = new JTextField("http://" |
1652 |
22 May 07 |
gregory |
346 |
+ HostInfo.getLocalIPorLocalhost() + ":" |
1652 |
22 May 07 |
gregory |
347 |
+ myOptions.i_portNr + "/", 17); |
741 |
10 Oct 06 |
olle |
348 |
|
741 |
10 Oct 06 |
olle |
349 |
addressInfo.setEditable(false); |
741 |
10 Oct 06 |
olle |
350 |
addressInfo.setFont(defaultFont); |
741 |
10 Oct 06 |
olle |
351 |
addressInfo.setForeground(Color.black); |
741 |
10 Oct 06 |
olle |
352 |
addressInfo.setBackground(Color.white); |
741 |
10 Oct 06 |
olle |
353 |
txtAboveIP.setFont(defaultFont); |
741 |
10 Oct 06 |
olle |
354 |
txtAboveIP.setForeground(Color.black); |
741 |
10 Oct 06 |
olle |
355 |
|
741 |
10 Oct 06 |
olle |
356 |
addressInfo2.setEditable(false); |
741 |
10 Oct 06 |
olle |
357 |
addressInfo2.setFont(defaultFont); |
741 |
10 Oct 06 |
olle |
358 |
addressInfo2.setForeground(Color.black); |
741 |
10 Oct 06 |
olle |
359 |
addressInfo2.setBackground(Color.white); |
741 |
10 Oct 06 |
olle |
360 |
txtAboveIP2.setFont(defaultFont); |
741 |
10 Oct 06 |
olle |
361 |
txtAboveIP2.setForeground(Color.black); |
741 |
10 Oct 06 |
olle |
362 |
|
1652 |
22 May 07 |
gregory |
363 |
theFields.add(MenuOptions.make2ContainersTo1ContainerBeside(MenuOptions |
1652 |
22 May 07 |
gregory |
364 |
.make2ContainersTo1ContainerAbove(txtAboveIP, MenuOptions |
1652 |
22 May 07 |
gregory |
365 |
.make2ContainersTo1ContainerBeside(addressInfo, |
1652 |
22 May 07 |
gregory |
366 |
aboutOuterIPButton)), EMPTY_JLABEL)); |
741 |
10 Oct 06 |
olle |
367 |
theFields.add(new JLabel(" ")); |
1652 |
22 May 07 |
gregory |
368 |
theFields.add(MenuOptions.make2ContainersTo1ContainerBeside(MenuOptions |
1652 |
22 May 07 |
gregory |
369 |
.make2ContainersTo1ContainerAbove(txtAboveIP2, MenuOptions |
1652 |
22 May 07 |
gregory |
370 |
.make2ContainersTo1ContainerBeside(addressInfo2, |
1652 |
22 May 07 |
gregory |
371 |
aboutLocalIPButton)), EMPTY_JLABEL)); |
741 |
10 Oct 06 |
olle |
372 |
|
1652 |
22 May 07 |
gregory |
373 |
Cont.add(MenuOptions.make2ContainersTo1ContainerAbove(MenuOptions |
1652 |
22 May 07 |
gregory |
374 |
.make2ContainersTo1ContainerBeside(theFields, EMPTY_JLABEL), |
1652 |
22 May 07 |
gregory |
375 |
EMPTY_JLABEL), BorderLayout.CENTER); |
1652 |
22 May 07 |
gregory |
// Cont.add(MenuOptions.make2ContainersTo1ContainerAbove(MenuOptions.make2ContainersTo1ContainerBeside(MenuOptions.make2ContainersTo1ContainerAbove(txtAboveIP,addressInfo),EMPTY_JLABEL),EMPTY_JLABEL),BorderLayout.CENTER); |
1652 |
22 May 07 |
gregory |
// Cont.add(MenuOptions.make2ContainersTo1ContainerBeside(MenuOptions.make2ContainersTo1ContainerAbove(txtAboveIP2,addressInfo2),EMPTY_JLABEL),BorderLayout.SOUTH); |
741 |
10 Oct 06 |
olle |
378 |
return Cont; |
741 |
10 Oct 06 |
olle |
379 |
} |
741 |
10 Oct 06 |
olle |
380 |
|
1652 |
22 May 07 |
gregory |
381 |
private void goToMinimizedMode() { |
741 |
10 Oct 06 |
olle |
382 |
new MinimizedMode(this); |
741 |
10 Oct 06 |
olle |
383 |
setVisible(false); |
741 |
10 Oct 06 |
olle |
384 |
/* |
1652 |
22 May 07 |
gregory |
* JDialog JD=new JDialog(this,"Minimized"); Container |
1652 |
22 May 07 |
gregory |
* newCP=getContentPane(); newCP JD.setContentPane(getContentPane()); |
1652 |
22 May 07 |
gregory |
* JD.setSize(getSize()); JD.setTitle(getTitle()); dispose(); |
1652 |
22 May 07 |
gregory |
* JD.setVisible(true); //setState(Frame.ICONIFIED); |
1652 |
22 May 07 |
gregory |
389 |
*/ |
741 |
10 Oct 06 |
olle |
390 |
} |
741 |
10 Oct 06 |
olle |
391 |
|
1652 |
22 May 07 |
gregory |
392 |
private JMenuBar giveTheMenu() { |
1652 |
22 May 07 |
gregory |
393 |
// ################################################################### |
1652 |
22 May 07 |
gregory |
// ############################ MENUBAR ############################## |
1652 |
22 May 07 |
gregory |
395 |
// ################################################################### |
1652 |
22 May 07 |
gregory |
396 |
JMenuBar theMenuBar = new JMenuBar(); |
1652 |
22 May 07 |
gregory |
397 |
JMenu[] a_menuNr = new JMenu[4]; |
1652 |
22 May 07 |
gregory |
398 |
JMenuItem[] a_optionNr1 = new JMenuItem[2]; |
1652 |
22 May 07 |
gregory |
399 |
JMenuItem[] a_optionNr2 = new JMenuItem[2]; |
1652 |
22 May 07 |
gregory |
400 |
JMenuItem[] a_optionNr3 = new JMenuItem[4]; |
1652 |
22 May 07 |
gregory |
401 |
JMenuItem[] a_optionNr4 = new JMenuItem[3]; |
741 |
10 Oct 06 |
olle |
402 |
|
1652 |
22 May 07 |
gregory |
403 |
a_menuNr[0] = new JMenu("File"); |
741 |
10 Oct 06 |
olle |
404 |
a_menuNr[0].setFont(defaultFont); |
741 |
10 Oct 06 |
olle |
405 |
a_menuNr[0].setMnemonic('f'); |
1652 |
22 May 07 |
gregory |
406 |
a_optionNr1[0] = new JMenuItem("Minimize", 'M'); |
741 |
10 Oct 06 |
olle |
407 |
a_optionNr1[0].setFont(defaultFont); |
741 |
10 Oct 06 |
olle |
408 |
a_optionNr1[0].addActionListener(this); |
1652 |
22 May 07 |
gregory |
// a_optionNr1[0].setMnemonic('M'); |
1652 |
22 May 07 |
gregory |
410 |
a_optionNr1[1] = new JMenuItem("Exit", 'x'); |
741 |
10 Oct 06 |
olle |
411 |
a_optionNr1[1].setFont(defaultFont); |
741 |
10 Oct 06 |
olle |
412 |
a_optionNr1[1].addActionListener(this); |
741 |
10 Oct 06 |
olle |
413 |
|
1652 |
22 May 07 |
gregory |
414 |
a_menuNr[1] = new JMenu("View"); |
741 |
10 Oct 06 |
olle |
415 |
a_menuNr[1].setFont(defaultFont); |
741 |
10 Oct 06 |
olle |
416 |
a_menuNr[1].setMnemonic('V'); |
1652 |
22 May 07 |
gregory |
417 |
a_optionNr2[0] = new JMenuItem("Statistic", 'S'); |
741 |
10 Oct 06 |
olle |
418 |
a_optionNr2[0].setFont(defaultFont); |
741 |
10 Oct 06 |
olle |
419 |
a_optionNr2[0].addActionListener(this); |
1652 |
22 May 07 |
gregory |
420 |
a_optionNr2[1] = new JMenuItem("Settings", 't'); |
741 |
10 Oct 06 |
olle |
421 |
a_optionNr2[1].setFont(defaultFont); |
741 |
10 Oct 06 |
olle |
422 |
a_optionNr2[1].addActionListener(this); |
741 |
10 Oct 06 |
olle |
423 |
|
1652 |
22 May 07 |
gregory |
424 |
a_menuNr[2] = new JMenu("FTP"); |
741 |
10 Oct 06 |
olle |
425 |
a_menuNr[2].setFont(defaultFont); |
741 |
10 Oct 06 |
olle |
426 |
a_menuNr[2].setMnemonic('T'); |
1652 |
22 May 07 |
gregory |
427 |
a_optionNr3[0] = turnOnFTPRadio; |
741 |
10 Oct 06 |
olle |
428 |
a_optionNr3[0].setFont(defaultFont); |
741 |
10 Oct 06 |
olle |
429 |
a_optionNr3[0].addActionListener(this); |
1652 |
22 May 07 |
gregory |
430 |
a_optionNr3[1] = turnOffFTPRadio; |
741 |
10 Oct 06 |
olle |
431 |
a_optionNr3[1].setFont(defaultFont); |
741 |
10 Oct 06 |
olle |
432 |
a_optionNr3[1].addActionListener(this); |
1652 |
22 May 07 |
gregory |
433 |
a_optionNr3[2] = turnOnFTPLocalSetupRadio; |
741 |
10 Oct 06 |
olle |
434 |
a_optionNr3[2].setFont(defaultFont); |
741 |
10 Oct 06 |
olle |
435 |
a_optionNr3[2].addActionListener(this); |
1652 |
22 May 07 |
gregory |
436 |
a_optionNr3[3] = turnOnFTPRemoteSetupRadio; |
741 |
10 Oct 06 |
olle |
437 |
a_optionNr3[3].setFont(defaultFont); |
741 |
10 Oct 06 |
olle |
438 |
a_optionNr3[3].addActionListener(this); |
1652 |
22 May 07 |
gregory |
// a_optionNr3[4]=turnOffFTPSetupRadio; |
1652 |
22 May 07 |
gregory |
// a_optionNr3[4].setFont(defaultFont); |
1652 |
22 May 07 |
gregory |
// a_optionNr3[4].addActionListener(this); |
741 |
10 Oct 06 |
olle |
442 |
|
1652 |
22 May 07 |
gregory |
443 |
a_menuNr[3] = new JMenu("Help"); |
741 |
10 Oct 06 |
olle |
444 |
a_menuNr[3].setFont(defaultFont); |
741 |
10 Oct 06 |
olle |
445 |
a_menuNr[3].setMnemonic('H'); |
1652 |
22 May 07 |
gregory |
446 |
a_optionNr4[0] = new JMenuItem("About", 'A'); |
741 |
10 Oct 06 |
olle |
447 |
a_optionNr4[0].setFont(defaultFont); |
741 |
10 Oct 06 |
olle |
448 |
a_optionNr4[0].addActionListener(this); |
1652 |
22 May 07 |
gregory |
449 |
a_optionNr4[1] = new JMenuItem("Check for Updates", 'U'); |
741 |
10 Oct 06 |
olle |
450 |
a_optionNr4[1].setFont(defaultFont); |
741 |
10 Oct 06 |
olle |
451 |
a_optionNr4[1].addActionListener(this); |
1652 |
22 May 07 |
gregory |
452 |
a_optionNr4[2] = new JMenuItem("Help", 'H'); |
741 |
10 Oct 06 |
olle |
453 |
a_optionNr4[2].setFont(defaultFont); |
741 |
10 Oct 06 |
olle |
454 |
a_optionNr4[2].addActionListener(this); |
741 |
10 Oct 06 |
olle |
455 |
|
741 |
10 Oct 06 |
olle |
456 |
theMenuBar.add(a_menuNr[0]); |
1652 |
22 May 07 |
gregory |
457 |
a_menuNr[0].add(a_optionNr1[0]); |
1652 |
22 May 07 |
gregory |
458 |
a_menuNr[0].addSeparator(); |
1652 |
22 May 07 |
gregory |
459 |
a_menuNr[0].add(a_optionNr1[1]); |
741 |
10 Oct 06 |
olle |
460 |
theMenuBar.add(a_menuNr[1]); |
1652 |
22 May 07 |
gregory |
461 |
a_menuNr[1].add(a_optionNr2[0]); |
1652 |
22 May 07 |
gregory |
462 |
a_menuNr[1].add(a_optionNr2[1]); |
741 |
10 Oct 06 |
olle |
463 |
theMenuBar.add(a_menuNr[2]); |
1652 |
22 May 07 |
gregory |
464 |
a_menuNr[2].add(a_optionNr3[0]); |
1652 |
22 May 07 |
gregory |
465 |
a_menuNr[2].add(a_optionNr3[1]); |
1652 |
22 May 07 |
gregory |
466 |
a_menuNr[2].addSeparator(); |
1652 |
22 May 07 |
gregory |
467 |
a_menuNr[2].add(a_optionNr3[2]); |
1652 |
22 May 07 |
gregory |
468 |
a_menuNr[2].add(a_optionNr3[3]); |
1652 |
22 May 07 |
gregory |
// a_menuNr[2].add(a_optionNr3[4]); |
741 |
10 Oct 06 |
olle |
470 |
theMenuBar.add(a_menuNr[3]); |
1652 |
22 May 07 |
gregory |
471 |
a_menuNr[3].add(a_optionNr4[0]); |
1652 |
22 May 07 |
gregory |
472 |
a_menuNr[3].add(a_optionNr4[1]); |
1652 |
22 May 07 |
gregory |
473 |
a_menuNr[3].add(a_optionNr4[2]); |
741 |
10 Oct 06 |
olle |
474 |
return theMenuBar; |
741 |
10 Oct 06 |
olle |
475 |
} |
741 |
10 Oct 06 |
olle |
476 |
|
1652 |
22 May 07 |
gregory |
477 |
public void updateContainers() // For example, if you want change text in |
1652 |
22 May 07 |
gregory |
// the statusbar |
741 |
10 Oct 06 |
olle |
479 |
{ |
1652 |
22 May 07 |
gregory |
480 |
showAsMainFrame(CPintoCPlarge); |
741 |
10 Oct 06 |
olle |
481 |
} |
741 |
10 Oct 06 |
olle |
482 |
|
1652 |
22 May 07 |
gregory |
483 |
public void actionPerformed(ActionEvent event) { |
1652 |
22 May 07 |
gregory |
// The four first if's are for the buttons, to turn on/off xerver/xerver |
1652 |
22 May 07 |
gregory |
// setup. |
1652 |
22 May 07 |
gregory |
486 |
if (event.getSource() == aboutOuterIPButton) { |
1652 |
22 May 07 |
gregory |
487 |
JOptionPane |
1652 |
22 May 07 |
gregory |
488 |
.showMessageDialog( |
1652 |
22 May 07 |
gregory |
489 |
this, |
1652 |
22 May 07 |
gregory |
490 |
"This IP shall be used by other Internet users.\n\nIf you are directly connected to Internet then this is most likely your computer's IP, but it could also be the IP of your ISP's gateway.\nIf it is your computers IP you are done and people should be able to use this IP to access Xerver unless you have a firewall preventing people to access Xerver.\n\nIf your computer is connected to a router, this is most likely the IP of your router.\nIf you have a router and want to use a webserver you must make sure to configure the router so it redirects incoming connections to this server.\nHow this is done depends on what router you have, but most routers have an option called 'Port Forwarding', 'Virtual Servers' or something similar.\nYou must use this option to forward the desired port (for example 80) on the router to a port\non your server computer (this can be the same or an other port number, for example 80 or 5080).\nYour visitors would then use this IP to 'visit' your router, which in turn forwards the connection to this computer (to Xerver).\n\nRemember that a computer network can have many different settings.\nWe have only discussed the most common ones here.\n\nFor more complex networks or for more general help, please visit Xerver Online Help or take a look at the local\nXerver help that is located in the 'Help'-directory in the directory where Xerver is installed."); |
1652 |
22 May 07 |
gregory |
491 |
} else if (event.getSource() == aboutLocalIPButton) { |
1652 |
22 May 07 |
gregory |
492 |
JOptionPane |
1652 |
22 May 07 |
gregory |
493 |
.showMessageDialog( |
1652 |
22 May 07 |
gregory |
494 |
this, |
1652 |
22 May 07 |
gregory |
495 |
"This IP shall be used by yourself or other computers in your LAN.\nThis IP can't be used by other Internet users to reach your website."); |
1652 |
22 May 07 |
gregory |
496 |
} else if (event.getSource() == turnOnButton) { |
741 |
10 Oct 06 |
olle |
497 |
myOptions.runXerver(); |
741 |
10 Oct 06 |
olle |
498 |
setIsRunningButton(); |
1652 |
22 May 07 |
gregory |
499 |
} else if (event.getSource() == turnOffButton) { |
741 |
10 Oct 06 |
olle |
500 |
myOptions.stopXerver(); |
741 |
10 Oct 06 |
olle |
501 |
setIsRunningButton(); |
1652 |
22 May 07 |
gregory |
502 |
} else if (event.getSource() == turnOnSetupButton) { |
741 |
10 Oct 06 |
olle |
503 |
myOptions.runXerverSetup(); |
1652 |
22 May 07 |
gregory |
504 |
showAsMainFrame(GUIMethods.showAsNorthBorderLayout(myOptions |
1652 |
22 May 07 |
gregory |
505 |
.showTurnOnSetup())); |
741 |
10 Oct 06 |
olle |
506 |
setSetupIsRunningButton(); |
1652 |
22 May 07 |
gregory |
507 |
} else if (event.getSource() == turnOffSetupButton) { |
741 |
10 Oct 06 |
olle |
508 |
myOptions.stopXerverSetup(); |
1652 |
22 May 07 |
gregory |
509 |
showAsMainFrame(GUIMethods.showAsNorthBorderLayout(myOptions |
1652 |
22 May 07 |
gregory |
510 |
.showTurnOffSetup())); |
741 |
10 Oct 06 |
olle |
511 |
setSetupIsRunningButton(); |
1652 |
22 May 07 |
gregory |
512 |
} else { |
1652 |
22 May 07 |
gregory |
513 |
if (event.getActionCommand().equals("Check for Updates")) { |
741 |
10 Oct 06 |
olle |
514 |
showAsMainFrame(myOptions.checkForUpdates()); |
1652 |
22 May 07 |
gregory |
515 |
} else if (event.getActionCommand().equals("Minimize")) { |
741 |
10 Oct 06 |
olle |
516 |
goToMinimizedMode(); |
1652 |
22 May 07 |
gregory |
517 |
} else if (event.getActionCommand().equals(turnOnFTPText)) { |
1652 |
22 May 07 |
gregory |
// turnOnFTPRadio.setSelected(true); |
1652 |
22 May 07 |
gregory |
// turnOffFTPRadio.setSelected(false); |
741 |
10 Oct 06 |
olle |
520 |
turnOnFTPRadio.setEnabled(false); |
741 |
10 Oct 06 |
olle |
521 |
turnOffFTPRadio.setEnabled(true); |
741 |
10 Oct 06 |
olle |
522 |
FTPServerController.startFTPServer(); |
1652 |
22 May 07 |
gregory |
523 |
if (FTPServerController.isPortInUseServer()) { |
1652 |
22 May 07 |
gregory |
524 |
showAsMainFrame(GUIMethods |
1652 |
22 May 07 |
gregory |
525 |
.showAsNorthBorderLayout(FTPMessages |
1652 |
22 May 07 |
gregory |
526 |
.getContainer(FTPMessages.SERVER_PORT_IN_USE))); |
1652 |
22 May 07 |
gregory |
527 |
} else if (FTPServerController.getPortErrorServer()) { |
1652 |
22 May 07 |
gregory |
528 |
showAsMainFrame(GUIMethods |
1652 |
22 May 07 |
gregory |
529 |
.showAsNorthBorderLayout(FTPMessages |
1652 |
22 May 07 |
gregory |
530 |
.getContainer(FTPMessages.SERVER_PORT_ERROR))); |
1652 |
22 May 07 |
gregory |
531 |
} else { |
1652 |
22 May 07 |
gregory |
532 |
showAsMainFrame(GUIMethods |
1652 |
22 May 07 |
gregory |
533 |
.showAsNorthBorderLayout(FTPMessages |
1652 |
22 May 07 |
gregory |
534 |
.getContainer(FTPMessages.START_FTP))); |
741 |
10 Oct 06 |
olle |
535 |
} |
1652 |
22 May 07 |
gregory |
536 |
} else if (event.getActionCommand().equals(turnOffFTPText)) { |
1652 |
22 May 07 |
gregory |
// turnOnFTPRadio.setSelected(false); |
1652 |
22 May 07 |
gregory |
// turnOffFTPRadio.setSelected(true); |
741 |
10 Oct 06 |
olle |
539 |
turnOnFTPRadio.setEnabled(true); |
741 |
10 Oct 06 |
olle |
540 |
turnOffFTPRadio.setEnabled(false); |
741 |
10 Oct 06 |
olle |
541 |
FTPServerController.stopFTPServer(); |
1652 |
22 May 07 |
gregory |
542 |
showAsMainFrame(GUIMethods.showAsNorthBorderLayout(FTPMessages |
1652 |
22 May 07 |
gregory |
543 |
.getContainer(FTPMessages.STOP_FTP))); |
1652 |
22 May 07 |
gregory |
544 |
} else if (event.getActionCommand().equals(turnOnFTPSetupText)) { |
1652 |
22 May 07 |
gregory |
545 |
turnOffFTPSetupText = "Stop FTP Remote Setup"; |
741 |
10 Oct 06 |
olle |
546 |
turnOnFTPLocalSetupRadio.setText(turnOffFTPSetupText); |
741 |
10 Oct 06 |
olle |
547 |
|
1652 |
22 May 07 |
gregory |
// turnOnFTPRemoteSetupRadio.setSelected(true); |
1652 |
22 May 07 |
gregory |
// turnOnFTPLocalSetupRadio.setSelected(false); |
1652 |
22 May 07 |
gregory |
// turnOnFTPLocalSetupRadio.setText("Stop FTP Remote Setup"); |
741 |
10 Oct 06 |
olle |
551 |
turnOnFTPRemoteSetupRadio.setEnabled(false); |
741 |
10 Oct 06 |
olle |
552 |
turnOnFTPLocalSetupRadio.setEnabled(true); |
741 |
10 Oct 06 |
olle |
553 |
FTPServerController.startFTPRemoteSetup(); |
1652 |
22 May 07 |
gregory |
554 |
if (FTPServerController.isPortInUseSetup()) { |
1652 |
22 May 07 |
gregory |
555 |
showAsMainFrame(GUIMethods |
1652 |
22 May 07 |
gregory |
556 |
.showAsNorthBorderLayout(FTPMessages |
1652 |
22 May 07 |
gregory |
557 |
.getContainer(FTPMessages.SETUP_PORT_IN_USE))); |
1652 |
22 May 07 |
gregory |
558 |
} else if (FTPServerController.getPortErrorSetup()) { |
1652 |
22 May 07 |
gregory |
559 |
showAsMainFrame(GUIMethods |
1652 |
22 May 07 |
gregory |
560 |
.showAsNorthBorderLayout(FTPMessages |
1652 |
22 May 07 |
gregory |
561 |
.getContainer(FTPMessages.SETUP_PORT_ERROR))); |
1652 |
22 May 07 |
gregory |
562 |
} else { |
1652 |
22 May 07 |
gregory |
563 |
showAsMainFrame(GUIMethods |
1652 |
22 May 07 |
gregory |
564 |
.showAsNorthBorderLayout(FTPMessages |
1652 |
22 May 07 |
gregory |
565 |
.getContainer(FTPMessages.START_FTP_SETUP))); |
741 |
10 Oct 06 |
olle |
566 |
} |
1652 |
22 May 07 |
gregory |
567 |
} else if (event.getActionCommand().equals(turnOffFTPSetupText)) { |
1652 |
22 May 07 |
gregory |
// turnOnFTPRemoteSetupRadio.setSelected(false); |
1652 |
22 May 07 |
gregory |
// turnOnFTPLocalSetupRadio.setSelected(true); |
741 |
10 Oct 06 |
olle |
570 |
turnOnFTPRemoteSetupRadio.setEnabled(true); |
741 |
10 Oct 06 |
olle |
571 |
turnOnFTPLocalSetupRadio.setEnabled(false); |
741 |
10 Oct 06 |
olle |
572 |
FTPServerController.startFTPLocalSetup(); |
1652 |
22 May 07 |
gregory |
573 |
if (FTPServerController.isPortInUseSetup()) { |
1652 |
22 May 07 |
gregory |
574 |
showAsMainFrame(GUIMethods |
1652 |
22 May 07 |
gregory |
575 |
.showAsNorthBorderLayout(FTPMessages |
1652 |
22 May 07 |
gregory |
576 |
.getContainer(FTPMessages.SETUP_PORT_IN_USE))); |
1652 |
22 May 07 |
gregory |
577 |
} else if (FTPServerController.getPortErrorSetup()) { |
1652 |
22 May 07 |
gregory |
578 |
showAsMainFrame(GUIMethods |
1652 |
22 May 07 |
gregory |
579 |
.showAsNorthBorderLayout(FTPMessages |
1652 |
22 May 07 |
gregory |
580 |
.getContainer(FTPMessages.SETUP_PORT_ERROR))); |
1652 |
22 May 07 |
gregory |
581 |
} else { |
1652 |
22 May 07 |
gregory |
582 |
showAsMainFrame(GUIMethods |
1652 |
22 May 07 |
gregory |
583 |
.showAsNorthBorderLayout(FTPMessages |
1652 |
22 May 07 |
gregory |
584 |
.getContainer(FTPMessages.STOP_FTP_SETUP))); |
741 |
10 Oct 06 |
olle |
585 |
} |
741 |
10 Oct 06 |
olle |
586 |
} |
1652 |
22 May 07 |
gregory |
587 |
/* |
1652 |
22 May 07 |
gregory |
* else if(event.getActionCommand().equals("Stop FTP Setup")) { |
1652 |
22 May 07 |
gregory |
* turnOnFTPRemoteSetupRadio.setSelected(false); |
1652 |
22 May 07 |
gregory |
* turnOnFTPLocalSetupRadio.setSelected(false); |
1652 |
22 May 07 |
gregory |
* turnOffFTPSetupRadio.setSelected(true); |
1652 |
22 May 07 |
gregory |
* FTPServerController.stopFTPSetup(); } |
1652 |
22 May 07 |
gregory |
593 |
*/ |
1652 |
22 May 07 |
gregory |
594 |
else if (event.getActionCommand().equals("Statistic")) { |
741 |
10 Oct 06 |
olle |
595 |
showAsMainFrame(myOptions.showStats()); |
1652 |
22 May 07 |
gregory |
596 |
} else if (event.getActionCommand().equals("Help")) { |
1652 |
22 May 07 |
gregory |
597 |
showAsMainFrame(GUIMethods.showAsNorthBorderLayout(myOptions |
1652 |
22 May 07 |
gregory |
598 |
.showHelp())); |
1652 |
22 May 07 |
gregory |
599 |
} else if (event.getActionCommand().equals("About")) { |
1652 |
22 May 07 |
gregory |
600 |
showAsMainFrame(GUIMethods.showAsNorthBorderLayout(myOptions |
1652 |
22 May 07 |
gregory |
601 |
.showAbout())); |
1652 |
22 May 07 |
gregory |
602 |
} else if (event.getActionCommand().equals("Settings")) { |
1652 |
22 May 07 |
gregory |
603 |
showAsMainFrame(GUIMethods.showAsNorthBorderLayout(myOptions |
1652 |
22 May 07 |
gregory |
604 |
.showXerverSetupInfo())); |
1652 |
22 May 07 |
gregory |
605 |
} else if (event.getActionCommand().equals("Exit")) |
741 |
10 Oct 06 |
olle |
606 |
exitXerver(); |
741 |
10 Oct 06 |
olle |
607 |
|
741 |
10 Oct 06 |
olle |
608 |
setSetupIsRunningButton(); |
741 |
10 Oct 06 |
olle |
609 |
} |
741 |
10 Oct 06 |
olle |
610 |
|
1652 |
22 May 07 |
gregory |
611 |
bottomCP.repaint(); // Makes sure that the Turn Off Remote Setup button |
1652 |
22 May 07 |
gregory |
// disappears when we choose something in the menu |
741 |
10 Oct 06 |
olle |
613 |
} |
741 |
10 Oct 06 |
olle |
614 |
|
1652 |
22 May 07 |
gregory |
615 |
public void setCurrentMode(int n) { |
1652 |
22 May 07 |
gregory |
616 |
currentMode = n; |
741 |
10 Oct 06 |
olle |
617 |
} |
741 |
10 Oct 06 |
olle |
618 |
|
1652 |
22 May 07 |
gregory |
619 |
public int getCurrentMode() { |
741 |
10 Oct 06 |
olle |
620 |
return currentMode; |
741 |
10 Oct 06 |
olle |
621 |
} |
741 |
10 Oct 06 |
olle |
622 |
|
1652 |
22 May 07 |
gregory |
623 |
public void updateStatsContainer() { |
741 |
10 Oct 06 |
olle |
624 |
CP.validate(); |
741 |
10 Oct 06 |
olle |
625 |
} |
741 |
10 Oct 06 |
olle |
626 |
|
1652 |
22 May 07 |
gregory |
627 |
public void showAsMainFrame(Container nyCP) { |
741 |
10 Oct 06 |
olle |
628 |
CPlarge.remove(CPintoCPlarge); |
1652 |
22 May 07 |
gregory |
629 |
CPintoCPlarge = nyCP; |
1652 |
22 May 07 |
gregory |
630 |
CPlarge.add(CPintoCPlarge, BorderLayout.CENTER); |
741 |
10 Oct 06 |
olle |
631 |
CPlarge.validate(); |
741 |
10 Oct 06 |
olle |
632 |
} |
741 |
10 Oct 06 |
olle |
633 |
|
1652 |
22 May 07 |
gregory |
634 |
public void setStatusText(String txt) { |
741 |
10 Oct 06 |
olle |
635 |
JL_statusBar.setText(txt); |
1652 |
22 May 07 |
gregory |
// CP.validate(); |
1652 |
22 May 07 |
gregory |
// updateStatusText(); |
741 |
10 Oct 06 |
olle |
638 |
} |
741 |
10 Oct 06 |
olle |
639 |
|
1652 |
22 May 07 |
gregory |
// Public because "MinimizedMode" shall be able to call |
1652 |
22 May 07 |
gregory |
// "setIsRunningButton()". |
1652 |
22 May 07 |
gregory |
642 |
public void setIsRunningButton() { |
1652 |
22 May 07 |
gregory |
643 |
if (myOptions.xerverIsRunning) { |
741 |
10 Oct 06 |
olle |
644 |
bottomCP.remove(turnOnButton); |
1652 |
22 May 07 |
gregory |
645 |
bottomCP.add(turnOffButton, BorderLayout.WEST); |
741 |
10 Oct 06 |
olle |
646 |
turnOffButton.repaint(); |
1652 |
22 May 07 |
gregory |
647 |
} else { |
741 |
10 Oct 06 |
olle |
648 |
bottomCP.remove(turnOffButton); |
1652 |
22 May 07 |
gregory |
649 |
bottomCP.add(turnOnButton, BorderLayout.WEST); |
741 |
10 Oct 06 |
olle |
650 |
turnOnButton.repaint(); |
741 |
10 Oct 06 |
olle |
651 |
} |
741 |
10 Oct 06 |
olle |
652 |
bottomCP.validate(); |
741 |
10 Oct 06 |
olle |
653 |
} |
741 |
10 Oct 06 |
olle |
654 |
|
1652 |
22 May 07 |
gregory |
655 |
private void setSetupIsRunningButton() { |
1652 |
22 May 07 |
gregory |
// Add the button if we are supposed to show a button... |
1652 |
22 May 07 |
gregory |
657 |
if (currentMode == SETUP_MODE || currentMode == SETUPTURNEDOFF_MODE |
1652 |
22 May 07 |
gregory |
658 |
|| currentMode == SETUPTURNEDON_MODE |
1652 |
22 May 07 |
gregory |
659 |
|| myOptions.xerverSetupIsRunning) // If [we are in setup mode] |
1652 |
22 May 07 |
gregory |
// or [the setup is |
1652 |
22 May 07 |
gregory |
// running], then... |
741 |
10 Oct 06 |
olle |
662 |
{ |
1652 |
22 May 07 |
gregory |
663 |
if (myOptions.xerverSetupIsRunning) { |
741 |
10 Oct 06 |
olle |
664 |
bottomCP.remove(turnOnSetupButton); |
1652 |
22 May 07 |
gregory |
665 |
bottomCP.add(turnOffSetupButton, BorderLayout.EAST); |
741 |
10 Oct 06 |
olle |
666 |
turnOffSetupButton.repaint(); |
1652 |
22 May 07 |
gregory |
667 |
} else { |
741 |
10 Oct 06 |
olle |
668 |
bottomCP.remove(turnOffSetupButton); |
1652 |
22 May 07 |
gregory |
669 |
bottomCP.add(turnOnSetupButton, BorderLayout.EAST); |
741 |
10 Oct 06 |
olle |
670 |
turnOnSetupButton.repaint(); |
741 |
10 Oct 06 |
olle |
671 |
} |
1652 |
22 May 07 |
gregory |
672 |
} else { |
741 |
10 Oct 06 |
olle |
673 |
bottomCP.remove(turnOnSetupButton); |
741 |
10 Oct 06 |
olle |
674 |
bottomCP.remove(turnOffSetupButton); |
1652 |
22 May 07 |
gregory |
675 |
bottomCP.add(EMPTY_JLABEL, BorderLayout.EAST); |
741 |
10 Oct 06 |
olle |
676 |
turnOnSetupButton.repaint(); |
741 |
10 Oct 06 |
olle |
677 |
turnOffSetupButton.repaint(); |
741 |
10 Oct 06 |
olle |
678 |
} |
741 |
10 Oct 06 |
olle |
679 |
|
741 |
10 Oct 06 |
olle |
680 |
bottomCP.validate(); |
741 |
10 Oct 06 |
olle |
681 |
} |
741 |
10 Oct 06 |
olle |
682 |
|
1652 |
22 May 07 |
gregory |
683 |
private void exitXerver() { |
1652 |
22 May 07 |
gregory |
684 |
if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null, |
1652 |
22 May 07 |
gregory |
685 |
"Really exit Xerver?", "Exit Xerver", |
1652 |
22 May 07 |
gregory |
686 |
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE)) |
741 |
10 Oct 06 |
olle |
687 |
System.exit(0); |
741 |
10 Oct 06 |
olle |
688 |
} |
741 |
10 Oct 06 |
olle |
689 |
|
1652 |
22 May 07 |
gregory |
690 |
private WindowAdapter MyWindowListener = new WindowAdapter() { |
2386 |
14 Nov 07 |
gregory |
691 |
@Override |
1652 |
22 May 07 |
gregory |
692 |
public void windowClosing(WindowEvent e) // Window is closeing |
741 |
10 Oct 06 |
olle |
693 |
{ |
741 |
10 Oct 06 |
olle |
694 |
System.exit(0); |
741 |
10 Oct 06 |
olle |
695 |
} |
741 |
10 Oct 06 |
olle |
696 |
}; |
741 |
10 Oct 06 |
olle |
697 |
} |