diff options
-rw-r--r-- | Interfaces/English.lproj/DBView.xib | 85 | ||||
-rw-r--r-- | Source/TableDump.h | 15 | ||||
-rw-r--r-- | Source/TableDump.m | 67 |
3 files changed, 121 insertions, 46 deletions
diff --git a/Interfaces/English.lproj/DBView.xib b/Interfaces/English.lproj/DBView.xib index 71b1dba3..14911286 100644 --- a/Interfaces/English.lproj/DBView.xib +++ b/Interfaces/English.lproj/DBView.xib @@ -2,13 +2,14 @@ <archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03"> <data> <int key="IBDocument.SystemTarget">1050</int> - <string key="IBDocument.SystemVersion">9F33</string> + <string key="IBDocument.SystemVersion">9G55</string> <string key="IBDocument.InterfaceBuilderVersion">677</string> - <string key="IBDocument.AppKitVersion">949.34</string> - <string key="IBDocument.HIToolboxVersion">352.00</string> + <string key="IBDocument.AppKitVersion">949.43</string> + <string key="IBDocument.HIToolboxVersion">353.00</string> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="27"/> + <integer value="970"/> + <integer value="676"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -6881,7 +6882,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> <string key="NSWindowContentMinSize">{213, 50}</string> <object class="NSView" key="NSWindowView" id="537060735"> - <nil key="NSNextResponder"/> + <reference key="NSNextResponder"/> <int key="NSvFlags">256</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -6889,7 +6890,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <reference key="NSNextResponder" ref="537060735"/> <int key="NSvFlags">1280</int> <object class="NSPSMatrix" key="NSDrawMatrix"/> - <string key="NSFrame">{{19, 40}, {337, 12}}</string> + <string key="NSFrame">{{19, 40}, {307, 12}}</string> <reference key="NSSuperview" ref="537060735"/> <int key="NSpiFlags">16652</int> <double key="NSMaxValue">1.000000e+02</double> @@ -6910,8 +6911,33 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <reference key="NSTextColor" ref="454249633"/> </object> </object> + <object class="NSButton" id="632761638"> + <reference key="NSNextResponder" ref="537060735"/> + <int key="NSvFlags">268</int> + <string key="NSFrame">{{333, 40}, {21, 14}}</string> + <reference key="NSSuperview" ref="537060735"/> + <bool key="NSEnabled">YES</bool> + <object class="NSButtonCell" key="NSCell" id="143557124"> + <int key="NSCellFlags">-2080244224</int> + <int key="NSCellFlags2">134217728</int> + <string key="NSContents"/> + <reference key="NSSupport" ref="244931163"/> + <reference key="NSControlView" ref="632761638"/> + <int key="NSButtonFlags">-2042347265</int> + <int key="NSButtonFlags2">134</int> + <object class="NSCustomResource" key="NSNormalImage"> + <string key="NSClassName">NSImage</string> + <string key="NSResourceName">NSStopProgressFreestandingTemplate</string> + </object> + <string key="NSAlternateContents"/> + <string key="NSKeyEquivalent"/> + <int key="NSPeriodicDelay">400</int> + <int key="NSPeriodicInterval">75</int> + </object> + </object> </object> <string key="NSFrameSize">{375, 72}</string> + <reference key="NSSuperview"/> </object> <string key="NSScreenRect">{{0, 0}, {1440, 878}}</string> <string key="NSMinSize">{213, 72}</string> @@ -11796,6 +11822,14 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> <int key="connectionID">4693</int> </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">cancelProgressBar:</string> + <reference key="source" ref="225526897"/> + <reference key="destination" ref="632761638"/> + </object> + <int key="connectionID">4701</int> + </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> <object class="NSArray" key="orderedObjects"> @@ -12954,6 +12988,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <bool key="EncodedWithXMLCoder">YES</bool> <reference ref="915740486"/> <reference ref="488280145"/> + <reference ref="632761638"/> </object> <reference key="parent" ref="12594599"/> </object> @@ -16837,6 +16872,20 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <reference key="object" ref="45017564"/> <reference key="parent" ref="531095296"/> </object> + <object class="IBObjectRecord"> + <int key="objectID">4699</int> + <reference key="object" ref="632761638"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="143557124"/> + </object> + <reference key="parent" ref="537060735"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">4700</int> + <reference key="object" ref="143557124"/> + <reference key="parent" ref="632761638"/> + </object> </object> </object> <object class="NSMutableDictionary" key="flattenedProperties"> @@ -17823,8 +17872,10 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string>4677.IBPluginDependency</string> <string>4686.IBPluginDependency</string> <string>4687.IBPluginDependency</string> + <string>4699.IBPluginDependency</string> <string>47.IBPluginDependency</string> <string>47.ImportedFromIB2</string> + <string>4700.IBPluginDependency</string> <string>495.IBAttributePlaceholdersKey</string> <string>495.IBPluginDependency</string> <string>495.ImportedFromIB2</string> @@ -19329,7 +19380,9 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <object class="NSMutableDictionary"> <string key="NS.key.0">ToolTip</string> <object class="IBToolTipAttribute" key="NS.object.0"> @@ -19340,8 +19393,8 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> - <string>{{119, 153}, {863, 550}}</string> - <string>{{119, 153}, {863, 550}}</string> + <string>{{41, 153}, {863, 550}}</string> + <string>{{41, 153}, {863, 550}}</string> <reference ref="9"/> <reference ref="9"/> <string>{{62, 352}, {845, 504}}</string> @@ -19719,8 +19772,8 @@ Y2hhbmdlIHRoZSBvcmRlcg</string> <reference ref="9"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> - <string>{{126, 624}, {375, 72}}</string> - <string>{{126, 624}, {375, 72}}</string> + <string>{{57, 736}, {375, 72}}</string> + <string>{{57, 736}, {375, 72}}</string> <reference ref="9"/> <reference ref="8"/> <reference ref="9"/> @@ -19754,7 +19807,7 @@ Y2hhbmdlIHRoZSBvcmRlcg</string> </object> </object> <nil key="sourceID"/> - <int key="maxID">4695</int> + <int key="maxID">4701</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> @@ -19922,6 +19975,14 @@ Y2hhbmdlIHRoZSBvcmRlcg</string> </object> </object> <object class="IBPartialClassDescription"> + <string key="className">NSImageView</string> + <string key="superclassName">NSControl</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBUserSource</string> + <string key="minorKey"/> + </object> + </object> + <object class="IBPartialClassDescription"> <string key="className">NSObject</string> <object class="IBClassDescriptionSource" key="sourceIdentifier"> <string key="majorKey">IBProjectSource</string> @@ -20267,6 +20328,7 @@ Y2hhbmdlIHRoZSBvcmRlcg</string> <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSMutableArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> + <string>cancelProgressBar:</string> <string>changeFormat:</string> <string>changeTable:</string> <string>closeSheet:</string> @@ -20282,6 +20344,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/Source/TableDump.h b/Source/TableDump.h index 22b123af..c8648eb4 100644 --- a/Source/TableDump.h +++ b/Source/TableDump.h @@ -94,6 +94,7 @@ NSString *savePath; NSString *openPath; NSUserDefaults *prefs; + BOOL progressCancelled; } //IBAction methods @@ -101,15 +102,13 @@ - (IBAction)selectTables:(id)sender; - (IBAction)closeSheet:(id)sender; - (IBAction)stepRow:(id)sender; -//- (IBAction)chooseDumpType:(id)sender; - +- (IBAction)cancelProgressBar:(id)sender; //export methods //- (IBAction)saveDump:(id)sender; - (void)exportFile:(int)tag; - (void)savePanelDidEnd:(NSSavePanel *)sheet returnCode:(int)returnCode contextInfo:(NSString *)contextInfo; //import methods -//- (IBAction)openDump:(id)sender; - (void)importFile; - (IBAction)changeFormat:(id)sender; - (IBAction)changeTable:(id)sender; @@ -139,16 +138,6 @@ //additional methods - (void)setConnection:(CMMCPConnection *)theConnection; -//tableView datasource methods -- (int)numberOfRowsInTableView:(NSTableView *)aTableView; -- (id)tableView:(NSTableView *)aTableView - objectValueForTableColumn:(NSTableColumn *)aTableColumn - row:(int)rowIndex; -- (void)tableView:(NSTableView *)aTableView - setObjectValue:(id)anObject - forTableColumn:(NSTableColumn *)aTableColumn - row:(int)rowIndex; - //last but not least - (id)init; - (void)dealloc; diff --git a/Source/TableDump.m b/Source/TableDump.m index 442ec84a..dd2b91c0 100644 --- a/Source/TableDump.m +++ b/Source/TableDump.m @@ -294,7 +294,10 @@ NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, NSLocalizedString(@"Couldn't write to file. Be sure that you have the necessary privileges.", @"message of panel when file cannot be written")); } - + if (progressCancelled) + { + progressCancelled = NO; + } // Export finished Growl notification [[SPGrowlController sharedGrowlController] notifyWithTitle:@"Export Finished" description:[NSString stringWithFormat:NSLocalizedString(@"Finished exporting to %@",@"description for finished exporting growl notification"), [[sheet filename] lastPathComponent]] @@ -342,29 +345,18 @@ [fieldMappingTableView reloadData]; } -- (void)openPanelDidEnd:(NSOpenPanel *)sheet returnCode:(int)returnCode contextInfo:(NSString *)contextInfo -/* - reads mysql-dumpfile - */ +- (void)importBackgroundProcess:(NSString*)filename { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString *dumpFile; NSError **errorStr; NSMutableString *errors = [NSMutableString string]; NSString *fileType = [[importFormatPopup selectedItem] title]; - - [sheet orderOut:self]; - - if ( returnCode != NSOKButton ) - return; - - //save path to preferences - [prefs setObject:[sheet directory] forKey:@"openPath"]; - //load file into string - dumpFile = [NSString stringWithContentsOfFile:[sheet filename] + dumpFile = [NSString stringWithContentsOfFile:filename encoding:[CMMCPConnection encodingForMySQLEncoding:[[tableDocumentInstance encoding] cString]] error:errorStr]; - + if ( !dumpFile ) { NSBeginAlertSheet(NSLocalizedString(@"Error", @"Title of error alert"), NSLocalizedString(@"OK", @"OK button"), @@ -442,6 +434,7 @@ //////////////// } else if ( [fileType isEqualToString:@"CSV"] ) { + //NSLog(@"CSV Import..."); //import csv file int code; NSPopUpButtonCell *buttonCell = [[NSPopUpButtonCell alloc] init]; @@ -474,7 +467,12 @@ [singleProgressBar setUsesThreadedAnimation:NO]; [singleProgressBar setIndeterminate:NO]; - + if (progressCancelled) { + progressCancelled = NO; + //NSLog(@"Progress Cancelled... cleaning up"); + [pool release]; + return; + } CMMCPResult *theResult; int i; theResult = (CMMCPResult *) [mySQLConnection listTables]; @@ -608,8 +606,25 @@ // Import finished Growl notification [[SPGrowlController sharedGrowlController] notifyWithTitle:@"Import Finished" - description:[NSString stringWithFormat:NSLocalizedString(@"Finished importing %@",@"description for finished importing growl notification"), [[sheet filename] lastPathComponent]] + description:[NSString stringWithFormat:NSLocalizedString(@"Finished importing %@",@"description for finished importing growl notification"), [filename lastPathComponent]] notificationName:@"Import Finished"]; + [pool release]; +} +- (void)openPanelDidEnd:(NSOpenPanel *)sheet returnCode:(int)returnCode contextInfo:(NSString *)contextInfo +/* + reads mysql-dumpfile + */ +{ + [sheet orderOut:self]; + + if ( returnCode != NSOKButton ) + return; + + //save path to preferences + [prefs setObject:[sheet directory] forKey:@"openPath"]; + + [NSThread detachNewThreadSelector:@selector(importBackgroundProcess:) toTarget:self withObject:[sheet filename]]; + } - (void)setupFieldMappingArray @@ -1120,12 +1135,16 @@ return TRUE; } + - (NSArray *)arrayForCSV:(NSString *)csv terminatedBy:(NSString *)terminated enclosedBy:(NSString *)enclosed escapedBy:(NSString *)escaped lineEnds:(NSString *)lineEnds /* loads a csv string into an array */ { + + //NSLog(@"In arrayForCSV..."); + NSMutableString *tempTerminated, *tempLineEnds; NSMutableArray *tempArray = [NSMutableArray array]; NSMutableArray *tempRowArray = [NSMutableArray array]; @@ -1166,7 +1185,7 @@ scanner = [NSScanner scannerWithString:csv]; [scanner setCharactersToBeSkipped:nil]; - while ( ![scanner isAtEnd] ) { + while ( ![scanner isAtEnd] && !progressCancelled) { [tempString setString:@""]; br = NO; @@ -1197,12 +1216,11 @@ // Skip blank lines if (![tempString length]) continue; - // Add the line to the array [linesArray addObject:[NSString stringWithString:tempString]]; } - for ( x = 0 ; x < [linesArray count] ; x++ ) { + for ( x = 0 ; x < [linesArray count] && !progressCancelled; x++ ) { //separate fields [tempRowArray removeAllObjects]; @@ -1258,6 +1276,7 @@ } //add row to tempArray [tempArray addObject:[NSArray arrayWithArray:tempRowArray]]; + //NSLog(@"tempArray count: %d", [tempArray count]); } return [NSArray arrayWithArray:tempArray]; @@ -1477,7 +1496,7 @@ [fileHandle writeData:[infoString dataUsingEncoding:connectionEncoding]]; // Loop through the selected tables - for ( i = 0 ; i < [selectedTables count] ; i++ ) { + for ( i = 0 ; i < [selectedTables count] && !progressCancelled; i++ ) { // Update the progress text and reset the progress bar to indeterminate status tableName = [selectedTables objectAtIndex:i]; @@ -1891,5 +1910,9 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn [super dealloc]; } +- (IBAction)cancelProgressBar:(id)sender +{ + progressCancelled = YES; +} @end |