Index: trunk/gsdl3/src/java/org/greenstone/server/BrowserLauncher.java
===================================================================
--- trunk/gsdl3/src/java/org/greenstone/server/BrowserLauncher.java	(revision 13229)
+++ trunk/gsdl3/src/java/org/greenstone/server/BrowserLauncher.java	(revision 13229)
@@ -0,0 +1,139 @@
+package org.greenstone.server;
+
+import org.greenstone.gsdl3.util.Misc;
+
+
+public class BrowserLauncher 
+    extends Thread {
+    
+    private Process process = null;
+    /** The initial command string given to this sub-process. */
+    private String command = null;
+    private String url = null;
+    private String[] commands = null;
+
+    public BrowserLauncher(String url) {
+	this.url = url;
+	setBrowserCommand();
+	System.err.println("new browser launcher");
+	printArray(commands);
+    }
+
+    // we should try and use settings from the settings panel??
+    protected void setBrowserCommand() {
+
+	// Try from a config setting??
+
+	if(Misc.isWindows()) {
+	    // we use cmd and start
+	    if (Misc.isWindows9x()) {
+		this.commands = StaticStrings.WIN_9X_OPEN_COMMAND;//"command.com /c start \""+url+"\"";
+	    } else {
+		this.commands = StaticStrings.WIN_OPEN_COMMAND;//"cmd.exe /c start \"\" \""+url+"\"";
+	    }
+	} else if (Misc.isMac()) {
+	    this.commands = StaticStrings.MAC_OPEN_COMMAND; // "open %1"
+	} else {
+	    // try mozilla for now
+	    this.commands = new String [] {"mozilla", "%1"};
+// 	    // we try to look for a browser
+// 	    String [] browsers = new String [] {"mozilla", "netscape"};
+// 	    for (int i=0; i<browsers.length; i++) {
+// 		if (isAvailable(browsers[i])) {
+// 		    command = browsers[i]+ " %1";
+// 		    break;
+// 		}
+// 	    }
+	}
+
+	for (int i=0; i<commands.length; i++) {
+	    if (commands[i].equals("%1")) {
+		commands[i] = url;
+		break;
+	    }
+	}
+
+	
+    }
+
+//     protected boolean isAvailable(String program) {
+// 	try {
+// 	    ExternalProgram e = new ExternalProgram("which", program);
+// 	    e.exitProgram();
+// 	    String out = e.getLineOfProgramOutput();
+// 	    if (out == null) {
+// 		return false;
+// 	    }
+// 	    return true;
+// 	} catch (Exception exc) {
+// 	    return false;
+// 	}
+//     }
+
+    /** We start the child process inside a new thread so it doesn't block the rest of Gatherer.
+     * @see java.lang.Exception
+     * @see java.lang.Process
+     * @see java.lang.Runtime
+     * @see java.lang.System
+     * @see java.util.Vector
+     */
+    public void run() {
+	System.err.println("in run method");
+	// Call an external process using the args.
+	if(commands == null) {
+	    //apps.remove(this);
+	    return;
+	}
+	try {
+	    String prog_name = commands[0];
+	    String lower_name = prog_name.toLowerCase();
+	    if (lower_name.indexOf("mozilla") != -1 || lower_name.indexOf("netscape") != -1) { 
+		System.err.println("found mozilla or netscape, trying remote it");
+		// mozilla and netscape, try using a remote command to get things in the same window
+		String [] new_commands = new String[] {prog_name, "-raise", "-remote", "openURL("+url+",new-tab)"};
+		printArray(new_commands);
+
+		Runtime rt = Runtime.getRuntime();
+		process = rt.exec(new_commands);
+		int exitCode = process.waitFor();
+		if (exitCode != 0) { // if Netscape or mozilla was not open
+		    System.err.println("couldn't do remote, trying original command");
+		    printArray(commands);
+		    process = rt.exec(commands); // try the original command
+		}
+	    } else {
+		// just run what we have been given
+		StringBuffer whole_command = new StringBuffer();
+		for(int i = 0; i < commands.length; i++) {
+		    whole_command.append(commands[i]);
+		    whole_command.append(" ");
+		}
+		System.err.println("Running " + whole_command.toString());
+		Runtime rt = Runtime.getRuntime();
+		process = rt.exec(commands);
+		process.waitFor();
+	    }
+	}
+	    
+	catch (Exception exception) {
+	    exception.printStackTrace();
+	}
+	// Remove ourself from Gatherer list of threads.
+	//apps.remove(this);
+	// Call exit if we were the last outstanding child process thread.
+	//if (apps.size() == 0 && exit == true) {
+	//    System.exit(exit_status);
+	//}
+    }
+    public void printArray(String [] array) {
+	for(int i = 0; i < array.length; i++) {
+	    System.err.println(array[i]+" ");
+	}
+    }
+    public void stopBrowserApplication() {
+	if(process != null) {
+	    process.destroy();
+	}
+    }
+
+}
Index: trunk/gsdl3/src/java/org/greenstone/server/RunAnt.java
===================================================================
--- trunk/gsdl3/src/java/org/greenstone/server/RunAnt.java	(revision 13229)
+++ trunk/gsdl3/src/java/org/greenstone/server/RunAnt.java	(revision 13229)
@@ -0,0 +1,49 @@
+package org.greenstone.server;
+
+import java.io.IOException;
+
+import org.greenstone.server.StreamGobbler;
+
+public class RunAnt extends Thread {
+    private String antCmd = null;
+
+    public RunAnt() {
+    }
+
+    public void run() {
+	Runtime run = Runtime.getRuntime();
+	Process process = null;
+	//BufferedReader processOut;
+	try {
+	    setPriority(MIN_PRIORITY);
+	    //Thread.sleep(1000);
+	    process = run.exec(getAntCmd());
+	    // any error message?
+	    StreamGobbler errorGobbler = new StreamGobbler(process.getErrorStream(), "ERROR");
+	    // any output?
+	    StreamGobbler outputGobbler = new StreamGobbler(process.getInputStream(), "OUTPUT");
+	    // kick them off
+	    errorGobbler.run();
+	    outputGobbler.run();
+	} catch (IOException ioe) {
+	    ioe.printStackTrace();
+	} catch (Throwable t) {
+	    t.printStackTrace();
+	}
+    }
+
+    public void setAntCmd(String cmd) {
+	String osName = System.getProperty("os.name");
+	System.out.println("command: " + cmd);
+	if (osName.startsWith("Windows")) {
+	    this.antCmd = "ant.bat " + cmd;
+	} else {
+	    this.antCmd = "ant " + cmd;
+	}
+    }
+
+    public String getAntCmd() {
+	return this.antCmd;
+    }
+
+}
Index: trunk/gsdl3/src/java/org/greenstone/server/ScriptReadWrite.java
===================================================================
--- trunk/gsdl3/src/java/org/greenstone/server/ScriptReadWrite.java	(revision 13229)
+++ trunk/gsdl3/src/java/org/greenstone/server/ScriptReadWrite.java	(revision 13229)
@@ -0,0 +1,102 @@
+package org.greenstone.server;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+
+public class ScriptReadWrite {
+
+    public ScriptReadWrite() {
+    }
+
+    public ArrayList readInFile(File file) {
+	try {
+	    ArrayList fileLines = new ArrayList();
+	    String oneLine = null;
+	    BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
+	    while ((oneLine = bufferedReader.readLine()) != null) {
+		fileLines.add(oneLine);
+	    }
+	    bufferedReader.close();
+	    return fileLines;
+	} catch (Exception e) {
+	    System.err.println("exception:" + e);
+	    return null;
+	}
+    }
+
+    public void writeOutFile(File file, ArrayList fileLines_in) {
+	try {
+	    PrintWriter printWriter = new PrintWriter(new BufferedWriter(new FileWriter(file)));
+	    for (int i = 0; i < fileLines_in.size(); i++) {
+		printWriter.println(fileLines_in.get(i));
+	    }
+	    printWriter.flush();
+	    printWriter.close();
+	} catch (Exception e) {
+	    System.err.println("exception:" + e);
+	}
+    }
+
+    public ArrayList queryReplace(ArrayList fileLines_ex, String param,
+				  String newValue) {
+
+	String oneLine = null;
+	String newLine = null;
+	String name = null;
+	// int oneLine_length = 0;
+	param = param.trim();
+	// int param_length = param.length();
+
+	for (int i = 0; i < fileLines_ex.size(); i++) {
+	    oneLine = ((String) fileLines_ex.get(i)).trim();
+	    // oneLine_length = oneLine.length();
+	    StringTokenizer st = new StringTokenizer(oneLine, "=");
+	    if (st.hasMoreTokens()) {
+		name = st.nextToken();
+		if (param.equals(name)) {
+		    newLine = param + "=" + newValue;
+		    fileLines_ex.set(i, newLine);
+		    break;
+		}
+	    }
+	}
+	return fileLines_ex;
+    }
+
+    public String existValue(ArrayList fileLines, String querytext) {
+	String retValue = null;
+	String oneline = null;
+	String name = null;
+	// String value=null;
+	// int oneline_length = 0;
+	querytext = querytext.trim();
+	// int querytext_length = querytext.length();
+	for (int i = 0; i < fileLines.size(); i++) {
+	    oneline = ((String) fileLines.get(i)).trim();
+	    // oneline_length = oneline.length();
+	    StringTokenizer st = new StringTokenizer(oneline, "=");
+	    if (st.hasMoreTokens()) {
+		name = st.nextToken();
+		if (querytext.equals(name)) {
+		    if (st.hasMoreTokens()) {
+			retValue = st.nextToken();
+			retValue = retValue.trim();
+			if (retValue.equals("")) {
+			    retValue = null;
+			}
+		    } else {
+			retValue = null;
+		    }
+		    break;
+		}
+	    }
+	}
+	return retValue;
+    }
+}
Index: trunk/gsdl3/src/java/org/greenstone/server/Server.java
===================================================================
--- trunk/gsdl3/src/java/org/greenstone/server/Server.java	(revision 13229)
+++ trunk/gsdl3/src/java/org/greenstone/server/Server.java	(revision 13229)
@@ -0,0 +1,74 @@
+
+package org.greenstone.server;
+
+import java.awt.Dimension;
+import java.awt.Toolkit;
+import java.io.File;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.greenstone.gsdl3.util.Dictionary;
+
+//import org.greenstone.gsdl3.util.GlobalProperties;
+
+public class Server
+{
+    public static Dimension screen_size = Toolkit.getDefaultToolkit().getScreenSize();
+    public static File build_properties_file;
+    public static String images_path; // should be in classpath??
+    public static Properties build_properties;
+    public static Dictionary dictionary;
+
+    public Server(String gsdl3_src_home)
+    {
+	//this.gsdl3_home = gsdl3_home;
+	//this.gsdl3_src_home = gsdl3_src_home;
+	
+	//this.global_properties=gsdl3_home+File.separatorChar+"WEB-INF"+File.separatorChar+"classes"+File.separatorChar+"global.properties";
+	String build_properties_path=gsdl3_src_home+File.separatorChar+"build.properties";
+	this.build_properties_file = new File(build_properties_path);
+	if (!this.build_properties_file.exists()) {
+	    System.err.println("Can't find build.properties file "+build_properties_path);
+	    System.exit(1);
+	}
+	build_properties = new Properties();
+	reloadBuildProperties();
+	this.images_path = gsdl3_src_home+File.separatorChar+"resources"+File.separatorChar+"images"+File.separatorChar;
+	
+	// make it dynamic language
+	this.dictionary = new Dictionary("server", "en", this.getClass().getClassLoader());
+	ServerControl serverControl = new ServerControl();
+    }
+    
+    public static void reloadBuildProperties() {
+	try {
+	    InputStream in = Class.forName("org.greenstone.server.Server").getClassLoader().getResourceAsStream("build.properties");
+	    if (in != null) {
+		System.err.println("loading build properties");
+		build_properties.load(in);
+		in.close();
+	    } else {
+		System.err.println("couldn't load build properties!");
+	    }
+	} catch (Exception e) {
+	    System.err.println("Exception trying to reload build.properties: "+e);
+	}
+
+
+    }
+    public static void main (String[] args){
+	System.out.println(args[0]);
+	if (args.length != 1) {
+	    System.err.println("Usage: java org.greenstone.server.ServerMain <gsdl3 src home> ");
+	    System.exit(1);
+	}
+	
+	File gsdl3_src_dir = new File(args[0]);
+	if (!gsdl3_src_dir.isDirectory()) {
+	    System.err.println("Usage: java org.greenstone.server.ServerMain <gsdl3 src home> ");
+	    System.err.println("src directory does not exist!");
+	    System.exit(1);
+	}
+	Server server = new Server(args[0]);
+    }
+}
Index: trunk/gsdl3/src/java/org/greenstone/server/ServerControl.java
===================================================================
--- trunk/gsdl3/src/java/org/greenstone/server/ServerControl.java	(revision 13229)
+++ trunk/gsdl3/src/java/org/greenstone/server/ServerControl.java	(revision 13229)
@@ -0,0 +1,215 @@
+package org.greenstone.server;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.io.File;
+import java.util.ArrayList;
+import javax.swing.*;
+import javax.swing.border.*;
+
+import org.greenstone.gsdl3.util.GlobalProperties;
+
+/**
+ * This class is to start or restart the library server
+ * 
+ */
+public class ServerControl extends JFrame {
+
+    /** The dimension of the frame */
+    static final private Dimension FRAME_SIZE = new Dimension(350, 250);
+
+    /** Ant command for managing Tomcat */
+    static final private String START_CMD = "start";
+    static final private String RESTART_CMD = "restart";
+    static final private String CONFIGURE_CMD = "configure";
+    static final private String STOP_CMD = "stop";
+    
+    /** images for the panel */
+    static final private String ICON_IMG = "gatherer_small.gif";
+    static final private String LOGO_IMG = "logogreenstone.gif";
+    static final private String CHALK_IMG = "chalk.gif";
+    
+    private boolean configure_required = false;
+    private boolean tomcat_running = false;
+
+    /** some components we need to refer to later */
+    private JPanel mid_panel;
+    private JLabel process_label;
+    private JTextArea info_label;
+    private JButton enter_button;
+
+    public ServerControl() {
+	super(Server.dictionary.get("ServerControl.Frame_Title"));
+	setSize(FRAME_SIZE);
+	setIconImage(Toolkit.getDefaultToolkit().getImage(Server.images_path + ICON_IMG));
+	setDefaultCloseOperation(EXIT_ON_CLOSE);
+	Dimension screen_size = Toolkit.getDefaultToolkit().getScreenSize();
+	setLocation((screen_size.width - FRAME_SIZE.width) / 2,
+		    (screen_size.height - FRAME_SIZE.height) / 2);
+	setBackground(Color.white);
+
+	// do we automatically start the server/browser on launching?
+	String auto_start_str = Server.build_properties.getProperty(StaticStrings.AUTOSTART_PROPERTY);
+	boolean auto_start = false;
+	if (auto_start_str!= null && auto_start_str.equals("true")) {
+	    auto_start = true;
+	}
+	addWindowListener(new MyWindowAdapter());
+
+	JPanel content_panel = (JPanel) getContentPane();
+	JPanel title_panel = new JPanel();
+	mid_panel = new JPanel();
+	JPanel button_panel = new JPanel();
+
+	JLabel title_label = new JLabel(Server.dictionary.get("ServerControl.Title"), JLabel.CENTER);
+	title_label.setFont(new Font("Dialog", Font.BOLD, 18));
+
+	JLabel version_label = new JLabel(Server.dictionary.get("ServerControl.Version", new String [] {GlobalProperties.getProperty(StaticStrings.GSDL3_VERSION_PROPERTY)}), JLabel.CENTER);
+		
+	title_panel.setBorder(BorderFactory.createEmptyBorder(20, 0, 0, 0));
+	title_panel.setLayout(new BorderLayout());
+	title_panel.add(title_label, BorderLayout.NORTH);
+	title_panel.add(version_label, BorderLayout.CENTER);
+	title_panel.setBackground(Color.white);
+
+	process_label = new JLabel(Server.dictionary.get("ServerControl.Starting"), JLabel.CENTER);
+	info_label = new JTextArea();
+	info_label.setEditable(false);
+	info_label.setLineWrap(true);
+	info_label.setWrapStyleWord(true);
+	mid_panel.setBorder(BorderFactory.createEmptyBorder(20, 0, 0, 0));
+	mid_panel.setLayout(new BorderLayout());
+	mid_panel.setBackground(Color.white);
+
+	if (auto_start) {
+	    // starting automatically, just show starting.... and set up the 
+	    // info and button to restart - will be added by windowListener
+	    
+	    mid_panel.add(process_label, BorderLayout.CENTER);
+	    enter_button = new JButton(Server.dictionary.get("ServerControl.Restart"));
+	    enter_button.setVisible(false);
+	    info_label.setText(Server.dictionary.get("ServerControl.Help_Restart"));
+	} else {
+	    info_label.setText(Server.dictionary.get("ServerControl.Help_Start"));
+	    mid_panel.add(info_label, BorderLayout.CENTER);
+	    enter_button = new JButton(Server.dictionary.get("ServerControl.Start"));
+	    enter_button.setVisible(true);
+	}
+	enter_button.addActionListener(new EnterButtonListener());
+
+	ImageIcon logo_icon = new ImageIcon(Toolkit.getDefaultToolkit().getImage(Server.images_path + LOGO_IMG));
+	button_panel.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 10));
+	button_panel.add(enter_button);
+	button_panel.add(new JLabel(logo_icon));
+	button_panel.setBackground(Color.white);
+
+	ImageIcon chalk_icon = new ImageIcon(Toolkit.getDefaultToolkit().getImage(Server.images_path + CHALK_IMG));
+	content_panel.setBorder(BorderFactory.createMatteBorder(0, 40, 0, 0,
+								chalk_icon));
+	content_panel.setLayout(new GridLayout(3, 1));
+	content_panel.add(title_panel);
+	content_panel.add(mid_panel);
+	content_panel.add(button_panel);
+	content_panel.setBackground(Color.white);
+
+	setJMenuBar(createMenu());
+	setVisible(true);
+    }
+
+    protected JMenuBar createMenu() {
+	JMenuBar menuBar = new JMenuBar();
+	JMenu fMenu = new JMenu(Server.dictionary.get("ServerControl.Menu.File"));
+	JMenuItem iConf = new JMenuItem(Server.dictionary.get("ServerControl.Menu.Settings"));
+	iConf.setBackground(Color.white);
+	iConf.addActionListener(new ActionListener() {
+		public void actionPerformed(ActionEvent ae) {
+		    ServerSettings serverSetting = new ServerSettings();
+		    configure_required = serverSetting.isConfigureRequired();
+		}
+	    });
+
+	JMenuItem iExit = new JMenuItem(Server.dictionary.get("ServerControl.Menu.Exit"));
+	iExit.setBackground(Color.white);
+	iExit.addActionListener(new ActionListener() {
+		public void actionPerformed(ActionEvent ae) {
+		    stopServer();
+		    System.exit(0);
+		}
+	    });
+	fMenu.add(iConf);
+	fMenu.add(iExit);
+	menuBar.add(fMenu);
+	menuBar.setBorder(new BevelBorder(BevelBorder.RAISED));
+	return menuBar;
+    }
+
+    protected void stopServer() {
+	RunAnt runAnt = new RunAnt();
+	runAnt.setAntCmd(STOP_CMD);
+	runAnt.run();
+    }
+    
+    protected void restartServer() {
+	RunAnt runAnt = new RunAnt();
+	// stop it if already running
+	if (tomcat_running) {
+	    runAnt.setAntCmd(STOP_CMD);
+	    runAnt.run();
+	}	    
+	// reconfigure if necessary
+	if (configure_required) {
+	    runAnt.setAntCmd(CONFIGURE_CMD);
+	    runAnt.run();
+	    GlobalProperties.reload(); // properties file may have changed, so reload it
+	    configure_required = false;
+	}
+	// start it up
+	runAnt.setAntCmd(START_CMD);
+	runAnt.run();
+	tomcat_running = true;
+    }
+	
+    protected void launchBrowser() {
+	setState(Frame.ICONIFIED); // make the server frame iconified
+	String url = GlobalProperties.getGSDL3WebAddress()+ Server.build_properties.getProperty(StaticStrings.DEFAULT_SERVLET_PROPERTY);
+	BrowserLauncher launcher = new BrowserLauncher(url);
+	launcher.start();
+    }
+    
+    private class MyWindowAdapter
+	extends WindowAdapter {
+	public void windowClosing(WindowEvent e) {
+	    /** When the frame is closed, the library server is terminated */
+	    stopServer();
+	    tomcat_running = false;
+	}
+	
+	public void windowOpened(WindowEvent e) {
+	    // if auto start is true, we start the server and launch a browser
+	    String auto_start = Server.build_properties.getProperty(StaticStrings.AUTOSTART_PROPERTY);
+	    if (auto_start != null && auto_start.equals("true")) {
+		restartServer();
+		launchBrowser();
+		// have to reset the panel to restart
+		mid_panel.remove(process_label);
+		mid_panel.add(info_label, BorderLayout.CENTER );
+		enter_button.setVisible(true);
+	    } 
+	}
+    }
+
+    private class EnterButtonListener
+	implements ActionListener {
+
+	public void actionPerformed(ActionEvent ev) {
+	    boolean tomcat_was_running = tomcat_running;
+	    restartServer();
+	    launchBrowser();
+	    if (!tomcat_was_running) {
+		// reset the panel to restart
+		info_label.setText(Server.dictionary.get("ServerControl.Help_Restart"));
+		enter_button.setText(Server.dictionary.get("ServerControl.Restart"));
+	    }
+	}
+    }
+}
Index: trunk/gsdl3/src/java/org/greenstone/server/ServerSettings.java
===================================================================
--- trunk/gsdl3/src/java/org/greenstone/server/ServerSettings.java	(revision 13229)
+++ trunk/gsdl3/src/java/org/greenstone/server/ServerSettings.java	(revision 13229)
@@ -0,0 +1,299 @@
+package org.greenstone.server;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import javax.swing.*;
+
+import org.w3c.dom.*;
+
+import org.greenstone.gsdl3.util.GSXML;
+import org.greenstone.gsdl3.util.GlobalProperties;
+import org.greenstone.gsdl3.util.XMLConverter;
+
+public class ServerSettings extends JDialog
+
+{
+    static final private String DEFPORT = "8080";
+
+    //    static final private String WARN_LABEL = "Could not find a port number for tomcat. System gives a default port below:";
+
+    //    static final private String PORT_LABEL = "Tomcat start port number:";
+
+    //    static final private String RESTART_LABEL = "Restarting...";
+
+    static final private String ICON_IMG = "gatherer_small.gif";
+
+    //   static final private String AUTO_INFO = "Enter Digital library automatically";
+
+    // static final private String BUILD_PROPERTIES="build.properties";
+    // static final private String
+    // WEB_GLOBAL_PROPERTIES="web/WEB-INF/classes/global.properties";
+    static final private String CHALK_IMG = "chalk.gif";
+
+    JPanel content_panel, top_panel, textfield_panel, comb_panel, mid_panel,
+	down_panel;
+
+    JLabel warn_label, port_label, server_label, servlet_label, restart_label;
+
+    JButton start_button, conne_button, stop_button, save_button, exit_button;
+
+    JCheckBox autoEnter;
+
+    JComboBox servlet_combobox;
+
+    private JTextField portNumber_textfield = null;
+
+    // private MsgDialog msgDialog=null;
+
+    private Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
+
+    static final private Dimension SIZE = new Dimension(370, 280);
+
+    private String portNum = null;
+
+    private boolean autoStart = false;
+
+    private String servletDefault = null;
+
+    private HashMap url_mappings = null;
+    protected boolean configure_required = false;
+    private JDialog self;
+    public ServerSettings() {
+	super((Frame)null, "", true);
+	this.self = this;
+	this.portNum = Server.build_properties.getProperty(StaticStrings.TOMCAT_PORT_PROPERTY);
+	String auto_start_str = Server.build_properties.getProperty(StaticStrings.AUTOSTART_PROPERTY);
+	if ((auto_start_str.trim()).equals("true")) {
+	    this.autoStart = true;
+	} else {
+	    this.autoStart = false;
+	}
+
+	this.servletDefault = Server.build_properties.getProperty(StaticStrings.DEFAULT_SERVLET_PROPERTY);
+
+	setSize(SIZE);
+	setTitle(Server.dictionary.get("ServerSettings.Title"));
+	//setIconImage(Toolkit.getDefaultToolkit().getImage(Server.images_path + ICON_IMG));
+	setLocation((screen.width - SIZE.width) / 2,
+		    (screen.height - SIZE.height) / 2);
+	setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
+
+	content_panel = (JPanel) getContentPane();
+	top_panel = new JPanel();
+	textfield_panel = new JPanel();
+	mid_panel = new JPanel();
+	comb_panel = new JPanel();
+	down_panel = new JPanel();
+
+	//warn_label = new JLabel(WARN_LABEL);
+	//warn_label.setForeground(Color.red);
+
+	//	restart_label = new JLabel(Server.dictionary.get("ServerSettings.Restart"));
+	//	restart_label.setForeground(Color.red);
+	// restart_label.setVisible(false);
+
+	port_label = new JLabel(Server.dictionary.get("ServerSettings.Tomcat_Port"));
+
+	if (portNum != null) {
+	    //warn_label.setVisible(false);
+	    portNumber_textfield = new JTextField(portNum, 10);
+	} else {
+	    //warn_label.setVisible(true);
+	    portNumber_textfield = new JTextField(DEFPORT, 10);
+	}
+	portNumber_textfield.setHorizontalAlignment(JTextField.LEFT);
+
+	autoEnter = new JCheckBox(Server.dictionary.get("ServerSettings.Auto_Start"));
+	
+	if (autoStart) {
+	    autoEnter.setSelected(true);
+	} else {
+	    autoEnter.setSelected(false);
+	}
+	autoEnter.setBackground(Color.white);
+
+	servlet_label = new JLabel(Server.dictionary.get("ServerSettings.Servlet"));
+
+	servlet_combobox = new JComboBox();
+	servlet_combobox.setMaximumRowCount(5);
+	servlet_combobox.setBackground(Color.white);
+
+	File web_xml = new File(GlobalProperties.getProperty(StaticStrings.GSDL3_HOME_PROPERTY) + File.separator + "WEB-INF" + File.separator + "web.xml");
+	XMLConverter converter = new XMLConverter();
+	Document web_config = converter.getDOM(web_xml);
+	if (web_config == null) {
+	    System.err.println("web.xml is null! "+web_xml.getAbsolutePath());
+	    return;
+	}
+
+	NodeList servlet_mappings = web_config.getElementsByTagName("servlet-mapping");
+	// make a little map class
+	url_mappings = new HashMap();
+	for (int i = 0; i < servlet_mappings.getLength(); i++) {
+	    Element map = (Element) servlet_mappings.item(i);
+	    Element servlet_name_elem = (Element) GSXML.getChildByTagName(map, "servlet-name");
+	    String name = GSXML.getNodeText(servlet_name_elem);
+	    Element url_pattern_elem = (Element) GSXML.getChildByTagName(map, "url-pattern");
+	    String pattern = GSXML.getNodeText(url_pattern_elem);
+	    // Ignore the Axis servlets
+	    if (!(name.equals("AxisServlet"))) {
+		servlet_combobox.addItem(name.trim());
+		url_mappings.put(name, pattern);
+	    }
+
+	    if (pattern.equals(servletDefault)) {
+		servlet_combobox.setSelectedItem(name);
+	    }
+
+	}
+
+	save_button = new JButton(Server.dictionary.get("ServerSettings.OK"));
+	save_button.addActionListener(new SaveActionListener());
+
+	exit_button = new JButton(Server.dictionary.get("ServerSettings.Cancel"));
+	exit_button.addActionListener(new ActionListener() {
+		public void actionPerformed(ActionEvent ev) {
+		    self.dispose();
+		}
+	    });
+
+	top_panel.setBorder(BorderFactory.createEmptyBorder(15, 10, 0, 0));
+	top_panel.setLayout(new BorderLayout());
+	//top_panel.add(warn_label, BorderLayout.CENTER);
+	// top_panel.add(restart_label,BorderLayout.CENTER);
+	top_panel.setBackground(Color.white);
+
+	textfield_panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
+	textfield_panel.setLayout(new FlowLayout(FlowLayout.LEFT));
+	textfield_panel.add(port_label);
+	textfield_panel.add(portNumber_textfield);
+	textfield_panel.setBackground(Color.white);
+
+	comb_panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 20, 0));
+	comb_panel.setLayout(new FlowLayout(FlowLayout.LEFT));
+	comb_panel.add(servlet_label);
+	comb_panel.add(servlet_combobox);
+	comb_panel.setBackground(Color.white);
+
+	mid_panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 40, 0));
+	mid_panel.setLayout(new GridLayout(3, 1));
+	mid_panel.add(textfield_panel);
+	mid_panel.add(autoEnter);
+	mid_panel.add(comb_panel);
+	mid_panel.setBackground(Color.white);
+
+	down_panel.setLayout(new FlowLayout(FlowLayout.CENTER, 20, 10));
+	down_panel.add(save_button);
+	down_panel.add(exit_button);
+	down_panel.setBackground(Color.white);
+
+	ImageIcon chalk_icon = new ImageIcon(Toolkit.getDefaultToolkit().getImage(Server.images_path + CHALK_IMG));
+	content_panel.setBorder(BorderFactory.createMatteBorder(0, 40, 0, 0,
+								chalk_icon));
+	content_panel.setLayout(new BorderLayout());
+
+	content_panel.add(top_panel, BorderLayout.NORTH);
+	content_panel.add(mid_panel, BorderLayout.CENTER);
+	content_panel.add(down_panel, BorderLayout.SOUTH);
+	content_panel.setBackground(Color.white);
+	setVisible(true);
+    }
+
+//     public boolean getAutoStatus() {
+
+// 	if (autoEnter.isSelected()) {
+// 	    return true;
+// 	} else {
+// 	    return false;
+// 	}
+//     }
+    public boolean isConfigureRequired() {
+	return configure_required;
+    }
+//     public String getValue(String file, String param) {
+// 	ScriptReadWrite scriptReadWrite = new ScriptReadWrite();
+// 	ArrayList fileLines = null;
+// 	fileLines = scriptReadWrite.readInFile(file);
+// 	String exValue = scriptReadWrite.existValue(fileLines, param);
+// 	return exValue;
+//     }
+
+//     public boolean getAutoStart() {
+// 	return autoStart;
+//     }
+
+//     public void setAutoStart(String g_properties, String auto_start) {
+// 	String autoStart_ex = getValue(g_properties, auto_start);
+// 	System.out.println("auto_start : "+autoStart_ex);
+// 	if ((autoStart_ex.trim()).equals("true")) {
+// 	    this.autoStart = true;
+// 	} else {
+// 	    this.autoStart = false;
+// 	}
+//     }
+
+//     public String getPortNum() {
+// 	return portNum;
+//     }
+
+//     public void setPortNum(String g_properties, String port) {
+// 	this.portNum = getValue(g_properties, port);
+//     }
+
+//     public String getServletDefault() {
+// 	return servletDefault;
+//     }
+
+//     public void setServletDefault(String g_properties, String servletDef) {
+// 	this.servletDefault = getValue(g_properties, servletDef);
+//     }
+
+    private class SaveActionListener
+	implements ActionListener {
+	
+	public void actionPerformed(ActionEvent ev) {
+	    // save everything to build_properties if things have changed
+	    System.out.println("auto_start: " + autoStart);
+	    System.out.println("auto_selected: " + autoEnter.isSelected());
+	    boolean has_changed = false;
+	    if (!portNum.equals(portNumber_textfield.getText().trim())) {
+		has_changed = true;
+		configure_required = true;
+		System.err.println("port changed");
+	    }
+	    if (autoStart != autoEnter.isSelected()) {
+		has_changed = true;
+	    }
+	    if (!servletDefault.equals(servlet_combobox.getSelectedItem())) {
+		has_changed = true;
+	    }
+	    if (has_changed) {
+		ArrayList oldFileLines = null;
+		ArrayList newFileLines = null;
+		
+		ScriptReadWrite scriptReadWrite = new ScriptReadWrite();
+		oldFileLines = scriptReadWrite.readInFile(Server.build_properties_file);
+		
+		newFileLines = scriptReadWrite.queryReplace(oldFileLines, StaticStrings.TOMCAT_PORT_PROPERTY, portNumber_textfield.getText());
+		
+		String newAutoEnter = (new Boolean(autoEnter.isSelected())).toString();
+		newFileLines = scriptReadWrite.queryReplace(newFileLines, StaticStrings.AUTOSTART_PROPERTY, newAutoEnter);
+		
+		String newServletDef = (String) servlet_combobox.getSelectedItem();
+		newFileLines = scriptReadWrite.queryReplace(newFileLines,StaticStrings.DEFAULT_SERVLET_PROPERTY, (String) url_mappings.get(newServletDef));
+		
+		scriptReadWrite.writeOutFile(Server.build_properties_file,
+					     newFileLines);
+		Server.reloadBuildProperties();
+		JOptionPane.showMessageDialog(null,"The new settings will be avaliable after the server restarted","Info", JOptionPane.INFORMATION_MESSAGE);
+	    } else {
+		JOptionPane.showMessageDialog(null,"No change has been made", "Info",JOptionPane.INFORMATION_MESSAGE);
+	    }
+	    self.dispose();
+	}
+    }
+
+}
Index: trunk/gsdl3/src/java/org/greenstone/server/StaticStrings.java
===================================================================
--- trunk/gsdl3/src/java/org/greenstone/server/StaticStrings.java	(revision 13229)
+++ trunk/gsdl3/src/java/org/greenstone/server/StaticStrings.java	(revision 13229)
@@ -0,0 +1,19 @@
+package org.greenstone.server;
+
+public class StaticStrings {
+
+    static final public String GSDL3_HOME_PROPERTY = "gsdl3.home";
+    static final public String GSDL3_VERSION_PROPERTY = "gsdl3.version";
+    static final public String AUTOSTART_PROPERTY = "server.auto.start";
+    static final public String DEFAULT_SERVLET_PROPERTY = "server.default.servlet";
+    static final public String TOMCAT_SERVER_PROPERTY = "tomcat.server";
+    static final public String TOMCAT_PORT_PROPERTY = "tomcat.port";
+    static final public String TOMCAT_CONTEXT_PROPERTY = "tomcat.context";
+    static final public String TOMCAT_INSTALL_PATH = "tomcat.installed.path";
+
+    static final public String [] WIN_9X_OPEN_COMMAND = new String[] {"command.com", "/c", "start", "%1"};
+    static final public String [] WIN_OPEN_COMMAND = new String[] {"cmd.exe", "/c", "start", "\"\"", "%1"};
+
+    static final public String [] MAC_OPEN_COMMAND = new String[] { "open", "%1"};
+
+}
Index: trunk/gsdl3/src/java/org/greenstone/server/StreamGobbler.java
===================================================================
--- trunk/gsdl3/src/java/org/greenstone/server/StreamGobbler.java	(revision 13229)
+++ trunk/gsdl3/src/java/org/greenstone/server/StreamGobbler.java	(revision 13229)
@@ -0,0 +1,28 @@
+package org.greenstone.server;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+class StreamGobbler extends Thread {
+    InputStream is;
+    String type;
+    
+    StreamGobbler(InputStream is, String type) {
+	this.is = is;
+	this.type = type;
+    }
+    
+    public void run() {
+	try {
+	    InputStreamReader isr = new InputStreamReader(is);
+	    BufferedReader br = new BufferedReader(isr);
+	    String line = null;
+	    while ((line = br.readLine()) != null)
+		System.out.println(type + ">" + line);
+	} catch (IOException ioe) {
+	    ioe.printStackTrace();
+	}
+    }
+}
