diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-03-06 12:36:37 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-03-06 12:36:37 +0000 |
commit | 5052718afb789f21654e094f2d065baf6bb6ac81 (patch) | |
tree | 88e9f2f8c03a7bf995208f17f619e3d40a437d71 /Source | |
parent | 37b41c535f442aa85750679dccc7885655cb3429 (diff) | |
download | sequelpro-5052718afb789f21654e094f2d065baf6bb6ac81.tar.gz sequelpro-5052718afb789f21654e094f2d065baf6bb6ac81.tar.bz2 sequelpro-5052718afb789f21654e094f2d065baf6bb6ac81.zip |
• CSV Import Field Mapper
- fixed some issues for displaying the default values for auto_increment and time_stamp
• added possibility to change the tab stop width in each CMTextView via Preference setting in Editor window
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CMTextView.h | 1 | ||||
-rw-r--r-- | Source/CMTextView.m | 81 | ||||
-rw-r--r-- | Source/SPConstants.h | 1 | ||||
-rw-r--r-- | Source/SPConstants.m | 1 | ||||
-rw-r--r-- | Source/SPFieldMapperController.m | 17 |
5 files changed, 63 insertions, 38 deletions
diff --git a/Source/CMTextView.h b/Source/CMTextView.h index c278c2c3..53afe0df 100644 --- a/Source/CMTextView.h +++ b/Source/CMTextView.h @@ -121,6 +121,7 @@ static inline id NSMutableAttributedStringAttributeAtIndex (NSMutableAttributedS - (BOOL) autouppercaseKeywords; - (void) setAutohelp:(BOOL)enableAutohelp; - (BOOL) autohelp; +- (void) setTabStops; - (void) selectLineNumber:(NSUInteger)lineNumber ignoreLeadingNewLines:(BOOL)ignLeadingNewLines; - (NSUInteger) getLineNumberForCharacterIndex:(NSUInteger)anIndex; - (void) autoHelp; diff --git a/Source/CMTextView.m b/Source/CMTextView.m index d6a1e9d7..3a95a6b5 100644 --- a/Source/CMTextView.m +++ b/Source/CMTextView.m @@ -140,40 +140,9 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) [self setAutohelp:[prefs boolForKey:SPCustomQueryUpdateAutoHelp]]; [self setAutouppercaseKeywords:[prefs boolForKey:SPCustomQueryAutoUppercaseKeywords]]; - // Re-define 64 tab stops for a better editing - NSFont *tvFont = [self font]; - float firstColumnInch = 0.5, otherColumnInch = 0.5, pntPerInch = 72.0; - NSInteger i; - NSTextTab *aTab; - NSMutableArray *myArrayOfTabs; - NSMutableParagraphStyle *paragraphStyle; - myArrayOfTabs = [NSMutableArray arrayWithCapacity:64]; - aTab = [[NSTextTab alloc] initWithType:NSLeftTabStopType location:firstColumnInch*pntPerInch]; - [myArrayOfTabs addObject:aTab]; - [aTab release]; - for(i=1; i<64; i++) { - aTab = [[NSTextTab alloc] initWithType:NSLeftTabStopType location:(firstColumnInch*pntPerInch) + ((float)i * otherColumnInch * pntPerInch)]; - [myArrayOfTabs addObject:aTab]; - [aTab release]; - } - paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; - [paragraphStyle setTabStops:myArrayOfTabs]; - // Soft wrapped lines are indented slightly - [paragraphStyle setHeadIndent:4.0]; - - NSMutableDictionary *textAttributes = [[[NSMutableDictionary alloc] initWithCapacity:1] autorelease]; - [textAttributes setObject:paragraphStyle forKey:NSParagraphStyleAttributeName]; + // Re-define tab stops for a better editing + [self setTabStops]; - NSRange range = NSMakeRange(0, [[self textStorage] length]); - if ([self shouldChangeTextInRange:range replacementString:nil]) { - [[self textStorage] setAttributes:textAttributes range: range]; - [self didChangeText]; - } - [self setTypingAttributes:textAttributes]; - [self setDefaultParagraphStyle:paragraphStyle]; - [paragraphStyle release]; - [self setFont:tvFont]; - // disabled to get the current text range in textView safer [[self layoutManager] setBackgroundLayoutEnabled:NO]; @@ -207,6 +176,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) [prefs addObserver:self forKeyPath:SPCustomQueryEditorNumericColor options:NSKeyValueObservingOptionNew context:NULL]; [prefs addObserver:self forKeyPath:SPCustomQueryEditorVariableColor options:NSKeyValueObservingOptionNew context:NULL]; [prefs addObserver:self forKeyPath:SPCustomQueryEditorTextColor options:NSKeyValueObservingOptionNew context:NULL]; + [prefs addObserver:self forKeyPath:SPCustomQueryEditorTabStopWidth options:NSKeyValueObservingOptionNew context:NULL]; } @@ -262,6 +232,8 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) [self setTextColor:[self otherTextColor]]; if([[self string] length]<100000 && [self isEditable]) [self performSelector:@selector(doSyntaxHighlighting) withObject:nil afterDelay:0.1]; + } else if ([keyPath isEqualToString:SPCustomQueryEditorTabStopWidth]) { + [self setTabStops]; } } @@ -3117,6 +3089,49 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) } +- (void) setTabStops +{ + NSFont *tvFont = [self font]; + NSInteger i; + NSTextTab *aTab; + NSMutableArray *myArrayOfTabs; + NSMutableParagraphStyle *paragraphStyle; + + NSInteger tabStopWidth = [prefs integerForKey:SPCustomQueryEditorTabStopWidth]; + if(tabStopWidth < 1) tabStopWidth = 1; + + float tabWidth = NSSizeToCGSize([[NSString stringWithString:@" "] sizeWithAttributes:[NSDictionary dictionaryWithObject:tvFont forKey:NSFontAttributeName]]).width; + tabWidth = (float)tabStopWidth * tabWidth; + + NSInteger numberOfTabs = 256/tabStopWidth; + myArrayOfTabs = [NSMutableArray arrayWithCapacity:numberOfTabs]; + aTab = [[NSTextTab alloc] initWithType:NSLeftTabStopType location:tabWidth]; + [myArrayOfTabs addObject:aTab]; + [aTab release]; + for(i=1; i<numberOfTabs; i++) { + aTab = [[NSTextTab alloc] initWithType:NSLeftTabStopType location:tabWidth + ((float)i * tabWidth)]; + [myArrayOfTabs addObject:aTab]; + [aTab release]; + } + paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; + [paragraphStyle setTabStops:myArrayOfTabs]; + // Soft wrapped lines are indented slightly + [paragraphStyle setHeadIndent:4.0]; + + NSMutableDictionary *textAttributes = [[[NSMutableDictionary alloc] initWithCapacity:1] autorelease]; + [textAttributes setObject:paragraphStyle forKey:NSParagraphStyleAttributeName]; + + NSRange range = NSMakeRange(0, [[self textStorage] length]); + if ([self shouldChangeTextInRange:range replacementString:nil]) { + [[self textStorage] setAttributes:textAttributes range: range]; + [self didChangeText]; + } + [self setTypingAttributes:textAttributes]; + [self setDefaultParagraphStyle:paragraphStyle]; + [paragraphStyle release]; + [self setFont:tvFont]; +} + - (void)drawRect:(NSRect)rect { diff --git a/Source/SPConstants.h b/Source/SPConstants.h index db38835d..07132538 100644 --- a/Source/SPConstants.h +++ b/Source/SPConstants.h @@ -133,6 +133,7 @@ extern NSString *SPCustomQueryAutoUppercaseKeywords; extern NSString *SPCustomQueryUpdateAutoHelp; extern NSString *SPCustomQueryAutoHelpDelay; extern NSString *SPCustomQueryHighlightCurrentQuery; +extern NSString *SPCustomQueryEditorTabStopWidth; // AutoUpdate Prefpane extern NSString *SPLastUsedVersion; diff --git a/Source/SPConstants.m b/Source/SPConstants.m index 338d15d4..c3d45b0a 100644 --- a/Source/SPConstants.m +++ b/Source/SPConstants.m @@ -101,6 +101,7 @@ NSString *SPCustomQueryAutoUppercaseKeywords = @"CustomQueryAutoUppercaseKey NSString *SPCustomQueryUpdateAutoHelp = @"CustomQueryUpdateAutoHelp"; NSString *SPCustomQueryAutoHelpDelay = @"CustomQueryAutoHelpDelay"; NSString *SPCustomQueryHighlightCurrentQuery = @"CustomQueryHighlightCurrentQuery"; +NSString *SPCustomQueryEditorTabStopWidth = @"CustomQueryEditorTabStopWidth"; // AutoUpdate Prefpane NSString *SPLastUsedVersion = @"LastUsedVersion"; diff --git a/Source/SPFieldMapperController.m b/Source/SPFieldMapperController.m index 5ed301d3..7224c38a 100644 --- a/Source/SPFieldMapperController.m +++ b/Source/SPFieldMapperController.m @@ -284,7 +284,7 @@ [selectedTableData setConnection:mySQLConnection]; NSDictionary *tableDetails = [selectedTableData informationForTable:[tableTargetPopup titleOfSelectedItem]]; BOOL isReplacePossible = NO; - + // NSLog(@"d %@", tableDetails); if (tableDetails) { for (NSDictionary *column in [tableDetails objectForKey:@"columns"]) { [fieldMappingTableColumnNames addObject:[NSString stringWithString:[column objectForKey:@"name"]]]; @@ -298,17 +298,24 @@ if([column objectForKey:@"isprimarykey"]) { [type appendFormat:@",%@",@"PRIMARY"]; - [fieldMappingTableDefaultValues addObject:@"auto_increment"]; + if([[[column objectForKey:@"autoincrement"] description] isEqualToString:@"1"]) { + [fieldMappingTableDefaultValues addObject:@"auto_increment"]; + } else { + [fieldMappingTableDefaultValues addObject:@"0"]; + } isReplacePossible = YES; } else { if([column objectForKey:@"unique"]) { [type appendFormat:@",%@",@"UNIQUE"]; isReplacePossible = YES; } - if ([column objectForKey:@"default"]) - [fieldMappingTableDefaultValues addObject:[column objectForKey:@"default"]]; + if([[[column objectForKey:@"onupdatetimestamp"] description] isEqualToString:@"1"]) + [fieldMappingTableDefaultValues addObject:@"time_stamp"]; else - [fieldMappingTableDefaultValues addObject:@"NULL"]; + if ([column objectForKey:@"default"]) + [fieldMappingTableDefaultValues addObject:[column objectForKey:@"default"]]; + else + [fieldMappingTableDefaultValues addObject:@"NULL"]; } [fieldMappingTableTypes addObject:[NSString stringWithString:type]]; |