aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Interfaces/English.lproj/FieldEditorSheet.xib107
-rw-r--r--Source/SPCustomQuery.m5
-rw-r--r--Source/SPFieldEditorController.h4
-rw-r--r--Source/SPFieldEditorController.m65
-rw-r--r--Source/SPTableContent.m5
5 files changed, 172 insertions, 14 deletions
diff --git a/Interfaces/English.lproj/FieldEditorSheet.xib b/Interfaces/English.lproj/FieldEditorSheet.xib
index 8e440290..cb389882 100644
--- a/Interfaces/English.lproj/FieldEditorSheet.xib
+++ b/Interfaces/English.lproj/FieldEditorSheet.xib
@@ -12,8 +12,8 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="2"/>
<integer value="81"/>
+ <integer value="2"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -2719,6 +2719,27 @@
<int key="NSPeriodicInterval">75</int>
</object>
</object>
+ <object class="NSButton" id="173283216">
+ <reference key="NSNextResponder" ref="539487490"/>
+ <int key="NSvFlags">268</int>
+ <string key="NSFrame">{{337, 66}, {39, 15}}</string>
+ <reference key="NSSuperview" ref="539487490"/>
+ <int key="NSTag">7</int>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="566456802">
+ <int key="NSCellFlags">-2080244224</int>
+ <int key="NSCellFlags2">134479872</int>
+ <string key="NSContents">NULL</string>
+ <reference key="NSSupport" ref="22"/>
+ <reference key="NSControlView" ref="173283216"/>
+ <int key="NSButtonFlags">-1232846593</int>
+ <int key="NSButtonFlags2">268435619</int>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent">N</string>
+ <int key="NSPeriodicDelay">400</int>
+ <int key="NSPeriodicInterval">75</int>
+ </object>
+ </object>
<object class="NSButton" id="557422946">
<reference key="NSNextResponder" ref="539487490"/>
<int key="NSvFlags">268</int>
@@ -3875,14 +3896,6 @@
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">nextKeyView</string>
- <reference key="source" ref="817754450"/>
- <reference key="destination" ref="824786228"/>
- </object>
- <int key="connectionID">396</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">nextKeyView</string>
<reference key="source" ref="818873877"/>
<reference key="destination" ref="912777084"/>
</object>
@@ -4848,6 +4861,38 @@
</object>
<int key="connectionID">519</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">bitSheetNULLButton</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="173283216"/>
+ </object>
+ <int key="connectionID">524</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">nextKeyView</string>
+ <reference key="source" ref="817754450"/>
+ <reference key="destination" ref="173283216"/>
+ </object>
+ <int key="connectionID">525</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">nextKeyView</string>
+ <reference key="source" ref="173283216"/>
+ <reference key="destination" ref="824786228"/>
+ </object>
+ <int key="connectionID">526</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">setToNull:</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="173283216"/>
+ </object>
+ <int key="connectionID">528</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -5228,6 +5273,7 @@
<reference ref="317620485"/>
<reference ref="817754450"/>
<reference ref="557422946"/>
+ <reference ref="173283216"/>
</object>
<reference key="parent" ref="620871617"/>
</object>
@@ -6529,6 +6575,20 @@
<reference key="object" ref="910142244"/>
<reference key="parent" ref="557422946"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">520</int>
+ <reference key="object" ref="173283216"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="566456802"/>
+ </object>
+ <reference key="parent" ref="539487490"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">521</int>
+ <reference key="object" ref="566456802"/>
+ <reference key="parent" ref="173283216"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -6757,6 +6817,9 @@
<string>4.IBPluginDependency</string>
<string>5.IBPluginDependency</string>
<string>5.ImportedFromIB2</string>
+ <string>520.IBAttributePlaceholdersKey</string>
+ <string>520.IBPluginDependency</string>
+ <string>521.IBPluginDependency</string>
<string>6.IBPluginDependency</string>
<string>6.ImportedFromIB2</string>
<string>7.CustomClassName</string>
@@ -7080,6 +7143,16 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
+ <object class="NSMutableDictionary">
+ <string key="NS.key.0">ToolTip</string>
+ <object class="IBToolTipAttribute" key="NS.object.0">
+ <string key="name">ToolTip</string>
+ <reference key="object" ref="173283216"/>
+ <string key="toolTip">Set to NULL (⇧⌘N)</string>
+ </object>
+ </object>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>SPImageView</string>
@@ -7175,7 +7248,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">519</int>
+ <int key="maxID">528</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -7588,6 +7661,7 @@
<string>quickLookFormatButton:</string>
<string>saveEditSheet:</string>
<string>segmentControllerChanged:</string>
+ <string>setToNull:</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -7601,6 +7675,7 @@
<string>id</string>
<string>id</string>
<string>id</string>
+ <string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
@@ -7617,6 +7692,7 @@
<string>quickLookFormatButton:</string>
<string>saveEditSheet:</string>
<string>segmentControllerChanged:</string>
+ <string>setToNull:</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -7660,6 +7736,10 @@
<string key="name">segmentControllerChanged:</string>
<string key="candidateClassName">id</string>
</object>
+ <object class="IBActionInfo">
+ <string key="name">setToNull:</string>
+ <string key="candidateClassName">id</string>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
@@ -7743,6 +7823,7 @@
<string>bitSheetFieldName</string>
<string>bitSheetHexTextField</string>
<string>bitSheetIntegerTextField</string>
+ <string>bitSheetNULLButton</string>
<string>bitSheetOctalTextField</string>
<string>bitSheetOkButton</string>
<string>editImage</string>
@@ -7840,6 +7921,7 @@
<string>NSTextField</string>
<string>NSTextField</string>
<string>NSTextField</string>
+ <string>NSButton</string>
<string>NSTextField</string>
<string>NSButton</string>
<string>id</string>
@@ -7940,6 +8022,7 @@
<string>bitSheetFieldName</string>
<string>bitSheetHexTextField</string>
<string>bitSheetIntegerTextField</string>
+ <string>bitSheetNULLButton</string>
<string>bitSheetOctalTextField</string>
<string>bitSheetOkButton</string>
<string>editImage</string>
@@ -8269,6 +8352,10 @@
<string key="candidateClassName">NSTextField</string>
</object>
<object class="IBToOneOutletInfo">
+ <string key="name">bitSheetNULLButton</string>
+ <string key="candidateClassName">NSButton</string>
+ </object>
+ <object class="IBToOneOutletInfo">
<string key="name">bitSheetOctalTextField</string>
<string key="candidateClassName">NSTextField</string>
</object>
diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m
index 2a805da2..ae1b01c0 100644
--- a/Source/SPCustomQuery.m
+++ b/Source/SPCustomQuery.m
@@ -2262,16 +2262,21 @@
NSString *fieldType = nil;
NSUInteger *fieldLength = 0;
NSString *fieldEncoding = nil;
+ BOOL allowNULL = YES;
+
// Retrieve the column defintion
fieldType = [columnDefinition objectForKey:@"type"];
if([columnDefinition objectForKey:@"char_length"])
fieldLength = [[columnDefinition objectForKey:@"char_length"] integerValue];
if([columnDefinition objectForKey:@"charset_name"] && ![[columnDefinition objectForKey:@"charset_name"] isEqualToString:@"binary"])
fieldEncoding = [columnDefinition objectForKey:@"charset_name"];
+ if([columnDefinition objectForKey:@"null"])
+ allowNULL = (![[columnDefinition objectForKey:@"null"] integerValue]);
[fieldEditor setTextMaxLength:fieldLength];
[fieldEditor setFieldType:(fieldType==nil) ? @"" : fieldType];
[fieldEditor setFieldEncoding:(fieldEncoding==nil) ? @"" : fieldEncoding];
+ [fieldEditor setAllowNULL:allowNULL];
id originalData = [resultData cellDataAtRow:rowIndex column:[[aTableColumn identifier] integerValue]];
if ([originalData isNSNull]) originalData = [prefs objectForKey:SPNullValue];
diff --git a/Source/SPFieldEditorController.h b/Source/SPFieldEditorController.h
index ba44469e..7c5c6c9a 100644
--- a/Source/SPFieldEditorController.h
+++ b/Source/SPFieldEditorController.h
@@ -48,6 +48,7 @@
IBOutlet NSTextField *bitSheetOctalTextField;
IBOutlet NSButton *bitSheetOkButton;
IBOutlet NSButton *bitSheetCloseButton;
+ IBOutlet NSButton *bitSheetNULLButton;
IBOutlet NSButton *bitSheetBitButton0;
IBOutlet NSButton *bitSheetBitButton1;
IBOutlet NSButton *bitSheetBitButton2;
@@ -125,6 +126,7 @@
BOOL editSheetWillBeInitialized;
BOOL _isBlob;
BOOL _isEditable;
+ BOOL _allowNULL;
NSInteger quickLookCloseMarker;
NSStringEncoding encoding;
NSString *fieldType;
@@ -161,6 +163,7 @@
- (IBAction)bitSheetSelectBit0:(id)sender;
- (IBAction)bitSheetBitButtonWasClicked:(id)sender;
- (IBAction)bitSheetOperatorButtonWasClicked:(id)sender;
+- (IBAction)setToNull:(id)sender;
- (void)updateBitSheet;
- (id)editWithObject:(id)data fieldName:(NSString*)fieldName usingEncoding:(NSStringEncoding)anEncoding
@@ -169,6 +172,7 @@
- (void)setTextMaxLength:(unsigned long long)length;
- (void)setFieldType:(NSString*)aType;
- (void)setFieldEncoding:(NSString*)aEncoding;
+- (void)setAllowNULL:(BOOL)allowNULL;
- (void)processPasteImageData;
- (void)processUpdatedImageData:(NSData *)data;
diff --git a/Source/SPFieldEditorController.m b/Source/SPFieldEditorController.m
index fc3f6eec..b8959ec8 100644
--- a/Source/SPFieldEditorController.m
+++ b/Source/SPFieldEditorController.m
@@ -46,6 +46,7 @@
stringValue = nil;
_isEditable = NO;
_isBlob = NO;
+ _allowNULL = YES;
prefs = [NSUserDefaults standardUserDefaults];
@@ -146,6 +147,11 @@
fieldEncoding = aEncoding;
}
+- (void)setAllowNULL:(BOOL)allowNULL
+{
+ _allowNULL = allowNULL;
+}
+
- (id)editWithObject:(id)data fieldName:(NSString*)fieldName usingEncoding:(NSStringEncoding)anEncoding
isObjectBlob:(BOOL)isFieldBlob isEditable:(BOOL)isEditable withWindow:(NSWindow *)theWindow
{
@@ -157,12 +163,14 @@
// Set field label
NSMutableString *label = [NSMutableString string];
[label appendFormat:@"“%@”", fieldName];
- if([fieldType length] || maxTextLength > 0 || [fieldEncoding length])
+ if([fieldType length] || maxTextLength > 0 || [fieldEncoding length] || !_allowNULL)
[label appendString:@" – "];
if([fieldType length])
[label appendString:fieldType];
if(maxTextLength > 0)
[label appendFormat:@"(%ld) ", maxTextLength];
+ if(!_allowNULL)
+ [label appendString:@"NOT NULL "];
if([fieldEncoding length])
[label appendString:fieldEncoding];
@@ -170,14 +178,25 @@
sheetEditData = [(NSString*)data retain];
+ [bitSheetNULLButton setEnabled:_allowNULL];
+
+ // Check for NULL
+ if([sheetEditData isEqualToString:[prefs objectForKey:SPNullValue]]) {
+ [bitSheetNULLButton setState:NSOnState];
+ [self setToNull:bitSheetNULLButton];
+ } else {
+ [bitSheetNULLButton setState:NSOffState];
+ }
+
[bitSheetFieldName setStringValue:label];
// Init according bit check boxes
NSInteger i = 0;
NSInteger maxBit = (maxTextLength > 64) ? 64 : maxTextLength;
- for(i=0; i<maxBit; i++)
- [[self valueForKeyPath:[NSString stringWithFormat:@"bitSheetBitButton%ld", i]]
- setState:([sheetEditData characterAtIndex:(maxBit-i-1)] == '1') ? NSOnState : NSOffState];
+ if([bitSheetNULLButton state] == NSOffState)
+ for(i=0; i<maxBit; i++)
+ [[self valueForKeyPath:[NSString stringWithFormat:@"bitSheetBitButton%ld", i]]
+ setState:([sheetEditData characterAtIndex:(maxBit-i-1)] == '1') ? NSOnState : NSOffState];
for(i=maxBit; i<64; i++)
[[self valueForKeyPath:[NSString stringWithFormat:@"bitSheetBitButton%ld", i]] setEnabled:NO];
@@ -909,6 +928,20 @@
NSInteger i = 0;
NSInteger maxBit = (maxTextLength > 64) ? 64 : maxTextLength;
+
+ if([bitSheetNULLButton state] == NSOnState) {
+ if ( sheetEditData != nil ) {
+ [sheetEditData release];
+ }
+
+ NSString *nullString = [prefs objectForKey:SPNullValue];
+ sheetEditData = [[NSString stringWithString:nullString] retain];
+ [bitSheetIntegerTextField setStringValue:nullString];
+ [bitSheetHexTextField setStringValue:nullString];
+ [bitSheetOctalTextField setStringValue:nullString];
+ return;
+ }
+
NSMutableString *bitString = [NSMutableString string];
[bitString setString:@""];
for(i=0; i<maxBit; i++) [bitString appendString:@"0"];
@@ -1005,6 +1038,30 @@
[[self window] makeFirstResponder:[self valueForKeyPath:@"bitSheetBitButton0"]];
}
+- (IBAction)setToNull:(id)sender
+{
+
+ NSInteger i;
+ NSInteger maxBit = (maxTextLength > 64) ? 64 : maxTextLength;
+
+ if([sender state] == NSOnState) {
+ for(i=0; i<maxBit; i++)
+ [[self valueForKeyPath:[NSString stringWithFormat:@"bitSheetBitButton%ld", i]] setEnabled:NO];
+ [bitSheetHexTextField setEnabled:NO];
+ [bitSheetIntegerTextField setEnabled:NO];
+ [bitSheetOctalTextField setEnabled:NO];
+ } else {
+ for(i=0; i<maxBit; i++)
+ [[self valueForKeyPath:[NSString stringWithFormat:@"bitSheetBitButton%ld", i]] setEnabled:YES];
+ [bitSheetHexTextField setEnabled:YES];
+ [bitSheetIntegerTextField setEnabled:YES];
+ [bitSheetOctalTextField setEnabled:YES];
+ }
+
+ [self updateBitSheet];
+
+}
+
- (IBAction)bitSheetBitButtonWasClicked:(id)sender
{
diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m
index 99e34af1..cff8a675 100644
--- a/Source/SPTableContent.m
+++ b/Source/SPTableContent.m
@@ -3522,12 +3522,16 @@
NSString *fieldType = nil;
NSUInteger *fieldLength = 0;
NSString *fieldEncoding = nil;
+ BOOL allowNULL = YES;
+
// Retrieve the column defintion
for(id c in cqColumnDefinition) {
if([[c objectForKey:@"datacolumnindex"] isEqualToNumber:[aTableColumn identifier]]) {
fieldType = [c objectForKey:@"type"];
if([c objectForKey:@"char_length"])
fieldLength = [[c objectForKey:@"char_length"] integerValue];
+ if([c objectForKey:@"null"])
+ allowNULL = (![[c objectForKey:@"null"] integerValue]);
if([c objectForKey:@"charset_name"] && ![[c objectForKey:@"charset_name"] isEqualToString:@"binary"])
fieldEncoding = [c objectForKey:@"charset_name"];
break;
@@ -3539,6 +3543,7 @@
[fieldEditor setTextMaxLength:fieldLength];
[fieldEditor setFieldType:(fieldType==nil) ? @"" : fieldType];
[fieldEditor setFieldEncoding:(fieldEncoding==nil) ? @"" : fieldEncoding];
+ [fieldEditor setAllowNULL:allowNULL];
id cellValue = [tableValues cellDataAtRow:rowIndex column:[[aTableColumn identifier] integerValue]];
if ([cellValue isNSNull]) cellValue = [NSString stringWithString:[prefs objectForKey:SPNullValue]];