Revision: 29197 http://sourceforge.net/p/bibdesk/svn/29197 Author: hofman Date: 2025-04-25 21:58:13 +0000 (Fri, 25 Apr 2025) Log Message: ----------- Reset rather than remove default server that has initial default settings and was customized
Modified Paths: -------------- trunk/bibdesk/BDSKSearchGroupServerManager.h trunk/bibdesk/BDSKSearchGroupServerManager.m trunk/bibdesk/BDSKSearchGroupSheetController.h 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 17:58:00 UTC (rev 29196) +++ trunk/bibdesk/BDSKSearchGroupServerManager.h 2025-04-25 21:58:13 UTC (rev 29197) @@ -54,8 +54,9 @@ - (void)resetServers; @property (nonatomic, readonly) NSArray *servers; -@property (nonatomic, readonly) NSSet *defaultServerNames; +- (BOOL)isCustomizedDefaultServerName:(NSString *)name; + - (void)addServer:(BDSKServerInfo *)info; - (void)setServer:(BDSKServerInfo *)info atIndex:(NSUInteger)index; - (void)removeServerAtIndex:(NSUInteger)index; Modified: trunk/bibdesk/BDSKSearchGroupServerManager.m =================================================================== --- trunk/bibdesk/BDSKSearchGroupServerManager.m 2025-04-25 17:58:00 UTC (rev 29196) +++ trunk/bibdesk/BDSKSearchGroupServerManager.m 2025-04-25 21:58:13 UTC (rev 29197) @@ -51,7 +51,7 @@ @implementation BDSKSearchGroupServerManager -@dynamic servers, defaultServerNames; +@dynamic servers; static BDSKSearchGroupServerManager *sharedManager = nil; @@ -193,8 +193,8 @@ return searchGroupServers; } -- (NSSet *)defaultServerNames { - return defaultSearchGroupServerNames; +- (BOOL)isCustomizedDefaultServerName:(NSString *)name { + return [defaultSearchGroupServerNames containsObject:name] && [searchGroupServerFiles objectForKey:name]; } - (void)addServer:(BDSKServerInfo *)serverInfo Modified: trunk/bibdesk/BDSKSearchGroupSheetController.h =================================================================== --- trunk/bibdesk/BDSKSearchGroupSheetController.h 2025-04-25 17:58:00 UTC (rev 29196) +++ trunk/bibdesk/BDSKSearchGroupSheetController.h 2025-04-25 21:58:13 UTC (rev 29197) @@ -49,6 +49,7 @@ BOOL custom; BOOL editable; + BOOL resettable; NSPopUpButton *serverPopup; @@ -110,6 +111,7 @@ @property (nonatomic, getter=isCustom) BOOL custom; @property (nonatomic, getter=isEditable) BOOL editable; +@property (nonatomic, getter=isResettable) BOOL resettable; @property (nonatomic, readonly, getter=isZoom) BOOL zoom; @property (nonatomic, readonly, getter=isISI) BOOL ISI; @property (nonatomic, readonly, getter=isSRU) BOOL SRU; Modified: trunk/bibdesk/BDSKSearchGroupSheetController.m =================================================================== --- trunk/bibdesk/BDSKSearchGroupSheetController.m 2025-04-25 17:58:00 UTC (rev 29196) +++ trunk/bibdesk/BDSKSearchGroupSheetController.m 2025-04-25 21:58:13 UTC (rev 29197) @@ -53,7 +53,7 @@ @implementation BDSKSearchGroupSheetController -@synthesize serverPopup, nameField, addressField, portField, databaseField, passwordField, userField, syntaxPopup, encodingComboBox, removeDiacriticsButton, liteButton, editButton, addRemoveButton, serverView, revealButton, okButton, cancelButton, bottomConstraint, objectController, custom, editable; +@synthesize serverPopup, nameField, addressField, portField, databaseField, passwordField, userField, syntaxPopup, encodingComboBox, removeDiacriticsButton, liteButton, editButton, addRemoveButton, serverView, revealButton, okButton, cancelButton, bottomConstraint, objectController, custom, editable, resettable; @dynamic zoom, ISI, SRU, zoomOrISI, zoomOrSRU, typeTag, databases, serverInfo, undoManager; + (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key { @@ -182,6 +182,7 @@ [revealButton performClick:self]; [self setCustom:YES]; [self setEditable:YES]; + [self setResettable:NO]; [addRemoveButton setTitle:NSLocalizedString(@"Add", @"Button title")]; [addRemoveButton setToolTip:NSLocalizedString(@"Add a new default server with the current settings", @"Tool tip message")]; } else { @@ -189,8 +190,15 @@ [self setServerInfo:[servers objectAtIndex:i]]; [self setCustom:NO]; [self setEditable:NO]; - [addRemoveButton setTitle:NSLocalizedString(@"Remove", @"Button title")]; - [addRemoveButton setToolTip:NSLocalizedString(@"Remove the selected default server", @"Tool tip message")]; + if ([[BDSKSearchGroupServerManager sharedManager] isCustomizedDefaultServerName:[[self serverInfo] name]]) { + [self setResettable:YES]; + [addRemoveButton setTitle:NSLocalizedString(@"Reset", @"Button title")]; + [addRemoveButton setToolTip:NSLocalizedString(@"Reset the selected default server to its default settings", @"Tool tip message")]; + } else { + [self setResettable:NO]; + [addRemoveButton setTitle:NSLocalizedString(@"Remove", @"Button title")]; + [addRemoveButton setToolTip:NSLocalizedString(@"Remove the selected default server", @"Tool tip message")]; + } } } @@ -223,30 +231,18 @@ [self reloadServersSelectingServerNamed:[[self serverInfo] name]]; [[NSNotificationCenter defaultCenter] postNotificationName:BDSKSearchGroupServersDidChangeNotification object:self]; + } else if ([self isResettable]) { + // reset the selected default server + + [[BDSKSearchGroupServerManager sharedManager] resetServerAtIndex:[serverPopup indexOfSelectedItem]]; + [self selectPredefinedServer:serverPopup]; + } else { // remove the selected default server - 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]; - } + [[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