From 224719bd0ed05f6ce757c08c3602808929f621cf Mon Sep 17 00:00:00 2001 From: Bibiko Date: Fri, 11 Feb 2011 10:45:58 +0000 Subject: =?UTF-8?q?=E2=80=A2=20show=20in=20Content=20tables'=20header=20co?= =?UTF-8?q?mments=20and=20ENUM/SET=20values=20-=20addresses=20i977=20?= =?UTF-8?q?=E2=80=A2=20suppress=20editing=20of=20ENUM/SET=20fields=20in=20?= =?UTF-8?q?Field=20Editor=20sheet=20since=20it=20doesn't=20make=20sense=20?= =?UTF-8?q?yet=20=E2=80=A2=20corrected=20method=20tableView:toolTipForCell?= =?UTF-8?q?:=20since=20aCell=20can=20be=20a=20NSComboCell?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPTableContent.m | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) (limited to 'Source') diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index 7acc0187..7d64ed4b 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -445,7 +445,13 @@ // Set up the column theCol = [[NSTableColumn alloc] initWithIdentifier:[columnDefinition objectForKey:@"datacolumnindex"]]; [[theCol headerCell] setStringValue:[columnDefinition objectForKey:@"name"]]; - [theCol setHeaderToolTip:[NSString stringWithFormat:@"%@ – %@%@", [columnDefinition objectForKey:@"name"], [columnDefinition objectForKey:@"type"], ([columnDefinition objectForKey:@"length"]) ? [NSString stringWithFormat:@"(%@)", [columnDefinition objectForKey:@"length"]] : @""]]; + [theCol setHeaderToolTip:[NSString stringWithFormat:@"%@ – %@%@%@%@", + [columnDefinition objectForKey:@"name"], + [columnDefinition objectForKey:@"type"], + ([columnDefinition objectForKey:@"length"]) ? [NSString stringWithFormat:@"(%@)", [columnDefinition objectForKey:@"length"]] : @"", + ([columnDefinition objectForKey:@"values"]) ? [NSString stringWithFormat:@"(\n- %@\n)", [[columnDefinition objectForKey:@"values"] componentsJoinedByString:@"\n- "]] : @"", + ([columnDefinition objectForKey:@"comment"] && [[columnDefinition objectForKey:@"comment"] length]) ? [NSString stringWithFormat:@"\n%@", [[columnDefinition objectForKey:@"comment"] stringByReplacingOccurrencesOfString:@"\\n" withString:@"\n"]] : @"" + ]]; [theCol setEditable:YES]; // Set up column for filterTable @@ -3455,7 +3461,7 @@ * - if blob data can be interpret as image data display the image as transparent thumbnail * (up to now using base64 encoded HTML data) */ -- (NSString *)tableView:(NSTableView *)aTableView toolTipForCell:(SPTextAndLinkCell *)aCell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)row mouseLocation:(NSPoint)mouseLocation +- (NSString *)tableView:(NSTableView *)aTableView toolTipForCell:(id)aCell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)row mouseLocation:(NSPoint)mouseLocation { if(aTableView == filterTableView) { @@ -4063,9 +4069,17 @@ BOOL isBlob = [tableDataInstance columnIsBlobOrText:[[aTableColumn headerCell] stringValue]]; BOOL isFieldEditable = YES; + // Retrieve the column defintion + NSDictionary *columnDefinition = nil; + for(id c in cqColumnDefinition) { + if([[c objectForKey:@"datacolumnindex"] isEqualToNumber:[aTableColumn identifier]]) { + columnDefinition = [NSDictionary dictionaryWithDictionary:c]; + break; + } + } // Open the sheet if the multipleLineEditingButton is enabled or the column was a blob or a text. - if ([multipleLineEditingButton state] == NSOnState || isBlob) { + if (([multipleLineEditingButton state] == NSOnState || isBlob) && ![[columnDefinition objectForKey:@"typegrouping"] isEqualToString:@"enum"]) { // A table is per definitionem editable isFieldEditable = YES; @@ -4081,19 +4095,13 @@ 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; - } - } + fieldType = [columnDefinition objectForKey:@"type"]; + if([columnDefinition objectForKey:@"char_length"]) + fieldLength = [[columnDefinition objectForKey:@"char_length"] integerValue]; + if([columnDefinition objectForKey:@"null"]) + allowNULL = (![[columnDefinition objectForKey:@"null"] integerValue]); + if([columnDefinition objectForKey:@"charset_name"] && ![[columnDefinition objectForKey:@"charset_name"] isEqualToString:@"binary"]) + fieldEncoding = [columnDefinition objectForKey:@"charset_name"]; if(fieldEditor) [fieldEditor release], fieldEditor = nil; fieldEditor = [[SPFieldEditorController alloc] init]; @@ -4393,7 +4401,7 @@ // Check if current edited field is a blob if ((fieldType = [[tableDataInstance columnWithName:[[NSArrayObjectAtIndex([tableContentView tableColumns], column) headerCell] stringValue]] objectForKey:@"typegrouping"]) - && ([fieldType isEqualToString:@"textdata"] || [fieldType isEqualToString:@"blobdata"] || [multipleLineEditingButton state] == NSOnState)) + && ![fieldType isEqualToString:@"enum"] && ([fieldType isEqualToString:@"textdata"] || [fieldType isEqualToString:@"blobdata"] || [multipleLineEditingButton state] == NSOnState)) { [tableContentView setFieldEditorSelectedRange:[fieldEditor selectedRange]]; -- cgit v1.2.3