Index: trunk/gli/src/org/greenstone/gatherer/cdm/IndexManager.java
===================================================================
--- trunk/gli/src/org/greenstone/gatherer/cdm/IndexManager.java	(revision 12084)
+++ trunk/gli/src/org/greenstone/gatherer/cdm/IndexManager.java	(revision 12087)
@@ -644,316 +644,312 @@
 	
 
-    private class NewIndexPrompt 
-	extends ModalDialog {
-
-	NewIndexPrompt new_index_prompt = null;
-	
-	private CheckList source_list;
-	// mg uses a level box
-	private JComboBox level_combobox;
-	// mgpp has a allfields selector
-	private JCheckBox allfields_box;
-
-	private JButton add_button;
-	private JButton replace_button;
-	private JButton add_all_button;
-	private JButton cancel_button;
-
-	// some panels that we need to manipulate later on
-	private JPanel boxes_pane;
-	private JPanel labels_pane;
-	private JLabel level_label;
-	private JPanel allfields_pane;
-
-	private boolean mgpp_enabled = false;
-	private boolean editing = false;
-	
-	public NewIndexPrompt(String build_type, Index existing_index) {
-	    super(Gatherer.g_man, true);
-	    new_index_prompt = this;
-
-	    setModal(true);
-	    setSize(PROMPT_SIZE);
-	    if (existing_index != null) {
-		setTitle (Dictionary.get("CDM.IndexManager.Edit_Index"));
-		editing = true;
-	    } else {
-		setTitle(Dictionary.get("CDM.IndexManager.New_Index"));
-	    }
-	    
-	    if (build_type.equals(BuildTypeManager.BUILD_TYPE_MGPP) || build_type.equals(BuildTypeManager.BUILD_TYPE_LUCENE)) {
-		mgpp_enabled = true;
-	    }
-	    JPanel content_pane = (JPanel)this.getContentPane();
-	    ArrayList new_data = new ArrayList();
-	    new_data.add(CollectionConfiguration.TEXT_STR);
-	    new_data.addAll(MetadataSetManager.getEveryMetadataSetElement());
-
-	    JPanel details_pane = new JPanel();
-	    labels_pane = new JPanel();
-	    boxes_pane = new JPanel();
-
-	    JPanel main_index_pane = new JPanel();
-
-	    JLabel source_label = new JLabel();
-	    Dictionary.registerText(source_label, "CDM.IndexManager.Source");
-	    source_list = new CheckList(false);
-	    source_list.setListData(new_data);
-	    Dictionary.registerTooltip(source_list, "CDM.IndexManager.Source_Tooltip");
-	    source_list.addListSelectionListener(new SourceListListener());
-
-	    JPanel button_pane = new JPanel();
-	    if (existing_index != null) {
-		button_pane.setLayout(new GridLayout(1,2,5,0));
-		replace_button = new GLIButton();
-		replace_button.setEnabled(false);
-		Dictionary.registerBoth(replace_button, "CDM.IndexManager.Replace_Index", "CDM.IndexManager.Replace_Index_Tooltip");
-		button_pane.add(replace_button);
-		replace_button.addActionListener(new ReplaceIndexListener());
-	    } else {
-		button_pane.setLayout(new GridLayout(1,3,5,0));
-		add_button = new GLIButton();
-		add_button.setEnabled(false);
-		add_button.setMnemonic(KeyEvent.VK_A);
-		Dictionary.registerBoth(add_button, "CDM.IndexManager.Add_Index", "CDM.IndexManager.Add_Index_Tooltip");
-		add_button.addActionListener(new AddIndexListener());
-
-		
-		add_all_button = new GLIButton();
-		add_all_button.setEnabled(true);
-		add_all_button.setMnemonic(KeyEvent.VK_L);
-		Dictionary.registerBoth(add_all_button, "CDM.IndexManager.Add_All", "CDM.IndexManager.Add_All_Tooltip");
-		add_all_button.addActionListener(new AddAllIndexActionListener());	    
-		button_pane.add(add_button);
-		button_pane.add(add_all_button);
-
-	    }
-	    cancel_button = new GLIButton();
-	    cancel_button.setEnabled(true);
-	    Dictionary.registerBoth(cancel_button, "General.Cancel", "General.Cancel");
-	    cancel_button.addActionListener(new ActionListener() {
-		public void actionPerformed(ActionEvent event) {
-		    new_index_prompt.dispose();
-		}
-	    });
-	    button_pane.add(cancel_button);
-
-	    // Layout
-	    labels_pane.setLayout(new BorderLayout());
-	    labels_pane.setBorder(BorderFactory.createEmptyBorder(5, 5, 10, 5));
-	    labels_pane.add(source_label, BorderLayout.CENTER);
-	    
-	    boxes_pane.setLayout(new BorderLayout());
-	    boxes_pane.add(new JScrollPane(source_list), BorderLayout.CENTER);
-	    
-	    details_pane.setLayout(new BorderLayout());
-	    details_pane.add(labels_pane, BorderLayout.WEST);
-	    details_pane.add(boxes_pane, BorderLayout.CENTER);
-
-
-	    // do type specific stuff
-	    if (!mgpp_enabled) {
-
-		level_label = new JLabel();
-		Dictionary.registerText(level_label, "CDM.IndexManager.Level");
-		level_combobox = new JComboBox();
-		level_combobox.setPreferredSize(FIELD_SIZE);
-		level_combobox.addItem(CollectionConfiguration.DOCUMENT_STR);//Dictionary.get("CDM.IndexManager.Document"));
-		level_combobox.addItem(CollectionConfiguration.PARAGRAPH_STR);//Dictionary.get("CDM.IndexManager.Paragraph"));
-		level_combobox.addItem(CollectionConfiguration.SECTION_STR);//Dictionary.get("CDM.IndexManager.Section"));
-		level_combobox.setEditable(false);
-		Dictionary.registerTooltip(level_combobox, "CDM.IndexManager.Level_Tooltip");
-		labels_pane.add(level_label, BorderLayout.SOUTH);
-		boxes_pane.add(level_combobox, BorderLayout.SOUTH);
-
-	    } else {
-		allfields_pane = new JPanel();
-		allfields_box = new JCheckBox();
-		JLabel allfields_label = new JLabel();
-		Dictionary.registerText(allfields_label, "CDM.IndexManager.Allfields_Index");
-		allfields_pane.setLayout(new BorderLayout());
-		allfields_pane.add(allfields_box, BorderLayout.WEST);
-		allfields_pane.add(allfields_label, BorderLayout.CENTER);
-		
-
-	    }
-	    // if we are editing, fill in the controls
-	    if (existing_index !=null) {
-		ArrayList sources = existing_index.getSources();
-		if (mgpp_enabled && sources.get(0).equals(ALLFIELDS)) {
-		    source_list.setEnabled(false);
-		    allfields_box.setSelected(true);
+	private class NewIndexPrompt 
+	    extends ModalDialog {
+
+	    NewIndexPrompt new_index_prompt = null;
+	
+	    private CheckList source_list;
+	    // mg uses a level box
+	    private JComboBox level_combobox;
+	    // mgpp has a allfields selector
+	    private JCheckBox allfields_box;
+
+	    private JButton add_button;
+	    private JButton replace_button;
+	    private JButton add_all_button;
+	    private JButton cancel_button;
+
+	    // some panels that we need to manipulate later on
+	    private JPanel boxes_pane;
+	    private JPanel labels_pane;
+	    private JLabel level_label;
+	    private JPanel allfields_pane;
+
+	    private boolean mgpp_enabled = false;
+	    private boolean editing = false;
+	
+	    public NewIndexPrompt(String build_type, Index existing_index) {
+		super(Gatherer.g_man, true);
+		new_index_prompt = this;
+
+		setModal(true);
+		setSize(PROMPT_SIZE);
+		if (existing_index != null) {
+		    setTitle (Dictionary.get("CDM.IndexManager.Edit_Index"));
+		    editing = true;
 		} else {
-		    source_list.setTickedObjects(sources.toArray());
-		    source_list.setEnabled(true); 
-		}
+		    setTitle(Dictionary.get("CDM.IndexManager.New_Index"));
+		}
+	    
+		if (build_type.equals(BuildTypeManager.BUILD_TYPE_MGPP) || build_type.equals(BuildTypeManager.BUILD_TYPE_LUCENE)) {
+		    mgpp_enabled = true;
+		}
+		JPanel content_pane = (JPanel)this.getContentPane();
+		ArrayList new_data = new ArrayList();
+		new_data.add(CollectionConfiguration.TEXT_STR);
+		new_data.addAll(MetadataSetManager.getEveryMetadataSetElement());
+
+		JPanel details_pane = new JPanel();
+		labels_pane = new JPanel();
+		boxes_pane = new JPanel();
+
+		JPanel main_index_pane = new JPanel();
+
+		JLabel source_label = new JLabel();
+		Dictionary.registerText(source_label, "CDM.IndexManager.Source");
+		source_list = new CheckList(false);
+		source_list.setListData(new_data);
+		Dictionary.registerTooltip(source_list, "CDM.IndexManager.Source_Tooltip");
+		source_list.addListSelectionListener(new SourceListListener());
+
+		JPanel button_pane = new JPanel();
+		if (existing_index != null) {
+		    button_pane.setLayout(new GridLayout(1,2,5,0));
+		    replace_button = new GLIButton();
+		    replace_button.setEnabled(false);
+		    Dictionary.registerBoth(replace_button, "CDM.IndexManager.Replace_Index", "CDM.IndexManager.Replace_Index_Tooltip");
+		    button_pane.add(replace_button);
+		    replace_button.addActionListener(new ReplaceIndexListener());
+		} else {
+		    button_pane.setLayout(new GridLayout(1,3,5,0));
+		    add_button = new GLIButton();
+		    add_button.setEnabled(false);
+		    add_button.setMnemonic(KeyEvent.VK_A);
+		    Dictionary.registerBoth(add_button, "CDM.IndexManager.Add_Index", "CDM.IndexManager.Add_Index_Tooltip");
+		    add_button.addActionListener(new AddIndexListener());
+
+		
+		    add_all_button = new GLIButton();
+		    add_all_button.setEnabled(true);
+		    add_all_button.setMnemonic(KeyEvent.VK_L);
+		    Dictionary.registerBoth(add_all_button, "CDM.IndexManager.Add_All", "CDM.IndexManager.Add_All_Tooltip");
+		    add_all_button.addActionListener(new AddAllIndexActionListener());	    
+		    button_pane.add(add_button);
+		    button_pane.add(add_all_button);
+
+		}
+		cancel_button = new GLIButton();
+		cancel_button.setEnabled(true);
+		Dictionary.registerBoth(cancel_button, "General.Cancel", "General.Cancel");
+		cancel_button.addActionListener(new ActionListener() {
+			public void actionPerformed(ActionEvent event) {
+			    new_index_prompt.dispose();
+			}
+		    });
+		button_pane.add(cancel_button);
+
+		// Layout
+		labels_pane.setLayout(new BorderLayout());
+		labels_pane.setBorder(BorderFactory.createEmptyBorder(5, 5, 10, 5));
+		labels_pane.add(source_label, BorderLayout.CENTER);
+	    
+		boxes_pane.setLayout(new BorderLayout());
+		boxes_pane.add(new JScrollPane(source_list), BorderLayout.CENTER);
+	    
+		details_pane.setLayout(new BorderLayout());
+		details_pane.add(labels_pane, BorderLayout.WEST);
+		details_pane.add(boxes_pane, BorderLayout.CENTER);
+
+
+		// do type specific stuff
 		if (!mgpp_enabled) {
-		    level_combobox.setSelectedIndex(existing_index.getLevel());
-		}
-		
-	    }
-	    content_pane.setLayout(new BorderLayout());
-	    content_pane.add(details_pane, BorderLayout.CENTER);
-	    content_pane.add(button_pane, BorderLayout.SOUTH);
-	    
-	    // Display on screen.
-	    Dimension screen_size = Configuration.screen_size;
-	    setLocation((screen_size.width - PROMPT_SIZE.width) / 2, (screen_size.height - PROMPT_SIZE.height) / 2);
-	    screen_size = null;
-	    setVisible(true);
-	    
-	}
-
-	/** Method which actually forces the dialog to be shown on screen.
-	 * @return <i>true</i> if the user completed configuration and pressed ok, <i>false</i> otherwise.
-	 */
-	public boolean display() {
-	    setVisible(true);
-	    return true;
-	    //    return success;
-	}
-	
-	public void destroy() {
-	}
-
-    	private class AddIndexListener
-	    implements ActionListener
-	{
-	    public void actionPerformed(ActionEvent event)
+
+		    level_label = new JLabel();
+		    Dictionary.registerText(level_label, "CDM.IndexManager.Level");
+		    level_combobox = new JComboBox();
+		    level_combobox.setPreferredSize(FIELD_SIZE);
+		    level_combobox.addItem(CollectionConfiguration.DOCUMENT_STR);//Dictionary.get("CDM.IndexManager.Document"));
+		    level_combobox.addItem(CollectionConfiguration.PARAGRAPH_STR);//Dictionary.get("CDM.IndexManager.Paragraph"));
+		    level_combobox.addItem(CollectionConfiguration.SECTION_STR);//Dictionary.get("CDM.IndexManager.Section"));
+		    level_combobox.setEditable(false);
+		    Dictionary.registerTooltip(level_combobox, "CDM.IndexManager.Level_Tooltip");
+		    labels_pane.add(level_label, BorderLayout.SOUTH);
+		    boxes_pane.add(level_combobox, BorderLayout.SOUTH);
+
+		} else {
+		    allfields_pane = new JPanel();
+		    allfields_box = new JCheckBox();
+		    JLabel allfields_label = new JLabel();
+		    Dictionary.registerText(allfields_label, "CDM.IndexManager.Allfields_Index");
+		    allfields_pane.setLayout(new BorderLayout());
+		    allfields_pane.add(allfields_box, BorderLayout.WEST);
+		    allfields_pane.add(allfields_label, BorderLayout.CENTER);
+		
+
+		}
+		// if we are editing, fill in the controls
+		if (existing_index !=null) {
+		    ArrayList sources = existing_index.getSources();
+		    if (mgpp_enabled && sources.get(0).equals(ALLFIELDS)) {
+			source_list.setEnabled(false);
+			allfields_box.setSelected(true);
+		    } else {
+			source_list.setTickedObjects(sources.toArray());
+			source_list.setEnabled(true); 
+		    }
+		    if (!mgpp_enabled) {
+			level_combobox.setSelectedIndex(existing_index.getLevel());
+		    }
+		
+		}
+		content_pane.setLayout(new BorderLayout());
+		content_pane.add(details_pane, BorderLayout.CENTER);
+		content_pane.add(button_pane, BorderLayout.SOUTH);
+	    
+		// Display on screen.
+		Dimension screen_size = Configuration.screen_size;
+		setLocation((screen_size.width - PROMPT_SIZE.width) / 2, (screen_size.height - PROMPT_SIZE.height) / 2);
+		screen_size = null;
+		setVisible(true);
+	    
+	    }
+
+	    /** Method which actually forces the dialog to be shown on screen.
+	     * @return <i>true</i> if the user completed configuration and pressed ok, <i>false</i> otherwise.
+	     */
+	    public boolean display() {
+		setVisible(true);
+		return true;
+		//    return success;
+	    }
+	
+	    public void destroy() {
+	    }
+
+	    private class AddIndexListener
+		implements ActionListener
 	    {
-		Index index;
-		if (mgpp_enabled && allfields_box.isSelected()) {
-		    ArrayList sources = new ArrayList();
-		    sources.add(ALLFIELDS);
-		    index = new Index(sources);
-		}
-		else if (!source_list.isNothingTicked()) {
-		    ArrayList sources = source_list.getTicked();
-		    if(mgpp_enabled) {
+		public void actionPerformed(ActionEvent event)
+		{
+		    Index index;
+		    if (mgpp_enabled && allfields_box.isSelected()) {
+			ArrayList sources = new ArrayList();
+			sources.add(ALLFIELDS);
 			index = new Index(sources);
+		    }
+		    else if (!source_list.isNothingTicked()) {
+			ArrayList sources = source_list.getTicked();
+			if(mgpp_enabled) {
+			    index = new Index(sources);
+			} else {
+			    index = new Index(level_combobox.getSelectedIndex(), sources);
+			}
 		    } else {
-			index = new Index(level_combobox.getSelectedIndex(), sources);
-		    }
-		} else {
-		    return;
-		}
+			return;
+		    }
 		 
-		// Before we add the index to the model, we have to add a default collection metadata for this
-		CollectionMeta metadatum = new CollectionMeta(CollectionConfiguration.STOP_CHARACTER + index.getID());
-		metadatum.setValue(index.getID());
-		
-		// Finally, add the index
-		addIndex(index, metadatum);
-		index_list.setSelectedValue(index, true);
-		new_index_prompt.dispose();
-	    }
-	}
-
-	/** add all sources as indexes. for MG, this adds them in one combined
-	    index, for MGPP this adds them as individual indexes (fields) */
-	private class AddAllIndexActionListener
-	    implements ActionListener {
-
-	    public void actionPerformed(ActionEvent event) {
-		ArrayList all_sources = source_list.getAll();
-		if (!mgpp_enabled) {
-		    Index index = new Index(level_combobox.getSelectedIndex(), all_sources);
-		    if (!index_model.contains(index)) {
-			CollectionMeta metadatum = new CollectionMeta(CollectionConfiguration.STOP_CHARACTER + index.getID());
-			metadatum.setValue("all fields"); // need a good name
-			addIndex(index, metadatum);
-		    }
-		    all_sources = null;
-		    index = null;
-		    return;
-		}
-		
-		ArrayList new_sources = new ArrayList();
-		for(int i = 0; i < all_sources.size(); i++) {
-		    Object source = all_sources.get(i);
-
-		    // Create new index
-		    new_sources.clear();
-		    new_sources.add(source);
-		    Index index = new Index(new_sources);
-		    if(!index_model.contains(index)) {
-			// Determine the metadatum value
-			String name = source.toString();
-			if(name.startsWith(StaticStrings.EXTRACTED_NAMESPACE)) {
-			    name = name.substring(StaticStrings.EXTRACTED_NAMESPACE.length());
-			}
-			// Create new metadatum
-			CollectionMeta metadatum = new CollectionMeta(CollectionConfiguration.STOP_CHARACTER + index.getID());
-			metadatum.setValue(name);
-			name = null;
-			// Assign new index
-			addIndex(index, metadatum);
-		    }
-		    source = null;
-		    index = null;
-		}
-		new_sources = null;
-		new_index_prompt.dispose();
-		
-	    }
-	}
-    
-	private class SourceListListener
-	    implements ListSelectionListener {
-	    
-	    public void valueChanged(ListSelectionEvent event) {
-		if (event.getValueIsAdjusting()) {
-		    return;
-		}
-		boolean enabled = !source_list.isNothingTicked();
-		if (editing) {
-		    replace_button.setEnabled(enabled);
-		} else { 
-		    add_button.setEnabled(enabled);
-		}
-		
-	    }
-	}
-	
-
-	private class ReplaceIndexListener
-	    implements ActionListener {
-	    
-	    public void actionPerformed(ActionEvent event) {
-		
-		ArrayList sources;
-		Index index = null;
-		if (mgpp_enabled && allfields_box.isSelected()) {
-		    sources = new ArrayList();
-		    sources.add(ALLFIELDS);
-		    index = new Index(sources);
-		} 
-		else if (!source_list.isNothingTicked()) {
-		    sources = source_list.getTicked();
-		    if (mgpp_enabled) {
-			index = new Index(sources);
-		    } else {
-			index = new Index(level_combobox.getSelectedIndex(), sources);
-		    }
-		}
-		if (index != null) {
-		    // Create the new collection meta
+		    // Before we add the index to the model, we have to add a default collection metadata for this
 		    CollectionMeta metadatum = new CollectionMeta(CollectionConfiguration.STOP_CHARACTER + index.getID());
 		    metadatum.setValue(index.getID());
+		
+		    // Finally, add the index
+		    addIndex(index, metadatum);
+		    index_list.setSelectedValue(index, true);
+		    new_index_prompt.dispose();
+		}
+	    }
+
+	    /** add all sources as indexes. for MG, this adds them in one combined
+		index, for MGPP this adds them as individual indexes (fields) */
+	    private class AddAllIndexActionListener
+		implements ActionListener {
+
+		public void actionPerformed(ActionEvent event) {
+		    ArrayList all_sources = source_list.getAll();
+		    if (!mgpp_enabled) {
+			Index index = new Index(level_combobox.getSelectedIndex(), all_sources);
+			if (!index_model.contains(index)) {
+			    CollectionMeta metadatum = new CollectionMeta(CollectionConfiguration.STOP_CHARACTER + index.getID());
+			    metadatum.setValue("all fields"); // need a good name
+			    addIndex(index, metadatum);
+			}
+			all_sources = null;
+			index = null;
+			return;
+		    }
+		
+		    ArrayList new_sources = new ArrayList();
+		    for(int i = 0; i < all_sources.size(); i++) {
+			Object source = all_sources.get(i);
+
+			// Create new index
+			new_sources.clear();
+			new_sources.add(source);
+			Index index = new Index(new_sources);
+			if(!index_model.contains(index)) {
+			    // Determine the metadatum value
+			    String name = source.toString();
+			    if(name.startsWith(StaticStrings.EXTRACTED_NAMESPACE)) {
+				name = name.substring(StaticStrings.EXTRACTED_NAMESPACE.length());
+			    }
+			    // Create new metadatum
+			    CollectionMeta metadatum = new CollectionMeta(CollectionConfiguration.STOP_CHARACTER + index.getID());
+			    metadatum.setValue(name);
+			    name = null;
+			    // Assign new index
+			    addIndex(index, metadatum);
+			}
+			source = null;
+			index = null;
+		    }
+		    new_sources = null;
+		    new_index_prompt.dispose();
+		
+		}
+	    }
+    
+	    private class SourceListListener
+		implements ListSelectionListener {
+	    
+		public void valueChanged(ListSelectionEvent event) {
+		    if (event.getValueIsAdjusting()) {
+			return;
+		    }
+		    boolean enabled = !source_list.isNothingTicked();
+		    if (editing) {
+			replace_button.setEnabled(enabled);
+		    } else { 
+			add_button.setEnabled(enabled);
+		    }
+		
+		}
+	    }
+	
+
+	    private class ReplaceIndexListener
+		implements ActionListener {
+	    
+		public void actionPerformed(ActionEvent event) {
+		
+		    ArrayList sources;
+		    Index index = null;
+		    if (mgpp_enabled && allfields_box.isSelected()) {
+			sources = new ArrayList();
+			sources.add(ALLFIELDS);
+			index = new Index(sources);
+		    } 
+		    else if (!source_list.isNothingTicked()) {
+			sources = source_list.getTicked();
+			if (mgpp_enabled) {
+			    index = new Index(sources);
+			} else {
+			    index = new Index(level_combobox.getSelectedIndex(), sources);
+			}
+		    }
+		    if (index != null) {
+			// Create the new collection meta
+			CollectionMeta metadatum = new CollectionMeta(CollectionConfiguration.STOP_CHARACTER + index.getID());
+			metadatum.setValue(index.getID());
 		    
-		    // replace the index
-		    replaceIndex((Index) index_list.getSelectedValue(), index, metadatum);
-		    index_list.setSelectedValue(index, true);
+			// replace the index
+			replaceIndex((Index) index_list.getSelectedValue(), index, metadatum);
+			index_list.setSelectedValue(index, true);
 		    
-		}
-		new_index_prompt.dispose();
-		
-	    }
-	}
-	
-    }
-	
-	
+		    }
+		    new_index_prompt.dispose();
+		
+		}
+	    }
+	}
+    }
 }
-
-}
