From 44e7c62bb12fa1d601cfbaf3ddf870a148b4f474 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Fri, 15 May 2009 11:55:52 +0000 Subject: =?UTF-8?q?=E2=80=A2=20corrected=20dynamic=20labeling=20of=20menu?= =?UTF-8?q?=20items/alerts=20for=20removing=20tables/views/procs/funcs=20a?= =?UTF-8?q?ccording=20to=20the=20selected=20table=20items?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/TablesList.m | 71 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 54 insertions(+), 17 deletions(-) diff --git a/Source/TablesList.m b/Source/TablesList.m index d8291598..4da85d7f 100644 --- a/Source/TablesList.m +++ b/Source/TablesList.m @@ -309,6 +309,7 @@ [alert setAlertStyle:NSCriticalAlertStyle]; NSIndexSet *indexes = [tablesListView selectedRowIndexes]; + NSString *tblTypes; unsigned currentIndex = [indexes lastIndex]; @@ -326,19 +327,37 @@ [alert setInformativeText:[NSString stringWithFormat:NSLocalizedString(@"Are you sure you want to delete the %@ '%@'. This operation cannot be undone.", @"delete table/view informative message"), tblTypes, [tables objectAtIndex:[tablesListView selectedRow]]]]; } else { - int tblTypesChecksum = 0; + + BOOL areTableTypeEqual = YES; + int lastType = [[tableTypes objectAtIndex:currentIndex] intValue]; while (currentIndex != NSNotFound) { - tblTypesChecksum += [[tableTypes objectAtIndex:currentIndex] intValue]; + if([[tableTypes objectAtIndex:currentIndex] intValue]!=lastType) + { + areTableTypeEqual = NO; + break; + } currentIndex = [indexes indexLessThanIndex:currentIndex]; } - - if(tblTypesChecksum == 0) - tblTypes = NSLocalizedString(@"tables", @"tables"); - else if(tblTypesChecksum == [indexes count]) - tblTypes = NSLocalizedString(@"views", @"views"); - else - tblTypes = NSLocalizedString(@"tables/views", @"tables/views"); + if(areTableTypeEqual) + { + switch(lastType) { + case SP_TABLETYPE_TABLE: + tblTypes = NSLocalizedString(@"tables", @"tables"); + break; + case SP_TABLETYPE_VIEW: + tblTypes = NSLocalizedString(@"views", @"views"); + break; + case SP_TABLETYPE_PROC: + tblTypes = NSLocalizedString(@"procedures", @"procedures"); + break; + case SP_TABLETYPE_FUNC: + tblTypes = NSLocalizedString(@"functions", @"functions"); + break; + } + + } else + tblTypes = NSLocalizedString(@"items", @"items"); [alert setMessageText:[NSString stringWithFormat:NSLocalizedString(@"Delete selected %@?", @"delete tables/views message"), tblTypes]]; [alert setInformativeText:[NSString stringWithFormat:NSLocalizedString(@"Are you sure you want to delete the selected %@. This operation cannot be undone.", @"delete tables/views informative message"), tblTypes]]; @@ -948,18 +967,36 @@ // Set gear menu items Remove/Duplicate table/view according to the table types NSIndexSet *indexes = [tablesListView selectedRowIndexes]; unsigned currentIndex = [indexes lastIndex]; - int tblTypesChecksum = 0; + BOOL areTableTypeEqual = YES; + int lastType = [[tableTypes objectAtIndex:currentIndex] intValue]; while (currentIndex != NSNotFound) { - tblTypesChecksum += [[tableTypes objectAtIndex:currentIndex] intValue]; + if([[tableTypes objectAtIndex:currentIndex] intValue]!=lastType) + { + areTableTypeEqual = NO; + break; + } 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")]; + if(areTableTypeEqual) + { + switch(lastType) { + case SP_TABLETYPE_TABLE: + [removeTableMenuItem setTitle:NSLocalizedString(@"Remove tables", @"remove tables menu title")]; + break; + case SP_TABLETYPE_VIEW: + [removeTableMenuItem setTitle:NSLocalizedString(@"Remove views", @"remove views menu title")]; + break; + case SP_TABLETYPE_PROC: + [removeTableMenuItem setTitle:NSLocalizedString(@"Remove procedures", @"remove procedures menu title")]; + break; + case SP_TABLETYPE_FUNC: + [removeTableMenuItem setTitle:NSLocalizedString(@"Remove functions", @"remove functions menu title")]; + break; + } + + } else + [removeTableMenuItem setTitle:NSLocalizedString(@"Remove items", @"remove items menu title")]; // set window title [tableWindow setTitle:[NSString stringWithFormat:@"(MySQL %@) %@/%@", [tableDocumentInstance mySQLVersion], -- cgit v1.2.3