2
package com.eireneh.bible.view.swing.beans;
8
import javax.swing.border.*;
9
import javax.swing.event.*;
11
// import org.apache.tomcat.shell.*;
13
import com.eireneh.util.*;
14
import com.eireneh.swing.*;
15
import com.eireneh.bible.util.Project;
18
* A Simple pane that contains the Apache Java web server for testing
21
* <table border='1' cellPadding='3' cellSpacing='0' width="100%">
22
* <tr><td bgColor='white'class='TableRowColor'><font size='-7'>
23
* Distribution Licence:<br />
24
* Project B is free software; you can redistribute it
25
* and/or modify it under the terms of the GNU General Public License,
26
* version 2 as published by the Free Software Foundation.<br />
27
* This program is distributed in the hope that it will be useful,
28
* but WITHOUT ANY WARRANTY; without even the implied warranty of
29
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30
* General Public License for more details.<br />
31
* The License is available on the internet
32
* <a href='http://www.gnu.org/copyleft/gpl.html'>here</a>, by writing to
33
* <i>Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
34
* MA 02111-1307, USA</i>, Or locally at the Licence link below.<br />
35
* The copyright to this program is held by it's authors.
36
* </font></td></tr></table>
37
* @see <a href='http://www.eireneh.com/servlets/Web'>Project B Home</a>
41
public class WebServerPane extends EirPanel
46
public WebServerPane()
56
chk_started.setMnemonic('W');
57
chk_started.setText("Web Server Running");
58
chk_started.addChangeListener(new ChangeListener()
60
public void stateChanged(ChangeEvent ev) { startStop(); }
63
lay_state.setAlignment(FlowLayout.LEFT);
64
pnl_state.setLayout(lay_state);
65
pnl_state.setBorder(new TitledBorder("Web Server State"));
66
pnl_state.add(chk_started, null);
68
txt_results.setColumns(30);
69
txt_results.setRows(10);
70
scr_results.getViewport().add(txt_results, null);
72
this.setLayout(new BorderLayout());
73
this.add(scr_results, BorderLayout.CENTER);
74
this.add(pnl_state, BorderLayout.NORTH);
78
* Show this Panel in a new dialog
80
public void showInDialog(Component parent)
82
showInDialog(parent, "Web Server", false);
86
* When someone toggles the state of the internal web server
88
private void startStop()
90
// if we are not started but should be
91
if (chk_started.isSelected() && work == null)
93
work = new Thread(new Runnable() {
98
URL url = NetUtil.lengthenURL(Project.getConfigRoot(), "server.xml");
99
String file = url.getFile().replace('\\', '/');
101
throw new Exception("Since tomcat 3.2 changed the embedded start system, this has been broken");
103
Startup start = new Startup();
104
start.configure(new String[] { "-config", file });
109
Reporter.informUser(this, ex);
116
// if we are started but shouldn't be
117
if (!chk_started.isSelected() && work != null)
120
Shutdown.main(new String[0]);
126
/** The web server thread */
127
private Thread work = null;
130
private JScrollPane scr_results = new JScrollPane();
131
private JTextArea txt_results = new JTextArea();
132
private JPanel pnl_state = new JPanel();
133
private JCheckBox chk_started = new JCheckBox();
134
private FlowLayout lay_state = new FlowLayout();