diff options
author | rowanbeentje <rowan@beent.je> | 2010-04-24 01:36:34 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2010-04-24 01:36:34 +0000 |
commit | a329d031aac349c0ad2b0768cc24ce69dc09a577 (patch) | |
tree | 12a58d877c97b742ecb9b00c8b707f9128543c42 /Source/TablesList.m | |
parent | b7d6974ed6993727bd5bd39ec905c69eecb709b8 (diff) | |
download | sequelpro-a329d031aac349c0ad2b0768cc24ce69dc09a577.tar.gz sequelpro-a329d031aac349c0ad2b0768cc24ce69dc09a577.tar.bz2 sequelpro-a329d031aac349c0ad2b0768cc24ce69dc09a577.zip |
Merge in a number of fixes from trunk (r2065, r2066, r2067, r2068, r2069, r2074, r2075, r2076, r2078, r2079, r2081, r2083, r2084, r2085, r2089, r2090, r2100, r2110, r2117, r2118, r2119, r2120, r2128, r2132, r2133, r2134, r2137, r2138, r2139, r2140, r2142, r2150, r2152, r2153, r2154, r2155, r2158, and r2160)
Diffstat (limited to 'Source/TablesList.m')
-rw-r--r-- | Source/TablesList.m | 81 |
1 files changed, 55 insertions, 26 deletions
diff --git a/Source/TablesList.m b/Source/TablesList.m index 1644c13d..b9e8270a 100644 --- a/Source/TablesList.m +++ b/Source/TablesList.m @@ -252,8 +252,12 @@ if (previousSelectedTable) [previousSelectedTable release]; // Query the structure of all databases in the background - [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:mySQLConnection withObject:nil]; - + if(sender == self) + // Invoked by SP + [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:mySQLConnection withObject:nil]; + else + // User press refresh button ergo force update + [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:mySQLConnection withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", [NSNumber numberWithBool:YES], @"cancelQuerying", nil]]; } @@ -634,7 +638,7 @@ [spHistoryControllerInstance updateHistoryEntries]; // Notify listeners of the table change now that the state is fully set up - [[NSNotificationCenter defaultCenter] postNotificationName:SPTableChangedNotification object:tableDocumentInstance]; + [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:SPTableChangedNotification object:tableDocumentInstance]; return; } @@ -751,37 +755,41 @@ // Update the selected table name and type if (selectedTableName) [selectedTableName release]; + if ([indexes count]) { selectedTableName = [[NSString alloc] initWithString:@""]; - } else { + } + else { selectedTableName = nil; } + selectedTableType = SPTableTypeNone; [tableSourceInstance loadTable:nil]; [tableContentInstance loadTable:nil]; [extendedTableInfoInstance loadTable:nil]; + structureLoaded = NO; contentLoaded = NO; statusLoaded = NO; // Set gear menu items Remove/Duplicate table/view according to the table types // if at least one item is selected - if([indexes count]) { + if ([indexes count]) { NSUInteger currentIndex = [indexes lastIndex]; BOOL areTableTypeEqual = YES; NSInteger lastType = [[filteredTableTypes objectAtIndex:currentIndex] integerValue]; + while (currentIndex != NSNotFound) { - if ([[filteredTableTypes objectAtIndex:currentIndex] integerValue] != lastType) - { + if ([[filteredTableTypes objectAtIndex:currentIndex] integerValue] != lastType) { areTableTypeEqual = NO; break; } + currentIndex = [indexes indexLessThanIndex:currentIndex]; } - if (areTableTypeEqual) - { + if (areTableTypeEqual) { switch (lastType) { case SPTableTypeTable: [removeTableMenuItem setTitle:NSLocalizedString(@"Remove Tables", @"remove tables menu title")]; @@ -818,14 +826,20 @@ [truncateTableContextButton setHidden:YES]; } } + + // Context menu [renameTableContextMenuItem setHidden:YES]; [duplicateTableContextMenuItem setHidden:YES]; [separatorTableContextMenuItem setHidden:YES]; + [separatorTableContextMenuItem2 setHidden:YES]; + [showCreateSyntaxContextMenuItem setHidden:YES]; + // 'Gear' menu [renameTableMenuItem setHidden:YES]; [duplicateTableMenuItem setHidden:YES]; [separatorTableMenuItem setHidden:YES]; - [separatorTableContextMenuItem setHidden:YES]; + [separatorTableMenuItem2 setHidden:YES]; + [showCreateSyntaxMenuItem setHidden:YES]; NSMenu *tableSubMenu = [[[NSApp mainMenu] itemWithTitle:@"Table"] submenu]; @@ -875,18 +889,23 @@ // Reset the table information caches [tableDataInstance resetAllData]; + // Show menu separatoes [separatorTableMenuItem setHidden:NO]; [separatorTableContextMenuItem setHidden:NO]; + [separatorTableMenuItem2 setHidden:NO]; + [separatorTableContextMenuItem2 setHidden:NO]; // Set gear menu items Remove/Duplicate table/view and mainMenu > Table items // according to the table types NSMenu *tableSubMenu = [[[NSApp mainMenu] itemWithTitle:@"Table"] submenu]; - if(selectedTableType == SPTableTypeView) + // Enable/disable the various menu items depending on the selected item. Also update their titles. + // Note, that this should ideally be moved to menu item validation as opposed to using fixed item positions. + if (selectedTableType == SPTableTypeView) { // Change mainMenu > Table > ... according to table type [[tableSubMenu itemAtIndex:3] setTitle:NSLocalizedString(@"Copy Create View Syntax", @"copy create view syntax menu item")]; - [[tableSubMenu itemAtIndex:4] setTitle:NSLocalizedString(@"Show Create View Syntax", @"show create view syntax menu item")]; + [[tableSubMenu itemAtIndex:4] setTitle:NSLocalizedString(@"Show Create View Syntax...", @"show create view syntax menu item")]; [[tableSubMenu itemAtIndex:5] setHidden:NO]; // Divider [[tableSubMenu itemAtIndex:6] setHidden:NO]; [[tableSubMenu itemAtIndex:6] setTitle:NSLocalizedString(@"Check View", @"check view menu item")]; @@ -904,6 +923,8 @@ [duplicateTableMenuItem setTitle:NSLocalizedString(@"Duplicate View...", @"duplicate view menu title")]; [truncateTableButton setHidden:YES]; [removeTableMenuItem setTitle:NSLocalizedString(@"Remove View", @"remove view menu title")]; + [showCreateSyntaxMenuItem setHidden:NO]; + [showCreateSyntaxMenuItem setTitle:NSLocalizedString(@"Show Create View Syntax...", @"show create view syntax menu item")]; [renameTableContextMenuItem setHidden:NO]; // we don't have to check the mysql version [renameTableContextMenuItem setTitle:NSLocalizedString(@"Rename View...", @"rename view menu title")]; @@ -911,10 +932,12 @@ [duplicateTableContextMenuItem setTitle:NSLocalizedString(@"Duplicate View...", @"duplicate view menu title")]; [truncateTableContextButton setHidden:YES]; [removeTableContextMenuItem setTitle:NSLocalizedString(@"Remove View", @"remove view menu title")]; + [showCreateSyntaxContextMenuItem setHidden:NO]; + [showCreateSyntaxContextMenuItem setTitle:NSLocalizedString(@"Show Create View Syntax...", @"show create view syntax menu item")]; } - else if(selectedTableType == SPTableTypeTable) { + else if (selectedTableType == SPTableTypeTable) { [[tableSubMenu itemAtIndex:3] setTitle:NSLocalizedString(@"Copy Create Table Syntax", @"copy create table syntax menu item")]; - [[tableSubMenu itemAtIndex:4] setTitle:NSLocalizedString(@"Show Create Table Syntax", @"show create table syntax menu item")]; + [[tableSubMenu itemAtIndex:4] setTitle:NSLocalizedString(@"Show Create Table Syntax...", @"show create table syntax menu item")]; [[tableSubMenu itemAtIndex:5] setHidden:NO]; // divider [[tableSubMenu itemAtIndex:6] setHidden:NO]; [[tableSubMenu itemAtIndex:6] setTitle:NSLocalizedString(@"Check Table", @"check table menu item")]; @@ -937,6 +960,8 @@ [truncateTableButton setHidden:NO]; [truncateTableButton setTitle:NSLocalizedString(@"Truncate Table", @"truncate table menu title")]; [removeTableMenuItem setTitle:NSLocalizedString(@"Remove Table", @"remove table menu title")]; + [showCreateSyntaxMenuItem setHidden:NO]; + [showCreateSyntaxMenuItem setTitle:NSLocalizedString(@"Show Create Table Syntax...", @"show create table syntax menu item")]; [renameTableContextMenuItem setHidden:NO]; [renameTableContextMenuItem setTitle:NSLocalizedString(@"Rename Table...", @"rename table menu title")]; @@ -945,11 +970,12 @@ [truncateTableContextButton setHidden:NO]; [truncateTableContextButton setTitle:NSLocalizedString(@"Truncate Table", @"truncate table menu title")]; [removeTableContextMenuItem setTitle:NSLocalizedString(@"Remove Table", @"remove table menu title")]; - + [showCreateSyntaxContextMenuItem setHidden:NO]; + [showCreateSyntaxContextMenuItem setTitle:NSLocalizedString(@"Show Create Table Syntax...", @"show create table syntax menu item")]; } - else if(selectedTableType == SPTableTypeProc) { + else if (selectedTableType == SPTableTypeProc) { [[tableSubMenu itemAtIndex:3] setTitle:NSLocalizedString(@"Copy Create Procedure Syntax", @"copy create proc syntax menu item")]; - [[tableSubMenu itemAtIndex:4] setTitle:NSLocalizedString(@"Show Create Procedure Syntax", @"show create proc syntax menu item")]; + [[tableSubMenu itemAtIndex:4] setTitle:NSLocalizedString(@"Show Create Procedure Syntax...", @"show create proc syntax menu item")]; [[tableSubMenu itemAtIndex:5] setHidden:YES]; // divider [[tableSubMenu itemAtIndex:6] setHidden:YES]; // copy columns [[tableSubMenu itemAtIndex:7] setHidden:YES]; // divider @@ -965,6 +991,8 @@ [duplicateTableMenuItem setTitle:NSLocalizedString(@"Duplicate Procedure...", @"duplicate proc menu title")]; [truncateTableButton setHidden:YES]; [removeTableMenuItem setTitle:NSLocalizedString(@"Remove Procedure", @"remove proc menu title")]; + [showCreateSyntaxMenuItem setHidden:NO]; + [showCreateSyntaxMenuItem setTitle:NSLocalizedString(@"Show Create Procedure Syntax...", @"show create proc syntax menu item")]; [renameTableContextMenuItem setHidden:NO]; [renameTableContextMenuItem setTitle:NSLocalizedString(@"Rename Procedure...", @"rename proc menu title")]; @@ -972,11 +1000,12 @@ [duplicateTableContextMenuItem setTitle:NSLocalizedString(@"Duplicate Procedure...", @"duplicate proc menu title")]; [truncateTableContextButton setHidden:YES]; [removeTableContextMenuItem setTitle:NSLocalizedString(@"Remove Procedure", @"remove proc menu title")]; - + [showCreateSyntaxContextMenuItem setHidden:NO]; + [showCreateSyntaxContextMenuItem setTitle:NSLocalizedString(@"Show Create Procedure Syntax...", @"show create proc syntax menu item")]; } - else if(selectedTableType == SPTableTypeFunc) { + else if (selectedTableType == SPTableTypeFunc) { [[tableSubMenu itemAtIndex:3] setTitle:NSLocalizedString(@"Copy Create Function Syntax", @"copy create func syntax menu item")]; - [[tableSubMenu itemAtIndex:4] setTitle:NSLocalizedString(@"Show Create Function Syntax", @"show create func syntax menu item")]; + [[tableSubMenu itemAtIndex:4] setTitle:NSLocalizedString(@"Show Create Function Syntax...", @"show create func syntax menu item")]; [[tableSubMenu itemAtIndex:5] setHidden:YES]; // divider [[tableSubMenu itemAtIndex:6] setHidden:YES]; // copy columns [[tableSubMenu itemAtIndex:7] setHidden:YES]; // divider @@ -992,6 +1021,8 @@ [duplicateTableMenuItem setTitle:NSLocalizedString(@"Duplicate Function...", @"duplicate func menu title")]; [truncateTableButton setHidden:YES]; [removeTableMenuItem setTitle:NSLocalizedString(@"Remove Function", @"remove func menu title")]; + [showCreateSyntaxMenuItem setHidden:NO]; + [showCreateSyntaxMenuItem setTitle:NSLocalizedString(@"Show Create Function Syntax...", @"show create func syntax menu item")]; [renameTableContextMenuItem setHidden:NO]; [renameTableContextMenuItem setTitle:NSLocalizedString(@"Rename Function...", @"rename func menu title")]; @@ -999,6 +1030,8 @@ [duplicateTableContextMenuItem setTitle:NSLocalizedString(@"Duplicate Function...", @"duplicate func menu title")]; [truncateTableContextButton setHidden:YES]; [removeTableContextMenuItem setTitle:NSLocalizedString(@"Remove Function", @"remove func menu title")]; + [showCreateSyntaxContextMenuItem setHidden:NO]; + [showCreateSyntaxContextMenuItem setTitle:NSLocalizedString(@"Show Create Function Syntax...", @"show create func syntax menu item")]; } // set window title @@ -1395,12 +1428,8 @@ return NO; } - // We have to be sure that TableSource and TableContent have finished editing - if ( ![tableSourceInstance saveRowOnDeselect] || ![tableContentInstance saveRowOnDeselect] ) { - return NO; - } else { - return YES; - } + // We have to be sure that document views have finished editing + return [tableDocumentInstance couldCommitCurrentViewActions]; } /** |