~sword-devel/jsword/trunk

« back to all changes in this revision

Viewing changes to jsword/java/historic/org/crosswire/bible/view/swing/beans/WebServerPane.java

  • Committer: joe
  • Date: 2002-10-08 21:36:18 UTC
  • Revision ID: svn-v4:a88caf3b-7e0a-0410-8d0d-cecb45342206:trunk:80
big config and comment update

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
package com.eireneh.bible.view.swing.beans;
3
 
 
4
 
import java.awt.*;
5
 
import java.net.*;
6
 
 
7
 
import javax.swing.*;
8
 
import javax.swing.border.*;
9
 
import javax.swing.event.*;
10
 
 
11
 
// import org.apache.tomcat.shell.*;
12
 
 
13
 
import com.eireneh.util.*;
14
 
import com.eireneh.swing.*;
15
 
import com.eireneh.bible.util.Project;
16
 
 
17
 
/**
18
 
 * A Simple pane that contains the Apache Java web server for testing
19
 
 * purposes
20
 
 *
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>
38
 
 * @see docs.Licence
39
 
 * @author Joe Walker
40
 
 */
41
 
public class WebServerPane extends EirPanel
42
 
{
43
 
    /**
44
 
     * Basic Constructor
45
 
     */
46
 
    public WebServerPane()
47
 
    {
48
 
        jbInit();
49
 
    }
50
 
 
51
 
    /**
52
 
     * Create the GUI
53
 
     */
54
 
    private void jbInit()
55
 
    {
56
 
        chk_started.setMnemonic('W');
57
 
        chk_started.setText("Web Server Running");
58
 
        chk_started.addChangeListener(new ChangeListener()
59
 
        {
60
 
            public void stateChanged(ChangeEvent ev) { startStop(); }
61
 
        });
62
 
 
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);
67
 
 
68
 
        txt_results.setColumns(30);
69
 
        txt_results.setRows(10);
70
 
        scr_results.getViewport().add(txt_results, null);
71
 
 
72
 
        this.setLayout(new BorderLayout());
73
 
        this.add(scr_results, BorderLayout.CENTER);
74
 
        this.add(pnl_state, BorderLayout.NORTH);
75
 
    }
76
 
 
77
 
    /**
78
 
     * Show this Panel in a new dialog
79
 
     */
80
 
    public void showInDialog(Component parent)
81
 
    {
82
 
        showInDialog(parent, "Web Server", false);
83
 
    }
84
 
 
85
 
    /**
86
 
     * When someone toggles the state of the internal web server
87
 
     */
88
 
    private void startStop()
89
 
    {
90
 
        // if we are not started but should be
91
 
        if (chk_started.isSelected() && work == null)
92
 
        {
93
 
            work = new Thread(new Runnable() {
94
 
                public void run()
95
 
                {
96
 
                    try
97
 
                    {
98
 
                        URL url = NetUtil.lengthenURL(Project.getConfigRoot(), "server.xml");
99
 
                        String file = url.getFile().replace('\\', '/');
100
 
 
101
 
                        throw new Exception("Since tomcat 3.2 changed the embedded start system, this has been broken");
102
 
                        /*
103
 
                        Startup start = new Startup();
104
 
                        start.configure(new String[] { "-config", file });
105
 
                        */
106
 
                    }
107
 
                    catch (Exception ex)
108
 
                    {
109
 
                        Reporter.informUser(this, ex);
110
 
                    }
111
 
                }
112
 
            });
113
 
            work.start();
114
 
        }
115
 
 
116
 
        // if we are started but shouldn't be
117
 
        if (!chk_started.isSelected() && work != null)
118
 
        {
119
 
            /*
120
 
            Shutdown.main(new String[0]);
121
 
            work = null;
122
 
            */
123
 
        }
124
 
    }
125
 
 
126
 
    /** The web server thread */
127
 
    private Thread work = null;
128
 
 
129
 
    /* GUI Components */
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();
135
 
}