Skip to content

Commit

Permalink
Remove duplicate setting of sheet title/message.
Browse files Browse the repository at this point in the history
  • Loading branch information
stuconnolly committed Mar 23, 2017
1 parent d37a2f4 commit 30d36cb
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 22 deletions.
1 change: 0 additions & 1 deletion Source/SPAlertSheets.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
modalDelegate:(id)modalDelegate
didEndSelector:(SEL)didEndSelector
contextInfo:(void *)contextInfo
msg:(NSString *)msg
infoText:(NSString *)infoText
returnCode:(NSInteger *)returnCode;

Expand Down
18 changes: 5 additions & 13 deletions Source/SPAlertSheets.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ + (void)beginWaitingAlertSheetWithTitle:(NSString *)title
modalDelegate:(id)modalDelegate
didEndSelector:(SEL)didEndSelector
contextInfo:(void *)contextInfo
msg:(NSString *)msg
infoText:(NSString *)infoText
returnCode:(NSInteger *)returnCode
{
Expand All @@ -69,7 +68,6 @@ + (void)beginWaitingAlertSheetWithTitle:(NSString *)title
modalDelegate:modalDelegate
didEndSelector:didEndSelector
contextInfo:contextInfo
msg:msg
infoText:infoText
returnCode:returnCode];
}
Expand All @@ -93,43 +91,37 @@ + (void)beginWaitingAlertSheetWithTitle:(NSString *)title
aButton = [alert addButtonWithTitle:alternateButton];
[aButton setTag:NSAlertAlternateReturn];
}

if (otherButton) {
aButton = [alert addButtonWithTitle:otherButton];
[aButton setTag:NSAlertOtherReturn];
}

// Set alert style
[alert setAlertStyle:NSWarningAlertStyle];
if(alertStyle)
[alert setAlertStyle:alertStyle];
[alert setAlertStyle:alertStyle ? alertStyle : NSWarningAlertStyle];

// Set the informative message if supplied
if (infoText) [alert setInformativeText:infoText];

// Set the informative message if supplied
if (msg) [alert setMessageText:msg];

// Run the alert on the main thread
[alert beginSheetModalForWindow:docWindow modalDelegate:modalDelegate didEndSelector:didEndSelector contextInfo:contextInfo];

// wait for the sheet
NSModalSession session = [NSApp beginModalSessionForWindow:[alert window]];

for (;;) {

// Since the returnCode can only be -1, 0, or 1
// run the session until returnCode was changed in
// the didEndSelector method of the calling class
if(returnCode != &initialReturnCode)
break;
if (returnCode != &initialReturnCode) break;

// Execute code on DefaultRunLoop
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
beforeDate:[NSDate distantFuture]];

// Break the run loop if sheet was closed
if ([NSApp runModalSession:session] != NSRunContinuesResponse
|| ![[alert window] isVisible])
break;
if ([NSApp runModalSession:session] != NSRunContinuesResponse || ![[alert window] isVisible]) break;

// Execute code on DefaultRunLoop
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
Expand Down
3 changes: 1 addition & 2 deletions Source/SPCustomQuery.m
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ - (void)performQueriesTask:(NSDictionary *)taskArguments
if (![mySQLConnection lastQueryWasCancelled]) {

[tableDocumentInstance setTaskIndicatorShouldAnimate:NO];
[SPAlertSheets beginWaitingAlertSheetWithTitle:@"title"
[SPAlertSheets beginWaitingAlertSheetWithTitle:NSLocalizedString(@"MySQL Error", @"mysql error message")
defaultButton:NSLocalizedString(@"Run All", @"run all button")
alternateButton:NSLocalizedString(@"Continue", @"continue button")
otherButton:NSLocalizedString(@"Stop", @"stop button")
Expand All @@ -763,7 +763,6 @@ - (void)performQueriesTask:(NSDictionary *)taskArguments
modalDelegate:self
didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
contextInfo:@"runAllContinueStopSheet"
msg:NSLocalizedString(@"MySQL Error", @"mysql error message")
infoText:[mySQLConnection lastErrorMessage]
returnCode:&runAllContinueStopSheetReturnCode];

Expand Down
6 changes: 2 additions & 4 deletions Source/SPDatabaseDocument.m
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ - (IBAction)copyDatabase:(id)sender

// Inform the user that we don't support copying objects other than tables and ask them if they'd like to proceed
if ([tablesListInstance hasNonTableObjects]) {
[SPAlertSheets beginWaitingAlertSheetWithTitle:@""
[SPAlertSheets beginWaitingAlertSheetWithTitle:NSLocalizedString(@"Only Partially Supported", @"partial copy database support message")
defaultButton:NSLocalizedString(@"Continue", "continue button")
alternateButton:NSLocalizedString(@"Cancel", @"cancel button")
otherButton:nil
Expand All @@ -884,7 +884,6 @@ - (IBAction)copyDatabase:(id)sender
modalDelegate:self
didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
contextInfo:SPConfirmCopyDatabaseAction
msg:NSLocalizedString(@"Only Partially Supported", @"partial copy database support message")
infoText:[NSString stringWithFormat:NSLocalizedString(@"Duplicating the database '%@' is only partially supported as it contains objects other tables (i.e. views, procedures, functions, etc.), which will not be copied.\n\nWould you like to continue?", @"partial copy database support informative message"), selectedDatabase]
returnCode:&confirmCopyDatabaseReturnCode];

Expand Down Expand Up @@ -3371,7 +3370,7 @@ - (BOOL)saveDocumentWithFilePath:(NSString *)fileName inBackground:(BOOL)saveInB

if(!spf || ![spf count] || readError != nil || [convError length] || !(format == NSPropertyListXMLFormat_v1_0 || format == NSPropertyListBinaryFormat_v1_0)) {

[SPAlertSheets beginWaitingAlertSheetWithTitle:@"title"
[SPAlertSheets beginWaitingAlertSheetWithTitle:[NSString stringWithFormat:NSLocalizedString(@"Error while reading connection data file", @"error while reading connection data file")]
defaultButton:NSLocalizedString(@"OK", @"OK button")
alternateButton:NSLocalizedString(@"Ignore", @"ignore button")
otherButton:nil
Expand All @@ -3380,7 +3379,6 @@ - (BOOL)saveDocumentWithFilePath:(NSString *)fileName inBackground:(BOOL)saveInB
modalDelegate:self
didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
contextInfo:@"saveDocPrefSheetStatus"
msg:[NSString stringWithFormat:NSLocalizedString(@"Error while reading connection data file", @"error while reading connection data file")]
infoText:[NSString stringWithFormat:NSLocalizedString(@"Connection data file “%@” couldn't be read. Please try to save the document under a different name.", @"message error while reading connection data file and suggesting to save it under a differnet name"), [fileName lastPathComponent]]
returnCode:&saveDocPrefSheetStatus];

Expand Down
3 changes: 1 addition & 2 deletions Source/SPEditorPreferencePane.m
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ - (BOOL)_checkForUnsavedTheme

[[NSColorPanel sharedColorPanel] close];

[SPAlertSheets beginWaitingAlertSheetWithTitle:@"title"
[SPAlertSheets beginWaitingAlertSheetWithTitle:NSLocalizedString(@"Unsaved Theme", @"unsaved theme message")
defaultButton:NSLocalizedString(@"Proceed", @"proceed button")
alternateButton:NSLocalizedString(@"Cancel", @"cancel button")
otherButton:nil
Expand All @@ -758,7 +758,6 @@ - (BOOL)_checkForUnsavedTheme
modalDelegate:self
didEndSelector:@selector(checkForUnsavedThemeDidEndSheet:returnCode:contextInfo:)
contextInfo:nil
msg:NSLocalizedString(@"Unsaved Theme", @"unsaved theme message")
infoText:NSLocalizedString(@"The current color theme is unsaved. Do you want to proceed without saving it?", @"unsaved theme informative message")
returnCode:&checkForUnsavedThemeSheetStatus];

Expand Down

0 comments on commit 30d36cb

Please sign in to comment.