diff options
-rw-r--r-- | English.lproj/DBView.xib | 60 | ||||
-rw-r--r-- | English.lproj/MainMenu.xib | 30 | ||||
-rw-r--r-- | TableDocument.h | 1 | ||||
-rw-r--r-- | TableDocument.m | 159 |
4 files changed, 141 insertions, 109 deletions
diff --git a/English.lproj/DBView.xib b/English.lproj/DBView.xib index 63c2f912..161501a0 100644 --- a/English.lproj/DBView.xib +++ b/English.lproj/DBView.xib @@ -3,13 +3,13 @@ <data> <int key="IBDocument.SystemTarget">1050</int> <string key="IBDocument.SystemVersion">9F33</string> - <string key="IBDocument.InterfaceBuilderVersion">670</string> + <string key="IBDocument.InterfaceBuilderVersion">672</string> <string key="IBDocument.AppKitVersion">949.34</string> <string key="IBDocument.HIToolboxVersion">352.00</string> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="2268"/> - <integer value="26"/> + <integer value="675"/> + <integer value="52"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -8786,14 +8786,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <int key="connectionID">117</int> </object> <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">closeSheet:</string> - <reference key="source" ref="427689665"/> - <reference key="destination" ref="936229991"/> - </object> - <int key="connectionID">118</int> - </object> - <object class="IBConnectionRecord"> <object class="IBOutletConnection" key="connection"> <string key="label">dataSource</string> <reference key="source" ref="581095761"/> @@ -10717,6 +10709,22 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> <int key="connectionID">4525</int> </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">cancelConnectSheet:</string> + <reference key="source" ref="427689665"/> + <reference key="destination" ref="1016292439"/> + </object> + <int key="connectionID">4526</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">delegate</string> + <reference key="source" ref="456332212"/> + <reference key="destination" ref="427689665"/> + </object> + <int key="connectionID">4528</int> + </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> <object class="NSArray" key="orderedObjects"> @@ -16279,7 +16287,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string>{{387, 725}, {432, 282}}</string> <reference ref="9"/> <string>{{387, 725}, {432, 282}}</string> - <reference ref="9"/> + <reference ref="8"/> <reference ref="9"/> <string>{3.40282e+38, 3.40282e+38}</string> <string>{350, 250}</string> @@ -16691,7 +16699,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <reference ref="9"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> - <reference ref="9"/> + <reference ref="8"/> <reference ref="9"/> <string>{3.40282e+38, 3.40282e+38}</string> <string>{213, 107}</string> @@ -16775,7 +16783,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string>{{99, 63}, {519, 335}}</string> <reference ref="9"/> <string>{{136, 447}, {519, 335}}</string> - <reference ref="9"/> + <reference ref="8"/> <reference ref="9"/> <string>{3.40282e+38, 3.40282e+38}</string> <string>{256, 191}</string> @@ -16859,7 +16867,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string>{{115, 214}, {588, 350}}</string> <reference ref="8"/> <string>{{115, 214}, {588, 350}}</string> - <reference ref="9"/> + <reference ref="8"/> <string>{3.40282e+38, 3.40282e+38}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> @@ -16880,7 +16888,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> - <reference ref="9"/> + <reference ref="8"/> <reference ref="9"/> <string>{3.40282e+38, 3.40282e+38}</string> <string>{213, 107}</string> @@ -16957,7 +16965,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <reference ref="9"/> <reference ref="9"/> <string>{{62, 352}, {845, 504}}</string> - <reference ref="9"/> + <reference ref="8"/> <reference ref="9"/> <string>{3.40282e+38, 3.40282e+38}</string> <string>{780, 480}</string> @@ -16967,7 +16975,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <reference ref="9"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> - <reference ref="9"/> + <reference ref="8"/> <reference ref="9"/> <string>{3.40282e+38, 3.40282e+38}</string> <string>{213, 107}</string> @@ -17015,7 +17023,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <reference ref="9"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> - <reference ref="9"/> + <reference ref="8"/> <reference ref="9"/> <string>{3.40282e+38, 3.40282e+38}</string> <string>{350, 200}</string> @@ -17068,7 +17076,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string>{{321, 837}, {381, 247}}</string> <reference ref="9"/> <string>{{321, 837}, {381, 247}}</string> - <reference ref="9"/> + <reference ref="8"/> <reference ref="9"/> <string>{3.40282e+38, 3.40282e+38}</string> <string>{213, 107}</string> @@ -17078,7 +17086,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <reference ref="9"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> - <reference ref="9"/> + <reference ref="8"/> <reference ref="9"/> <string>{3.40282e+38, 3.40282e+38}</string> <string>{213, 107}</string> @@ -17211,7 +17219,7 @@ Y2hhbmdlIHRoZSBvcmRlcg</string> <string>{{321, 508}, {411, 341}}</string> <reference ref="9"/> <string>{{321, 508}, {411, 341}}</string> - <reference ref="9"/> + <reference ref="8"/> <reference ref="9"/> <string>{3.40282e+38, 3.40282e+38}</string> <string>{300, 200}</string> @@ -17309,7 +17317,7 @@ Y2hhbmdlIHRoZSBvcmRlcg</string> <reference ref="9"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> - <reference ref="9"/> + <reference ref="8"/> <reference ref="9"/> <string>{3.40282e+38, 3.40282e+38}</string> <string>{213, 107}</string> @@ -17325,7 +17333,7 @@ Y2hhbmdlIHRoZSBvcmRlcg</string> <reference ref="9"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> - <reference ref="9"/> + <reference ref="8"/> <reference ref="9"/> <string>{3.40282e+38, 3.40282e+38}</string> <string>{213, 50}</string> @@ -17407,7 +17415,7 @@ Y2hhbmdlIHRoZSBvcmRlcg</string> </object> </object> <nil key="sourceID"/> - <int key="maxID">4525</int> + <int key="maxID">4528</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> @@ -17712,6 +17720,7 @@ Y2hhbmdlIHRoZSBvcmRlcg</string> <bool key="EncodedWithXMLCoder">YES</bool> <string>addDatabase:</string> <string>analyzeTable:</string> + <string>cancelConnectSheet:</string> <string>checkTable:</string> <string>checksumTable:</string> <string>chooseDatabase:</string> @@ -17777,6 +17786,7 @@ Y2hhbmdlIHRoZSBvcmRlcg</string> <string>id</string> <string>id</string> <string>id</string> + <string>id</string> </object> </object> <object class="NSMutableDictionary" key="outlets"> diff --git a/English.lproj/MainMenu.xib b/English.lproj/MainMenu.xib index 4d343708..7dc4e9d7 100644 --- a/English.lproj/MainMenu.xib +++ b/English.lproj/MainMenu.xib @@ -3,12 +3,12 @@ <data> <int key="IBDocument.SystemTarget">1050</int> <string key="IBDocument.SystemVersion">9F33</string> - <string key="IBDocument.InterfaceBuilderVersion">670</string> + <string key="IBDocument.InterfaceBuilderVersion">672</string> <string key="IBDocument.AppKitVersion">949.34</string> <string key="IBDocument.HIToolboxVersion">352.00</string> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="370"/> + <integer value="57"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -2883,14 +2883,6 @@ </object> <object class="IBConnectionRecord"> <object class="IBActionConnection" key="connection"> - <string key="label">terminate:</string> - <reference key="source" ref="515727999"/> - <reference key="destination" ref="867125855"/> - </object> - <int key="connectionID">139</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> <string key="label">orderFrontStandardAboutPanel:</string> <reference key="source" ref="515727999"/> <reference key="destination" ref="962420073"/> @@ -3825,6 +3817,14 @@ </object> <int key="connectionID">809</int> </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">terminate:</string> + <reference key="source" ref="63651044"/> + <reference key="destination" ref="867125855"/> + </object> + <int key="connectionID">810</int> + </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> <object class="NSArray" key="orderedObjects"> @@ -6407,7 +6407,7 @@ <string>{{59, 583}, {710, 292}}</string> <reference ref="9"/> <string>{{59, 583}, {710, 292}}</string> - <reference ref="9"/> + <integer value="0" id="6"/> <reference ref="9"/> <string>{3.40282e+38, 3.40282e+38}</string> <string>{213, 107}</string> @@ -6504,7 +6504,7 @@ Y2hhbmdlIHRoZSBvcmRlcg</string> <string>{{828, 556}, {278, 365}}</string> <reference ref="9"/> <string>{{828, 556}, {278, 365}}</string> - <reference ref="9"/> + <reference ref="6"/> <reference ref="9"/> <string>{3.40282e+38, 3.40282e+38}</string> <string>{213, 107}</string> @@ -6568,7 +6568,7 @@ Y2hhbmdlIHRoZSBvcmRlcg</string> </object> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> - <string>{{131, 483}, {511, 20}}</string> + <string>{{123, 602}, {511, 20}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> <string>{{506, 836}, {511, 20}}</string> @@ -6763,7 +6763,7 @@ Y2hhbmdlIHRoZSBvcmRlcg</string> <reference ref="9"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> - <string>{{122, 334}, {218, 253}}</string> + <string>{{135, 349}, {218, 253}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> <string>{{518, 583}, {218, 253}}</string> @@ -6924,7 +6924,7 @@ Y2hhbmdlIHRoZSBvcmRlcg</string> </object> </object> <nil key="sourceID"/> - <int key="maxID">809</int> + <int key="maxID">810</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> diff --git a/TableDocument.h b/TableDocument.h index 5ade5ec1..aed99756 100644 --- a/TableDocument.h +++ b/TableDocument.h @@ -96,6 +96,7 @@ //start sheet - (IBAction)connectToDB:(id)sender; - (IBAction)connect:(id)sender; +- (IBAction)cancelConnectSheet:(id)sender; - (IBAction)closeSheet:(id)sender; - (IBAction)chooseFavorite:(id)sender; - (id)selectedFavorite; diff --git a/TableDocument.m b/TableDocument.m index 5ecc75b2..5c93c09f 100644 --- a/TableDocument.m +++ b/TableDocument.m @@ -99,8 +99,6 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa */ - (IBAction)connectToDB:(id)sender { - CMMCPResult *theResult; - id version; // load the details of the curretnly selected favorite into the text boxes in connect sheet [self chooseFavorite:self]; @@ -109,12 +107,74 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa [NSApp beginSheet:connectSheet modalForWindow:tableWindow modalDelegate:self - didEndSelector:nil + didEndSelector:@selector(connectSheetDidEnd:returnCode:contextInfo:) contextInfo:nil]; - int code = [NSApp runModalForWindow:connectSheet]; +} - [NSApp endSheet:connectSheet]; + +/* +invoked when user hits the connect-button of the connectSheet +stops modal session with code: +1 when connected with success +2 when no connection to host +3 when no connection to db +4 when hostField and socketField are empty +*/ +- (IBAction)connect:(id)sender +{ + int code; + + [connectProgressBar startAnimation:self]; + [connectProgressStatusText setHidden:NO]; + [connectProgressStatusText display]; + + [selectedDatabase autorelease]; + selectedDatabase = nil; + + code = 0; + if ( [[hostField stringValue] isEqualToString:@""] && [[socketField stringValue] isEqualToString:@""] ) { + code = 4; + } else { + if ( ![[socketField stringValue] isEqualToString:@""] ) { + //connect to socket + mySQLConnection = [[CMMCPConnection alloc] initToSocket:[socketField stringValue] + withLogin:[userField stringValue] + password:[passwordField stringValue]]; + [hostField setStringValue:@"localhost"]; + } else { + //connect to host + mySQLConnection = [[CMMCPConnection alloc] initToHost:[hostField stringValue] + withLogin:[userField stringValue] + password:[passwordField stringValue] + usingPort:[portField intValue]]; + } + if ( ![mySQLConnection isConnected] ) + code = 2; + if ( !code && ![[databaseField stringValue] isEqualToString:@""] ) { + if ([mySQLConnection selectDB:[databaseField stringValue]]) { + selectedDatabase = [[databaseField stringValue] retain]; + } else { + code = 3; + } + } + if ( !code ) + code = 1; + } + + // close sheet [connectSheet orderOut:nil]; + [NSApp endSheet:connectSheet returnCode:code]; +// [NSApp stopModalWithCode:code]; + [connectProgressBar stopAnimation:self]; + [connectProgressStatusText setHidden:YES]; +} + +-(void)connectSheetDidEnd:(NSWindow*)sheet returnCode:(int)code contextInfo:(void*)contextInfo +{ + [sheet orderOut:self]; + + CMMCPResult *theResult; + id version; if ( code == 1) { //connected with success @@ -145,9 +205,9 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa [tableDumpInstance setConnection:mySQLConnection]; [tableStatusInstance setConnection:mySQLConnection]; [self setFileName:[NSString stringWithFormat:@"(MySQL %@) %@@%@ %@", mySQLVersion, [userField stringValue], - [hostField stringValue], [databaseField stringValue]]]; + [hostField stringValue], [databaseField stringValue]]]; [tableWindow setTitle:[NSString stringWithFormat:@"(MySQL %@) %@@%@/%@", mySQLVersion, [userField stringValue], - [hostField stringValue], [databaseField stringValue]]]; + [hostField stringValue], [databaseField stringValue]]]; // Connected Growl Notification [GrowlApplicationBridge notifyWithTitle:@"Connected" @@ -163,81 +223,32 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa } else if (code == 2) { //can't connect to host NSBeginAlertSheet(NSLocalizedString(@"Connection failed!", @"connection failed"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, - @selector(sheetDidEnd:returnCode:contextInfo:), @"connect", - [NSString stringWithFormat:NSLocalizedString(@"Unable to connect to host %@.\nBe sure that the address is correct and that you have the necessary privileges.\nMySQL said: %@", @"message of panel when connection to host failed"), [hostField stringValue], [mySQLConnection getLastErrorMessage]]); + @selector(sheetDidEnd:returnCode:contextInfo:), @"connect", + [NSString stringWithFormat:NSLocalizedString(@"Unable to connect to host %@.\nBe sure that the address is correct and that you have the necessary privileges.\nMySQL said: %@", @"message of panel when connection to host failed"), [hostField stringValue], [mySQLConnection getLastErrorMessage]]); } else if (code == 3) { //can't connect to db NSBeginAlertSheet(NSLocalizedString(@"Connection failed!", @"connection failed"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, - @selector(sheetDidEnd:returnCode:contextInfo:), @"connect", - [NSString stringWithFormat:NSLocalizedString(@"Unable to connect to database %@.\nBe sure that the database exists and that you have the necessary privileges.\nMySQL said: %@", @"message of panel when connection to db failed"), [databaseField stringValue], [mySQLConnection getLastErrorMessage]]); + @selector(sheetDidEnd:returnCode:contextInfo:), @"connect", + [NSString stringWithFormat:NSLocalizedString(@"Unable to connect to database %@.\nBe sure that the database exists and that you have the necessary privileges.\nMySQL said: %@", @"message of panel when connection to db failed"), [databaseField stringValue], [mySQLConnection getLastErrorMessage]]); } else if (code == 4) { //no host is given NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, - @selector(sheetDidEnd:returnCode:contextInfo:), @"connect", NSLocalizedString(@"Please enter at least a host or socket.", @"message of panel when host/socket are missing")); + @selector(sheetDidEnd:returnCode:contextInfo:), @"connect", NSLocalizedString(@"Please enter at least a host or socket.", @"message of panel when host/socket are missing")); } else { //cancel button was pressed //since the window is getting ready to be toast ignore events for awhile //so as not to crash, this happens to me when hitten esc key instead of //cancel button, but with this code it does not crash - [[NSApplication sharedApplication] discardEventsMatchingMask:NSAnyEventMask - beforeEvent:[[NSApplication sharedApplication] nextEventMatchingMask:NSLeftMouseDownMask | NSLeftMouseUpMask |NSRightMouseDownMask | NSRightMouseUpMask | NSFlagsChangedMask | NSKeyDownMask | NSKeyUpMask untilDate:[NSDate distantPast] inMode:NSEventTrackingRunLoopMode dequeue:YES]]; - [tableWindow close]; + // [[NSApplication sharedApplication] discardEventsMatchingMask:NSAnyEventMask + // beforeEvent:[[NSApplication sharedApplication] nextEventMatchingMask:NSLeftMouseDownMask | NSLeftMouseUpMask |NSRightMouseDownMask | NSRightMouseUpMask | NSFlagsChangedMask | NSKeyDownMask | NSKeyUpMask untilDate:[NSDate distantPast] inMode:NSEventTrackingRunLoopMode dequeue:YES]]; + // [tableWindow close]; } + } -/* -invoked when user hits the connect-button of the connectSheet -stops modal session with code: -1 when connected with success -2 when no connection to host -3 when no connection to db -4 when hostField and socketField are empty -*/ -- (IBAction)connect:(id)sender +- (IBAction)cancelConnectSheet:(id)sender { - int code; - - [connectProgressBar startAnimation:self]; - [connectProgressStatusText setHidden:NO]; - [connectProgressStatusText display]; - - [selectedDatabase autorelease]; - selectedDatabase = nil; - - code = 0; - if ( [[hostField stringValue] isEqualToString:@""] && [[socketField stringValue] isEqualToString:@""] ) { - code = 4; - } else { - if ( ![[socketField stringValue] isEqualToString:@""] ) { - //connect to socket - mySQLConnection = [[CMMCPConnection alloc] initToSocket:[socketField stringValue] - withLogin:[userField stringValue] - password:[passwordField stringValue]]; - [hostField setStringValue:@"localhost"]; - } else { - //connect to host - mySQLConnection = [[CMMCPConnection alloc] initToHost:[hostField stringValue] - withLogin:[userField stringValue] - password:[passwordField stringValue] - usingPort:[portField intValue]]; - } - if ( ![mySQLConnection isConnected] ) - code = 2; - if ( !code && ![[databaseField stringValue] isEqualToString:@""] ) { - if ([mySQLConnection selectDB:[databaseField stringValue]]) { - selectedDatabase = [[databaseField stringValue] retain]; - } else { - code = 3; - } - } - if ( !code ) - code = 1; - } - - // close sheet - [NSApp stopModalWithCode:code]; - [connectProgressBar stopAnimation:self]; - [connectProgressStatusText setHidden:YES]; + [NSApp endSheet:connectSheet]; } - (IBAction)closeSheet:(id)sender @@ -247,7 +258,10 @@ stops modal session with code 0 reused when user hits the close button of the variablseSheet or of the createTableSyntaxSheet */ { - [NSApp stopModalWithCode:0]; + if (sender != nil) { + [NSApp endSheet:[sender window] returnCode:0]; + } + } /** @@ -1434,7 +1448,8 @@ sets upt the interface (small fonts) //set up toolbar [self setupToolbar]; - [self connectToDB:nil]; +// [self connectToDB:nil]; + [self performSelector:@selector(connectToDB:) withObject:tableWindow afterDelay:0.0f]; } - (void)windowWillClose:(NSNotification *)aNotification @@ -1566,6 +1581,12 @@ invoked when query gave an error return theValue; } +- (IBAction)terminate:(id)sender +{ + [[NSApp orderedDocuments] makeObjectsPerformSelector:@selector(cancelConnectSheet:) withObject:nil]; + [NSApp terminate:sender]; +} + - (void)dealloc { [chooseDatabaseButton release]; |