Revision: 29195 http://sourceforge.net/p/bibdesk/svn/29195 Author: hofman Date: 2025-04-25 17:46:55 +0000 (Fri, 25 Apr 2025) Log Message: ----------- Ask the user whether to reset a default server to its default values when choosing Remove while editing a server for whih default values exist.
Modified Paths: -------------- trunk/bibdesk/BDSKSearchGroupServerManager.h trunk/bibdesk/BDSKSearchGroupServerManager.m trunk/bibdesk/BDSKSearchGroupSheetController.m trunk/bibdesk/de.lproj/Localizable.strings trunk/bibdesk/en.lproj/Localizable.strings trunk/bibdesk/fr.lproj/Localizable.strings Modified: trunk/bibdesk/BDSKSearchGroupServerManager.h =================================================================== --- trunk/bibdesk/BDSKSearchGroupServerManager.h 2025-04-25 16:30:07 UTC (rev 29194) +++ trunk/bibdesk/BDSKSearchGroupServerManager.h 2025-04-25 17:46:55 UTC (rev 29195) @@ -54,10 +54,12 @@ - (void)resetServers; @property (nonatomic, readonly) NSArray *servers; +@property (nonatomic, readonly) NSSet *defaultServerNames; - (void)addServer:(BDSKServerInfo *)info; - (void)setServer:(BDSKServerInfo *)info atIndex:(NSUInteger)index; - (void)removeServerAtIndex:(NSUInteger)index; +- (void)resetServerAtIndex:(NSUInteger)index; @end Modified: trunk/bibdesk/BDSKSearchGroupServerManager.m =================================================================== --- trunk/bibdesk/BDSKSearchGroupServerManager.m 2025-04-25 16:30:07 UTC (rev 29194) +++ trunk/bibdesk/BDSKSearchGroupServerManager.m 2025-04-25 17:46:55 UTC (rev 29195) @@ -51,7 +51,7 @@ @implementation BDSKSearchGroupServerManager -@dynamic servers; +@dynamic servers, defaultServerNames; static BDSKSearchGroupServerManager *sharedManager = nil; @@ -193,6 +193,10 @@ return searchGroupServers; } +- (NSSet *)defaultServerNames { + return defaultSearchGroupServerNames; +} + - (void)addServer:(BDSKServerInfo *)serverInfo { // this also makes sure any password is saved in the keychain @@ -224,4 +228,18 @@ [searchGroupServers removeObjectAtIndex:idx]; } +- (void)resetServerAtIndex:(NSUInteger)idx { + NSString *name = [[searchGroupServers objectAtIndex:idx] name]; + NSString *path = [[NSBundle mainBundle] pathForResource:SERVERS_FILENAME ofType:@"plist"]; + NSArray *serverDicts = [NSArray arrayWithContentsOfFile:path]; + for (NSDictionary *dict in serverDicts) { + if ([[dict objectForKey:@"name"] isEqualToString:name]) { + BDSKServerInfo *info = [[BDSKServerInfo alloc] initWithDictionary:dict]; + [self deleteServerFile:info]; + [searchGroupServers replaceObjectAtIndex:idx withObject:info]; + break; + } + } +} + @end Modified: trunk/bibdesk/BDSKSearchGroupSheetController.m =================================================================== --- trunk/bibdesk/BDSKSearchGroupSheetController.m 2025-04-25 16:30:07 UTC (rev 29194) +++ trunk/bibdesk/BDSKSearchGroupSheetController.m 2025-04-25 17:46:55 UTC (rev 29195) @@ -226,9 +226,27 @@ } else { // remove the selected default server - [[BDSKSearchGroupServerManager sharedManager] removeServerAtIndex:[serverPopup indexOfSelectedItem]]; - [self reloadServersSelectingServerNamed:DEFAULT_SERVER_NAME]; - [[NSNotificationCenter defaultCenter] postNotificationName:BDSKSearchGroupServersDidChangeNotification object:self]; + if ([self isEditable] && [[[BDSKSearchGroupServerManager sharedManager] defaultServerNames] containsObject:[serverInfo name]]) { + NSAlert *alert = [[NSAlert alloc] init]; + [alert setMessageText:NSLocalizedString(@"Default Server Name", @"Message in alert dialog when deleting a search group server with a default name")]; + [alert setInformativeText:NSLocalizedString(@"Do you want to reset this server to its default settings, or remove it from the default servers?", @"Informative text in alert dialog when deleting a search group server server with a default name")]; + [alert addButtonWithTitle:NSLocalizedString(@"Remove", @"Button title")]; + [alert addButtonWithTitle:NSLocalizedString(@"Reset", @"Button title")]; + [alert beginSheetModalForWindow:[self window] completionHandler:^(NSModalResponse returnCode){ + if (returnCode == NSAlertFirstButtonReturn) { + [[BDSKSearchGroupServerManager sharedManager] removeServerAtIndex:[serverPopup indexOfSelectedItem]]; + [self reloadServersSelectingServerNamed:DEFAULT_SERVER_NAME]; + [[NSNotificationCenter defaultCenter] postNotificationName:BDSKSearchGroupServersDidChangeNotification object:self]; + } else { + [[BDSKSearchGroupServerManager sharedManager] resetServerAtIndex:[serverPopup indexOfSelectedItem]]; + [self selectPredefinedServer:serverPopup]; + } + }]; + } else { + [[BDSKSearchGroupServerManager sharedManager] removeServerAtIndex:[serverPopup indexOfSelectedItem]]; + [self reloadServersSelectingServerNamed:DEFAULT_SERVER_NAME]; + [[NSNotificationCenter defaultCenter] postNotificationName:BDSKSearchGroupServersDidChangeNotification object:self]; + } } } 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 Bibdesk-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-commit