aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPFieldMapperController.m
diff options
context:
space:
mode:
Diffstat (limited to 'Source/SPFieldMapperController.m')
-rw-r--r--Source/SPFieldMapperController.m34
1 files changed, 28 insertions, 6 deletions
diff --git a/Source/SPFieldMapperController.m b/Source/SPFieldMapperController.m
index f6633172..ae76f8e2 100644
--- a/Source/SPFieldMapperController.m
+++ b/Source/SPFieldMapperController.m
@@ -94,11 +94,12 @@ static NSString *SPTableViewSqlColumnID = @"sql";
tablesListInstance = [theDelegate valueForKeyPath:@"tablesListInstance"];
databaseDataInstance = [tablesListInstance valueForKeyPath:@"databaseDataInstance"];
+#ifndef SP_REFACTOR /* init ivars */
if(![prefs objectForKey:SPLastImportIntoNewTableType])
[prefs setObject:@"Default" forKey:SPLastImportIntoNewTableType];
if(![prefs objectForKey:SPLastImportIntoNewTableEncoding])
[prefs setObject:@"Default" forKey:SPLastImportIntoNewTableEncoding];
-
+#endif
}
return self;
@@ -387,8 +388,10 @@ static NSString *SPTableViewSqlColumnID = @"sql";
{
// Only save selection if the user selected 'OK'
if ([sender tag]) {
+#ifndef SP_REFACTOR
[prefs setObject:[newTableInfoEnginePopup titleOfSelectedItem] forKey:SPLastImportIntoNewTableType];
[prefs setObject:[newTableInfoEncodingPopup titleOfSelectedItem] forKey:SPLastImportIntoNewTableEncoding];
+#endif
}
[NSApp endSheet:[sender window] returnCode:[sender tag]];
@@ -453,13 +456,15 @@ static NSString *SPTableViewSqlColumnID = @"sql";
}
[createString appendString:@")"];
+#ifndef SP_REFACTOR
if(![[prefs objectForKey:SPLastImportIntoNewTableType] isEqualToString:@"Default"])
[createString appendFormat:@" ENGINE=%@", [prefs objectForKey:SPLastImportIntoNewTableType]];
if(![[prefs objectForKey:SPLastImportIntoNewTableEncoding] isEqualToString:@"Default"]) {
NSString *encodingName = [[prefs objectForKey:SPLastImportIntoNewTableEncoding] stringByMatching:@"\\((.*)\\)" capture:1L];
if (!encodingName) encodingName = @"utf8";
- [createString appendFormat:[NSString stringWithFormat:@" DEFAULT CHARACTER SET %@", [encodingName backtickQuotedString]]];
+ [createString appendString:[NSString stringWithFormat:@" DEFAULT CHARACTER SET %@", [encodingName backtickQuotedString]]];
}
+#endif
[mySQLConnection queryString:createString];
@@ -728,9 +733,11 @@ static NSString *SPTableViewSqlColumnID = @"sql";
}
[fieldMapperTableView reloadData];
+#ifndef SP_REFACTOR
// Remember last field alignment if not "custom order"
if([[alignByPopup selectedItem] tag] != 3)
[prefs setInteger:[[alignByPopup selectedItem] tag] forKey:SPCSVFieldImportMappingAlignment];
+#endif
}
/*
@@ -834,8 +841,8 @@ static NSString *SPTableViewSqlColumnID = @"sql";
columnCounter = 0;
for(id col in row) {
if(col && col != [NSNull null]) {
- if([col isKindOfClass:[NSString class]] && maxLengthOfSourceColumns[columnCounter] < (NSInteger)[col length]) {
- maxLengthOfSourceColumns[columnCounter] = [col length];
+ if([col isKindOfClass:[NSString class]] && maxLengthOfSourceColumns[columnCounter] < (NSInteger)[(NSString*)col length]) {
+ maxLengthOfSourceColumns[columnCounter] = [(NSString*)col length];
}
if(typeOfSourceColumns[columnCounter] == 1) {
if(![[[NSNumber numberWithLongLong:[col longLongValue]] stringValue] isEqualToString:col])
@@ -1034,7 +1041,9 @@ static NSString *SPTableViewSqlColumnID = @"sql";
[newTableInfoEnginePopup addItemWithTitle:[engine objectForKey:@"Engine"]];
}
+#ifndef SP_REFACTOR
[newTableInfoEnginePopup selectItemWithTitle:[prefs objectForKey:SPLastImportIntoNewTableType]];
+#endif
// Populate the table encoding popup button with a default menu item
[newTableInfoEncodingPopup removeAllItems];
@@ -1065,7 +1074,9 @@ static NSString *SPTableViewSqlColumnID = @"sql";
[newTableInfoEncodingPopup insertItemWithTitle:utf8MenuItemTitle atIndex:2];
}
+#ifndef SP_REFACTOR
[newTableInfoEncodingPopup selectItemWithTitle:[prefs objectForKey:SPLastImportIntoNewTableEncoding]];
+#endif
}
[NSApp beginSheet:newTableInfoWindow
@@ -1092,10 +1103,12 @@ static NSString *SPTableViewSqlColumnID = @"sql";
while([insertPullDownButton numberOfItems] > (([[self selectedImportMethod] isEqualToString:@"UPDATE"]) ? 6 : 5))
[insertPullDownButton removeItemAtIndex:[insertPullDownButton numberOfItems]-1];
+#ifndef SP_REFACTOR
// Add recent global value menu
if([prefs objectForKey:SPGlobalValueHistory] && [[prefs objectForKey:SPGlobalValueHistory] isKindOfClass:[NSArray class]] && [[prefs objectForKey:SPGlobalValueHistory] count])
for(id item in [prefs objectForKey:SPGlobalValueHistory])
[recentGlobalValueMenu addItemWithTitle:item action:@selector(insertRecentGlobalValue:) keyEquivalent:@""];
+#endif
// Add column placeholder
NSInteger i = 0;
@@ -1107,7 +1120,7 @@ static NSString *SPTableViewSqlColumnID = @"sql";
} else if ([item isSPNotLoaded]) {
[insertPullDownButton addItemWithTitle:[NSString stringWithFormat:@"%i. <%@>", i, @"DEFAULT"]];
} else {
- if([item length] > 20)
+ if([(NSString*)item length] > 20)
[insertPullDownButton addItemWithTitle:[NSString stringWithFormat:@"%i. %@…", i, [item substringToIndex:20]]];
else
[insertPullDownButton addItemWithTitle:[NSString stringWithFormat:@"%i. %@", i, item]];
@@ -1309,6 +1322,7 @@ static NSString *SPTableViewSqlColumnID = @"sql";
- (void)resizeWindowByHeightDelta:(NSInteger)delta
{
+#ifndef SP_REFACTOR /* resizeWindowByHeightDelta: */
NSUInteger tableMask = [fieldMapperTableScrollView autoresizingMask];
NSUInteger headerSwitchMask = [importFieldNamesHeaderSwitch autoresizingMask];
NSUInteger alignPopupMask = [alignByPopup autoresizingMask];
@@ -1362,7 +1376,7 @@ static NSString *SPTableViewSqlColumnID = @"sql";
[advancedUpdateView setAutoresizingMask:updateViewMask];
[advancedInsertView setAutoresizingMask:insertViewMask];
[advancedBox setAutoresizingMask:NSViewNotSizable|NSViewWidthSizable|NSViewMaxYMargin|NSViewMaxXMargin|NSViewMinXMargin];
-
+#endif
}
- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
@@ -1535,11 +1549,13 @@ static NSString *SPTableViewSqlColumnID = @"sql";
NSInteger alignment = 0;
+#ifndef SP_REFACTOR
if([prefs integerForKey:SPCSVFieldImportMappingAlignment]
&& [prefs integerForKey:SPCSVFieldImportMappingAlignment] >= 0
&& [prefs integerForKey:SPCSVFieldImportMappingAlignment] < 4) {
alignment = [prefs integerForKey:SPCSVFieldImportMappingAlignment];
}
+#endif
// Set matching names only if csv file has an header
if(importFieldNamesHeader && alignment == 2)
@@ -1642,7 +1658,9 @@ static NSString *SPTableViewSqlColumnID = @"sql";
- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
{
+#ifndef SP_REFACTOR
[aCell setFont:([prefs boolForKey:SPUseMonospacedFonts]) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
+#endif
}
- (void)tableView:(NSTableView*)aTableView didClickTableColumn:(NSTableColumn *)aTableColumn
@@ -1940,15 +1958,19 @@ static NSString *SPTableViewSqlColumnID = @"sql";
// Store anObject as recent global value if it's new
NSMutableArray *recents = [NSMutableArray array];
+#ifndef SP_REFACTOR
if([prefs objectForKey:SPGlobalValueHistory] && [[prefs objectForKey:SPGlobalValueHistory] isKindOfClass:[NSArray class]] && [[prefs objectForKey:SPGlobalValueHistory] count])
[recents setArray:[prefs objectForKey:SPGlobalValueHistory]];
+#endif
if([recents containsObject:anObject])
[recents removeObject:anObject];
[recents insertObject:anObject atIndex:0];
while([recents count] > 20)
[recents removeObjectAtIndex:[recents count]-1];
+#ifndef SP_REFACTOR
if([recents count])
[prefs setObject:recents forKey:SPGlobalValueHistory];
+#endif
// Re-init recent menu
[recentGlobalValueMenu compatibleRemoveAllItems];