Index: /main/trunk/gli/src/org/greenstone/gatherer/cdm/SortFieldManager.java
===================================================================
--- /main/trunk/gli/src/org/greenstone/gatherer/cdm/SortFieldManager.java	(revision 36252)
+++ /main/trunk/gli/src/org/greenstone/gatherer/cdm/SortFieldManager.java	(revision 36253)
@@ -25,4 +25,10 @@
 package org.greenstone.gatherer.cdm;
 
+import java.awt.*;
+import java.awt.event.*;
+import java.util.*;
+import javax.swing.*;
+
+import org.greenstone.gatherer.Dictionary;
 import org.greenstone.gatherer.util.StaticStrings;
 import org.w3c.dom.*;
@@ -30,4 +36,7 @@
 /** handles sortfields for lucene and solr collections */
 public class SortFieldManager extends BaseIndexManager {
+
+    static final private String NONE = "none";
+    static final private String RANK = "rank";
 
     public SortFieldManager(Element sortfields, String current_build_type) {
@@ -48,4 +57,7 @@
 	this.nip_replace_index_button_key = "CDM.SortFieldManager.Replace";
 	this.nip_replace_index_tooltip_key = "CDM.SortFieldManager.Replace_Tooltip";
+	this.nip_add_all_index_button_key = "CDM.IndexManager.AddAll";
+      this.nip_add_all_index_tooltip_key = "CDM.SortFieldManager.AddAll_Tooltip";
+
     }
 
@@ -60,3 +72,119 @@
     }
 
+    public Control getControls() {
+	if (controls == null) {
+	    controls = new SortFieldControl();
+	}
+	return controls;
+    }
+
+    private class SortFieldControl
+	extends IndexControl {
+
+	public SortFieldControl() {
+	    super();	    
+	}
+
+	/** we want our own custom new index prompt for searhc indexes */
+	protected NewIndexPrompt createNewIndexPrompt(String build_type, Index index) {
+	    return new NewSortFieldPrompt(build_type, index);
+	    
+	}
+
+	// we extend this to add in the rank/none options
+	protected class NewSortFieldPrompt
+	    extends NewIndexPrompt {
+
+	    private JCheckBox none_checkbox;
+	    private JCheckBox rank_checkbox;
+
+          public NewSortFieldPrompt(String build_type, Index existing_index) {
+            super(build_type, existing_index);	    
+          }
+          
+          /** inside here is where we customise our controls */
+          protected void generateContents(String build_type, Index existing_index) {
+	      super.generateContents(build_type, existing_index);
+	      none_checkbox = new JCheckBox(Dictionary.get("CDM.SortFieldManager.Field_None"));
+              none_checkbox.addItemListener(new NoneRankBoxListener());
+              none_checkbox.setComponentOrientation(Dictionary.getOrientation());
+	      none_checkbox.setToolTipText(Dictionary.get("CDM.SortFieldManager.Field_None_Tooltip"));
+
+	      rank_checkbox = new JCheckBox(Dictionary.get("CDM.SortFieldManager.Field_Rank"));
+              rank_checkbox.addItemListener(new NoneRankBoxListener());
+              rank_checkbox.setComponentOrientation(Dictionary.getOrientation());
+	      rank_checkbox.setToolTipText(Dictionary.get("CDM.SortFieldManager.Field_Rank_Tooltip"));
+
+	      // fill in none/rank if it is selected in existing index
+	      if (existing_index !=null) {
+		  ArrayList sources = existing_index.getSources();
+		  if (sources.contains(NONE)) {
+		      none_checkbox.setSelected(true);
+		      rank_checkbox.setEnabled(false);
+		      source_list.setEnabled(false);
+		  } else if (sources.contains(RANK)) {
+		      rank_checkbox.setSelected(true);
+		      none_checkbox.setEnabled(false);
+		      source_list.setEnabled(false);
+		  }
+		  
+	      }
+
+
+	      JPanel extra_options_panel = new JPanel();
+	      extra_options_panel.setComponentOrientation(Dictionary.getOrientation());
+	      extra_options_panel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
+
+	      extra_options_panel.setLayout(new GridLayout(2,1,5,5));//**
+	      extra_options_panel.add(none_checkbox);
+	      extra_options_panel.add(rank_checkbox);
+              details_pane.add(extra_options_panel, BorderLayout.NORTH);
+
+	  }
+
+	    // override this to take into account none/rank options
+	    protected Index generateNewIndex() {
+		ArrayList sources;
+
+		if (none_checkbox.isSelected()) {
+		    sources = new ArrayList();
+		    sources.add(NONE);
+		} else if (rank_checkbox.isSelected()) {
+		    sources = new ArrayList();
+		    sources.add(RANK);
+		} else if (!source_list.isNothingTicked()) {
+		    sources = source_list.getTicked();
+		} else {
+		    // nothing selected
+		    return null;
+		}
+		return new SortField(sources);
+
+	    }
+
+
+	    private class NoneRankBoxListener
+		implements ItemListener {
+
+		public void itemStateChanged(ItemEvent event) {
+
+		    if (none_checkbox.isSelected() ) {
+			source_list.setEnabled(false);
+			rank_checkbox.setEnabled(false);
+		    } else if (rank_checkbox.isSelected()) {
+			source_list.setEnabled(false);
+			none_checkbox.setEnabled(false);
+		    } else {
+			// neither button is selected
+			none_checkbox.setEnabled(true);
+			rank_checkbox.setEnabled(true);
+			source_list.setEnabled(true);
+		    }
+		    validateAddOrReplaceButton();
+		}
+		
+	    }
+	}
+	    
+    }
 }
