Changeset 9907
- Timestamp:
- 2005-05-18T17:08:50+12:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/cdm/SearchTypeManager.java
r8243 r9907 45 45 import org.w3c.dom.*; 46 46 47 /** This class maintains an ordered list of the search types available in the collection (MGPP command available in G2.39 or later). Currently only 'form' and 'plain' are valid.47 /** This class maintains an ordered list of the search types available in the collection (MGPP/lucene command available in G2.39 or later). Currently only 'form' and 'plain' are valid. 48 48 * @author John Thompson, Greenstone Digital Library, University of Waikato 49 49 * @version 2.4 … … 51 51 public class SearchTypeManager 52 52 extends DOMProxyListModel { 53 54 static final public String[] SEARCH_TYPES = { "form", "plain" }; 55 53 54 static final public String[] SEARCH_TYPES = { "plain" , "form"}; 55 static final public String[] BUILD_TYPES = { "lucene", "mgpp" }; 56 57 /** the buildtype element in the config file - searchtypemanager looks 58 * after this now */ 59 public CollectionMeta build_type = null; 56 60 /** The controls used to edit the search types. */ 57 61 private Control controls = null; … … 63 67 this.model = this; 64 68 DebugStream.println("SearchTypeManager: parsed " + getSize() + " search types."); 69 build_type = new CollectionMeta(CollectionDesignManager.collect_config.getBuildType()); 70 65 71 } 66 72 … … 71 77 } 72 78 } 73 79 74 80 public Control getControls() { 75 81 if(controls == null) { … … 79 85 } 80 86 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 /** Beexamining the SearchType 'root' we were created with, determine if mgpp is enabled.97 98 99 100 101 102 87 /** Return a list of the currently assigned search types as a comma separated string. 88 * @return a String 89 */ 90 public String getSearchTypes() { 91 StringBuffer search_types = new StringBuffer(); 92 ArrayList types = children(); 93 for (int i = 0; i < types.size(); i++) { 94 if (i>0) { 95 search_types.append(","); 96 } 97 search_types.append(((SearchType)types.get(i)).getName()); 98 } 99 return search_types.toString(); 100 } 101 102 /** By examining the SearchType 'root' we were created with, determine if mgpp is enabled. 103 * @return true if MGPP is enabled, false otherwise 104 */ 105 public boolean isMGPPEnabled() { 106 return root.getAttribute(CollectionConfiguration.ASSIGNED_ATTRIBUTE).equals(CollectionConfiguration.TRUE_STR); 107 } 108 103 109 private void moveSearchType(SearchType search_type, boolean direction) { 104 110 // Try to move the classifier one step in the desired direction. … … 142 148 143 149 private GComboBox search_type_combobox; 150 private GComboBox build_type_combobox; 144 151 145 152 private JButton add_button; … … 159 166 160 167 public SearchTypeControl() { 168 161 169 // Creation 162 170 title_label = new JLabel(); … … 179 187 JPanel inner_panel = new JPanel(); 180 188 189 JPanel indexer_type_panel = new JPanel(); 190 JPanel build_type_panel = new JPanel(); 191 181 192 enable_advanced_searches_checkbox = new JCheckBox(); 182 193 Dictionary.registerText(enable_advanced_searches_checkbox, "CDM.SearchTypeManager.Enable"); 183 194 195 build_type_combobox = new GComboBox(BUILD_TYPES); 196 build_type_combobox.setPreferredSize(Utility.LABEL_SIZE); 197 build_type_combobox.setBackgroundNonSelectionColor(Configuration.getColor("coloring.editable_background", false)); 198 build_type_combobox.setBackgroundSelectionColor(Configuration.getColor("coloring.collection_selection_background", false)); 199 build_type_combobox.setEditable(true); 200 build_type_combobox.setSelectedIndex(1);// mgpp is at 1 201 String selected_value = build_type.getValue(CollectionMeta.TEXT); 202 if (!selected_value.equals("")) { 203 for (int i=0; i<build_type_combobox.getItemCount();i++) { 204 String item = (String)build_type_combobox.getItemAt(i); 205 if (item.equals(selected_value)) { 206 build_type_combobox.setSelectedIndex(i); 207 break; 208 } 209 } 210 } else { 211 build_type.setValue((String)build_type_combobox.getSelectedItem()); 212 build_type.setAssigned(isMGPPEnabled()); 213 214 } 215 build_type_combobox.setTextNonSelectionColor(Configuration.getColor("coloring.workspace_tree_foreground", false)); 216 build_type_combobox.setTextSelectionColor(Configuration.getColor("coloring.collection_selection_foreground", false)); 217 Dictionary.registerTooltip(build_type_combobox, "CDM.SearchTypeManager.BuildType_Selection_Tooltip"); 218 219 JLabel build_type_label = new JLabel(); 220 Dictionary.registerText(build_type_label, "CDM.SearchTypeManager.BuildType_Selection"); 184 221 JPanel current_search_types_panel = new JPanel(); 185 222 current_search_types_label = new JLabel(); … … 193 230 move_up_button.setEnabled(false); 194 231 move_up_button.setMnemonic(KeyEvent.VK_U); 195 //move_up_button.setPreferredSize(Utility.DOUBLE_IMAGE_BUTTON_SIZE); 232 196 233 Dictionary.registerBoth(move_up_button, "CDM.Move.Move_Up", "CDM.Move.Move_Up_Tooltip"); 197 234 … … 199 236 move_down_button.setEnabled(false); 200 237 move_down_button.setMnemonic(KeyEvent.VK_D); 201 //move_down_button.setPreferredSize(Utility.DOUBLE_IMAGE_BUTTON_SIZE); 238 202 239 Dictionary.registerBoth(move_down_button, "CDM.Move.Move_Down", "CDM.Move.Move_Down_Tooltip"); 203 240 … … 210 247 search_type_combobox.setBackgroundSelectionColor(Configuration.getColor("coloring.collection_selection_background", false)); 211 248 search_type_combobox.setEditable(true); 212 search_type_combobox.setSelectedIndex(0); 249 search_type_combobox.setSelectedIndex(0); 213 250 search_type_combobox.setTextNonSelectionColor(Configuration.getColor("coloring.workspace_tree_foreground", false)); 214 251 search_type_combobox.setTextSelectionColor(Configuration.getColor("coloring.collection_selection_foreground", false)); … … 225 262 remove_button.setMnemonic(KeyEvent.VK_R); 226 263 Dictionary.registerBoth(remove_button, "CDM.SearchTypeManager.Remove", "CDM.SearchTypeManager.Remove_Tooltip"); 227 264 265 228 266 // Connection 229 267 add_button.addActionListener(new AddActionListener()); 268 build_type_combobox.addActionListener(new BuildTypeActionListener()); 230 269 current_search_types_list.addListSelectionListener(new CurrentSearchTypesListSelectionListener()); 231 270 enable_advanced_searches_checkbox.addActionListener(new EnableAdvancedSearchesActionListener()); … … 254 293 current_search_types_panel.add(movement_panel, BorderLayout.EAST); 255 294 295 build_type_panel.setLayout(new BorderLayout()); 296 build_type_panel.add(build_type_label, BorderLayout.WEST); 297 build_type_panel.add(build_type_combobox, BorderLayout.CENTER); 298 299 indexer_type_panel.setLayout(new GridLayout(1,2,0,5)); 300 indexer_type_panel.add(enable_advanced_searches_checkbox); 301 indexer_type_panel.add(build_type_panel); 302 256 303 button_panel.setBorder(BorderFactory.createEmptyBorder(2,0,0,0)); 257 304 button_panel.setLayout(new GridLayout(1,2,0,5)); … … 265 312 266 313 inner_panel.setLayout(new BorderLayout()); 267 inner_panel.add( enable_advanced_searches_checkbox, BorderLayout.NORTH);314 inner_panel.add(indexer_type_panel, BorderLayout.NORTH); 268 315 inner_panel.add(current_search_types_panel, BorderLayout.CENTER); 269 316 inner_panel.add(search_type_panel, BorderLayout.SOUTH); … … 298 345 // validate other controls. 299 346 current_search_types_list.setEnabled(advanced_search_enabled); 347 build_type_combobox.setEnabled(advanced_search_enabled); 300 348 enable_advanced_searches_checkbox.setSelected(advanced_search_enabled); 301 349 search_type_combobox.setEnabled(advanced_search_enabled); … … 362 410 CollectionDesignManager.index_manager.setMGPPEnabled(advanced_search_enabled); 363 411 validateControls(advanced_search_enabled); 412 build_type.setAssigned(advanced_search_enabled); 364 413 Gatherer.g_man.wait(false); 365 414 } 366 415 } 367 416 417 private class BuildTypeActionListener 418 implements ActionListener { 419 420 public void actionPerformed(ActionEvent event) { 421 build_type.setValue((String)build_type_combobox.getSelectedItem()); 422 } 423 424 } 368 425 /** Listenes for actions on the Remove button, and if detected removes the currently selected search types. */ 369 426 private class RemoveActionListener
Note:
See TracChangeset
for help on using the changeset viewer.