From ddc5add77f3984cae1601e96d564cf4ba7347202 Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Thu, 9 Apr 2009 19:42:43 +0000 Subject: Make table operation messages more user friendly (issue #192) and display them in sheets instead of modal dialogs. Also performed a general tidy up of TableDocument.[hm]. --- Interfaces/English.lproj/MainMenu.xib | 170 ++++++++------- Source/TableDocument.h | 24 --- Source/TableDocument.m | 377 ++++++++++++++++++++++------------ 3 files changed, 345 insertions(+), 226 deletions(-) diff --git a/Interfaces/English.lproj/MainMenu.xib b/Interfaces/English.lproj/MainMenu.xib index ceec55a8..ed5a59d3 100644 --- a/Interfaces/English.lproj/MainMenu.xib +++ b/Interfaces/English.lproj/MainMenu.xib @@ -2,13 +2,13 @@ 1050 - 9G2141 + 9G55 677 949.43 353.00 YES - + YES @@ -1388,27 +1388,37 @@ - + - Analyze Table + Repair Table 1048576 2147483647 - + - Optimize Table + YES + YES + + + 2147483647 + + + + + + Analyze Table 1048576 2147483647 - + - Repair Table + Optimize Table 1048576 2147483647 @@ -5837,63 +5847,6 @@ ARcABAAAAAEAAAACARwAAwAAAAEAAQAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA - - 758 - - - YES - - - - - - - - - - - - - - 759 - - - - - 760 - - - - - 761 - - - - - 762 - - - - - 763 - - - - - 764 - - - - - 765 - - - - - 778 - - - 782 @@ -5934,11 +5887,6 @@ ARcABAAAAAEAAAACARwAAwAAAAEAAQAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA - - 797 - - - 805 @@ -6326,6 +6274,74 @@ ARcABAAAAAEAAAACARwAAwAAAAEAAQAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA + + 758 + + + YES + + + + + + + + + + + + + + + 763 + + + + + 906 + + + + + 797 + + + + + 778 + + + + + 765 + + + + + 764 + + + + + 762 + + + + + 761 + + + + + 760 + + + + + 759 + + + @@ -6910,6 +6926,7 @@ ARcABAAAAAEAAAACARwAAwAAAAEAAQAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA 863.IBPluginDependency 864.IBPluginDependency 865.IBPluginDependency + 906.IBPluginDependency 92.IBPluginDependency 92.ImportedFromIB2 @@ -6972,7 +6989,7 @@ ARcABAAAAAEAAAACARwAAwAAAAEAAQAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA com.apple.InterfaceBuilder.CocoaPlugin - {{764, 298}, {146, 213}} + {{677, 298}, {146, 213}} com.apple.InterfaceBuilder.CocoaPlugin {{654, 613}, {157, 223}} @@ -7182,7 +7199,7 @@ Y2hhbmdlIHRoZSBvcmRlcg com.apple.InterfaceBuilder.CocoaPlugin - {{616, 511}, {511, 20}} + {{202, 280}, {511, 20}} com.apple.InterfaceBuilder.CocoaPlugin {{506, 836}, {511, 20}} @@ -7396,7 +7413,7 @@ Y2hhbmdlIHRoZSBvcmRlcg com.apple.InterfaceBuilder.CocoaPlugin - {{791, 404}, {231, 153}} + {{444, 127}, {231, 153}} com.apple.InterfaceBuilder.CocoaPlugin {{312, 683}, {231, 153}} @@ -7515,7 +7532,7 @@ Y2hhbmdlIHRoZSBvcmRlcg com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{872, 384}, {268, 173}} + {{525, 97}, {268, 183}} com.apple.InterfaceBuilder.CocoaPlugin {{829, 663}, {268, 173}} com.apple.InterfaceBuilder.CocoaPlugin @@ -7570,7 +7587,7 @@ Y2hhbmdlIHRoZSBvcmRlcg com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{910, 228}, {213, 143}} + {{823, 228}, {213, 143}} com.apple.InterfaceBuilder.CocoaPlugin ToolTip @@ -7643,6 +7660,7 @@ w6gg4oaSIGZhY2FkZV0 com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin @@ -7666,7 +7684,7 @@ w6gg4oaSIGZhY2FkZV0 - 905 + 907 diff --git a/Source/TableDocument.h b/Source/TableDocument.h index 5bb29a9f..299e5430 100644 --- a/Source/TableDocument.h +++ b/Source/TableDocument.h @@ -187,34 +187,10 @@ - (BOOL)validateToolbarItem:(NSToolbarItem *)toolbarItem; - (void)updateChooseDatabaseToolbarItemWidth; -//NSDocument methods -- (NSString *)windowNibName; -- (void)windowControllerDidLoadNib:(NSWindowController *)aController; -- (void)windowWillClose:(NSNotification *)aNotification; - -//NSWindow delegate methods -- (BOOL)windowShouldClose:(id)sender; - //SMySQL delegate methods - (void)willQueryString:(NSString *)query; - (void)queryGaveError:(NSString *)error; -// Connection sheet delegate methods -- (void) controlTextDidChange:(NSNotification *)aNotification; - -//splitView delegate methods -- (BOOL)splitView:(NSSplitView *)sender canCollapseSubview:(NSView *)subview; -- (float)splitView:(NSSplitView *)sender constrainMaxCoordinate:(float)proposedMax ofSubviewAt:(int)offset; -- (float)splitView:(NSSplitView *)sender constrainMinCoordinate:(float)proposedMin ofSubviewAt:(int)offset; -- (NSRect)splitView:(NSSplitView *)splitView additionalEffectiveRectOfDividerAtIndex:(int)dividerIndex; - - -//tableView datasource methods -- (int)numberOfRowsInTableView:(NSTableView *)aTableView; -- (id)tableView:(NSTableView *)aTableView - objectValueForTableColumn:(NSTableColumn *)aTableColumn - row:(int)rowIndex; - @end extern NSString *TableDocumentFavoritesControllerSelectionIndexDidChange; diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 15bc444b..269af5e1 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -42,18 +42,17 @@ #import "CMMCPResult.h" NSString *TableDocumentFavoritesControllerSelectionIndexDidChange = @"TableDocumentFavoritesControllerSelectionIndexDidChange"; -NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFavoritesControllerFavoritesDidChange"; +NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFavoritesControllerFavoritesDidChange"; @implementation TableDocument - (id)init { - if (![super init]) - return nil; - - _encoding = [@"utf8" retain]; - chooseDatabaseButton = nil; - chooseDatabaseToolbarItem = nil; + if ((self = [super init])) { + _encoding = [@"utf8" retain]; + chooseDatabaseButton = nil; + chooseDatabaseToolbarItem = nil; + } return self; } @@ -106,7 +105,6 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa return mySQLConnection; } - //start sheet /** @@ -259,12 +257,12 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa [tableWindow close]; } -- (IBAction)closeSheet:(id)sender -/* - invoked when user hits the cancel button of the connectSheet - stops modal session with code 0 - reused when user hits the close button of the variablseSheet or of the createTableSyntaxSheet +/** + * Invoked when user hits the cancel button of the connectSheet + * stops modal session with code 0 + * reused when user hits the close button of the variablseSheet or of the createTableSyntaxSheet */ +- (IBAction)closeSheet:(id)sender { [NSApp stopModalWithCode:0]; } @@ -819,9 +817,11 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa return _supportsEncoding; } - #pragma mark Table Methods +/** + * Displays the CREATE TABLE syntax of the selected table to the user via a HUD panel. + */ - (IBAction)showCreateTableSyntax:(id)sender { //Create the query and get results @@ -845,6 +845,9 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa [createTableSyntaxWindow makeKeyAndOrderFront:self]; } +/** + * Copies the CREATE TABLE syntax of the selected table to the pasteboard. + */ - (IBAction)copyCreateTableSyntax:(id)sender { // Create the query and get results @@ -875,146 +878,264 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa notificationName:@"Table Syntax Copied"]; } +/** + * Performs a MySQL check table on the selected table and presents the result to the user via an alert sheet. + */ - (IBAction)checkTable:(id)sender -{ - NSString *query; - CMMCPResult *theResult; - NSDictionary *theRow; - - //Create the query and get results - query = [NSString stringWithFormat:@"CHECK TABLE %@", [[self table] backtickQuotedString]]; - theResult = [mySQLConnection queryString:query]; +{ + CMMCPResult *theResult = [mySQLConnection queryString:[NSString stringWithFormat:@"CHECK TABLE %@", [[self table] backtickQuotedString]]]; // Check for errors, only displaying if the connection hasn't been terminated if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) { if ([mySQLConnection isConnected]) { - NSRunAlertPanel(@"Error", [NSString stringWithFormat:@"An error occured while checking table.\n\n: %@",[mySQLConnection getLastErrorMessage]], @"OK", nil, nil); + + [[NSAlert alertWithMessageText:@"Unable to check table" + defaultButton:@"OK" + alternateButton:nil + otherButton:nil + informativeTextWithFormat:[NSString stringWithFormat:@"An error occurred while trying to check the table '%@'. Please try again.\n\n%@", [self table], [mySQLConnection getLastErrorMessage]]] + beginSheetModalForWindow:tableWindow + modalDelegate:self + didEndSelector:NULL + contextInfo:NULL]; } + return; } // Process result - theRow = [[theResult fetch2DResultAsType:MCPTypeDictionary] lastObject]; - NSRunInformationalAlertPanel([NSString stringWithFormat:@"Check '%@' table", [self table]], [NSString stringWithFormat:@"Check: %@", [theRow objectForKey:@"Msg_text"]], @"OK", nil, nil); + NSDictionary *result = [[theResult fetch2DResultAsType:MCPTypeDictionary] lastObject]; + + NSString *message = @""; + + message = ([[result objectForKey:@"Msg_type"] isEqualToString:@"status"]) ? @"Check table successfully passed." : @"Check table failed."; + + message = [NSString stringWithFormat:@"%@\n\nMySQL said: %@", message, [result objectForKey:@"Msg_text"]]; + + [[NSAlert alertWithMessageText:[NSString stringWithFormat:@"Check table '%@'", [self table]] + defaultButton:@"OK" + alternateButton:nil + otherButton:nil + informativeTextWithFormat:message] + beginSheetModalForWindow:tableWindow + modalDelegate:self + didEndSelector:NULL + contextInfo:NULL]; } +/** + * Analyzes the selected table and presents the result to the user via an alert sheet. + */ - (IBAction)analyzeTable:(id)sender { - NSString *query; - CMMCPResult *theResult; - NSDictionary *theRow; - - //Create the query and get results - query = [NSString stringWithFormat:@"ANALYZE TABLE %@", [[self table] backtickQuotedString]]; - theResult = [mySQLConnection queryString:query]; + CMMCPResult *theResult = [mySQLConnection queryString:[NSString stringWithFormat:@"ANALYZE TABLE %@", [[self table] backtickQuotedString]]]; // Check for errors, only displaying if the connection hasn't been terminated if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) { if ([mySQLConnection isConnected]) { - NSRunAlertPanel(@"Error", [NSString stringWithFormat:@"An error occured while analyzing table.\n\n: %@",[mySQLConnection getLastErrorMessage]], @"OK", nil, nil); + + [[NSAlert alertWithMessageText:@"Unable to analyze table" + defaultButton:@"OK" + alternateButton:nil + otherButton:nil + informativeTextWithFormat:[NSString stringWithFormat:@"An error occurred while trying to analyze the table '%@'. Please try again.\n\n%@", [self table], [mySQLConnection getLastErrorMessage]]] + beginSheetModalForWindow:tableWindow + modalDelegate:self + didEndSelector:NULL + contextInfo:NULL]; } + return; } // Process result - theRow = [[theResult fetch2DResultAsType:MCPTypeDictionary] lastObject]; - NSRunInformationalAlertPanel([NSString stringWithFormat:@"Analyze '%@' table", [self table]], [NSString stringWithFormat:@"Analyze: %@", [theRow objectForKey:@"Msg_text"]], @"OK", nil, nil); + NSDictionary *result = [[theResult fetch2DResultAsType:MCPTypeDictionary] lastObject]; + + NSString *message = @""; + + message = ([[result objectForKey:@"Msg_type"] isEqualToString:@"status"]) ? @"Successfully analyzed table" : @"Analyze table failed."; + + message = [NSString stringWithFormat:@"%@\n\nMySQL said: %@", message, [result objectForKey:@"Msg_text"]]; + + [[NSAlert alertWithMessageText:[NSString stringWithFormat:@"Analyze table '%@'", [self table]] + defaultButton:@"OK" + alternateButton:nil + otherButton:nil + informativeTextWithFormat:message] + beginSheetModalForWindow:tableWindow + modalDelegate:self + didEndSelector:NULL + contextInfo:NULL]; } +/** + * Optimizes the selected table and presents the result to the user via an alert sheet. + */ - (IBAction)optimizeTable:(id)sender { - NSString *query; - CMMCPResult *theResult; - NSDictionary *theRow; - - //Create the query and get results - query = [NSString stringWithFormat:@"OPTIMIZE TABLE %@", [[self table] backtickQuotedString]]; - theResult = [mySQLConnection queryString:query]; + CMMCPResult *theResult = [mySQLConnection queryString:[NSString stringWithFormat:@"OPTIMIZE TABLE %@", [[self table] backtickQuotedString]]]; // Check for errors, only displaying if the connection hasn't been terminated - if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) { + if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) { if ([mySQLConnection isConnected]) { - NSRunAlertPanel(@"Error", [NSString stringWithFormat:@"An error occured while optimizing table.\n\n: %@",[mySQLConnection getLastErrorMessage]], @"OK", nil, nil); + + [[NSAlert alertWithMessageText:@"Unable to optimize table" + defaultButton:@"OK" + alternateButton:nil + otherButton:nil + informativeTextWithFormat:[NSString stringWithFormat:@"An error occurred while trying to optimize the table '%@'. Please try again.\n\n%@", [self table], [mySQLConnection getLastErrorMessage]]] + beginSheetModalForWindow:tableWindow + modalDelegate:self + didEndSelector:NULL + contextInfo:NULL]; } + return; } // Process result - theRow = [[theResult fetch2DResultAsType:MCPTypeDictionary] lastObject]; - NSRunInformationalAlertPanel([NSString stringWithFormat:@"Optimize '%@' table", [self table]], [NSString stringWithFormat:@"Optimize: %@", [theRow objectForKey:@"Msg_text"]], @"OK", nil, nil); + NSDictionary *result = [[theResult fetch2DResultAsType:MCPTypeDictionary] lastObject]; + + NSString *message = @""; + + message = ([[result objectForKey:@"Msg_type"] isEqualToString:@"status"]) ? @"Successfully optimized table" : @"Optimize table failed."; + + message = [NSString stringWithFormat:@"%@\n\nMySQL said: %@", message, [result objectForKey:@"Msg_text"]]; + + [[NSAlert alertWithMessageText:[NSString stringWithFormat:@"Optimize table '%@'", [self table]] + defaultButton:@"OK" + alternateButton:nil + otherButton:nil + informativeTextWithFormat:message] + beginSheetModalForWindow:tableWindow + modalDelegate:self + didEndSelector:NULL + contextInfo:NULL]; } +/** + * Repairs the selected table and presents the result to the user via an alert sheet. + */ - (IBAction)repairTable:(id)sender { - NSString *query; - CMMCPResult *theResult; - NSDictionary *theRow; - - //Create the query and get results - query = [NSString stringWithFormat:@"REPAIR TABLE %@", [[self table] backtickQuotedString]]; - theResult = [mySQLConnection queryString:query]; + CMMCPResult *theResult = [mySQLConnection queryString:[NSString stringWithFormat:@"REPAIR TABLE %@", [[self table] backtickQuotedString]]]; // Check for errors, only displaying if the connection hasn't been terminated if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) { if ([mySQLConnection isConnected]) { - NSRunAlertPanel(@"Error", [NSString stringWithFormat:@"An error occured while repairing table.\n\n: %@",[mySQLConnection getLastErrorMessage]], @"OK", nil, nil); + + [[NSAlert alertWithMessageText:@"Unable to repair table" + defaultButton:@"OK" + alternateButton:nil + otherButton:nil + informativeTextWithFormat:[NSString stringWithFormat:@"An error occurred while trying to repair the table '%@'. Please try again.\n\n%@", [self table], [mySQLConnection getLastErrorMessage]]] + beginSheetModalForWindow:tableWindow + modalDelegate:self + didEndSelector:NULL + contextInfo:NULL]; } + return; } // Process result - theRow = [[theResult fetch2DResultAsType:MCPTypeDictionary] lastObject]; - NSRunInformationalAlertPanel([NSString stringWithFormat:@"Repair '%@' table", [self table]], [NSString stringWithFormat:@"Repair: %@", [theRow objectForKey:@"Msg_text"]], @"OK", nil, nil); + NSDictionary *result = [[theResult fetch2DResultAsType:MCPTypeDictionary] lastObject]; + + NSString *message = @""; + + message = ([[result objectForKey:@"Msg_type"] isEqualToString:@"status"]) ? @"Successfully repaired table" : @"Repair table failed."; + + message = [NSString stringWithFormat:@"%@\n\nMySQL said: %@", message, [result objectForKey:@"Msg_text"]]; + + [[NSAlert alertWithMessageText:[NSString stringWithFormat:@"Repair table '%@'", [self table]] + defaultButton:@"OK" + alternateButton:nil + otherButton:nil + informativeTextWithFormat:message] + beginSheetModalForWindow:tableWindow + modalDelegate:self + didEndSelector:NULL + contextInfo:NULL]; } +/** + * Flush the selected table and inform the user via a dialog sheet. + */ - (IBAction)flushTable:(id)sender { - NSString *query; - CMMCPResult *theResult; - - //Create the query and get results - query = [NSString stringWithFormat:@"FLUSH TABLE %@", [[self table] backtickQuotedString]]; - theResult = [mySQLConnection queryString:query]; + [mySQLConnection queryString:[NSString stringWithFormat:@"FLUSH TABLE %@", [[self table] backtickQuotedString]]]; // Check for errors, only displaying if the connection hasn't been terminated if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) { if ([mySQLConnection isConnected]) { - NSRunAlertPanel(@"Error", [NSString stringWithFormat:@"An error occured while flushing table.\n\n: %@",[mySQLConnection getLastErrorMessage]], @"OK", nil, nil); + + [[NSAlert alertWithMessageText:@"Unable to flush table" + defaultButton:@"OK" + alternateButton:nil + otherButton:nil + informativeTextWithFormat:[NSString stringWithFormat:@"An error occurred while trying to flush the table '%@'. Please try again.\n\n%@", [self table], [mySQLConnection getLastErrorMessage]]] + beginSheetModalForWindow:tableWindow + modalDelegate:self + didEndSelector:NULL + contextInfo:NULL]; } + return; } - - // Process result - NSRunInformationalAlertPanel([NSString stringWithFormat:@"Flush '%@' table", [self table]], @"Flushed", @"OK", nil, nil); + + [[NSAlert alertWithMessageText:[NSString stringWithFormat:@"Flush table '%@'", [self table]] + defaultButton:@"OK" + alternateButton:nil + otherButton:nil + informativeTextWithFormat:@"Table was successfully flushed"] + beginSheetModalForWindow:tableWindow + modalDelegate:self + didEndSelector:NULL + contextInfo:NULL]; } +/** + * Runs a MySQL checksum on the selected table and present the result to the user via an alert sheet. + */ - (IBAction)checksumTable:(id)sender -{ - NSString *query; - CMMCPResult *theResult; - NSDictionary *theRow; - - //Create the query and get results - query = [NSString stringWithFormat:@"CHECKSUM TABLE %@", [[self table] backtickQuotedString]]; - theResult = [mySQLConnection queryString:query]; +{ + CMMCPResult *theResult = [mySQLConnection queryString:[NSString stringWithFormat:@"CHECKSUM TABLE %@", [[self table] backtickQuotedString]]]; // Check for errors, only displaying if the connection hasn't been terminated if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) { if ([mySQLConnection isConnected]) { - NSRunAlertPanel(@"Error", [NSString stringWithFormat:@"An error occured while performming checksum on table.\n\n: %@",[mySQLConnection getLastErrorMessage]], @"OK", nil, nil); + + [[NSAlert alertWithMessageText:@"Unable to perform checksum" + defaultButton:@"OK" + alternateButton:nil + otherButton:nil + informativeTextWithFormat:[NSString stringWithFormat:@"An error occurred while performing the checksum on table '%@'. Please try again.\n\n%@", [self table], [mySQLConnection getLastErrorMessage]]] + beginSheetModalForWindow:tableWindow + modalDelegate:self + didEndSelector:NULL + contextInfo:NULL]; } return; } // Process result - theRow = [[theResult fetch2DResultAsType:MCPTypeDictionary] lastObject]; - NSRunInformationalAlertPanel([NSString stringWithFormat:@"Checksum '%@' table", [self table]], [NSString stringWithFormat:@"Checksum: %@", [theRow objectForKey:@"Checksum"]], @"OK", nil, nil); + NSString *result = [[[theResult fetch2DResultAsType:MCPTypeDictionary] lastObject] objectForKey:@"Checksum"]; + + [[NSAlert alertWithMessageText:[NSString stringWithFormat:@"Checksum table '%@'", [self table]] + defaultButton:@"OK" + alternateButton:nil + otherButton:nil + informativeTextWithFormat:[NSString stringWithFormat:@"Table checksum: %@", result]] + beginSheetModalForWindow:tableWindow + modalDelegate:self + didEndSelector:NULL + contextInfo:NULL]; } - #pragma mark Other Methods + /** - * returns the host + * Returns the host */ - (NSString *)host { @@ -1022,7 +1143,7 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa } /** - * passes query to tablesListInstance + * Passes query to tablesListInstance */ - (void)doPerformQueryService:(NSString *)query { @@ -1031,7 +1152,7 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa } /** - * flushes the mysql privileges + * Flushes the mysql privileges */ - (void)flushPrivileges:(id)sender { @@ -1047,10 +1168,10 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa } } -- (void)showVariables:(id)sender -/* - shows the mysql variables +/** + * Shows the MySQL server variables */ +- (void)showVariables:(id)sender { CMMCPResult *theResult; NSMutableArray *tempResult = [NSMutableArray array]; @@ -1088,48 +1209,48 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa notificationName:@"Disconnected"]; } +// Getter methods -//getter methods -- (NSString *)database -/* - returns the currently selected database +/** + * Returns the currently selected database */ +- (NSString *)database { return selectedDatabase; } -- (NSString *)table -/* - returns the currently selected table (passing the request to TablesList) +/** + * Returns the currently selected table (passing the request to TablesList) */ +- (NSString *)table { return [tablesListInstance tableName]; } -- (NSString *)mySQLVersion -/* - returns the mysql version +/** + * Returns the MySQL version */ +- (NSString *)mySQLVersion { return mySQLVersion; } -- (NSString *)user -/* - returns the mysql version +/** + * Returns the current user */ +- (NSString *)user { return [userField stringValue]; } +// Notification center methods -//notification center methods -- (void)willPerformQuery:(NSNotification *)notification -/* - invoked before a query is performed +/** + * Invoked before a query is performed */ +- (void)willPerformQuery:(NSNotification *)notification { - // Only start the progress indicator is this document window is key. + // Only start the progress indicator if this document window is key. // Because we are starting the progress indicator based on the notification // of a query being started, we have to prevent other windows from // starting theirs. The same is also true for the below hasPerformedQuery: @@ -1142,44 +1263,45 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa } } -- (void)hasPerformedQuery:(NSNotification *)notification -/* - invoked after a query has been performed +/** + * Invoked after a query has been performed */ +- (void)hasPerformedQuery:(NSNotification *)notification { if ([tableWindow isKeyWindow]) { [queryProgressBar stopAnimation:self]; } } -- (void)applicationWillTerminate:(NSNotification *)notification -/* - invoked when the application will terminate +/** + * Invoked when the application will terminate */ +- (void)applicationWillTerminate:(NSNotification *)notification { [tablesListInstance selectionShouldChangeInTableView:nil]; } -- (void)tunnelStatusChanged:(NSNotification *)notification -/* - the status of the tunnel has changed +/** + * The status of the tunnel has changed */ +- (void)tunnelStatusChanged:(NSNotification *)notification { } -//menu methods -- (IBAction)import:(id)sender -/* - passes the request to the tableDump object +// Menu methods + +/** + * Passes the request to the tableDump object */ +- (IBAction)import:(id)sender { [tableDumpInstance importFile]; } -- (IBAction)export:(id)sender -/* - passes the request to the tableDump object +/** + * Passes the request to the tableDump object */ +- (IBAction)export:(id)sender { [tableDumpInstance exportFile:[sender tag]]; } @@ -1563,6 +1685,11 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa } } +// NSWindow delegate methods + +/** + * Invoked when the document window is about to close + */ - (void)windowWillClose:(NSNotification *)aNotification { //reset print settings, so we're not prompted about saving them @@ -1573,11 +1700,10 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa [[NSNotificationCenter defaultCenter] removeObserver:self]; } -//NSWindow delegate methods -- (BOOL)windowShouldClose:(id)sender -/* - invoked when the document window should close +/** + * Invoked when the document window should close */ +- (BOOL)windowShouldClose:(id)sender { if ( ![tablesListInstance selectionShouldChangeInTableView:nil] ) { return NO; @@ -1688,15 +1814,14 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa } -//tableView datasource methods +// TableView datasource methods + - (int)numberOfRowsInTableView:(NSTableView *)aTableView { return [variables count]; } -- (id)tableView:(NSTableView *)aTableView -objectValueForTableColumn:(NSTableColumn *)aTableColumn - row:(int)rowIndex +- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex { id theValue; -- cgit v1.2.3