Changeset 5088
- Timestamp:
- 2003-08-04T11:45:43+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/cdm/SearchTypeManager.java
r5037 r5088 52 52 extends DOMProxyListModel { 53 53 54 static final public String[] SEARCH_TYPES = {"form", "plain"}; 55 54 56 /** The default size of a label, in an attempt to make labels/fields line up. */ 55 57 static final private Dimension LABEL_SIZE = new Dimension(150,25); 56 58 57 static final private String[] SEARCH_TYPES = {"form", "plain"};58 59 59 60 /** The controls used to edit the search types. */ … … 125 126 title_label.setHorizontalAlignment(JLabel.CENTER); 126 127 instructions_textarea = new JTextArea("CDM.SearchTypeManager.Instructions"); 127 instructions_textarea.setCaretPosition(0);128 128 instructions_textarea.setEditable(false); 129 129 instructions_textarea.setLineWrap(true); 130 instructions_textarea.setRows( 4);130 instructions_textarea.setRows(6); 131 131 instructions_textarea.setWrapStyleWord(true); 132 132 … … 257 257 258 258 public void gainFocus() { 259 instructions_textarea.setCaretPosition(0); 259 260 validateControls(isMGPPEnabled()); 260 261 } … … 266 267 private void validateControls(boolean advanced_search_enabled) { 267 268 // Enable or disable controls based on whether MGPP is enabled 268 add_button.setEnabled(add_button.isEnabled() && advanced_search_enabled); 269 // validate add button, which depends on the current combobox selection and the contents of the assigned search types list 270 Object selected_item = search_type_combobox.getSelectedItem(); 271 add_button.setEnabled(advanced_search_enabled && selected_item != null && !model.contains(selected_item)); 272 // validate other controls. 269 273 current_search_types_list.setEnabled(advanced_search_enabled); 270 274 enable_advanced_searches_checkbox.setSelected(advanced_search_enabled); 271 275 search_type_combobox.setEnabled(advanced_search_enabled); 272 remove_button.setEnabled( remove_button.isEnabled() && advanced_search_enabled);276 remove_button.setEnabled(current_search_types_list.getModel().getSize() > 1 && !current_search_types_list.isSelectionEmpty() && advanced_search_enabled); 273 277 } 274 278 … … 301 305 public void valueChanged(ListSelectionEvent event) { 302 306 if(!event.getValueIsAdjusting()) { 303 remove_button.setEnabled( !current_search_types_list.isSelectionEmpty());307 remove_button.setEnabled(current_search_types_list.getModel().getSize() > 1 && !current_search_types_list.isSelectionEmpty()); 304 308 } 305 309 } … … 316 320 boolean advanced_search_enabled = enable_advanced_searches_checkbox.isSelected(); 317 321 model.root.setAttribute(CollectionConfiguration.ASSIGNED_ATTRIBUTE, (advanced_search_enabled ? CollectionConfiguration.TRUE_STR : CollectionConfiguration.FALSE_STR)); 322 CollectionDesignManager.index_manager.setMGPPEnabled(advanced_search_enabled); 318 323 validateControls(advanced_search_enabled); 319 CollectionDesignManager.index_manager.setMGPPEnabled(advanced_search_enabled);320 324 Gatherer.g_man.wait(false); 321 325 } … … 335 339 } 336 340 } 341 Object selected_object = search_type_combobox.getSelectedItem(); 342 if(selected_object != null) { 343 add_button.setEnabled(!model.contains(selected_object)); 344 } 345 else { 346 add_button.setEnabled(false); 347 } 337 348 remove_button.setEnabled(false); 338 349 } … … 373 384 Object selected_object = search_type_combobox.getSelectedItem(); 374 385 if(selected_object != null) { 375 add_button.setEnabled( model.contains(selected_object));386 add_button.setEnabled(!model.contains(selected_object)); 376 387 } 377 388 else {
Note:
See TracChangeset
for help on using the changeset viewer.