Changeset 12302
- Timestamp:
- 2006-07-25T13:48:07+12:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/cdm/FormatManager.java
r12273 r12302 162 162 controls = null; 163 163 } 164 }165 166 /** Gets the format indicated by the index.167 * @param index The location of the desired format, as an <i>int</i>.168 */169 private Format getFormat(int index) {170 Format result = null;171 if(0 < index && index < getSize()) {172 result = (Format) getElementAt(index);173 }174 return result;175 164 } 176 165 … … 315 304 JPanel header_pane = new DesignPaneHeader("CDM.GUI.Formats", "formatstatements"); 316 305 317 JLabel format_label = new JLabel(Dictionary.get("CDM.FormatManager.Assigned_Formats"));318 306 format_list = new JList(model); 319 307 … … 527 515 String p = ""; 528 516 if (entry.canHavePart()) { 529 p = part_combobox.getSelectedItem().toString();517 p = ((Part)part_combobox.getSelectedItem()).getName(); 530 518 } 531 519 … … 776 764 view_type = VALUE; 777 765 // Initial values 778 779 // Try to match the part. 780 String part_entry = format.getPart(); 781 // Set Selected Item doesn't work so I'll do this manually 782 boolean found = false; 783 for(int i=0; i < part_combobox.getItemCount(); i++) { 784 Part a_part = (Part) part_combobox.getItemAt(i); 785 if(a_part.equals(part_entry)) { 786 part_combobox.setSelectedItem(a_part); 787 found = true; 788 } 789 a_part = null; 766 // do we have a part? 767 if (format.canHavePart()) { 768 part_combobox.setEnabled(true); 769 // Try to match the part. 770 String part_entry = format.getPart(); 771 // Set Selected Item doesn't work so I'll do this manually 772 boolean found = false; 773 for(int i=0; i < part_combobox.getItemCount(); i++) { 774 Part a_part = (Part) part_combobox.getItemAt(i); 775 if(a_part.equals(part_entry)) { 776 part_combobox.setSelectedItem(a_part); 777 found = true; 778 } 779 a_part = null; 780 } 781 // If we didn't match anything, add it and select it again 782 if(!found) { 783 Part a_part = new Part(part_entry, ""); 784 part_combobox.insertItemAt(a_part, part_combobox.getItemCount()); 785 part_combobox.setSelectedItem(a_part); 786 787 } 788 } else { 789 part_combobox.setEnabled(false); 790 part_combobox.setSelectedIndex(0); 790 791 } 791 // If we didn't match anything, add it and select it again792 if(!found) {793 Part a_part = new Part(part_entry, "");794 part_combobox.insertItemAt(a_part, part_combobox.getItemCount());795 part_combobox.setSelectedItem(a_part);796 797 }798 799 792 editor_textarea.setText(format.getValue()); 800 793 editor_textarea.setCaretPosition(0); … … 956 949 957 950 958 951 private class DefaultListener 959 952 implements ActionListener { 960 953 … … 1130 1123 // Return the classifier - less the 'classify ' prefix and with its CL index shown 1131 1124 return classifier.getPositionString() + StaticStrings.COLON_CHARACTER + StaticStrings.SPACE_CHARACTER + classifier.toString().substring(9); 1125 } 1126 if (text.equals("")) { 1127 return "<html><body><i>"+Dictionary.get("CDM.FormatManager.AllFeatures")+"</i></body></html>"; 1132 1128 } 1133 1129 return text; … … 1185 1181 */ 1186 1182 public int compareTo(Object obj) { 1187 return name.compareTo(obj.toString()); 1183 if (obj instanceof Part) { 1184 return name.compareTo(((Part)obj).getName()); 1185 } 1186 return name.compareTo(obj.toString()); 1188 1187 } 1189 1188 … … 1193 1192 */ 1194 1193 public boolean equals(Object obj) { 1195 return name.equals(obj.toString()); 1194 if (obj instanceof Part) { 1195 return name.equals(((Part)obj).getName()); 1196 } 1197 return name.equals(obj.toString()); 1196 1198 } 1197 1199 … … 1219 1221 */ 1220 1222 public String toString() { 1221 return name; 1223 if (name.equals("")) { 1224 return "<html><body><i>"+Dictionary.get("CDM.FormatManager.AllParts")+"</i></body></html>"; 1225 } 1226 return name; 1222 1227 } 1223 1228 }
Note:
See TracChangeset
for help on using the changeset viewer.