aboutsummaryrefslogtreecommitdiffstats
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
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)
-rw-r--r--Interfaces/English.lproj/MainMenu.xib217
-rw-r--r--Source/CustomQuery.m21
-rw-r--r--Source/SPTextViewAdditions.h1
-rw-r--r--Source/SPTextViewAdditions.m13
-rw-r--r--Source/TableContent.m4
5 files changed, 250 insertions, 6 deletions
diff --git a/Interfaces/English.lproj/MainMenu.xib b/Interfaces/English.lproj/MainMenu.xib
index c2f1b725..6e1e77b2 100644
--- a/Interfaces/English.lproj/MainMenu.xib
+++ b/Interfaces/English.lproj/MainMenu.xib
@@ -663,6 +663,25 @@
</object>
</object>
</object>
+ <object class="NSMenuItem" id="765987997">
+ <reference key="NSMenu" ref="71086556"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="625762401"/>
+ <reference key="NSMixedImage" ref="315854375"/>
+ </object>
+ <object class="NSMenuItem" id="784426029">
+ <reference key="NSMenu" ref="71086556"/>
+ <string key="NSTitle">Insert NULL value</string>
+ <string key="NSKeyEquiv">N</string>
+ <int key="NSKeyEquivModMask">262144</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="625762401"/>
+ <reference key="NSMixedImage" ref="315854375"/>
+ </object>
<object class="NSMenuItem" id="16954220">
<reference key="NSMenu" ref="71086556"/>
<bool key="NSIsDisabled">YES</bool>
@@ -2457,6 +2476,14 @@
</object>
<int key="connectionID">939</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">insertNULLvalue:</string>
+ <reference key="source" ref="63651044"/>
+ <reference key="destination" ref="784426029"/>
+ </object>
+ <int key="connectionID">942</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -3270,6 +3297,8 @@
<reference ref="1946"/>
<reference ref="609933882"/>
<reference ref="121139500"/>
+ <reference ref="765987997"/>
+ <reference ref="784426029"/>
</object>
<reference key="parent" ref="119995921"/>
</object>
@@ -3656,6 +3685,16 @@
<reference key="object" ref="860424953"/>
<reference key="parent" ref="1021151289"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">940</int>
+ <reference key="object" ref="765987997"/>
+ <reference key="parent" ref="71086556"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">941</int>
+ <reference key="object" ref="784426029"/>
+ <reference key="parent" ref="71086556"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -3994,6 +4033,8 @@
<string>932.IBPluginDependency</string>
<string>935.IBPluginDependency</string>
<string>938.IBPluginDependency</string>
+ <string>940.IBPluginDependency</string>
+ <string>941.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -4054,7 +4095,7 @@
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
- <string>{{312, 466}, {282, 253}}</string>
+ <string>{{312, 436}, {283, 283}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{654, 613}, {157, 223}}</string>
@@ -4264,7 +4305,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{181, 543}, {209, 193}}</string>
+ <string>{{270, 526}, {209, 193}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{180, 535}, {182, 253}}</string>
@@ -4286,7 +4327,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{408, 447}, {213, 143}}</string>
+ <string>{{594, 366}, {213, 143}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSMutableDictionary">
<string key="NS.key.0">ToolTip</string>
@@ -4372,6 +4413,8 @@ w6gg4oaSIGZhY2FkZV0</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>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
@@ -4394,7 +4437,7 @@ w6gg4oaSIGZhY2FkZV0</string>
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">939</int>
+ <int key="maxID">942</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -4909,6 +4952,172 @@ w6gg4oaSIGZhY2FkZV0</string>
</object>
<reference key="sourceIdentifier" ref="939419192"/>
</object>
+ <object class="IBPartialClassDescription">
+ <string key="className">TableDocument</string>
+ <string key="superclassName">NSDocument</string>
+ <object class="NSMutableDictionary" key="actions">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSMutableArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>addConnectionToFavorites:</string>
+ <string>addDatabase:</string>
+ <string>analyzeTable:</string>
+ <string>checkTable:</string>
+ <string>checksumTable:</string>
+ <string>chooseDatabase:</string>
+ <string>chooseEncoding:</string>
+ <string>closeDatabaseSheet:</string>
+ <string>closeErrorConnectionSheet:</string>
+ <string>closeSheet:</string>
+ <string>copyCreateTableSyntax:</string>
+ <string>export:</string>
+ <string>exportMultipleTables:</string>
+ <string>exportTable:</string>
+ <string>flushPrivileges:</string>
+ <string>flushTable:</string>
+ <string>import:</string>
+ <string>insertNULLvalue:</string>
+ <string>optimizeTable:</string>
+ <string>removeDatabase:</string>
+ <string>repairTable:</string>
+ <string>saveServerVariables:</string>
+ <string>setDatabases:</string>
+ <string>showCreateTableSyntax:</string>
+ <string>showMySQLHelp:</string>
+ <string>showVariables:</string>
+ <string>viewContent:</string>
+ <string>viewQuery:</string>
+ <string>viewRelations:</string>
+ <string>viewStatus:</string>
+ <string>viewStructure:</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="outlets">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSMutableArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>addDatabaseButton</string>
+ <string>chooseDatabaseButton</string>
+ <string>connectionErrorDialog</string>
+ <string>contentViewSplitter</string>
+ <string>createTableSyntaxWindow</string>
+ <string>customQueryInstance</string>
+ <string>customQueryTextView</string>
+ <string>databaseDataInstance</string>
+ <string>databaseEncodingButton</string>
+ <string>databaseNameField</string>
+ <string>databaseSheet</string>
+ <string>dbTablesTableView</string>
+ <string>extendedTableInfoInstance</string>
+ <string>favoritesButton</string>
+ <string>historyControl</string>
+ <string>queryProgressBar</string>
+ <string>saveVariablesButton</string>
+ <string>sidebarGrabber</string>
+ <string>spExportControllerInstance</string>
+ <string>spHistoryControllerInstance</string>
+ <string>syntaxView</string>
+ <string>syntaxViewContent</string>
+ <string>tableContentInstance</string>
+ <string>tableDataInstance</string>
+ <string>tableDumpInstance</string>
+ <string>tableInfoCollapseButton</string>
+ <string>tableInfoTable</string>
+ <string>tableListSplitter</string>
+ <string>tableRelationsInstance</string>
+ <string>tableSourceInstance</string>
+ <string>tableTabView</string>
+ <string>tableWindow</string>
+ <string>tablesListInstance</string>
+ <string>titleAccessoryView</string>
+ <string>titleImageView</string>
+ <string>titleStringView</string>
+ <string>variablesSearchField</string>
+ <string>variablesSheet</string>
+ <string>variablesTableView</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>id</string>
+ <string>id</string>
+ <string>NSWindow</string>
+ <string>NSSplitView</string>
+ <string>NSWindow</string>
+ <string>id</string>
+ <string>NSTextView</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>NSTableView</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>NSButton</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>NSButton</string>
+ <string>NSTableView</string>
+ <string>NSSplitView</string>
+ <string>id</string>
+ <string>id</string>
+ <string>NSTabView</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>NSSearchField</string>
+ <string>id</string>
+ <string>id</string>
+ </object>
+ </object>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBDocumentRelativeSource</string>
+ <string key="minorKey">../../Source/TableDocument.h</string>
+ </object>
+ </object>
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
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