aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPDataImport.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-09-03 10:53:26 +0000
committerBibiko <bibiko@eva.mpg.de>2010-09-03 10:53:26 +0000
commitca60d2e7bdec4763489e79ff4c457c32cd1f57db (patch)
tree85ba4e228f51ec6975833d3e2a8a7b0860f0df8e /Source/SPDataImport.m
parent4aaa7dda2d01afbebb9f7c2a6ba8537a3206858a (diff)
downloadsequelpro-ca60d2e7bdec4763489e79ff4c457c32cd1f57db.tar.gz
sequelpro-ca60d2e7bdec4763489e79ff4c457c32cd1f57db.tar.bz2
sequelpro-ca60d2e7bdec4763489e79ff4c457c32cd1f57db.zip
• finished the first implementation of CSV Import into new table
note:What else is needed for such an import? table encoding settings? ... has to be discussed
Diffstat (limited to 'Source/SPDataImport.m')
-rw-r--r--Source/SPDataImport.m39
1 files changed, 31 insertions, 8 deletions
diff --git a/Source/SPDataImport.m b/Source/SPDataImport.m
index c9b5664b..efc85bbc 100644
--- a/Source/SPDataImport.m
+++ b/Source/SPDataImport.m
@@ -76,8 +76,10 @@
fieldMappingImportArrayIsPreview = NO;
fieldMappingArrayHasGlobalVariables = NO;
importMethodIsUpdate = NO;
+ importIntoNewTable = NO;
insertRemainingRowsAfterUpdate = NO;
numberOfImportDataColumns = 0;
+ selectedTableTarget = nil;
prefs = nil;
lastFilename = nil;
@@ -1074,15 +1076,34 @@
document:tableDocumentInstance
notificationName:@"Import Finished"];
- // If the table selected for import is also selected in the content view,
- // update the content view - on the main thread to avoid crashes.
- if ([tablesListInstance tableName] && [selectedTableTarget isEqualToString:[tablesListInstance tableName]]) {
- if ([[tableDocumentInstance selectedToolbarItemIdentifier] isEqualToString:SPMainToolbarTableContent]) {
- [tableContentInstance performSelectorOnMainThread:@selector(reloadTable:) withObject:nil waitUntilDone:YES];
- } else {
- [tablesListInstance setContentRequiresReload:YES];
+
+ if(importIntoNewTable) {
+
+ // Select the new table
+
+ // Update current database tables
+ [tablesListInstance performSelectorOnMainThread:@selector(updateTables:) withObject:self waitUntilDone:YES];
+
+ // Re-query the structure of all databases in the background
+ [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:mySQLConnection withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]];
+
+ // Select the new table
+ [tablesListInstance selectItemWithName:selectedTableTarget];
+
+ } else {
+
+ // If import was done into a new table or the table selected for import is also selected in the content view,
+ // update the content view - on the main thread to avoid crashes.
+ if ([tablesListInstance tableName] && [selectedTableTarget isEqualToString:[tablesListInstance tableName]]) {
+ if ([[tableDocumentInstance selectedToolbarItemIdentifier] isEqualToString:SPMainToolbarTableContent]) {
+ [tableContentInstance performSelectorOnMainThread:@selector(reloadTable:) withObject:nil waitUntilDone:YES];
+ } else {
+ [tablesListInstance setContentRequiresReload:YES];
+ }
}
+
}
+
}
/**
@@ -1165,13 +1186,14 @@
// Get mapping settings and preset some global variables
fieldMapperOperator = [[NSArray arrayWithArray:[fieldMapperController fieldMapperOperator]] retain];
fieldMappingArray = [[NSArray arrayWithArray:[fieldMapperController fieldMappingArray]] retain];
- selectedTableTarget = [NSString stringWithString:[fieldMapperController selectedTableTarget]];
+ selectedTableTarget = [[NSString stringWithString:[fieldMapperController selectedTableTarget]] retain];
selectedImportMethod = [NSString stringWithString:[fieldMapperController selectedImportMethod]];
fieldMappingTableColumnNames = [[NSArray arrayWithArray:[fieldMapperController fieldMappingTableColumnNames]] retain];
fieldMappingGlobalValueArray = [[NSArray arrayWithArray:[fieldMapperController fieldMappingGlobalValueArray]] retain];
fieldMappingTableDefaultValues = [[NSArray arrayWithArray:[fieldMapperController fieldMappingTableDefaultValues]] retain];
csvImportHeaderString = [[NSString stringWithString:[fieldMapperController importHeaderString]] retain];
csvImportTailString = [[NSString stringWithString:[fieldMapperController onupdateString]] retain];
+ importIntoNewTable = [fieldMapperController importIntoNewTable];
fieldMappingArrayHasGlobalVariables = [fieldMapperController globalValuesInUsage];
csvImportMethodHasTail = ([csvImportTailString length] == 0) ? NO : YES;
insertRemainingRowsAfterUpdate = [fieldMapperController insertRemainingRowsAfterUpdate];
@@ -1475,6 +1497,7 @@
if (fieldMappingImportArray) [fieldMappingImportArray release];
if (lastFilename) [lastFilename release];
if (prefs) [prefs release];
+ if(selectedTableTarget) [selectedTableTarget release];
for (id retainedObject in nibObjectsToRelease) [retainedObject release];