Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #2210 from nacho4d/feature/2105-part1
Feature/2105 part1
  • Loading branch information
dmoagx committed Aug 22, 2015
2 parents cf83388 + c10748c commit 23e86b8
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 22 deletions.
3 changes: 2 additions & 1 deletion Source/SPAlertSheets.h
Expand Up @@ -61,5 +61,6 @@ void SPOnewayAlertSheet(
NSString *title,
NSString *defaultButton,
NSWindow *docWindow,
NSString *msg
NSString *msg,
NSAlertStyle alertStyle
);
17 changes: 12 additions & 5 deletions Source/SPAlertSheets.m
Expand Up @@ -149,12 +149,14 @@ + (void)beginWaitingAlertSheetWithTitle:(NSString *)title
* Because of that there is no way to set a delegate and callback method
* and there is only one default button.
* If nil is passed as the button title it will be changed to @"OK".
* If nil is passed as the window NSAlert will be modal
*/
void SPOnewayAlertSheet(
NSString *title,
NSString *defaultButton,
NSWindow *docWindow,
NSString *msg)
NSString *msg,
NSAlertStyle alertStyle)
{
NSString *defaultText = (defaultButton)? defaultButton : NSLocalizedString(@"OK", @"OK button");

Expand All @@ -168,12 +170,17 @@ void SPOnewayAlertSheet(

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

// Set style (Defaults to NSWarningAlertStyle)
[alert setAlertStyle:alertStyle];

// Run the alert
[alert beginSheetModalForWindow:docWindow modalDelegate:nil didEndSelector:NULL contextInfo:NULL];

// Ensure the alerting window is frontmost
[docWindow makeKeyWindow];
if (docWindow) {
[alert beginSheetModalForWindow:docWindow modalDelegate:nil didEndSelector:NULL contextInfo:NULL];
[docWindow makeKeyWindow]; // Ensure the alerting window is frontmost
} else {
[alert runModal];
}
});
}

Expand Down
3 changes: 2 additions & 1 deletion Source/SPDatabaseDocument.m
Expand Up @@ -6162,7 +6162,8 @@ - (void)_selectDatabaseAndItem:(NSDictionary *)selectionDetails
NSLocalizedString(@"Error", @"error"),
nil,
parentWindow,
[NSString stringWithFormat:NSLocalizedString(@"Unable to select database %@.\nPlease check you have the necessary privileges to view the database, and that the database still exists.", @"message of panel when connection to db failed after selecting from popupbutton"), targetDatabaseName]
[NSString stringWithFormat:NSLocalizedString(@"Unable to select database %@.\nPlease check you have the necessary privileges to view the database, and that the database still exists.", @"message of panel when connection to db failed after selecting from popupbutton"), targetDatabaseName],
NSWarningAlertStyle
);
}

Expand Down
35 changes: 20 additions & 15 deletions Source/SPTableData.m
Expand Up @@ -492,7 +492,8 @@ - (NSDictionary *) informationForTable:(NSString *)tableName
NSLocalizedString(@"Error retrieving table information", @"error retrieving table information message"),
nil,
[NSApp mainWindow],
errorMessage
errorMessage,
NSWarningAlertStyle
);

if (changeEncoding) [mySQLConnection restoreStoredEncoding];
Expand All @@ -517,7 +518,8 @@ - (NSDictionary *) informationForTable:(NSString *)tableName
NSLocalizedString(@"Permission Denied", @"Permission Denied"),
nil,
[NSApp mainWindow],
NSLocalizedString(@"The creation syntax could not be retrieved due to a permissions error.\n\nPlease check your user permissions with an administrator.", @"Create syntax permission denied detail")
NSLocalizedString(@"The creation syntax could not be retrieved due to a permissions error.\n\nPlease check your user permissions with an administrator.", @"Create syntax permission denied detail"),
NSWarningAlertStyle
);

if (changeEncoding) [mySQLConnection restoreStoredEncoding];
Expand Down Expand Up @@ -568,15 +570,13 @@ - (NSDictionary *) informationForTable:(NSString *)tableName
returningInclusively: NO
ignoringQuotedStrings: NO];
if(fieldName == nil || [fieldName length] == 0) {
#warning NSAlert from background thread! (This whole function needs improvement)
NSBeep();
NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:NSLocalizedString(@"OK", @"OK button")];
[alert setInformativeText:[NSString stringWithFormat:NSLocalizedString(@"%@” couldn't be parsed. You can edit the column setup but the column will not be shown in the Content view; please report this issue to the Sequel Pro team using the Help menu item.", @"%@” couldn't be parsed. You can edit the column setup but the column will not be shown in the Content view; please report this issue to the Sequel Pro team using the Help menu item."), fieldsParser]];
[alert setMessageText:NSLocalizedString(@"Error while parsing CREATE TABLE syntax",@"error while parsing CREATE TABLE syntax")];
[alert setAlertStyle:NSCriticalAlertStyle];
[alert runModal];
[alert release];
SPOnewayAlertSheet(
NSLocalizedString(@"Error while parsing CREATE TABLE syntax",@"error while parsing CREATE TABLE syntax"),
nil,
nil,
[NSString stringWithFormat:NSLocalizedString(@"%@” couldn't be parsed. You can edit the column setup but the column will not be shown in the Content view; please report this issue to the Sequel Pro team using the Help menu item.", @"%@” couldn't be parsed. You can edit the column setup but the column will not be shown in the Content view; please report this issue to the Sequel Pro team using the Help menu item."), fieldsParser],
NSCriticalAlertStyle);
continue;
}
//if the next character is again a backtick, we stumbled across an escaped backtick. we have to continue parsing.
Expand Down Expand Up @@ -849,7 +849,8 @@ - (NSDictionary *) informationForView:(NSString *)viewName
NSLocalizedString(@"Error", @"error"),
nil,
[NSApp mainWindow],
[NSString stringWithFormat:NSLocalizedString(@"An error occurred while retrieving information.\nMySQL said: %@", @"message of panel when retrieving information failed"),[mySQLConnection lastErrorMessage]]
[NSString stringWithFormat:NSLocalizedString(@"An error occurred while retrieving information.\nMySQL said: %@", @"message of panel when retrieving information failed"),[mySQLConnection lastErrorMessage]],
NSWarningAlertStyle
);
if (changeEncoding) [mySQLConnection restoreStoredEncoding];
}
Expand All @@ -866,7 +867,8 @@ - (NSDictionary *) informationForView:(NSString *)viewName
NSLocalizedString(@"Permission Denied", @"Permission Denied"),
nil,
[NSApp mainWindow],
NSLocalizedString(@"The creation syntax could not be retrieved due to a permissions error.\n\nPlease check your user permissions with an administrator.", @"Create syntax permission denied detail")
NSLocalizedString(@"The creation syntax could not be retrieved due to a permissions error.\n\nPlease check your user permissions with an administrator.", @"Create syntax permission denied detail"),
NSWarningAlertStyle
);
if (changeEncoding) [mySQLConnection restoreStoredEncoding];
return nil;
Expand All @@ -885,7 +887,8 @@ - (NSDictionary *) informationForView:(NSString *)viewName
NSLocalizedString(@"Error", @"error"),
nil,
[NSApp mainWindow],
[NSString stringWithFormat:NSLocalizedString(@"An error occurred while retrieving information.\nMySQL said: %@", @"message of panel when retrieving information failed"), [mySQLConnection lastErrorMessage]]
[NSString stringWithFormat:NSLocalizedString(@"An error occurred while retrieving information.\nMySQL said: %@", @"message of panel when retrieving information failed"), [mySQLConnection lastErrorMessage]],
NSWarningAlertStyle
);
if (changeEncoding) [mySQLConnection restoreStoredEncoding];
}
Expand Down Expand Up @@ -996,7 +999,8 @@ - (BOOL)updateStatusInformationForCurrentTable
NSLocalizedString(@"Error", @"error"),
nil,
[NSApp mainWindow],
[NSString stringWithFormat:NSLocalizedString(@"An error occured while retrieving status data.\nMySQL said: %@", @"message of panel when retrieving view information failed"), [mySQLConnection lastErrorMessage]]
[NSString stringWithFormat:NSLocalizedString(@"An error occured while retrieving status data.\nMySQL said: %@", @"message of panel when retrieving view information failed"), [mySQLConnection lastErrorMessage]],
NSWarningAlertStyle
);
if (changeEncoding) [mySQLConnection restoreStoredEncoding];
}
Expand Down Expand Up @@ -1083,7 +1087,8 @@ - (BOOL) updateTriggersForCurrentTable
NSLocalizedString(@"Error retrieving trigger information", @"error retrieving trigger information message"),
nil,
[NSApp mainWindow],
[NSString stringWithFormat:NSLocalizedString(@"An error occurred while retrieving the trigger information for table '%@'. Please try again.\n\nMySQL said: %@", @"error retrieving table information informative message"), [tableListInstance tableName], [mySQLConnection lastErrorMessage]]
[NSString stringWithFormat:NSLocalizedString(@"An error occurred while retrieving the trigger information for table '%@'. Please try again.\n\nMySQL said: %@", @"error retrieving table information informative message"), [tableListInstance tableName], [mySQLConnection lastErrorMessage]],
NSWarningAlertStyle
);
if (triggers) SPClear(triggers);
if (changeEncoding) [mySQLConnection restoreStoredEncoding];
Expand Down

0 comments on commit 23e86b8

Please sign in to comment.