Revision: 30044
          http://sourceforge.net/p/bibdesk/svn/30044
Author:   hofman
Date:     2026-02-22 22:48:07 +0000 (Sun, 22 Feb 2026)
Log Message:
-----------
convenience method to reload fields table after field change

Modified Paths:
--------------
    trunk/bibdesk/BDSKEditor.m

Modified: trunk/bibdesk/BDSKEditor.m
===================================================================
--- trunk/bibdesk/BDSKEditor.m  2026-02-22 17:44:09 UTC (rev 30043)
+++ trunk/bibdesk/BDSKEditor.m  2026-02-22 22:48:07 UTC (rev 30044)
@@ -139,6 +139,7 @@
 - (void)setupTypePopUp;
 - (NSArray *)currentFields;
 - (void)reloadTableWithFields:(NSArray *)newFields;
+- (void)reloadTableIgnoringEditsForField:(NSString *)field;
 - (void)updateTableViewDisplay;
 - (void)registerForNotifications;
 - (void)updateCiteKeyDuplicateWarning;
@@ -2381,14 +2382,7 @@
        }
     else if (changeKey == nil){
         // all fields are set
-        NSInteger editedRow = [tableView editedTextRow];
-        if (editedRow != -1) {
-            NSString *key = [fields objectAtIndex:editedRow];
-            NSString *tmpValue = [publication valueOfField:key] ?: @"";
-            NSTextField *textField = [self textFieldAtRow:editedRow];
-            [[textField currentEditor] setString:[textField formatter] ? 
[[textField formatter] editingStringForObjectValue:tmpValue] : tmpValue];
-        }
-        [self reloadTableWithFields:[self currentFields]];
+        [self reloadTableIgnoringEditsForField:nil];
         if (inheritedValueChanged == NO)
             [self setupCollectionView];
         [self synchronizeWindowTitleWithDocumentName];
@@ -2423,13 +2417,7 @@
         NSInteger row = [fields indexOfObject:changeKey];
         if (row >= minNumberOfFields && ([NSString 
isEmptyAsComplexString:newValue] != [NSString 
isEmptyAsComplexString:oldValue])) {
                        // a custom field was added or removed
-            NSInteger editedRow = [tableView editedTextRow];
-            if (editedRow != -1 && [[fields objectAtIndex:editedRow] 
isEqualToString:changeKey]) {
-                NSString *tmpValue = [publication valueOfField:changeKey] ?: 
@"";
-                BDSKEditorTextField *textField = [self 
textFieldAtRow:editedRow];
-                [[textField currentEditor] setString:[textField formatter] ? 
[[textField formatter] editingStringForObjectValue:tmpValue] : tmpValue];
-            }
-            [self reloadTableWithFields:[self currentFields]];
+            [self reloadTableIgnoringEditsForField:changeKey];
         } else if (row != NSNotFound) {
             // a field value changed
             // don't use newValue, because this can be the parent's value
@@ -3286,6 +3274,19 @@
         [self editTextFieldAtRow:NSNotFound forField:editedTitle 
selection:selection];
 }
 
+- (void)reloadTableIgnoringEditsForField:(NSString *)field {
+    NSInteger editedRow = [tableView editedTextRow];
+    if (editedRow != -1) {
+        NSString *editedField = [fields objectAtIndex:editedRow];
+        if (field == nil || [field isEqualToString:editedField]) {
+            NSString *value = [publication valueOfField:editedField] ?: @"";
+            BDSKEditorTextField *textField = [self textFieldAtRow:editedRow];
+            [[textField currentEditor] setString:[textField formatter] ? 
[[textField formatter] editingStringForObjectValue:value] : value];
+        }
+    }
+    [self reloadTableWithFields:[self currentFields]];
+}
+
 - (void)updateTableViewDisplay {
     [fields enumerateObjectsUsingBlock:^(NSString *field, NSUInteger row, BOOL 
*stop){
         BDSKEditorTextField *textField = [self textFieldAtRow:row];

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to