Changeset 14745
- Timestamp:
- 2007-10-30T15:16:00+13:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gli/trunk/src/org/greenstone/gatherer/cdm/FormatManager.java
r14231 r14745 29 29 import java.awt.*; 30 30 import java.awt.event.*; 31 import java.lang.reflect.Field; 31 32 import java.util.*; 32 33 import javax.swing.*; … … 166 167 } 167 168 169 public String getDefaultFormatString(String name){ 170 String default_str = ""; 171 try{ 172 String field_name = name.toUpperCase()+"_DEFAULT_FORMAT"; 173 Field field = this.getClass().getDeclaredField(field_name); 174 Class fieldType = field.getType(); 175 default_str = (String) field.get(fieldType); 176 } catch (SecurityException e) { 177 //System.err.println("Debug: "+e.getMessage()); 178 default_str = VLIST_DEFAULT_FORMAT; 179 } catch (NoSuchFieldException e) { 180 //System.err.println("Debug: "+e.getMessage()); 181 default_str = VLIST_DEFAULT_FORMAT; 182 } catch (IllegalArgumentException e) { 183 //System.err.println("Debug: "+e.getMessage()); 184 default_str = VLIST_DEFAULT_FORMAT; 185 } catch (IllegalAccessException e) { 186 //System.err.println("Debug: "+e.getMessage()); 187 default_str = VLIST_DEFAULT_FORMAT; 188 } 189 return default_str; 190 } 191 168 192 /** Method to retrieve this managers controls. 169 193 * @return the Control for this collection. … … 225 249 return part_model; 226 250 } 227 251 228 252 private ArrayList buildVariableModel() { 229 253 ArrayList variable_model = new ArrayList(); … … 555 579 556 580 public void update() { 557 581 558 582 // Determine if replace should be enabled 559 583 if(!format_list.isSelectionEmpty()) { … … 563 587 if (shouldSave){ 564 588 String format_str = editor_textarea.getText().trim(); 565 format_str = (format_str.equals(""))? VLIST_DEFAULT_FORMAT: format_str;589 format_str = (format_str.equals(""))? getDefaultFormatString(format.getName()) : format_str; 566 590 format.setValue(format_str); 567 591 model.refresh((DOMProxyListEntry)format); … … 608 632 // Step one: reset part 609 633 if (entry.canHavePart()) { 634 // update AffectedComponents according to current entry 635 part_model = entry.getPartModel(); 636 part_combobox.setModel(new DefaultComboBoxModel(part_model.toArray())); 637 part_combobox.updateUI(); 638 610 639 part_combobox.setEnabled(true); 611 part_combobox.setSelectedIndex(part_combobox.getModel().getSize()-1); 640 part_combobox.setSelectedIndex(part_combobox.getModel().getSize()-1); 612 641 613 642 } else { … … 718 747 Format format = (Format)format_list.getSelectedValue(); 719 748 // Try to match the target, remembering the entries within are Entry's 720 Entry an_entry = new Entry(format.getFeature()); 721 feature_combobox.setSelectedItem(an_entry); 749 Entry an_entry = new Entry(format.getFeature()); 750 feature_combobox.setSelectedItem(an_entry); 722 751 // If we didn't match anything, add it and select it again 723 752 Entry result_entry = (Entry) feature_combobox.getSelectedItem(); … … 746 775 if (format.canHavePart()) { 747 776 part_combobox.setEnabled(true); 777 778 // Should update the part list and re-render the part ComboBox here 779 part_model = result_entry.getPartModel(); 780 part_combobox.setModel(new DefaultComboBoxModel(part_model.toArray())); 781 part_combobox.updateUI(); 782 748 783 // Try to match the part. 749 784 String part_entry = format.getPart(); … … 1081 1116 } 1082 1117 1118 public ArrayList getPartModel(){ 1119 DebugStream.println("getPartModel(): get appopriate affected components of this classifier"); 1120 String classifier_name = classifier == null ? "" : classifier.toString(); 1121 if(!classifier_name.equals("")){ 1122 classifier_name = classifier_name.substring(0, classifier_name.indexOf("-")).trim(); 1123 } 1124 ArrayList part_model = new ArrayList(); 1125 // DateList only has DateList component 1126 if(classifier_name.equals("DateList")){ 1127 part_model.add(new Part(DATELIST, DATELIST_DEFAULT_FORMAT)); 1128 } 1129 // Other Format Entries, display the default Affected Components 1130 else if(classifier_name.equals("")){ 1131 part_model = buildPartModel(); 1132 } 1133 // Other Classifiers have HList and VList as Affected Component 1134 else { 1135 part_model.add(new Part(HLIST, HLIST_DEFAULT_FORMAT)); 1136 part_model.add(new Part(VLIST, VLIST_DEFAULT_FORMAT)); 1137 } 1138 return part_model; 1139 } 1140 1083 1141 public String toString() { 1084 1142 if(classifier != null) {
Note:
See TracChangeset
for help on using the changeset viewer.