Index: gs3-extensions/mat/trunk/src/org/greenstone/admin/guiext/ControlPanel.java
===================================================================
--- gs3-extensions/mat/trunk/src/org/greenstone/admin/guiext/ControlPanel.java	(revision 21921)
+++ gs3-extensions/mat/trunk/src/org/greenstone/admin/guiext/ControlPanel.java	(revision 21921)
@@ -0,0 +1,181 @@
+package org.greenstone.admin.guiext.mat;
+
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.GridLayout;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+
+import org.greenstone.admin.guiext.BasePanel;
+
+import org.greenstone.admin.GAI;
+
+public class ControlPanel implements BasePanel
+{
+    JPanel _controlPanel = null;
+    
+    public ControlPanel()
+    {
+	_controlPanel = new JPanel();
+	_controlPanel.setLayout(new BorderLayout());
+
+	Mat mat = new Mat();
+
+	final int left_margin = 7;
+	final int right_margin = 7;
+	final int HORIZONTAL_GAP = 5;
+	final int VERTICAL_GAP = 5;
+
+	String fileSep = System.getProperty("file.separator");
+
+	JButton start_button = new JButton("Analyse");
+	start_button.setPreferredSize(new Dimension(50,25));
+	start_button.setMaximumSize(new Dimension(50,25));
+	start_button.setName("Analyse");
+	start_button.setEnabled(true);
+	start_button.addActionListener(new aListener(mat));
+
+	JLabel oai_temp_directory = new JLabel();
+	oai_temp_directory.setText("OAI temporary download directory:");
+	
+	JTextField oai_temp_directory_text = new JTextField();
+	oai_temp_directory_text.setText(GAI.getGSDL3ExtensionHome() + fileSep + "mat" + fileSep + "tmp");
+	oai_temp_directory_text.setEditable(false);
+	oai_temp_directory_text.setBackground(Color.WHITE);
+	
+	JLabel install_path = new JLabel();
+	install_path.setText("Metadata Quality Tool is installed in:");
+	
+	JTextField install_path_text = new JTextField();
+	install_path_text.setText(GAI.getGSDL3ExtensionHome() + fileSep + "mat");
+	install_path_text.setEditable(false);
+	install_path_text.setBackground(Color.WHITE);	
+
+	JCheckBox web_tool_checkbox = new JCheckBox("Web OAI Collection Building");
+	web_tool_checkbox.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
+	web_tool_checkbox.setVisible(false);
+
+	JCheckBox java_tool_checkbox = new JCheckBox("Local Collection Analysis");
+	java_tool_checkbox.addItemListener(new checkBoxStatus(mat));
+	java_tool_checkbox.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
+	
+	GridLayout gridLayout3 = new GridLayout(3,3);
+	gridLayout3.setVgap(VERTICAL_GAP);
+	JPanel control_content_pane = new JPanel(gridLayout3);
+	control_content_pane.setBorder(BorderFactory.createEmptyBorder(5, left_margin, 5, right_margin));
+	
+	GridLayout gridLayout2 = new GridLayout(1,2);
+	gridLayout2.setHgap(HORIZONTAL_GAP);
+	JPanel control_button_pane = new JPanel(gridLayout2);
+	control_button_pane.setBorder(BorderFactory.createEmptyBorder(5, left_margin, 5, right_margin));
+	
+	GridLayout gridLayout1 = new GridLayout(2,2);
+	gridLayout1.setVgap(VERTICAL_GAP);
+	JPanel control_description_pane = new JPanel(gridLayout1);
+	control_description_pane.setBorder(BorderFactory.createEmptyBorder(5, left_margin, 5, right_margin));
+	
+	JPanel control_pane = new JPanel();
+	control_pane.setLayout(new BoxLayout(control_pane, BoxLayout.Y_AXIS));
+
+	control_content_pane.add(java_tool_checkbox);
+	control_content_pane.add(Box.createRigidArea(new Dimension(10,5)));
+	control_content_pane.add(Box.createRigidArea(new Dimension(10,5)));
+	
+	JPanel tempPane = new JPanel(new BorderLayout());
+	tempPane.add(Box.createRigidArea(new Dimension(18,5)), BorderLayout.WEST);
+	tempPane.add(start_button, BorderLayout.CENTER);
+	control_content_pane.add(tempPane);
+	control_content_pane.add(Box.createRigidArea(new Dimension(10,5)));
+	control_content_pane.add(Box.createRigidArea(new Dimension(10,5)));
+	
+	//control_content_pane.add(web_tool_checkbox);
+	control_content_pane.add(Box.createRigidArea(new Dimension(10,5)));
+	control_content_pane.add(Box.createRigidArea(new Dimension(10,5)));
+	control_content_pane.add(Box.createRigidArea(new Dimension(10,5)));
+
+	control_description_pane.add(install_path);
+	control_description_pane.add(install_path_text);
+	
+	control_description_pane.add(oai_temp_directory);
+	control_description_pane.add(oai_temp_directory_text);
+      	
+	control_content_pane.setAlignmentX(Component.LEFT_ALIGNMENT);
+	control_pane.add(control_content_pane);
+	
+	control_description_pane.setAlignmentX(Component.LEFT_ALIGNMENT);
+	control_pane.add(control_description_pane);
+	
+	control_button_pane.setAlignmentX(Component.LEFT_ALIGNMENT);
+	control_pane.add(control_button_pane);
+	_controlPanel.add(control_pane, BorderLayout.CENTER);
+    }
+    
+    public JPanel getControlPanel()
+    {
+	System.err.println("*x* HERE!");
+	return _controlPanel;
+    }
+
+    class checkBoxStatus implements ItemListener{
+
+	private Mat adaptee;
+	
+	public checkBoxStatus(Mat adaptee){
+	    
+	    this.adaptee = adaptee;
+	}
+	
+	public void itemStateChanged(ItemEvent e) {
+	    
+	    JCheckBox source = (JCheckBox)e.getItemSelectable();
+	    
+	    if (source == adaptee.java_tool_checkbox) {
+		if(source.isSelected()){
+		    adaptee.start_button.setEnabled(true);
+		}
+		else{
+		    adaptee.start_button.setEnabled(false);
+		}
+	    } 
+	    else{
+	    }
+	}
+    }
+
+    class aListener implements ActionListener {
+	
+	private Mat adaptee;
+	
+	aListener(Mat adaptee) {	
+	    this.adaptee = adaptee;
+	}
+    
+	public void actionPerformed(ActionEvent e) {
+	
+	    JButton button = (JButton)e.getSource();
+	
+	    if(button.getName().equalsIgnoreCase("Analyse")){
+		execute_application();
+	    }
+	}
+    
+	public void execute_application(){
+	    MatLaunchApplication app = new MatLaunchApplication(adaptee);
+	    app.start();
+	}
+    }
+}
Index: gs3-extensions/mat/trunk/src/org/greenstone/admin/guiext/Mat.java
===================================================================
--- gs3-extensions/mat/trunk/src/org/greenstone/admin/guiext/Mat.java	(revision 21921)
+++ gs3-extensions/mat/trunk/src/org/greenstone/admin/guiext/Mat.java	(revision 21921)
@@ -0,0 +1,764 @@
+package org.greenstone.admin.guiext.mat;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.GridLayout;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+
+import javax.swing.*;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+//import org.apache.tools.ant.Project;
+//import org.apache.tools.ant.ProjectHelper;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Set;
+
+import org.greenstone.gsdl3.util.GSPath;
+import org.greenstone.gsdl3.util.GlobalProperties;
+
+import org.greenstone.admin.guiext.BaseExt;
+import org.greenstone.admin.guiext.ExtPane;
+import org.greenstone.admin.guiext.ExtXMLHelper;
+import org.greenstone.admin.GAI;
+
+public class Mat extends BaseExt{
+
+    JButton start_button;
+    JButton enable_disable_button;
+    JButton option_button;
+    JButton description_control_button;
+    JButton control_description_button;
+    JPanel description_control_button_pane;
+    
+    JPanel control_content_pane;
+    JPanel control_button_pane;
+    JPanel control_description_pane;
+    
+    JLabel install_path;
+    JLabel oai_temp_directory;
+    JTextField install_path_text;
+    JTextField oai_temp_directory_text;
+    JCheckBox web_tool_checkbox;
+    JCheckBox java_tool_checkbox;
+    SimpleDateFormat sdf;
+		
+    private GlobalProperties globalProperty = null;
+    private final String fileSeparator = File.separator;
+    private GSPath gspath = null;
+    
+    static final int left_margin = 7;
+    static final int right_margin = 7;
+    static final int HORIZONTAL_GAP = 5;
+    static final int VERTICAL_GAP = 5;
+    
+    String install_options_filePath = null;
+    static String extension_list_path;
+    static String extension_buildProperty_path;
+    static String extension_runtimeProperty_path;
+    static String extension_log_path;
+    static String extension_log_directory;
+    static String extension_path;
+    static String os_type;
+    static String oai_folder;
+    static String web_xml_path;
+    static final String InstallCompleteMsg = "The extension (Mat) has been installed successfully.";
+    static final String InstallErrorMsg =  "Sorry, the extension (Mat) could not be installed. Please try again!";
+    
+    static final String DownloadCompleteMsg = "The extension (Mat) has been downloaded successfully.";
+    static final String DownloadErrorMsg =  "Sorry, the extension (Mat) could not be downloaded. Please try again!";
+    
+    public Mat(){}
+    
+    public Mat (String extensionName){
+
+	group = new String();		
+	description = new String();
+	download_type = new String();
+	
+	extension_name = extensionName;
+	url = new String();
+	configurable = new Boolean(false);
+	
+	os_type = System.getProperty("os.name");
+	
+	String gsdl3Home = GAI.getGSDL3Home();
+	
+	extension_list_path = gsdl3Home+fileSeparator+"ext"+fileSeparator+"extension_project_list.xml";
+	extension_buildProperty_path = gsdl3Home+fileSeparator+"ext"+fileSeparator+"mat"+fileSeparator+"build.properties";
+	extension_runtimeProperty_path = gsdl3Home+fileSeparator+"ext"+fileSeparator+"mat"+fileSeparator+"properties.xml";
+	extension_log_path = gsdl3Home+fileSeparator+"ext"+fileSeparator+"logs"+fileSeparator+"mat"+fileSeparator+"extension_log.xml";
+	extension_log_directory = gsdl3Home+fileSeparator+"ext"+fileSeparator+"logs"+fileSeparator+"mat";
+	extension_path = gsdl3Home+fileSeparator+"ext"+fileSeparator+"Mat"+fileSeparator;
+	oai_folder = gsdl3Home+fileSeparator+"ext"+fileSeparator+"mat"+fileSeparator+"tmp"+fileSeparator;
+	web_xml_path = gsdl3Home+fileSeparator+"web"+fileSeparator+"WEB-INF"+fileSeparator+"web.xml";
+	
+	start_button = new JButton("Analyse");
+	start_button.setPreferredSize(new Dimension(50,25));
+	start_button.setMaximumSize(new Dimension(50,25));
+	start_button.setName("Analyse");
+	start_button.setEnabled(false);
+	start_button.addActionListener(new aListener(this));
+		
+	enable_disable_button = new JButton("Enable");
+	enable_disable_button.setName("enable_disable");
+	enable_disable_button.setVisible(false);
+	enable_disable_button.addActionListener(new aListener(this));
+	enable_disable_button.setPreferredSize(new Dimension(50,25));
+	enable_disable_button.setMaximumSize(new Dimension(50,25));
+	
+	option_button = new JButton("Options");
+	option_button.setName("options");
+	option_button.addActionListener(new aListener(this));
+	
+	control_description_button = new JButton("Description");
+	control_description_button.setName("control_description");
+	control_description_button.addActionListener(new aListener(this));
+	
+	description_control_button = new JButton("Control Panel");
+	description_control_button.setName("description_control");
+	description_control_button.addActionListener(new aListener(this));
+	description_control_button.setEnabled(getCommandStatus("install"));
+	description_control_button_pane = new JPanel(new GridLayout(1,3));
+	
+	description_pane = new JScrollPane ();
+	control_pane = new JPanel ();
+	descriptionTextArea = new JTextArea();
+	button_pane = new JPanel();
+
+	oai_temp_directory = new JLabel();
+	oai_temp_directory.setText("OAI temporary download directory:");
+	oai_temp_directory_text = new JTextField();
+	oai_temp_directory_text.setText(oai_folder);
+	oai_temp_directory_text.setEditable(false);
+	oai_temp_directory_text.setBackground(Color.WHITE);
+	
+	install_path = new JLabel();
+	install_path.setText("Metadata Quality Tool is installed in:");
+	install_path_text = new JTextField();
+	install_path_text.setText(extension_path);
+	install_path_text.setEditable(false);
+	install_path_text.setBackground(Color.WHITE);
+		
+	web_tool_checkbox = new JCheckBox("Web OAI Collection Building");
+	web_tool_checkbox.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
+	web_tool_checkbox.setVisible(false);
+	java_tool_checkbox = new JCheckBox("Local Collection Analysis");
+	java_tool_checkbox.addItemListener(new checkBoxStatus(this));
+	java_tool_checkbox.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
+	
+	GridLayout gridLayout3 = new GridLayout(3,3);
+	gridLayout3.setVgap(VERTICAL_GAP);
+	control_content_pane = new JPanel(gridLayout3);
+	control_content_pane.setBorder(BorderFactory.createEmptyBorder(5, left_margin, 5, right_margin));
+	
+	GridLayout gridLayout2 = new GridLayout(1,2);
+	gridLayout2.setHgap(HORIZONTAL_GAP);
+	control_button_pane = new JPanel(gridLayout2);
+	control_button_pane.setBorder(BorderFactory.createEmptyBorder(5, left_margin, 5, right_margin));
+	
+	GridLayout gridLayout1 = new GridLayout(2,2);
+	gridLayout1.setVgap(VERTICAL_GAP);
+	control_description_pane = new JPanel(gridLayout1);
+	control_description_pane.setBorder(BorderFactory.createEmptyBorder(5, left_margin, 5, right_margin));
+	
+	control_pane = new JPanel();
+	control_pane.setLayout(new BoxLayout(control_pane, BoxLayout.Y_AXIS));
+	
+	//setup();
+	setupControlPane();
+	loadProjectInformation();
+
+
+    };
+    
+    public JPanel getControlPane(){
+
+	return control_pane;
+    }
+
+    public JPanel getButtonPane(){
+	return button_pane;
+    }
+   
+    public JPanel getDescriptionPane(){
+	
+	
+	description_control_button_pane.add(Box.createRigidArea(new Dimension(18,5)));
+	description_control_button_pane.add(description_control_button);
+	description_control_button_pane.add(Box.createRigidArea(new Dimension(18,5)));
+	
+	main_pane = new JPanel(new BorderLayout());
+	main_pane.add(description_pane, BorderLayout.CENTER);
+	main_pane.add(description_control_button_pane, BorderLayout.SOUTH);
+	return main_pane;
+	
+    }
+	
+    private void setupControlPane(){
+	
+	control_content_pane.add(java_tool_checkbox);
+	control_content_pane.add(Box.createRigidArea(new Dimension(10,5)));
+	control_content_pane.add(Box.createRigidArea(new Dimension(10,5)));
+	
+	JPanel tempPane = new JPanel(new BorderLayout());
+	tempPane.add(Box.createRigidArea(new Dimension(18,5)), BorderLayout.WEST);
+	tempPane.add(start_button, BorderLayout.CENTER);
+	control_content_pane.add(tempPane);
+	control_content_pane.add(Box.createRigidArea(new Dimension(10,5)));
+	control_content_pane.add(Box.createRigidArea(new Dimension(10,5)));
+
+	
+	//control_content_pane.add(web_tool_checkbox);
+	control_content_pane.add(Box.createRigidArea(new Dimension(10,5)));
+	control_content_pane.add(Box.createRigidArea(new Dimension(10,5)));
+	control_content_pane.add(Box.createRigidArea(new Dimension(10,5)));
+	/*
+	  JPanel tempPane2 = new JPanel(new BorderLayout());
+	  tempPane2.add(Box.createRigidArea(new Dimension(18,5)), BorderLayout.WEST);
+	  tempPane2.add(enable_disable_button, BorderLayout.CENTER);
+	  control_content_pane.add(tempPane2);
+	  control_content_pane.add(Box.createRigidArea(new Dimension(10,5)));
+	  control_content_pane.add(Box.createRigidArea(new Dimension(10,5)));
+	*/
+	control_description_pane.add(install_path);
+	control_description_pane.add(install_path_text);
+	
+	control_description_pane.add(oai_temp_directory);
+	control_description_pane.add(oai_temp_directory_text);
+	
+	control_button_pane.add(control_description_button);
+	control_button_pane.add(option_button);
+	
+	control_content_pane.setAlignmentX(Component.LEFT_ALIGNMENT);
+	control_pane.add(control_content_pane);
+	
+	control_description_pane.setAlignmentX(Component.LEFT_ALIGNMENT);
+	control_pane.add(control_description_pane);
+	
+	control_button_pane.setAlignmentX(Component.LEFT_ALIGNMENT);
+	control_pane.add(control_button_pane);
+	
+    }
+
+    public boolean doCallback(String methodName)
+    {
+	return false;
+    }
+	
+    protected Object[][] getConfigureContent(){
+	
+	return null;
+    
+    }
+    	
+    public Boolean isConfigurable(){
+	
+	return configurable ;
+    
+    }
+
+    public String getDestinationLocation(){
+	
+	return destination_folder;
+    }
+    
+    public String getDownloadLocation(){
+	
+	return url;
+    
+    }
+	
+    public String getDownloadType(){
+	
+	return download_type;
+    
+    }
+
+    protected void loadProjectInformation(){
+        /*
+	  Element rootNode = getRootElement(extension_list_path);
+	
+	  NodeList projectNodeList = rootNode.getElementsByTagName(EXTENSION);
+        
+	  for(int i = 0; i < projectNodeList.getLength(); i++){
+	    
+	  Element projectNode = (Element)projectNodeList.item(i);
+	  NodeList nameNodeList = projectNode.getElementsByTagName(NAME);
+	  String name = nameNodeList.item(0).getChildNodes().item(0).getNodeValue();
+	    
+	  if(name.equalsIgnoreCase(extension_name)){	
+	  NodeList groupNodeList = projectNode.getElementsByTagName(GROUP);
+	  group = groupNodeList.item(0).getChildNodes().item(0).getNodeValue();
+           	
+           	
+	  NodeList stepList = projectNode.getElementsByTagName(STEP);
+	  GridLayout gl = new GridLayout(stepList.getLength(),1);
+	  gl.setVgap(5);
+	  button_pane.setLayout(gl);
+		
+	  for (int y = 0; y< stepList.getLength(); y++){
+		    
+	  Node e = stepList.item(y);
+	  Element stepElement = (Element) e;
+	  JButton button = new JButton();
+	  String command = stepElement.getAttribute("action");
+	  button.setText(stepElement.getAttribute("label"));
+	  button.setName(command);
+				
+	  button.addActionListener(new aListener(this));
+	  boolean status = getCommandStatus(command);
+	  button.setEnabled(status);
+
+	  if(stepElement.getAttribute("action").equalsIgnoreCase(DOWNLOAD)){
+	  download_type = stepElement.getAttribute("method");
+	  url = stepElement.getElementsByTagName("source").item(0).getChildNodes().item(0).getNodeValue();
+	  //destination_folder = stepElement.getElementsByTagName("destination").item(0).getChildNodes().item(0).getNodeValue();
+	  destination_folder = extension_path;
+	  }
+		    
+	  if(stepElement.getAttribute("action").equalsIgnoreCase("Install_option")){
+	  //install_options_filePath = stepElement.getAttribute("filePath");
+	  install_options_filePath = extension_path+"build.properties";
+	  }
+	  button_pane.add(button);
+	  }
+	  }
+	    
+	  }
+	*/
+    }
+    
+    public boolean getCommandStatus (String command){
+
+     	Element root = getRootElement(extension_list_path);
+
+    	NodeList extensionList = root.getElementsByTagName("extension");
+	
+    	boolean s = false;
+	
+    	for(int i = 0; i < extensionList.getLength(); i++){
+	    
+    	    Element projectNode = (Element)extensionList.item(i);
+    	    NodeList nameNodeList = projectNode.getElementsByTagName(ExtXMLHelper.NAME);
+    	    String name = nameNodeList.item(0).getChildNodes().item(0).getNodeValue();
+	    
+	    if(name.equalsIgnoreCase(extension_name)){	
+    		
+		Element actionElement = (Element)extensionList.item(0);
+		NodeList individual_extension_detail_list = actionElement.getElementsByTagName("sequence_list");
+		Node sequenceListNode = individual_extension_detail_list.item(0);
+		NodeList sequenceDetailList = sequenceListNode.getChildNodes();
+		
+		for(int j = 0; j < sequenceDetailList.getLength(); j++){
+		    Node n = sequenceDetailList.item(j);
+		    
+		    if(n instanceof Element){
+    			
+			Element e = (Element)n;
+			if(e.getAttribute("action").equalsIgnoreCase(command)){
+			    String status = e.getAttribute("status");
+			    
+			    Boolean bv = Boolean.valueOf(status);
+			    s = bv.booleanValue();
+			}
+		    }
+		}
+	    }
+	}//
+	return s;
+    }
+
+    public void updateButtonPane(){
+    	
+	String gsdl3Home = GAI.getGSDL3Home();
+    	Element root = getRootElement(extension_list_path);
+	NodeList extensionList = root.getElementsByTagName("extension");
+    	    	
+    	for(int a = 0; a < extensionList.getLength(); a++){
+	    
+    	    Element projectNode = (Element)extensionList.item(a);
+    	    NodeList nameNodeList = projectNode.getElementsByTagName(ExtXMLHelper.NAME);
+    	    String name = nameNodeList.item(0).getChildNodes().item(0).getNodeValue();
+    	    if(name.equalsIgnoreCase(extension_name)){	
+    	    	//System.out.println(extension_name);
+		NodeList actionList = projectNode.getElementsByTagName("sequence_list");
+		//System.out.println(actionList.getLength());
+		Node x  = actionList.item(0);
+		NodeList stepList = x.getChildNodes();
+		
+		for(int i = 0; i<stepList.getLength(); i++){
+		    Node n = stepList.item(i);
+		    if(n instanceof Element){
+			Element actionElement = (Element) n;
+			
+			String action = actionElement.getAttribute("action");
+			boolean status = getCommandStatus(action);
+				
+			Component[] c = button_pane.getComponents();
+			
+		    	for(int j = 0; j<c.length; j++){
+			    JButton button = (JButton)c[j];
+			    if(button.getName().equalsIgnoreCase(action)){
+				button.setEnabled(status);
+				button_pane.updateUI();
+			    }
+		    	}
+		    }
+		    
+		}///
+	    }
+    	}
+	
+    }
+    
+    public void setCommandStatus(String command){
+    	
+    	String gsdl3Home = GAI.getGSDL3Home();
+    	Element root = getRootElement(extension_list_path);
+    	NodeList actionList = root.getElementsByTagName("sequence_list");
+	
+    	if(command.equalsIgnoreCase("download")){
+	    
+	    Node x  = actionList.item(0);
+	    NodeList stepList = x.getChildNodes();
+	    
+	    for(int i = 0; i<stepList.getLength(); i++){
+		Node n = stepList.item(i);
+		if(n instanceof Element){
+		    Element actionElement = (Element) n;
+		    
+		    String action = actionElement.getAttribute("action");
+		    
+		    if(!action.equalsIgnoreCase(command)){
+    			
+			String status = actionElement.getAttribute("status");
+			actionElement.setAttribute("status", "true");
+		    }
+    		}
+	    }
+	}
+    	
+    	else if(command.equalsIgnoreCase("uninstall")){
+    	    Node x  = actionList.item(0);
+    	    NodeList stepList = x.getChildNodes();
+    	    
+    	    for(int i = 0; i<stepList.getLength(); i++){
+    		Node n = stepList.item(i);
+    		if(n instanceof Element){
+    		    Element actionElement = (Element) n;
+    		    
+    		    String action = actionElement.getAttribute("action");
+    		    
+    		    if(!action.equalsIgnoreCase("download")){
+        			
+    			String status = actionElement.getAttribute("status");
+			actionElement.setAttribute("status", "false");
+    		    }
+        	}
+    	    }
+    	}
+    	
+	try{
+	    TransformerFactory tf= TransformerFactory.newInstance();     
+	    Transformer transformer= tf.newTransformer();     
+	    DOMSource source= new DOMSource(root);     
+	    transformer.setOutputProperty(OutputKeys.INDENT,"yes");     
+	    
+	    Writer pwx= new  BufferedWriter(new OutputStreamWriter(new FileOutputStream(extension_list_path),"UTF-8"));     
+	    StreamResult   result= new   StreamResult(pwx);     
+	    transformer.transform(source,result);  
+	    pwx.close();
+	    
+	    updateButtonPane();
+    	}catch(Exception ex){
+	    ex.printStackTrace();
+    	}
+    }
+    
+    public Object[][] getConfiguration(String filePath){
+    	
+    	try{
+	    Properties prop = new Properties();
+	    FileInputStream fis = new FileInputStream(filePath);
+	    prop.load(fis);
+	    Set s = prop.keySet();
+	    Object[][] properties = new Object[prop.size()][2];
+	    Iterator i = s.iterator();
+	    int counter = 0;
+	    
+	    while(i.hasNext()){
+        	String setting = (String)i.next();
+        	String value = prop.getProperty(setting);
+		
+    		properties[counter][0] = setting;
+    		properties[counter][1] = value;
+    		counter++;
+	    }
+	    
+	    return properties;
+    	}catch(IOException ex){
+	    ex.printStackTrace();
+	    return new Object[0][0];
+    	}
+    }
+}
+
+class checkBoxStatus implements ItemListener{
+
+    private Mat adaptee;
+    
+    public checkBoxStatus(Mat adaptee){
+	
+	this.adaptee = adaptee;
+    }
+    
+    public void itemStateChanged(ItemEvent e) {
+	
+	JCheckBox source = (JCheckBox)e.getItemSelectable();
+	
+	if (source == adaptee.java_tool_checkbox) {
+	    if(source.isSelected()){
+		adaptee.start_button.setEnabled(true);
+	    }
+	    else{
+		adaptee.start_button.setEnabled(false);
+	    }
+	} 
+	else{
+	}
+    }
+}
+
+class aListener implements ActionListener {
+    
+    private Mat adaptee;
+    Calendar cl;
+    SimpleDateFormat sdf;
+    private final String fileSeparator = File.separator;
+    
+    aListener(Mat adaptee) {
+	
+	this.adaptee = adaptee;
+    	cl=Calendar.getInstance(); 
+    	sdf = new SimpleDateFormat("dd/MMM/yyyy 'at' HH:mm:ss z 'GMT'Z");
+    }
+    
+    public void actionPerformed(ActionEvent e) {
+	
+	JButton button = (JButton)e.getSource();
+	
+	if(button.getName().equalsIgnoreCase("Download")){
+	    downloadExtension();
+	    
+	    String msg = createInfoMsg(button.getName());
+	    String timestamp = getTimestamp();
+	
+	    //updateLOG("Download",msg , timestamp);
+	    //adaptee.setCommandStatus("Download");
+	}
+	else if(button.getName().equalsIgnoreCase("control_description") || button.getName().equalsIgnoreCase("description_control")){
+	    ExtPane.updateExtensionContentPane();
+	}
+	else if(button.getName().equalsIgnoreCase("options")){
+	    configure_option();
+	}
+	else if(button.getName().equalsIgnoreCase("Install")){
+	    installExtension();
+	    String msg = createInfoMsg(button.getName());
+	    String timestamp = getTimestamp();
+	    //updateLOG("Install", msg , timestamp);
+	}
+	else if(button.getName().equalsIgnoreCase("Install_option")){
+	    //System.out.println("--------install options-------------");
+	    install_configuration();
+	}
+	else if(button.getName().equalsIgnoreCase("Analyse")){
+	    execute_application();
+	}
+	else if(button.getName().equalsIgnoreCase("Uninstall")){
+	    String msg = createInfoMsg(button.getName());
+	    String timestamp = getTimestamp();
+	    uninstallExtension();
+	    adaptee.setCommandStatus("Uninstall");
+	    updateLOG("Unistall", msg , timestamp);
+	}
+	else if(button.getName().equalsIgnoreCase("disable")){
+	    String msg = createInfoMsg(button.getName());
+	    String timestamp = getTimestamp();
+	    updateLOG("Disable", msg , timestamp);
+	}
+	else if(button.getName().equalsIgnoreCase("enable")){
+	    String msg = createInfoMsg(button.getName());
+	    String timestamp = getTimestamp();
+	    updateLOG("Enable", msg , timestamp);
+	}
+    }
+    
+    public void uninstallExtension(){
+    	File temp = new File(adaptee.extension_path);
+    	deleteDir(temp);
+    }
+    
+    private static boolean deleteDir(File dir) {
+        
+    	if (dir.isDirectory()) {
+	    String[] children = dir.list();
+	    for (int i=0; i<children.length; i++) {
+		boolean success = deleteDir(new File(dir, children[i]));
+		if (!success) {
+		    return false;
+		}
+	    }
+	}
+    	return dir.delete();
+    } 
+
+
+    public void downloadExtension(){	
+	MatSVNDownloadThread download = new MatSVNDownloadThread(adaptee, ExtPane.message_textarea ,adaptee.url, adaptee.destination_folder, adaptee.extension_name);
+	download.start();
+    }
+
+    public void installExtension(){
+	MatExtensionInstallation ei = new MatExtensionInstallation(adaptee);
+	ei.start();
+	adaptee.description_control_button.setEnabled(adaptee.getCommandStatus("install"));
+    }
+    
+    public void install_configuration(){
+	File buildProperty = new File (adaptee.install_options_filePath);
+	if(!buildProperty.exists()) { return; }
+	Object[][] temp = adaptee.getConfiguration(adaptee.install_options_filePath);
+	MatExtensionConfigurePrompt ecp = new MatExtensionConfigurePrompt(temp,adaptee.install_options_filePath,adaptee.extension_name,"Configure Install Settings");
+	ecp.display();
+    }
+    
+    public void configure_option(){
+	String gsdl3Home = GAI.getGSDL3Home();//used to be: adaptee.get_GSDL3HOME(); //xxxxx
+	File buildProperty = new File (adaptee.extension_runtimeProperty_path);
+	if(!buildProperty.exists()) { return; }
+	Object[][] temp = adaptee.getConfiguration(adaptee.extension_runtimeProperty_path);
+	MatExtensionConfigurePrompt ecp = new MatExtensionConfigurePrompt(temp,adaptee.extension_runtimeProperty_path,adaptee.extension_name,"Configure Runtime Settings");
+	ecp.display();
+    }
+    
+    public void execute_application(){
+	MatLaunchApplication app = new MatLaunchApplication(adaptee);
+	app.start();
+    }
+	
+    public String createInfoMsg(String step){
+	
+	String info = new String();
+	
+	if(step.equalsIgnoreCase(ExtXMLHelper.DOWNLOAD)){
+	    info = "The extension Mat has been downloaded to local folder";
+	}
+	else if (step.equalsIgnoreCase(ExtXMLHelper.INSTALL)){
+	    info = "The extension Mat has been installed";
+	}
+	else if (step.equalsIgnoreCase(ExtXMLHelper.UNINSTALL)){
+	    info = "The extension Mat has been uninstalled";
+	}
+	else if (step.equalsIgnoreCase(ExtXMLHelper.ENABLE)){
+	    info = "The OAI Web Building has been enabled";
+	}
+	else if (step.equalsIgnoreCase(ExtXMLHelper.DISABLE)){
+	    info = "The OAI Web Building has been disabled";
+	}
+	
+	return info;
+    }
+    
+    public String getTimestamp(){
+	
+	String timestamp = sdf.format(cl.getTime());
+	return timestamp;
+    }
+    
+    public void updateLOG(String type , String info, String timestamp){
+
+    	Element root = null;
+	
+	try{
+	    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+	    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
+	    Document doc = docBuilder.newDocument();
+	    String gsdl3Home = GAI.getGSDL3Home();
+	    
+	    File logFile = new File(adaptee.extension_log_path);
+	    boolean fileExist = logFile.exists();
+	    
+	    File logDir = new File(adaptee.extension_log_directory);
+	    if(logDir.mkdirs()){}
+
+	    if(!fileExist){
+	    	logFile.createNewFile();
+	    	root = doc.createElement("log");
+	    }
+	    else{
+		
+		doc = docBuilder.parse (new File(adaptee.extension_log_path));
+		root = doc.getDocumentElement();
+	    }
+	    
+	    Element actElement = doc.createElement("action");
+	    actElement.setAttribute("type", type);
+	    Element timeElement = doc.createElement("time");
+	    Element infoElement = doc.createElement("info");
+	    Text text_info = doc.createTextNode(info);
+	    infoElement.appendChild(text_info);
+		    
+	    Text text_time = doc.createTextNode(timestamp);
+	    timeElement.appendChild(text_time);
+	    actElement.appendChild(infoElement);
+	    actElement.appendChild(timeElement);
+	    root.appendChild(actElement);
+		    
+	    TransformerFactory tf= TransformerFactory.newInstance();     
+	    Transformer transformer= tf.newTransformer();     
+	    DOMSource source= new DOMSource(root);     
+	    transformer.setOutputProperty(OutputKeys.INDENT,"yes");     
+			
+	    Writer pwx= new  BufferedWriter(new OutputStreamWriter(new FileOutputStream(adaptee.extension_log_path),"UTF-8"));     
+	    StreamResult   result= new   StreamResult(pwx);     
+	    transformer.transform(source,result);  
+	    pwx.close();
+	    
+	}catch(Exception ex){
+	    ex.printStackTrace();
+	}
+    }
+}
Index: gs3-extensions/mat/trunk/src/org/greenstone/admin/guiext/MatExtensionConfigurePrompt.java
===================================================================
--- gs3-extensions/mat/trunk/src/org/greenstone/admin/guiext/MatExtensionConfigurePrompt.java	(revision 21921)
+++ gs3-extensions/mat/trunk/src/org/greenstone/admin/guiext/MatExtensionConfigurePrompt.java	(revision 21921)
@@ -0,0 +1,226 @@
+package org.greenstone.admin.guiext.mat;
+
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.*;
+import org.greenstone.admin.Configuration;
+import javax.swing.*;
+import javax.swing.table.AbstractTableModel;
+import javax.swing.table.TableCellRenderer;
+
+import org.greenstone.admin.guiext.ExtPane;
+
+public class MatExtensionConfigurePrompt extends JFrame {
+
+    JPanel main_pane;
+    JScrollPane table_pane;
+    JTable configure_table;
+    
+    JButton save_button;
+    JButton cancel_button;
+    JPanel control_pane;
+    JPanel button_pane;
+	
+    JLabel prompt_title;
+    JPanel label_pane;
+    
+    String heading;
+    String destination;
+
+    static final String Setting = "setting";
+    static final String Value = "value";
+    static final String Property = "property";
+    
+    Object[][] data;
+    String title;
+    
+    public MatExtensionConfigurePrompt(Object[][] o, String directory, String extensionName, String titleString){
+
+	String[] columnNames = {"Setting","Value"};
+
+	title = titleString;
+	data = o;
+	destination = directory;
+	
+	main_pane = new JPanel();
+	main_pane.setBorder(BorderFactory.createLoweredBevelBorder());
+	main_pane.setBackground(Configuration.getColor("coloring.workspace_selection_background"));
+	main_pane.setForeground(Configuration.getColor("coloring.workspace_selection_foreground"));
+	
+	configure_table = new JTable(new MyTableModel(columnNames, data)){		
+		public Component prepareRenderer (TableCellRenderer renderer, int rowIndex, int colIndex){
+		    Component c = super.prepareRenderer(renderer, rowIndex, colIndex);
+		    if (colIndex == 0) {
+			c.setBackground(Configuration.getColor("coloring.table_noneditable_background"));
+		    } else {
+			c.setBackground(Configuration.getColor("coloring.table_editable_background"));
+		    }
+		    
+		    return c;
+		}};
+	configure_table.setIntercellSpacing(new Dimension(ExtPane.left_padding,0));
+	table_pane = new JScrollPane(configure_table);
+	table_pane.setVisible(true);
+	
+	save_button = new JButton("Save");
+	save_button.addActionListener(new Save_button_Adapter(this));
+	
+	cancel_button= new JButton("Cancel");
+	cancel_button.addActionListener(new Cancel_button_Adapter(this));
+	button_pane = new JPanel();
+	button_pane.setLayout(new GridLayout(1,2));
+	button_pane.add(save_button);
+	button_pane.add(cancel_button);
+	
+	control_pane = new JPanel();
+	control_pane.setLayout (new BorderLayout());
+	control_pane.setBorder(BorderFactory.createEmptyBorder(05,10,5,10));
+	control_pane.add (button_pane, BorderLayout.CENTER);
+	
+	prompt_title = new JLabel();
+	prompt_title.setOpaque(true);
+	prompt_title.setBackground(Configuration.getColor("coloring.workspace_selection_background"));
+	prompt_title.setForeground(Configuration.getColor("coloring.workspace_selection_foreground"));
+	prompt_title.setText(extensionName);
+	prompt_title.setBorder(BorderFactory.createEmptyBorder(0, ExtPane.left_padding, 0, 0));
+    }
+    
+    
+    class MyTableModel extends AbstractTableModel {
+	
+    	private String [] columnNames;
+    	private Object[][] data;
+	
+    	public MyTableModel(String[] s , Object[][]o){
+	    columnNames = s;
+	    data = o;
+    	}
+	
+        public int getColumnCount() {
+            return columnNames.length;
+        }
+	
+        public int getRowCount() {
+            return data.length;
+        }
+
+        public String getColumnName(int col) {
+            return columnNames[col];
+        }
+
+        public Object getValueAt(int row, int col) {
+            return data[row][col];
+        }
+
+
+        public Class getColumnClass(int c) {
+            return getValueAt(0, c).getClass();
+        }
+
+	public boolean isCellEditable(int row, int col) {
+	    if (col < 1) {
+                return false;
+            } else {
+                return true;
+            }
+        }
+	
+        public void setValueAt(Object value, int row, int col) {
+        	if(isCellEditable(row, col)){
+		    data[row][col] = value;
+        	}
+        }
+    }
+    
+    public void display(){
+	
+	main_pane.setLayout(new BorderLayout());
+	main_pane.add(prompt_title, BorderLayout.NORTH);
+	main_pane.add(table_pane, BorderLayout.CENTER);
+	main_pane.add(control_pane, BorderLayout.SOUTH);
+		
+	this.getContentPane().add(main_pane);
+	//this.setPreferredSize(new Dimension(500,300));
+	this.setSize(new Dimension(500,300));
+	this.setVisible(true);
+	this.setTitle(title);
+	this.pack();
+	this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+	
+    }
+
+    public void cancel_button_actionPerformed(ActionEvent actionevent){
+    	
+	this.dispose();
+
+    }
+    
+    public void save_button_actionPerformed(ActionEvent actionevent){
+    	
+	this.saveConfiguration();
+    	this.dispose();
+    
+    }
+   
+    
+    private void saveConfiguration(){
+    	
+    	File propertyFile = new File(destination);
+	boolean fileExists = propertyFile.exists();
+	Writer writer = null;
+ 	
+	if(fileExists){
+	    try{
+		propertyFile.delete();
+		propertyFile.createNewFile();
+		writer = new BufferedWriter(new FileWriter(propertyFile));
+ 	    	
+		for(int i = 0; i< data.length; i++){
+		    String setting = (String)data[i][0];
+		    String value = (String) data[i][1];
+		    writer.write(setting + " = " + value+"\n\n");
+		}
+		
+		writer.close();
+		}catch (IOException ex){
+		ex.printStackTrace();
+	    }
+	}
+	else{
+	    String errMsg ="These settings cannot be saved.";
+	    JOptionPane.showMessageDialog(new JFrame(),errMsg);
+	}
+    }
+}
+
+class Cancel_button_Adapter implements ActionListener {
+    
+    private MatExtensionConfigurePrompt adaptee;
+    
+    Cancel_button_Adapter(MatExtensionConfigurePrompt adaptee) {
+        this.adaptee = adaptee;
+    }
+    
+    public void actionPerformed(ActionEvent e) {
+        adaptee.cancel_button_actionPerformed(e);
+    }
+}
+
+class Save_button_Adapter implements ActionListener {
+    
+    private MatExtensionConfigurePrompt adaptee;
+    
+    Save_button_Adapter(MatExtensionConfigurePrompt adaptee) {
+        this.adaptee = adaptee;
+    }
+    
+    public void actionPerformed(ActionEvent e) {
+        adaptee.save_button_actionPerformed(e);
+    }
+}
+
+
Index: gs3-extensions/mat/trunk/src/org/greenstone/admin/guiext/MatExtensionInstallation.java
===================================================================
--- gs3-extensions/mat/trunk/src/org/greenstone/admin/guiext/MatExtensionInstallation.java	(revision 21921)
+++ gs3-extensions/mat/trunk/src/org/greenstone/admin/guiext/MatExtensionInstallation.java	(revision 21921)
@@ -0,0 +1,222 @@
+package org.greenstone.admin.guiext.mat;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.GridLayout;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+
+import javax.swing.*;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Set;
+
+import java.awt.BorderLayout;
+import javax.swing.JFrame;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.DefaultStyledDocument;
+import javax.swing.text.SimpleAttributeSet;
+import javax.swing.text.Style;
+import javax.swing.text.StyleConstants;
+import javax.swing.text.StyleContext;
+import javax.swing.text.StyledDocument;
+import java.io.DataInputStream;
+import java.io.*;
+import java.awt.Insets;
+
+import org.greenstone.gsdl3.util.GSPath;
+import org.greenstone.gsdl3.util.GlobalProperties;
+
+import org.greenstone.admin.guiext.ExtPane;
+import org.greenstone.admin.GAI;
+
+class MatExtensionInstallation extends Thread {
+    
+    Mat adaptee;
+	
+    public MatExtensionInstallation (Mat m){
+	adaptee = m;
+    }
+    
+    public void run() {
+    	try{
+	    
+	    String gsdl3Home = GAI.getGSDL3Home();
+	    String fileSeparator = File.separator;
+            
+	    File wd = new File(adaptee.extension_path);
+	    Process proc = null;
+	    
+	    try {
+		
+		if(adaptee.os_type.toLowerCase().indexOf("windows")!=-1){
+		    String[] arrays = {"ant.bat", "compile"};
+		    proc = Runtime.getRuntime().exec(arrays, null, wd);
+		}
+		
+		else{
+		    proc = Runtime.getRuntime().exec("ant compile", null, wd);
+		}
+		
+		BufferedReader stdInput = new BufferedReader(new InputStreamReader(proc.getInputStream()));
+		BufferedReader errInput = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
+		String s= "";
+		
+		ExtPane.message_textarea.setText("");
+		
+		while ((s = stdInput.readLine()) != null) {
+		    ExtPane.message_textarea.append(s+"\n");
+		    ExtPane.message_textarea.setSelectionEnd(ExtPane.message_textarea.getDocument().getLength());
+		}  
+		
+		while ((s = errInput.readLine()) != null) {
+   		   ExtPane.message_textarea.append(s+"\n");
+		   JOptionPane.showMessageDialog(new JFrame(),adaptee.InstallErrorMsg);	
+		  return;
+		}  
+		
+		ExtPane.message_textarea.append(adaptee.InstallCompleteMsg+"\n");
+		
+		Calendar cl;
+		SimpleDateFormat sdf;    
+		cl=Calendar.getInstance(); 
+		sdf = new SimpleDateFormat("dd/MMM/yyyy 'at' HH:mm:ss z 'GMT'Z");
+		String timestamp = sdf.format(cl.getTime());
+		
+		ExtPane.message_textarea.append(timestamp);
+		proc.waitFor();
+		JTextPaneStyle msgpane  = new JTextPaneStyle(adaptee.extension_path,adaptee.web_xml_path);
+		msgpane.display();
+
+		ExtPane.updateExtensionContentPane();
+		
+	    } catch (Exception e) {
+		JOptionPane.showMessageDialog(new JFrame(),adaptee.InstallErrorMsg+" \"Ant\" could not be run.\n Please run gs3-setup");	
+	    }
+	    
+    	}catch(Exception ex){
+	    ex.printStackTrace();
+    	}
+    }
+} 
+
+
+class JTextPaneStyle implements ActionListener{
+
+    private static String message ="";
+    
+    JFrame frame = new JFrame("The extension (Mat) has been installed.");
+    private String filePath;
+    private String webPath;
+
+    public JTextPaneStyle (String path, String web_xml_path){
+	filePath = path + "README.txt";
+	webPath = web_xml_path;
+	loadReadMe();
+    }
+
+    public void loadReadMe(){
+		message = new String();
+
+       	try{
+
+			FileInputStream fstream = new FileInputStream(filePath);
+			DataInputStream in = new DataInputStream(fstream);
+			BufferedReader br = new BufferedReader(new InputStreamReader(in));
+			String strLine;
+
+			while ((strLine = br.readLine()) != null)   {
+				if(strLine.indexOf("web@xml@path")!=-1){
+				webPath = webPath.replaceAll("\\\\","@");
+				strLine = strLine.replaceAll("web@xml@path",webPath);
+				strLine = strLine.replaceAll("@","\\\\");
+				}
+				message = message+ "\n "+ strLine;
+			}
+
+			in.close();
+    	}catch (Exception e){
+			System.err.println("Error: " + e.getMessage());
+    	}
+	}
+
+	public void display() {
+
+	    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+	    frame.setSize(new Dimension(550, 450));
+	    JPanel mainPane = new JPanel(new BorderLayout());
+	    JTextArea textPane = new JTextArea(message);
+	    textPane.setEditable(false);
+		textPane.setLineWrap(true);
+		textPane.setWrapStyleWord(true);
+		textPane.setMargin(new Insets(0,ExtPane.left_padding,0,0));
+	    JScrollPane scrollPane = new JScrollPane(textPane);
+	    mainPane.add(scrollPane,BorderLayout.CENTER);
+		JPanel button_pane = new JPanel(new GridLayout(1,3));
+
+	
+	    JButton jbutton = new JButton("OK");
+		
+		button_pane.add(Box.createRigidArea(new Dimension(18,5)));
+		button_pane.add(jbutton);
+		button_pane.add(Box.createRigidArea(new Dimension(18,5)));
+		
+	    jbutton.addActionListener(this);
+	    mainPane.add(button_pane,BorderLayout.SOUTH);
+	    frame.getContentPane().add(mainPane, BorderLayout.CENTER);
+	    frame.setVisible(true);
+	  }
+
+	public void actionPerformed(ActionEvent e) {
+		writeReadMe();
+		frame.dispose();
+	}
+	
+	
+	
+	public void writeReadMe(){
+       	try{
+			FileWriter fstream = new FileWriter(filePath);
+			BufferedWriter br = new BufferedWriter(fstream);
+			br.write(message);
+			br.close();
+    	}catch (Exception e){
+			System.err.println("Error: " + e.getMessage());
+    	}
+	}
+}
+
+
Index: gs3-extensions/mat/trunk/src/org/greenstone/admin/guiext/MatLaunchApplication.java
===================================================================
--- gs3-extensions/mat/trunk/src/org/greenstone/admin/guiext/MatLaunchApplication.java	(revision 21921)
+++ gs3-extensions/mat/trunk/src/org/greenstone/admin/guiext/MatLaunchApplication.java	(revision 21921)
@@ -0,0 +1,107 @@
+package org.greenstone.admin.guiext.mat;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.GridLayout;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+
+import javax.swing.*;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+//import org.apache.tools.ant.Project;
+//import org.apache.tools.ant.ProjectHelper;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Set;
+
+import org.greenstone.gsdl3.util.GSPath;
+import org.greenstone.gsdl3.util.GlobalProperties;
+import org.greenstone.admin.GAI;
+
+class MatLaunchApplication extends Thread{
+ 
+    Mat adaptee;
+	
+    public MatLaunchApplication (Mat m){
+	adaptee = m;
+    }
+    
+    public void run()
+    {    	
+	try{
+	    String gsdl3Home = GAI.getGSDL3Home();
+	    String fileSeparator = File.separator;
+	    String extPath = GAI.getGSDL3ExtensionHome() + System.getProperty("file.separator") + "mat";
+	    System.err.println(extPath);
+	    
+	    File wd = new File(extPath);
+	    Process proc = null;
+	    ArrayList alist = new ArrayList();
+	    
+	    if(System.getProperty("os.name").equals("windows")){
+	    	alist.add("cmd.exe");
+	    	alist.add("/C");
+	    	alist.add("Mat.bat");
+	    }
+	    else{
+	    	alist.add("bash");
+		alist.add("-c");
+	    	alist.add("bash Mat.sh");
+	    }
+	    String[] arrays = new String[alist.size()];
+	    for(int i = 0; i<arrays.length; i++){
+	    	arrays[i] = (String)alist.get(i);
+	    }
+	   
+	    try {
+		proc = Runtime.getRuntime().exec(arrays, null, wd);
+		
+		BufferedReader stdInput = new BufferedReader(new InputStreamReader(proc.getInputStream()));
+		String s= "";
+		    
+		while ((s = stdInput.readLine()) != null) {
+		    System.out.println(s);
+		}   
+		
+		proc.waitFor();
+		    
+		
+	    } catch (Exception e) {
+		e.printStackTrace();
+	    }
+    	}catch(Exception ex){
+	    ex.printStackTrace();
+    	}
+    }
+} 
Index: gs3-extensions/mat/trunk/src/org/greenstone/admin/guiext/MatSVNDownloadThread.java
===================================================================
--- gs3-extensions/mat/trunk/src/org/greenstone/admin/guiext/MatSVNDownloadThread.java	(revision 21921)
+++ gs3-extensions/mat/trunk/src/org/greenstone/admin/guiext/MatSVNDownloadThread.java	(revision 21921)
@@ -0,0 +1,80 @@
+package org.greenstone.admin.guiext.mat;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.GridLayout;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+
+import javax.swing.*;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.greenstone.gsdl3.util.GSPath;
+import org.greenstone.gsdl3.util.GlobalProperties;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Set;
+
+
+class MatSVNDownloadThread extends Thread {
+    
+    JTextArea _messageTextArea;
+    String _extensionName;
+    String _URL;
+    Mat _mat;
+    MatWorkingCopy _MatWorkingCopy = new MatWorkingCopy();
+    String _destination;
+    public MatSVNDownloadThread (Mat mat,JTextArea messageArea, String svnURL, String destination, String extension_name) {
+	System.err.println("*** message area = " + messageArea);
+	    _messageTextArea = messageArea;
+    	_URL = svnURL;
+    	_extensionName = extension_name;
+    	_mat = mat;
+    	_destination = destination;
+    
+    }
+
+    public void run(){
+	try{
+		MatWorkingCopy wc = new MatWorkingCopy();
+		wc.Download(_messageTextArea, _URL,_destination, _extensionName);
+	if(wc.getStatus()){
+		_mat.setCommandStatus("download");
+	}
+	}catch(Exception ex){
+		ex.printStackTrace();
+		return;
+	}
+    }     
+}
+ 
Index: gs3-extensions/mat/trunk/src/org/greenstone/admin/guiext/MatUpdateEventHandler.java
===================================================================
--- gs3-extensions/mat/trunk/src/org/greenstone/admin/guiext/MatUpdateEventHandler.java	(revision 21921)
+++ gs3-extensions/mat/trunk/src/org/greenstone/admin/guiext/MatUpdateEventHandler.java	(revision 21921)
@@ -0,0 +1,172 @@
+package org.greenstone.admin.guiext.mat;
+
+import java.awt.Graphics;
+import java.util.List;
+
+import javax.swing.JOptionPane;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.SwingUtilities;
+
+import org.tmatesoft.svn.core.SVNCancelException;
+import org.tmatesoft.svn.core.wc.ISVNEventHandler;
+import org.tmatesoft.svn.core.wc.SVNEvent;
+import org.tmatesoft.svn.core.wc.SVNStatusType;
+import org.tmatesoft.svn.core.wc.SVNEventAction;
+
+
+public class MatUpdateEventHandler extends Thread implements ISVNEventHandler, Runnable {
+	
+    JTextArea messageArea = new JTextArea();
+    String localDirectory;
+    String extensionName;
+    public MatUpdateEventHandler(JTextArea messgaeTextArea, String dir, String extensionName) {
+	
+	
+	messageArea = messgaeTextArea;
+	messageArea.setEditable(false);
+	messageArea.setLineWrap(true);
+	messageArea.setWrapStyleWord(true);
+	
+	localDirectory = dir;
+	this.extensionName = extensionName;
+	
+    }
+    
+    public MatUpdateEventHandler() {
+	// TODO Auto-generated constructor stub
+    }
+    
+    public void handleEvent(SVNEvent event, double progress) {
+        /*
+         * Gets the current action. An action is represented by SVNEventAction.
+         * In case of an update an  action  can  be  determined  via  comparing 
+         * SVNEvent.getAction() and SVNEventAction.UPDATE_-like constants. 
+         */
+	
+	//System.out.println(" event occurs");
+        SVNEventAction action = event.getAction();
+        String pathChangeType = " ";
+        if (action == SVNEventAction.UPDATE_ADD) {
+            /*
+             * the item was added
+             */
+            pathChangeType = "A";
+        } else if (action == SVNEventAction.UPDATE_DELETE) {
+            /*
+             * the item was deleted
+             */
+            pathChangeType = "D";
+        } else if (action == SVNEventAction.UPDATE_UPDATE) {
+            /*
+             * Find out in details what  state the item is (after  having  been 
+             * updated).
+             * 
+             * Gets  the  status  of  file/directory  item   contents.  It   is 
+             * SVNStatusType  who contains information on the state of an item.
+             */
+            SVNStatusType contentsStatus = event.getContentsStatus();
+            if (contentsStatus == SVNStatusType.CHANGED) {
+                /*
+                 * the  item  was  modified in the repository (got  the changes 
+                 * from the repository
+                 */
+                pathChangeType = "U";
+            }else if (contentsStatus == SVNStatusType.CONFLICTED) {
+                /*
+                 * The file item is in  a  state  of Conflict. That is, changes
+                 * received from the repository during an update, overlap  with 
+                 * local changes the user has in his working copy.
+                 */
+                pathChangeType = "C";
+            } else if (contentsStatus == SVNStatusType.MERGED) {
+                /*
+                 * The file item was merGed (those  changes that came from  the 
+                 * repository  did  not  overlap local changes and were  merged 
+                 * into the file).
+                 */
+                pathChangeType = "G";
+            }
+        } else if (action == SVNEventAction.UPDATE_EXTERNAL) {
+            /*for externals definitions*/
+            System.out.println("Fetching external item into '"
+                    + event.getFile().getAbsolutePath() + "'");
+            System.out.println("External at revision " + event.getRevision());
+            return;
+        } else if (action == SVNEventAction.UPDATE_COMPLETED) {
+            /*
+             * Updating the working copy is completed. Prints out the revision.
+             */
+            //System.out.println("At revision " + event.getRevision());
+        	messageArea.append("At revision " + event.getRevision()+"\n");
+        	messageArea.append("The extension ("+  extensionName +") has been downloaded to the local folder: \n"+ localDirectory +"\n");
+        	messageArea.setSelectionEnd(messageArea.getDocument().getLength());
+            return;
+        } else if (action == SVNEventAction.ADD){
+            System.out.println("A     " +  event.getURL().getPath());
+            return;
+        } else if (action == SVNEventAction.DELETE){
+            System.out.println("D     " +  event.getURL().getPath());
+            return;
+        } else if (action == SVNEventAction.LOCKED){
+            System.out.println("L     " +  event.getURL().getPath());
+            return;
+        } else if (action == SVNEventAction.LOCK_FAILED){
+            System.out.println("failed to lock    " +  event.getURL().getPath());
+            return;
+        }
+
+        /*
+         * Now getting the status of properties of an item. SVNStatusType  also
+         * contains information on the properties state.
+         */
+        SVNStatusType propertiesStatus = event.getPropertiesStatus();
+        /*
+         * At first consider properties are normal (unchanged).
+         */
+        String propertiesChangeType = " ";
+        if (propertiesStatus == SVNStatusType.CHANGED) {
+            /*
+             * Properties were updated.
+             */
+            propertiesChangeType = "U";
+        } else if (propertiesStatus == SVNStatusType.CONFLICTED) {
+            /*
+             * Properties are in conflict with the repository.
+             */
+            propertiesChangeType = "C";
+        } else if (propertiesStatus == SVNStatusType.MERGED) {
+            /*
+             * Properties that came from the repository were  merged  with  the
+             * local ones.
+             */
+            propertiesChangeType = "G";
+        }
+
+        /*
+         * Gets the status of the lock.
+         */
+        String lockLabel = " ";
+        SVNStatusType lockType = event.getLockStatus();
+        
+        if (lockType == SVNStatusType.LOCK_UNLOCKED) {
+            /*
+             * The lock is broken by someone.
+             */
+            lockLabel = "B";
+        }
+	
+        
+	String content = pathChangeType
+	    + propertiesChangeType
+	    + lockLabel
+	    + "       "
+	    +  event.getURL().getPath()+"\n";
+	
+       messageArea.append(content);
+       messageArea.setSelectionEnd(messageArea.getDocument().getLength());
+    }
+
+    public void checkCancelled() throws SVNCancelException {    }
+
+} 
Index: gs3-extensions/mat/trunk/src/org/greenstone/admin/guiext/MatWorkingCopy.java
===================================================================
--- gs3-extensions/mat/trunk/src/org/greenstone/admin/guiext/MatWorkingCopy.java	(revision 21921)
+++ gs3-extensions/mat/trunk/src/org/greenstone/admin/guiext/MatWorkingCopy.java	(revision 21921)
@@ -0,0 +1,129 @@
+package org.greenstone.admin.guiext.mat;
+
+import java.io.File;
+
+import javax.swing.JFrame;
+import javax.swing.JOptionPane;
+import javax.swing.JTextArea;
+
+import org.tmatesoft.svn.core.SVNException;
+import org.tmatesoft.svn.core.SVNURL;
+import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
+import org.tmatesoft.svn.core.internal.io.fs.FSRepositoryFactory;
+import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl;
+import org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions;
+import org.tmatesoft.svn.core.wc.SVNClientManager;
+import org.tmatesoft.svn.core.wc.SVNRevision;
+import org.tmatesoft.svn.core.wc.SVNUpdateClient;
+import org.tmatesoft.svn.core.wc.SVNWCUtil;
+import org.tmatesoft.svn.core.wc.ISVNEventHandler;
+
+import org.greenstone.admin.gui.*;
+
+public class MatWorkingCopy {
+
+    private static SVNClientManager ourClientManager;
+    private static ISVNEventHandler myMatUpdateEventHandler;
+    public static boolean suc = true; 
+    JTextArea messageTextArea;
+
+    
+    public void Download(JTextArea messageArea,String svnURL, String destination, String extensionName) throws SVNException {
+    	
+    	messageTextArea = messageArea;
+        setupLibrary();
+        SVNURL repositoryURL = null;
+        try {
+            repositoryURL = SVNURL.parseURIEncoded(svnURL);
+        } catch (SVNException e) {
+        	e.printStackTrace();
+        }
+        String name = "";
+        String password = "";
+        String myMatWorkingCopyPath = destination;
+
+ 
+        SVNURL url = repositoryURL;
+ 
+        myMatUpdateEventHandler = new MatUpdateEventHandler(messageTextArea, destination, extensionName);
+       
+        DefaultSVNOptions options = SVNWCUtil.createDefaultOptions(true);
+     
+        ourClientManager = SVNClientManager.newInstance(options, name, password);
+     
+        ourClientManager.getUpdateClient().setEventHandler(myMatUpdateEventHandler);
+
+        File wcDir = new File(myMatWorkingCopyPath);
+        if (wcDir.exists()) {
+        	
+        	Object[] option = {"Remove it!","Keep it!"};
+        	int n = JOptionPane.showOptionDialog(new JFrame(),"The folder '"+ wcDir.getAbsolutePath() + "' already exists!","Attention", 
+        			JOptionPane.YES_NO_CANCEL_OPTION,
+        			JOptionPane.QUESTION_MESSAGE,
+        			null,
+        			option,
+        			option[0]);
+
+        	if(n == 0){
+        		deleteDir(wcDir);
+        	}
+        	else{return;}
+        }
+        wcDir.mkdirs();
+
+        messageTextArea.append("Checking out a working copy from '" + url + "'...\n");
+   
+        try {
+          checkout(url, SVNRevision.HEAD, wcDir, true);
+        } catch (SVNException svne) {
+            error("error while checking out a working copy for the location '"
+                            + url + "'", svne);
+        }
+
+    }
+
+    private static boolean deleteDir(File dir) {
+        
+    	if (dir.isDirectory()) {
+	    String[] children = dir.list();
+	    for (int i=0; i<children.length; i++) {
+		boolean success = deleteDir(new File(dir, children[i]));
+		if (!success) {
+		    return false;
+		}
+	    }
+	}
+    	return dir.delete();
+    } 
+
+    private static void setupLibrary() {
+
+        DAVRepositoryFactory.setup();
+
+        SVNRepositoryFactoryImpl.setup();
+
+        FSRepositoryFactory.setup();
+    }
+
+    private static void checkout(SVNURL url,
+				 SVNRevision revision, File destPath, boolean isRecursive)
+	throws SVNException {
+
+        SVNUpdateClient updateClient = ourClientManager.getUpdateClient();
+    
+        updateClient.setIgnoreExternals(false);
+
+        long x = updateClient.doCheckout(url, destPath, revision, revision, isRecursive);
+
+    }
+
+    public boolean getStatus(){	
+	return suc;
+    }
+    
+    private static void error(String message, Exception e){
+        System.err.println(message+(e!=null ? ": "+e.getMessage() : ""));
+        JOptionPane.showMessageDialog(new JFrame(),Mat.DownloadErrorMsg);	
+	suc = false;
+    }
+} 
