aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-08-03 18:23:53 +0000
committerBibiko <bibiko@eva.mpg.de>2009-08-03 18:23:53 +0000
commit20ad5eaa3826dc8b5d1fb5496a3c6f49d802c632 (patch)
tree73b1deea4593bec9e7614bfdfc19301358d32289 /Source
parent14bd0cf3680e261b979be98e792bafc5e8e1afd5 (diff)
downloadsequelpro-20ad5eaa3826dc8b5d1fb5496a3c6f49d802c632.tar.gz
sequelpro-20ad5eaa3826dc8b5d1fb5496a3c6f49d802c632.tar.bz2
sequelpro-20ad5eaa3826dc8b5d1fb5496a3c6f49d802c632.zip
• add Menu Item "Insert NULL value" SHIFT+CTRL+N
- it inserts the value set in the preferences • a NULL value will be displayed greyed in the Custom Query result • make usage of NSArrayObjectAtIndex() in TableContent for tableView:willDisplayCell - and negated the NULL checking for column (is NULL allowed)
Diffstat (limited to 'Source')
-rw-r--r--Source/CustomQuery.m21
-rw-r--r--Source/SPTextViewAdditions.h1
-rw-r--r--Source/SPTextViewAdditions.m13
-rw-r--r--Source/TableContent.m4
4 files changed, 37 insertions, 2 deletions
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m
index 7616fb5d..d6194484 100644
--- a/Source/CustomQuery.m
+++ b/Source/CustomQuery.m
@@ -1276,6 +1276,27 @@
}
}
+/**
+ * This function changes the text color of text/blob fields whose content is NULL
+ */
+- (void)tableView:(CMCopyTable *)aTableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn*)aTableColumn row:(int)row
+{
+
+ if ( aTableView == customQueryView ) {
+
+ // For NULL cell's display the user's NULL value placeholder in grey to easily distinguish it from other values
+ if ([cell respondsToSelector:@selector(setTextColor:)]) {
+
+ // Note that this approach of changing the color of NULL placeholders is dependent on the cell's value matching that
+ // of the user's NULL value preference which was set in the result array when it was retrieved (see fetchResultAsArray).
+ // Also, as an added measure check that the table column actually allows NULLs to make sure we don't change a cell that
+ // happens to have a value matching the NULL placeholder, but the column doesn't allow NULLs.
+ [cell setTextColor:([[cell stringValue] isEqualToString:[prefs objectForKey:@"NullValue"]]) ? [NSColor lightGrayColor] : [NSColor blackColor]];
+ }
+ }
+
+}
+
- (id)tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex
diff --git a/Source/SPTextViewAdditions.h b/Source/SPTextViewAdditions.h
index 22b809c8..2ced6555 100644
--- a/Source/SPTextViewAdditions.h
+++ b/Source/SPTextViewAdditions.h
@@ -40,6 +40,7 @@
- (IBAction)doPrecomposedStringWithCompatibilityMapping:(id)sender;
- (IBAction)doTranspose:(id)sender;
- (IBAction)doRemoveDiacritics:(id)sender;
+- (IBAction)insertNULLvalue:(id)sender;
- (void)makeTextSizeLarger;
- (void)makeTextSizeSmaller;
diff --git a/Source/SPTextViewAdditions.m b/Source/SPTextViewAdditions.m
index 2dcf0614..f3c41fa8 100644
--- a/Source/SPTextViewAdditions.m
+++ b/Source/SPTextViewAdditions.m
@@ -385,6 +385,19 @@
}
}
+/**
+ * Inserts the preference's NULL value set by the user
+ */
+- (IBAction)insertNULLvalue:(id)sender
+{
+ id prefs = [NSUserDefaults standardUserDefaults];
+ if([self respondsToSelector:@selector(insertText:)])
+ if([prefs objectForKey:@"NullValue"] && [[prefs objectForKey:@"NullValue"] length])
+ [self insertText:[prefs objectForKey:@"NullValue"]];
+ else
+ [self insertText:@"NULL"];
+
+}
/*
* Increase the textView's font size by 1
diff --git a/Source/TableContent.m b/Source/TableContent.m
index 18cd8e78..93929d00 100644
--- a/Source/TableContent.m
+++ b/Source/TableContent.m
@@ -1873,7 +1873,7 @@
*/
- (void)tableView:(CMCopyTable *)aTableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn*)aTableColumn row:(int)row
{
- NSDictionary *column = [dataColumns objectAtIndex:[[aTableColumn identifier] intValue]];
+ NSDictionary *column = NSArrayObjectAtIndex(dataColumns, [[aTableColumn identifier] intValue]);
// For NULL cell's display the user's NULL value placeholder in grey to easily distinguish it from other values
if ([cell respondsToSelector:@selector(setTextColor:)]) {
@@ -1882,7 +1882,7 @@
// of the user's NULL value preference which was set in the result array when it was retrieved (see fetchResultAsArray).
// Also, as an added measure check that the table column actually allows NULLs to make sure we don't change a cell that
// happens to have a value matching the NULL placeholder, but the column doesn't allow NULLs.
- [cell setTextColor:([[cell stringValue] isEqualToString:[prefs objectForKey:@"NullValue"]] && [[column objectForKey:@"null"] boolValue]) ? [NSColor lightGrayColor] : [NSColor blackColor]];
+ [cell setTextColor:([[cell stringValue] isEqualToString:[prefs objectForKey:@"NullValue"]] && ![[column objectForKey:@"null"] boolValue]) ? [NSColor lightGrayColor] : [NSColor blackColor]];
}
// Check if loading of text/blob fields is disabled