Changeset 4362
- Timestamp:
- 2003-05-27T15:28:23+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/msm/MetadataSetManager.java
r4315 r4362 941 941 * @param element The metadata element, contained within an ElementWrapper to base metadata on. 942 942 * @param value The value to assign to the metadata as a String. 943 * @param action The default action to take in the prompt. 944 * @param file_level If true then the metadata can be replaced normally, if false then we should actually use an add method instead. 943 945 * @return The Metadata we just assigned. 944 946 */ 945 public Metadata updateMetadata(long id, Metadata old_metadata, FileNode records[], String value_str, int action ) {947 public Metadata updateMetadata(long id, Metadata old_metadata, FileNode records[], String value_str, int action, boolean file_level) { 946 948 // Retrieve the new value node from the same value tree as the old metadata. 947 949 ElementWrapper element = old_metadata.getElement(); … … 964 966 // And then update each selection file node. 965 967 for(int i = 0; action != MetaEditPrompt.CANCEL && i < records.length; i++) { 966 action = updateMetadata(id, records[i], old_metadata, new_metadata, action, (records.length > 1) );968 action = updateMetadata(id, records[i], old_metadata, new_metadata, action, (records.length > 1), file_level); 967 969 } 968 970 // If we were cancelled we should undo any changes so far … … 1109 1111 } 1110 1112 // Store undo information 1111 undo_buffer.put(record, data);1113 undo_buffer.put(record, undo); 1112 1114 } 1113 1115 // If we've been cancelled higher up, undo action. … … 1163 1165 Metadata new_data = (Metadata) undo.get(1); 1164 1166 fireMetadataChanged(id, record, new_data, null); 1165 fireMetadataChanged(id, record, null, old_data); 1167 if(old_data != new_data) { // Correct reference comparison 1168 fireMetadataChanged(id, record, null, old_data); 1169 } 1166 1170 } 1167 1171 } … … 1176 1180 * @return An <i>int</i> specifying the current action. Thus changes in lower parts of the tree continue to effect other disjoint subtrees. 1177 1181 */ 1178 private int updateMetadata(long id, FileNode record, Metadata old_data, Metadata new_data, int action, boolean multiple_selection) { 1179 ArrayList metadata = Gatherer.c_man.getCollection().gdm.getMetadata(record.getFile()); 1182 private int updateMetadata(long id, FileNode record, Metadata old_data, Metadata new_data, int action, boolean multiple_selection, boolean file_level) { 1183 ArrayList metadata; 1184 if(file_level) { 1185 metadata = Gatherer.c_man.getCollection().gdm.getMetadata(record.getFile()); 1186 } 1187 else { 1188 metadata = Gatherer.c_man.getCollection().gdm.getAllMetadata(record.getFile()); 1189 } 1180 1190 int user_action = MetaEditPrompt.OVERWRITE; 1181 1191 // Standard case of updating an existing metadata value. … … 1194 1204 if(action == MetaEditPrompt.OVERWRITE_ALL || user_action == MetaEditPrompt.OVERWRITE || user_action == MetaEditPrompt.UPDATE_ONCE) { 1195 1205 ///ystem.err.println("Updating:\n"+old_data+"\nto\n"+new_data); 1196 fireMetadataChanged(id, record, old_data, new_data); 1197 undo.add(old_data); 1198 undo.add(new_data); 1206 // If this is file level then we can do a normal replace 1207 if(file_level) { 1208 fireMetadataChanged(id, record, old_data, new_data); 1209 undo.add(old_data); 1210 undo.add(new_data); 1211 } 1212 // Otherwise we are dealing with someone attempting to override inherited metadata, so we actually fire an add. To this end we add new data twice to the undo buffer, thus we can detect if this has happened. 1213 else { 1214 fireMetadataChanged(id, record, null, new_data); 1215 undo.add(new_data); 1216 undo.add(new_data); 1217 } 1199 1218 } 1200 1219 // Store the undo information
Note:
See TracChangeset
for help on using the changeset viewer.