Revision: 28408
          http://sourceforge.net/p/bibdesk/svn/28408
Author:   hofman
Date:     2023-10-15 08:56:13 +0000 (Sun, 15 Oct 2023)
Log Message:
-----------
Add allowsEmptyString property to field name and type name formatters. Check 
for empty strings in type info editor and field sheet.

Modified Paths:
--------------
    trunk/bibdesk/BDSKFieldNameFormatter.h
    trunk/bibdesk/BDSKFieldNameFormatter.m
    trunk/bibdesk/BDSKFieldSheetController.m
    trunk/bibdesk/BDSKTypeInfoEditor.m
    trunk/bibdesk/BDSKTypeNameFormatter.h
    trunk/bibdesk/BDSKTypeNameFormatter.m
    trunk/bibdesk/de.lproj/Localizable.strings
    trunk/bibdesk/en.lproj/Localizable.strings
    trunk/bibdesk/fr.lproj/Localizable.strings

Modified: trunk/bibdesk/BDSKFieldNameFormatter.h
===================================================================
--- trunk/bibdesk/BDSKFieldNameFormatter.h      2023-10-15 08:27:54 UTC (rev 
28407)
+++ trunk/bibdesk/BDSKFieldNameFormatter.h      2023-10-15 08:56:13 UTC (rev 
28408)
@@ -43,8 +43,10 @@
 
 @interface BDSKFieldNameFormatter : NSFormatter {
     NSArray *knownFieldNames;
+    BOOL allowsEmptyString;
 }
 
 @property (nonatomic, copy) NSArray *knownFieldNames;
+@property (nonatomic) BOOL allowsEmptyString;
 
 @end

Modified: trunk/bibdesk/BDSKFieldNameFormatter.m
===================================================================
--- trunk/bibdesk/BDSKFieldNameFormatter.m      2023-10-15 08:27:54 UTC (rev 
28407)
+++ trunk/bibdesk/BDSKFieldNameFormatter.m      2023-10-15 08:56:13 UTC (rev 
28408)
@@ -49,7 +49,7 @@
 
 @implementation BDSKFieldNameFormatter
 
-@synthesize knownFieldNames;
+@synthesize knownFieldNames, allowsEmptyString;
 
 - (void)dealloc {
     BDSKDESTROY(knownFieldNames);
@@ -70,6 +70,10 @@
         *obj = string;
         return YES;
     }
+    if (allowsEmptyString == NO && [NSString isEmptyString:string]){
+        if(error) *error = NSLocalizedString(@"Empty field names are not 
allowed.", @"Error description");
+        return NO;
+    }
     NSCharacterSet *invalidSet = [[BDSKTypeManager sharedManager] 
invalidFieldNameCharacterSet];
     NSRange r = [string rangeOfCharacterFromSet:invalidSet];
     if (r.location != NSNotFound) {

Modified: trunk/bibdesk/BDSKFieldSheetController.m
===================================================================
--- trunk/bibdesk/BDSKFieldSheetController.m    2023-10-15 08:27:54 UTC (rev 
28407)
+++ trunk/bibdesk/BDSKFieldSheetController.m    2023-10-15 08:56:13 UTC (rev 
28408)
@@ -107,6 +107,7 @@
         [choosableFields release];
         choosableFields = [array copy];
         [[chosenFieldComboBox formatter] setKnownFieldNames:choosableFields];
+        [[chosenFieldComboBox formatter] setAllowsEmptyString:NO];
     }
 }
 

Modified: trunk/bibdesk/BDSKTypeInfoEditor.m
===================================================================
--- trunk/bibdesk/BDSKTypeInfoEditor.m  2023-10-15 08:27:54 UTC (rev 28407)
+++ trunk/bibdesk/BDSKTypeInfoEditor.m  2023-10-15 08:56:13 UTC (rev 28408)
@@ -378,7 +378,8 @@
         // NSDictionary copies its keys, so types may be the only thing 
retaining oldValue (see bug #1596532)
         NSString *oldValue = [[[types objectAtIndex:row] retain] autorelease];
         NSString *newValue = [[sender stringValue] entryType];
-        if (NO == [newValue isEqualToString:oldValue] &&
+        if (NO == [NSString isEmptyString:newValue] &&
+            NO == [newValue isEqualToString:oldValue] &&
             NO == [types containsObject:newValue]) {
             
             [types replaceObjectAtIndex:row withObject:newValue];
@@ -397,7 +398,8 @@
         // NSDictionary copies its keys, so types may be the only thing 
retaining oldValue (see bug #1596532)
         NSString *oldValue = [currentRequiredFields objectAtIndex:row];
         NSString *newValue = [[sender stringValue] fieldName];
-        if (NO == [newValue isEqualToString:oldValue] &&
+        if (NO == [NSString isEmptyString:newValue] &&
+            NO == [newValue isEqualToString:oldValue] &&
             NO == [currentRequiredFields containsObject:newValue] &&
             NO == [currentOptionalFields containsObject:newValue]) {
             
@@ -414,7 +416,8 @@
         // NSDictionary copies its keys, so types may be the only thing 
retaining oldValue (see bug #1596532)
         NSString *oldValue = [currentOptionalFields objectAtIndex:row];
         NSString *newValue = [[sender stringValue] fieldName];
-        if (NO == [newValue isEqualToString:oldValue] &&
+        if (NO == [NSString isEmptyString:newValue] &&
+            NO == [newValue isEqualToString:oldValue] &&
             NO == [currentRequiredFields containsObject:newValue] &&
             NO == [currentOptionalFields containsObject:newValue]) {
             
@@ -538,6 +541,7 @@
     }
     [textField setObjectValue:value];
     [textField setEnabled:editable];
+    [[textField formatter] setAllowsEmptyString:NO];
     return view;
 }
 

Modified: trunk/bibdesk/BDSKTypeNameFormatter.h
===================================================================
--- trunk/bibdesk/BDSKTypeNameFormatter.h       2023-10-15 08:27:54 UTC (rev 
28407)
+++ trunk/bibdesk/BDSKTypeNameFormatter.h       2023-10-15 08:56:13 UTC (rev 
28408)
@@ -42,7 +42,9 @@
 
 
 @interface BDSKTypeNameFormatter : NSFormatter {
-
+    BOOL allowsEmptyString;
 }
 
+@property (nonatomic) BOOL allowsEmptyString;
+
 @end

Modified: trunk/bibdesk/BDSKTypeNameFormatter.m
===================================================================
--- trunk/bibdesk/BDSKTypeNameFormatter.m       2023-10-15 08:27:54 UTC (rev 
28407)
+++ trunk/bibdesk/BDSKTypeNameFormatter.m       2023-10-15 08:56:13 UTC (rev 
28408)
@@ -49,6 +49,8 @@
 
 @implementation BDSKTypeNameFormatter
 
+@synthesize allowsEmptyString;
+
 - (NSString *)stringForObjectValue:(id)obj{
     return obj;
 }
@@ -58,6 +60,10 @@
 }
 
 - (BOOL)getObjectValue:(id *)obj forString:(NSString *)string 
errorDescription:(NSString **)error{
+    if (allowsEmptyString == NO && [NSString isEmptyString:string]){
+        if(error) *error = NSLocalizedString(@"Empty type names are not 
allowed.", @"Error description");
+        return NO;
+    }
     NSRange r = [string rangeOfCharacterFromSet:[[BDSKTypeManager 
sharedManager] invalidFieldNameCharacterSet]];
     if ( r.location != NSNotFound) {
         if (error) *error = NSLocalizedString(@"The type name contains an 
invalid character", @"field name warning");

Modified: trunk/bibdesk/de.lproj/Localizable.strings
===================================================================
(Binary files differ)

Modified: trunk/bibdesk/en.lproj/Localizable.strings
===================================================================
(Binary files differ)

Modified: trunk/bibdesk/fr.lproj/Localizable.strings
===================================================================
(Binary files differ)

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