From 4d4db598830ce633c32577ff98c65963aa4c7aa4 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Thu, 23 Apr 2009 07:10:57 +0000 Subject: =?UTF-8?q?=E2=80=A2=20synchronized=20gear=20menu=20titles=20for?= =?UTF-8?q?=20"Remove=20table/view"=20according=20to=20selected=20table/vi?= =?UTF-8?q?ew=20types=20=E2=80=A2=20disable/enable=20gear=20menu=20item=20?= =?UTF-8?q?"Duplicate=20table/view"=20according=20to=20the=20number=20of?= =?UTF-8?q?=20selected=20tables/views=20=3D>=20for=20>=201=20selected=20it?= =?UTF-8?q?ems=20disable=20the=20menu=20item?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/TablesList.m | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'Source/TablesList.m') 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]]]; -- cgit v1.2.3