aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTableStructureDelegate.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2012-08-05 13:21:44 +0000
committerrowanbeentje <rowan@beent.je>2012-08-05 13:21:44 +0000
commit784641222e5d9ee521a5846682f9ec2cc4cf6a3f (patch)
tree788473085483ff733c9b8942803268c88b89391a /Source/SPTableStructureDelegate.m
parent55d98a1ec966116a6cd821c7e90bd658ca3c5530 (diff)
downloadsequelpro-784641222e5d9ee521a5846682f9ec2cc4cf6a3f.tar.gz
sequelpro-784641222e5d9ee521a5846682f9ec2cc4cf6a3f.tar.bz2
sequelpro-784641222e5d9ee521a5846682f9ec2cc4cf6a3f.zip
- Fix table structure issues with default collations on non-default encodings, fixing a number of exceptions with various actions (Issue #1416)
- Fix which item is selected after reordering columns in the structure view - Display enodings and collations which match the table settings in gray
Diffstat (limited to 'Source/SPTableStructureDelegate.m')
-rw-r--r--Source/SPTableStructureDelegate.m17
1 files changed, 15 insertions, 2 deletions
diff --git a/Source/SPTableStructureDelegate.m b/Source/SPTableStructureDelegate.m
index 582f961f..a220b85e 100644
--- a/Source/SPTableStructureDelegate.m
+++ b/Source/SPTableStructureDelegate.m
@@ -75,12 +75,25 @@
[[tableColumn dataCell] removeAllItems];
if ([collations count] > 0) {
+ NSString *defaultCollation = [[tableDataInstance statusValues] objectForKey:@"collation"];
+ if (!defaultCollation) {
+ defaultCollation = [databaseDataInstance getDatabaseDefaultCollation];
+ }
[[tableColumn dataCell] addItemWithTitle:@""];
// Populate collation popup button
for (NSDictionary *collation in collations)
{
- [[tableColumn dataCell] addItemWithTitle:[collation objectForKey:@"COLLATION_NAME"]];
+ NSString *collationName = [collation objectForKey:@"COLLATION_NAME"];
+ [[tableColumn dataCell] addItemWithTitle:collationName];
+
+ // If this matches the table's collation, draw in gray
+ if ([collationName length] && [collationName isEqualToString:defaultCollation]) {
+ NSMenuItem *collationMenuItem = [(NSPopUpButtonCell *)[tableColumn dataCell] itemAtIndex:([[tableColumn dataCell] numberOfItems] - 1)];
+ NSDictionary *menuAttributes = [NSDictionary dictionaryWithObjectsAndKeys:[NSColor lightGrayColor], NSForegroundColorAttributeName, [NSFont systemFontOfSize: [NSFont smallSystemFontSize]], NSFontAttributeName, nil];
+ NSAttributedString *itemString = [[[NSAttributedString alloc] initWithString:collationName attributes:menuAttributes] autorelease];
+ [collationMenuItem setAttributedTitle:itemString];
+ }
}
}
}
@@ -380,7 +393,7 @@
// Mark the content table cache for refresh
[tableDocumentInstance setContentRequiresReload:YES];
- [tableSourceView selectRowIndexes:[NSIndexSet indexSetWithIndex:destinationRowIndex - (originalRowIndex < destinationRowIndex) ? 1 : 0] byExtendingSelection:NO];
+ [tableSourceView selectRowIndexes:[NSIndexSet indexSetWithIndex:destinationRowIndex - ((originalRowIndex < destinationRowIndex) ? 1 : 0)] byExtendingSelection:NO];
}
[[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance];