Index: /trunk/gli/src/org/greenstone/gatherer/gui/MetaEditPrompt.java
===================================================================
--- /trunk/gli/src/org/greenstone/gatherer/gui/MetaEditPrompt.java	(revision 4309)
+++ /trunk/gli/src/org/greenstone/gatherer/gui/MetaEditPrompt.java	(revision 4310)
@@ -28,7 +28,10 @@
 import java.awt.*;
 import java.awt.event.*;
+import java.io.File;
 import javax.swing.*;
+import org.greenstone.gatherer.Configuration;
 import org.greenstone.gatherer.Gatherer;
-import org.greenstone.gatherer.Configuration;
+import org.greenstone.gatherer.gui.TextFieldLabel;
+import org.greenstone.gatherer.util.Utility;
 /** Displays a dynamic prompt to allow the user to choose how metadata is to be added, updated or removed from target FileNodes. The prompt changes depending on the action requested, the file nodes encountered and the number of file nodes in the selection. */
 public class MetaEditPrompt
@@ -36,306 +39,184 @@
 	 implements ActionListener {
 
-	 private boolean multiple_selection = false;
-
-	 private int type;
 	 private int value;
-
-	 private JButton accumulate_b;
-	 private JButton accumulate_all_b;
-	 private JButton cancel_b;
-	 private JButton skip_b;
-	 private JButton overwrite_b;
-	 private JButton overwrite_all_b;
-	 private JButton remove_b;
-	 private JButton remove_all_b;
-	 private JButton update_b;
-	 private JButton update_all_b;
-
-	 private JLabel title;
-
-	 private JTextArea text;
-
-	 private JPanel button_row;
-	 private JPanel content_pane;
-
-	 static private Dimension SIZE    = new Dimension(400, 280);
-
-	 // Prompt Types
-	 static public int ADD_PROMPT      =  0;
-	 static public int REMOVE_PROMPT   =  1;
-	 static public int UPDATE_PROMPT   =  2;
-
+	 private JButton accumulate;
+	 private JButton accumulate_all;
+	 private JButton cancel;
+	 private JButton skip;
+	 private JButton overwrite;
+	 private JButton overwrite_all;
+	 private JButton remove;
+	 private JButton remove_all;
+	 private JButton update;
+	 private JButton update_all;
+	 static private Dimension LABEL_SIZE = new Dimension(100, 25);
+	 static private Dimension SIZE = new Dimension(400, 280);
 	 // Generic prompt values.
 	 static public int CONFIRM         =  0;
 	 static public int CANCEL          =  1;
 	 static public int SKIP            =  2;
-
-	 // Values for the different add action prompts.
+	 // Values for the different add and update action prompts.
 	 static public int ACCUMULATE      =  3;
 	 static public int ACCUMULATE_ALL  =  4;
 	 static public int OVERWRITE       =  5;
 	 static public int OVERWRITE_ALL   =  6;
-
-	 // Values for the different update action prompts.
-	 static public int UPDATE          =  7;
-	 static public int UPDATE_ALL      =  8;
-	 static public int UPDATE_ONCE     =  9;
-
+	 static public int UPDATE_ONCE     =  7; // Caused by SARM
 	 // Values for the different remove action prompts.
-	 static public int REMOVE          = 10;
-	 static public int REMOVE_ALL      = 11;
-
-	 public MetaEditPrompt(int type, boolean multiple_selection) {
-		  super(Gatherer.g_man); // Needed for modal response!
-		  this.multiple_selection = multiple_selection;
-		  this.setFont(Gatherer.config.getFont("general.font", false));
-		  this.setModal(true);
+	 static public int REMOVE          =  8;
+	 static public int REMOVE_ALL      =  9;
+	 // Prompt Types
+	 static public String ADD_PROMPT    = "Add_Prompt";
+	 static public String REMOVE_PROMPT = "Remove_Prompt";
+	 static public String UPDATE_PROMPT = "Overwrite_Prompt";
+
+	 public MetaEditPrompt(String type, boolean multiple_selection, File file, String element, String current_value, String new_value) {
+		  super(Gatherer.g_man, true); // Needed for modal response!
+		  
+		  // Setup
 		  this.setSize(SIZE);
-		  this.type = type;
-		  if(type == ADD_PROMPT) {
-				this.setTitle(get("Add_Title"));
-				title = new JLabel(get("Add_Title"));
-		  }
-		  else if(type == REMOVE_PROMPT) {
-				this.setTitle(get("Remove_Title"));
-				title = new JLabel(get("Remove_Title"));
-		  }
-		  else {
-				this.setTitle(get("Update_Title"));
-				title = new JLabel(get("Update_Title"));
-		  }
-		  title.setOpaque(false);
-
-		  content_pane = (JPanel)this.getContentPane();
-		  content_pane.setBackground(Gatherer.config.getColor("coloring.collection_heading_background", false));
-		  content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
-
-		  // Set up some preset components.
-		  text = new JTextArea();
-		  text.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false));
-		  text.setEditable(false);
-
-		  button_row = new JPanel();
-		  button_row.setOpaque(false);
-
-		  accumulate_b = new JButton(get("Accumulate"));
-		  accumulate_b.addActionListener(this);
-		  accumulate_b.setBackground(Gatherer.config.getColor("coloring.button_background", false));
-		  accumulate_b.setMnemonic(KeyEvent.VK_A);
-
-		  accumulate_all_b = new JButton(get("Accumulate_All"));
-		  accumulate_all_b.addActionListener(this);
-		  accumulate_all_b.setBackground(Gatherer.config.getColor("coloring.button_background", false));
-		  accumulate_all_b.setMnemonic(KeyEvent.VK_D);
-
-		  cancel_b = new JButton(get("Cancel"));
-		  cancel_b.addActionListener(this);
-		  cancel_b.setBackground(Gatherer.config.getColor("coloring.button_background", false));
-		  cancel_b.setMnemonic(KeyEvent.VK_C);
-
-		  skip_b = new JButton(get("Skip"));
-		  skip_b.addActionListener(this);
-		  skip_b.setBackground(Gatherer.config.getColor("coloring.button_background", false));
-		  skip_b.setMnemonic(KeyEvent.VK_S);
-
-		  overwrite_b = new JButton(get("Overwrite"));
-		  overwrite_b.addActionListener(this);
-		  overwrite_b.setBackground(Gatherer.config.getColor("coloring.button_background", false));
-		  overwrite_b.setMnemonic(KeyEvent.VK_R);
-
-		  overwrite_all_b = new JButton(get("Overwrite_All"));
-		  overwrite_all_b.addActionListener(this);
-		  overwrite_all_b.setBackground(Gatherer.config.getColor("coloring.button_background", false));
-		  overwrite_all_b.setMnemonic(KeyEvent.VK_E);
-
-		  remove_b = new JButton(get("Remove"));
-		  remove_b.addActionListener(this);
-		  remove_b.setBackground(Gatherer.config.getColor("coloring.button_background", false));
-		  remove_b.setMnemonic(KeyEvent.VK_R);
-
-		  remove_all_b = new JButton(get("Remove_All"));
-		  remove_all_b.addActionListener(this);
-		  remove_all_b.setBackground(Gatherer.config.getColor("coloring.button_background", false));
-		  remove_all_b.setMnemonic(KeyEvent.VK_A);
-
-		  update_b = new JButton(get("Update"));
-		  update_b.addActionListener(this);
-		  update_b.setBackground(Gatherer.config.getColor("coloring.button_background", false));
-		  update_b.setMnemonic(KeyEvent.VK_U);
-
-		  update_all_b = new JButton(get("Update_All"));
-		  update_all_b.addActionListener(this);
-		  update_all_b.setBackground(Gatherer.config.getColor("coloring.button_background", false));
-		  update_all_b.setMnemonic(KeyEvent.VK_A);
+		  this.setTitle(get("MetaEditPrompt.Title"));
+
+		  // Creation
+		  JPanel content_pane = (JPanel)this.getContentPane();
+		  JLabel title_label = new JLabel(get("MetaEditPrompt." + type));
+
+		  JPanel details_pane = new JPanel();
+		  JPanel filename_panel = new JPanel();
+		  JLabel filename_label = new JLabel(get("MetaEditPrompt.File"));
+		  filename_label.setPreferredSize(LABEL_SIZE);
+		  TextFieldLabel filename_field = new TextFieldLabel(Utility.trimCenter(file.getAbsolutePath(), 40));
+		  filename_field.setFont(Gatherer.config.getFont("general.tooltip_font", false));
+		  JPanel element_panel = new JPanel();
+		  JLabel element_label = new JLabel(get("MetaEditPrompt.Element"));
+		  element_label.setPreferredSize(LABEL_SIZE);
+		  TextFieldLabel element_field = new TextFieldLabel(element);		  
+		  JPanel current_value_panel = new JPanel();
+		  JLabel current_value_label = new JLabel(get("MetaEditPrompt.Current_Value"));
+		  current_value_label.setPreferredSize(LABEL_SIZE);
+		  TextFieldLabel current_value_field = new TextFieldLabel(current_value);
+		  JPanel new_value_panel = new JPanel();
+		  JLabel new_value_label = new JLabel(get("MetaEditPrompt.New_Value"));
+		  new_value_label.setPreferredSize(LABEL_SIZE);
+		  TextFieldLabel new_value_field = new TextFieldLabel(new_value, (type == ADD_PROMPT || type == UPDATE_PROMPT));
+
+		  JPanel buttons_pane = new JPanel();
+		  accumulate = new JButton(get("MetaEditPrompt.Accumulate"));
+		  accumulate.setEnabled(type == ADD_PROMPT);
+		  accumulate.setMnemonic(KeyEvent.VK_A);
+		  accumulate_all = new JButton(get("MetaEditPrompt.Accumulate_All"));
+		  accumulate_all.setEnabled(type == ADD_PROMPT && multiple_selection);
+		  accumulate_all.setMnemonic(KeyEvent.VK_L);
+		  cancel = new JButton(get("MetaEditPrompt.Cancel"));
+		  cancel.setMnemonic(KeyEvent.VK_C);
+		  skip = new JButton(get("MetaEditPrompt.Skip"));
+		  skip.setEnabled(multiple_selection);
+		  skip.setMnemonic(KeyEvent.VK_S);
+		  overwrite = new JButton(get("MetaEditPrompt.Overwrite"));
+		  overwrite.setEnabled((type == ADD_PROMPT || type == UPDATE_PROMPT));
+		  overwrite.setMnemonic(KeyEvent.VK_R);
+		  overwrite_all = new JButton(get("MetaEditPrompt.Overwrite_All"));
+		  overwrite_all.setEnabled((type == ADD_PROMPT || type == UPDATE_PROMPT) && multiple_selection);
+		  overwrite_all.setMnemonic(KeyEvent.VK_P);
+		  remove = new JButton(get("MetaEditPrompt.Remove"));
+		  remove.setEnabled(type == REMOVE_PROMPT);
+		  remove.setMnemonic(KeyEvent.VK_R);
+		  remove_all = new JButton(get("MetaEditPrompt.Remove_All"));
+		  remove_all.setEnabled(type == REMOVE_PROMPT && multiple_selection);
+		  remove_all.setMnemonic(KeyEvent.VK_A);
+
+		  // Connection
+		  accumulate.addActionListener(this);
+		  accumulate_all.addActionListener(this);
+		  cancel.addActionListener(this);
+		  overwrite.addActionListener(this);
+		  overwrite_all.addActionListener(this);
+		  remove.addActionListener(this);
+		  remove_all.addActionListener(this);
+		  skip.addActionListener(this);
+
+		  // Layout
+		  title_label.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
+		  
+		  filename_panel.setLayout(new BorderLayout());
+		  filename_panel.add(filename_label, BorderLayout.WEST);
+		  filename_panel.add(filename_field, BorderLayout.CENTER);
+
+		  element_panel.setLayout(new BorderLayout());
+		  element_panel.add(element_label, BorderLayout.WEST);
+		  element_panel.add(element_field, BorderLayout.CENTER);
+
+		  current_value_panel.setLayout(new BorderLayout());
+		  current_value_panel.add(current_value_label, BorderLayout.WEST);
+		  current_value_panel.add(current_value_field, BorderLayout.CENTER);
+
+		  new_value_panel.setLayout(new BorderLayout());
+		  new_value_panel.add(new_value_label, BorderLayout.WEST);
+		  new_value_panel.add(new_value_field, BorderLayout.CENTER);
+
+		  details_pane.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
+		  details_pane.setLayout(new GridLayout(4,1,0,4));
+		  details_pane.add(filename_panel);
+		  details_pane.add(element_panel);
+		  details_pane.add(current_value_panel);
+		  details_pane.add(new_value_panel);
+
+		  buttons_pane.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
+		  buttons_pane.setLayout(new GridLayout(4,2,0,0));
+		  buttons_pane.add(accumulate);
+		  buttons_pane.add(accumulate_all);
+		  buttons_pane.add(overwrite);
+		  buttons_pane.add(overwrite_all);
+		  buttons_pane.add(remove);
+		  buttons_pane.add(remove_all);
+		  buttons_pane.add(skip);
+		  buttons_pane.add(cancel);
+
+		  content_pane.setBorder(BorderFactory.createEmptyBorder(3,3,3,3));
+		  content_pane.setLayout(new BorderLayout());
+		  content_pane.add(title_label, BorderLayout.NORTH);
+		  content_pane.add(details_pane, BorderLayout.CENTER);
+		  content_pane.add(buttons_pane, BorderLayout.SOUTH);
+
+		  // Position
+		  Rectangle frame_bounds = Gatherer.g_man.getBounds();
+		  this.setLocation(frame_bounds.x + ((frame_bounds.width - SIZE.width) / 2), frame_bounds.y + ((frame_bounds.height - SIZE.height) / 2));
 	 }
 
 	 public void actionPerformed(ActionEvent event) {
 		  Object esrc = event.getSource();
-		  if(esrc == accumulate_b) {
+		  if(esrc == accumulate) {
 				value = ACCUMULATE;
 		  }
-		  else if(esrc == accumulate_all_b) {
+		  else if(esrc == accumulate_all) {
 				value = ACCUMULATE_ALL;
 		  }
-		  else if(esrc == cancel_b) {
+		  else if(esrc == cancel) {
 				value = CANCEL;
 		  }
-		  else if(esrc == skip_b) {
+		  else if(esrc == skip) {
 				value = SKIP;
 		  }		  
-		  else if(esrc == overwrite_b) {
+		  else if(esrc == overwrite) {
 				value = OVERWRITE;
 		  }
-		  else if(esrc == overwrite_all_b) {
+		  else if(esrc == overwrite_all) {
 				value = OVERWRITE_ALL;
 		  }
-		  else if(esrc == remove_b) {
+		  else if(esrc == remove) {
 				value = REMOVE;
 		  }
-		  else if(esrc == remove_all_b) {
+		  else if(esrc == remove_all) {
 				value = REMOVE_ALL;
 		  }
-		  else if(esrc == update_b) {
-				value = UPDATE;
-		  }
-		  else if(esrc == update_all_b) {
-				value = UPDATE_ALL;
-		  }
 		  this.dispose();
 	 }
 
-	 public int display(String f, String k, String v) {
-		  String args[] = new String[1];
-
-		  content_pane.setLayout(new BorderLayout());
-
-		  content_pane.add(title, BorderLayout.NORTH);
-
-		  JPanel middle_pane = new JPanel(new BorderLayout());
-		  middle_pane.setOpaque(false);
-		  middle_pane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5,5,5,5), BorderFactory.createLoweredBevelBorder()));
-
-		  args[0] = f;
-		  text.append(get("File", args));
-		  text.append("\n");
-		  args[0] = k;
-		  text.append(get("Key", args));
-		  text.append("\n");
-		  args[0] = v;
-		  text.append(get("Value", args));
-		  text.append("\n");
-		  
-		  button_row.setLayout(new GridLayout(4,1,2,2));
-
-		  // Add the components
-		  middle_pane.add(new JScrollPane(text), BorderLayout.CENTER);
-
-		  button_row.add(remove_b);
-		  if(multiple_selection) {
-				button_row.add(remove_all_b);
-		  }
-		  else {
-				button_row.add(new JPanel());
-		  }
-		  button_row.add(skip_b);
-		  button_row.add(cancel_b);
-
-		  content_pane.add(title, BorderLayout.NORTH);
-		  content_pane.add(middle_pane, BorderLayout.CENTER);
-		  content_pane.add(button_row, BorderLayout.SOUTH);
-
-		  text.setCaretPosition(0);
-
-		  Rectangle frame_bounds = Gatherer.g_man.getBounds();
-		  this.setLocation(frame_bounds.x + ((frame_bounds.width - SIZE.width) / 2), frame_bounds.y + ((frame_bounds.height - SIZE.height) / 2));
+	 public int display() {
 		  show();
 		  return value;
 	 }
 
-	 public int display(String f, String k, String o_v, String n_v) {
-		  String args[] = new String[1];
-		  
-		  content_pane.setLayout(new BorderLayout());
-		  
-		  content_pane.add(title, BorderLayout.NORTH);
-		  
-		  JPanel middle_pane = new JPanel(new BorderLayout());
-		  middle_pane.setOpaque(false);
-		  middle_pane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5,5,5,5), BorderFactory.createLoweredBevelBorder()));
-		  		  
-		  args[0] = f;
-		  text.append(get("File", args));
-		  text.append("\n");
-		  args[0] = k;
-		  text.append(get("Key", args));
-		  text.append("\n");
-		  args[0] = o_v;
-		  text.append(get("Old_Value", args));
-		  text.append("\n");
-		  args[0] = n_v;
-		  text.append(get("New_Value", args));
-		  text.append("\n");
-
-		  if(type == ADD_PROMPT) {
-				button_row.setLayout(new GridLayout(3,2,2,2));
-		  }
-		  else {
-				button_row.setLayout(new GridLayout(2,2,2,2));
-		  }
-		  
-		  // Add the components
-		  middle_pane.add(new JScrollPane(text), BorderLayout.CENTER);
-
-		  if(type == ADD_PROMPT) {
-				button_row.add(accumulate_b);
-				if(multiple_selection) {
-					 button_row.add(accumulate_all_b);
-				}
-				else {
-					 button_row.add(new JPanel());
-				}
-				button_row.add(overwrite_b);
-				if(multiple_selection) {
-					 button_row.add(overwrite_all_b);
-				}
-				else {
-					 button_row.add(new JPanel());
-				}
-				button_row.add(skip_b);
-				button_row.add(cancel_b);
-		  }
-		  else {
-				button_row.add(update_b);
-				if(multiple_selection) {
-					 button_row.add(update_all_b);
-				}
-				else {
-					 button_row.add(new JPanel());
-				}
-				button_row.add(skip_b);
-				button_row.add(cancel_b);
-		  }
-
-		  content_pane.add(title, BorderLayout.NORTH);
-		  content_pane.add(middle_pane, BorderLayout.CENTER);
-		  content_pane.add(button_row, BorderLayout.SOUTH);
-
-		  text.setCaretPosition(0);
-
-		  Rectangle frame_bounds = Gatherer.g_man.getBounds();
-		  this.setLocation(frame_bounds.x + ((frame_bounds.width - SIZE.width) / 2), frame_bounds.y + ((frame_bounds.height - SIZE.height) / 2));
-		  show();
-		  return value;
-	 }
-
 	 private String get(String key) {
-		  return get(key, null);
-	 }
-
-	 private String get(String key, String args[]) {
-		  if(key.indexOf(".") == -1) {
-				key = "MetaEditPrompt." + key;
-		  }
-		  return Gatherer.dictionary.get(key, args);
+		  return Gatherer.dictionary.get(key);
 	 }
 }
