diff options
author | Bibiko <bibiko@eva.mpg.de> | 2009-04-23 07:10:57 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2009-04-23 07:10:57 +0000 |
commit | 4d4db598830ce633c32577ff98c65963aa4c7aa4 (patch) | |
tree | 52a0378ab3580ad68be8dfec5051be02f08e2130 /Source | |
parent | 60d4410b32e957df668713fb53c8f041d1325fdb (diff) | |
download | sequelpro-4d4db598830ce633c32577ff98c65963aa4c7aa4.tar.gz sequelpro-4d4db598830ce633c32577ff98c65963aa4c7aa4.tar.bz2 sequelpro-4d4db598830ce633c32577ff98c65963aa4c7aa4.zip |
• synchronized gear menu titles for "Remove table/view" according to selected table/view types
• disable/enable gear menu item "Duplicate table/view" according to the number of selected tables/views => for > 1 selected items disable the menu item
Diffstat (limited to 'Source')
-rw-r--r-- | Source/TablesList.h | 3 | ||||
-rw-r--r-- | Source/TablesList.m | 38 |
2 files changed, 39 insertions, 2 deletions
diff --git a/Source/TablesList.h b/Source/TablesList.h index 76b49609..f3abca1b 100644 --- a/Source/TablesList.h +++ b/Source/TablesList.h @@ -53,6 +53,9 @@ enum sp_table_types IBOutlet id tableNameField; IBOutlet id tableEncodingButton; IBOutlet id addTableButton; + + IBOutlet NSMenuItem *removeTableMenuItem; + IBOutlet NSMenuItem *duplicateTableMenuItem; CMMCPConnection *mySQLConnection; diff --git a/Source/TablesList.m b/Source/TablesList.m index 0d3aa48e..c78ca385 100644 --- a/Source/TablesList.m +++ b/Source/TablesList.m @@ -715,7 +715,21 @@ contentLoaded = NO; statusLoaded = NO; } - + + // To be able to disable duplicateTableMenuItem + [[duplicateTableMenuItem menu] setAutoenablesItems:NO]; + + // Set gear menu items Remove/Duplicate table/view according to the table types + [duplicateTableMenuItem setEnabled:YES]; + if([[tableTypes objectAtIndex:[tablesListView selectedRow]] intValue] == SP_TABLETYPE_VIEW) + { + [removeTableMenuItem setTitle:NSLocalizedString(@"Remove view", @"remove view menu title")]; + [duplicateTableMenuItem setTitle:NSLocalizedString(@"Duplicate view", @"duplicate view menu title")]; + } else { + [removeTableMenuItem setTitle:NSLocalizedString(@"Remove table", @"remove table menu title")]; + [duplicateTableMenuItem setTitle:NSLocalizedString(@"Duplicate table", @"duplicate table menu title")]; + } + // set window title [tableWindow setTitle:[NSString stringWithFormat:@"(MySQL %@) %@/%@/%@", [tableDocumentInstance mySQLVersion], [tableDocumentInstance name], [tableDocumentInstance database], [tables objectAtIndex:[tablesListView selectedRow]]]]; @@ -726,7 +740,27 @@ structureLoaded = NO; contentLoaded = NO; statusLoaded = NO; - + + // To be able to disable duplicateTableMenuItem + [[duplicateTableMenuItem menu] setAutoenablesItems:NO]; + + // Set gear menu items Remove/Duplicate table/view according to the table types + NSIndexSet *indexes = [tablesListView selectedRowIndexes]; + unsigned currentIndex = [indexes lastIndex]; + [duplicateTableMenuItem setEnabled:NO]; + int tblTypesChecksum = 0; + while (currentIndex != NSNotFound) + { + tblTypesChecksum += [[tableTypes objectAtIndex:currentIndex] intValue]; + currentIndex = [indexes indexLessThanIndex:currentIndex]; + } + if(tblTypesChecksum == 0) + [removeTableMenuItem setTitle:NSLocalizedString(@"Remove tables", @"remove tables menu title")]; + else if(tblTypesChecksum == [indexes count]) + [removeTableMenuItem setTitle:NSLocalizedString(@"Remove views", @"remove views menu title")]; + else + [removeTableMenuItem setTitle:NSLocalizedString(@"Remove tables/views", @"remove tables/views menu title")]; + // set window title [tableWindow setTitle:[NSString stringWithFormat:@"(MySQL %@) %@/%@", [tableDocumentInstance mySQLVersion], [tableDocumentInstance name], [tableDocumentInstance database]]]; |