Index: /main/trunk/gli/src/org/greenstone/gatherer/gui/FormatConversionDialog.java
===================================================================
--- /main/trunk/gli/src/org/greenstone/gatherer/gui/FormatConversionDialog.java	(revision 29029)
+++ /main/trunk/gli/src/org/greenstone/gatherer/gui/FormatConversionDialog.java	(revision 29030)
@@ -80,6 +80,8 @@
     private GLIButton next_button = null;
     private GLIButton accept_all_button = null;
-    private GLIButton undo_button = null;
-    private GLIButton redo_button = null;
+    private GLIButton gs2_undo_button = null;
+    private GLIButton gs2_redo_button = null;
+    private GLIButton gs3_undo_button = null;
+    private GLIButton gs3_redo_button = null;
     private GLIButton htmltidy_button = null;
     private GLIButton xmltidy_button = null;
@@ -88,5 +90,4 @@
     private JLabel count_label = null;
     private JLabel statusbar = null;
-    private UndoManager undoManager;
 
     public FormatConversionDialog (File collect_cfg_file, Document xml_file_doc, NodeList gsf_format_gs2_list) {
@@ -104,7 +105,24 @@
 	
 
+	gs2_textarea = new NumberedJTextArea();
+	gs3_textarea = new NumberedJTextArea();
+
+
 	JPanel midbutton_panel = new JPanel(); // FlowLayout by default in a JPanel
 	midbutton_panel.setComponentOrientation(Dictionary.getOrientation());
+
+	gs2_undo_button = new GLIButton(Dictionary.get("General.Undo"), Dictionary.get("General.Undo_Tooltip"));
+	gs2_undo_button.setEnabled(false);
+
+	gs2_redo_button = new GLIButton(Dictionary.get("General.Redo"), Dictionary.get("General.Redo_Tooltip"));
+	gs2_redo_button.setEnabled(false);
+
+	gs2_undo_button.addActionListener(new UndoListener(gs2_textarea, gs2_undo_button, gs2_redo_button));
+	gs2_redo_button.addActionListener(new RedoListener(gs2_textarea, gs2_undo_button, gs2_redo_button));
+
 	JButton reconvert_button = new GLIButton(Dictionary.get("FormatConversionDialog.Reconvert"), Dictionary.get("FormatConversionDialog.Reconvert_Tooltip"));
+
+	midbutton_panel.add(gs2_undo_button);
+	midbutton_panel.add(gs2_redo_button);
 	midbutton_panel.add(reconvert_button);
 	reconvert_button.addActionListener(new ReconvertListener());
@@ -117,17 +135,19 @@
 	JPanel button1_panel = new JPanel();
 	button1_panel.setComponentOrientation(Dictionary.getOrientation());
-	undo_button = new GLIButton(Dictionary.get("General.Undo"), Dictionary.get("General.Undo_Tooltip"));
-	undo_button.addActionListener(new UndoListener());
-	undo_button.setEnabled(false);
-
-	redo_button = new GLIButton(Dictionary.get("General.Redo"), Dictionary.get("General.Redo_Tooltip"));
-	redo_button.addActionListener(new RedoListener());
-	redo_button.setEnabled(false);
+	gs3_undo_button = new GLIButton(Dictionary.get("General.Undo"), Dictionary.get("General.Undo_Tooltip"));
+	gs3_undo_button.setEnabled(false);
+
+	gs3_redo_button = new GLIButton(Dictionary.get("General.Redo"), Dictionary.get("General.Redo_Tooltip"));
+	gs3_redo_button.setEnabled(false);
+
+	gs3_undo_button.addActionListener(new UndoListener(gs3_textarea, gs3_undo_button, gs3_redo_button));
+	gs3_redo_button.addActionListener(new RedoListener(gs3_textarea, gs3_undo_button, gs3_redo_button));
+	
 
 	xmltidy_button = new GLIButton(Dictionary.get("FormatConversionDialog.XHTML_Tidy"), Dictionary.get("FormatConversionDialog.XHTML_Tidy_Tooltip"));
 	xmltidy_button.addActionListener(new XMLTidyButtonListener());
 
-	button1_panel.add(undo_button);
-	button1_panel.add(redo_button);
+	button1_panel.add(gs3_undo_button);
+	button1_panel.add(gs3_redo_button);
 	button1_panel.add(xmltidy_button);
 
@@ -149,12 +169,7 @@
 	// The undoable text areas. Adding the UndoableEditListener has to come after instantiation
 	// of the undo and redo buttons, since the listener expects these buttons to already exist
-	undoManager = new UndoManager();
-
-	gs2_textarea = new NumberedJTextArea();
-	gs3_textarea = new NumberedJTextArea();
-
-	CustomUndoableEditListener customUndoableEditListener = new CustomUndoableEditListener();
-	gs2_textarea.getDocument().addUndoableEditListener(customUndoableEditListener);
-	gs3_textarea.getDocument().addUndoableEditListener(customUndoableEditListener);
+
+	gs2_textarea.getDocument().addUndoableEditListener(new CustomUndoableEditListener(gs2_undo_button, gs2_redo_button));
+	gs3_textarea.getDocument().addUndoableEditListener(new CustomUndoableEditListener(gs3_undo_button, gs3_redo_button));
 
 	initTextArea(gs2_textarea);
@@ -639,7 +654,10 @@
 
 	// as we're on a new screen of dialog, need to clear all undo/redo history
-	undoManager.discardAllEdits();
-	undo_button.setEnabled(false);
-	redo_button.setEnabled(false);
+	gs2_undo_button.setEnabled(false);
+	gs2_redo_button.setEnabled(false);
+	gs3_undo_button.setEnabled(false);
+	gs3_redo_button.setEnabled(false);
+	gs2_textarea.discardAllEdits();
+	gs3_textarea.discardAllEdits();
 
 	int len = gsf_format_gs2_list.getLength();
@@ -935,20 +953,32 @@
     private class UndoListener implements ActionListener
     {	
+	NumberedJTextArea textarea = null;
+	GLIButton undobutton, redobutton;
+
+	public UndoListener(NumberedJTextArea textarea, GLIButton undobutton, GLIButton redobutton) {
+	    
+	    this.textarea = textarea;
+	    this.undobutton = undobutton;
+	    this.redobutton = redobutton;		
+	    
+	}
+	
 	public void actionPerformed(ActionEvent event)
 	{
 	    try	{
-		if (undoManager.canUndo()) {						
-		    redo_button.setEnabled(true);
-		    undoManager.undo();					
-		}
-		
-		if (!undoManager.canUndo()) {
-		    undo_button.setEnabled(false);
+		if (textarea.canUndo()) {						
+		    redobutton.setEnabled(true);
+		    textarea.undoLastAction();					
+		}
+		
+		if (!textarea.canUndo()) {
+		    undobutton.setEnabled(false);
 		} else {
-		    undo_button.setEnabled(true);
+		    undobutton.setEnabled(true);
 		}
 		
 	    } catch (Exception e) {
 		System.err.println("Exception trying to undo: " + e.getMessage());
+		e.printStackTrace();
 	    }
 	}
@@ -957,20 +987,31 @@
     private class RedoListener implements ActionListener
     {
+	NumberedJTextArea textarea = null;
+	GLIButton undobutton, redobutton;
+
+	public RedoListener(NumberedJTextArea textarea, GLIButton undobutton, GLIButton redobutton) {
+
+	    this.textarea = textarea;
+	    this.undobutton = undobutton;
+	    this.redobutton = redobutton;
+	}
+
 	public void actionPerformed(ActionEvent evt)
 	{
 	    try	{
-		if (undoManager.canRedo()) {
-		    undo_button.setEnabled(true); // the difference with Format4gs3Manager, and no DocumentListener
-		    undoManager.redo();
-		}
-		
-		if (!undoManager.canRedo()) {
-		    redo_button.setEnabled(false);
+		if (textarea.canRedo()) {
+		    undobutton.setEnabled(true); // the difference with Format4gs3Manager, and no DocumentListener
+		    textarea.redoLastAction();
+		}
+		
+		if (!textarea.canRedo()) {
+		    redobutton.setEnabled(false);
 		} else {
-		    redo_button.setEnabled(true);
+		    redobutton.setEnabled(true);
 		}
 		
 	    } catch (Exception e) {
 		System.err.println("Exception trying to redo: " + e.getMessage());
+		e.printStackTrace();
 	    }
 	}
@@ -978,12 +1019,17 @@
 
     private class CustomUndoableEditListener implements UndoableEditListener {
+	GLIButton undobutton = null;
+	GLIButton redobutton = null;
+
+	public CustomUndoableEditListener(GLIButton undo_button, GLIButton redo_button) {
+	    undobutton = undo_button;
+	    redobutton = redo_button;
+	}
+
 	public void undoableEditHappened(UndoableEditEvent evt)
-	{
-	    
-	    undoManager.addEdit(evt.getEdit());
-	    redo_button.setEnabled(false);
-	    undo_button.setEnabled(true);
-	}
-    }
-
+	{	    
+	    undobutton.setEnabled(true);
+	    redobutton.setEnabled(false);	    
+	}
+    }
 }
