From 484955136b25948d2268ebeecce9491903594fb1 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Mon, 5 Jul 2010 09:50:55 +0000 Subject: =?UTF-8?q?=E2=80=A2=20localisation=20issues=20-=20made=20"This=20?= =?UTF-8?q?table=20currently=20does=20not=20support=20relations..."=20=20l?= =?UTF-8?q?ocalisable=20-=20resized=20some=20nib=20elements=20for=20longer?= =?UTF-8?q?=20translations=20-=20replaced=20[[NSApp=20mainMenu]=20itemWith?= =?UTF-8?q?Title:@"Table"]=20by=20[[NSApp=20mainMenu]=20itemWithTag:SPMain?= =?UTF-8?q?MenuTable]=20for=20dynamic=20title=20changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Interfaces/English.lproj/Console.xib | 19 ++-- Interfaces/English.lproj/ContentFilterManager.xib | 20 ++-- Source/SPTableRelations.m | 121 +++++++++++----------- Source/SPTablesList.m | 9 +- 4 files changed, 87 insertions(+), 82 deletions(-) diff --git a/Interfaces/English.lproj/Console.xib b/Interfaces/English.lproj/Console.xib index dbf9017a..777528e5 100644 --- a/Interfaces/English.lproj/Console.xib +++ b/Interfaces/English.lproj/Console.xib @@ -12,7 +12,9 @@ YES - + + + YES @@ -88,7 +90,7 @@ 289 - {{447, 2}, {118, 17}} + {{399, 2}, {166, 17}} YES @@ -533,7 +535,7 @@ - 5 + 1 YES 1 YES @@ -571,14 +573,14 @@ - + 268 YES 268 - {{10, 6}, {151, 18}} + {{10, 8}, {260, 18}} YES @@ -605,7 +607,7 @@ 268 - {{10, 30}, {154, 18}} + {{10, 32}, {260, 18}} YES @@ -625,7 +627,8 @@ - {178, 54} + {278, 56} + NSView @@ -1304,7 +1307,7 @@ {575, 130} com.apple.InterfaceBuilder.CocoaPlugin - {{568, 619}, {178, 54}} + {{568, 617}, {278, 56}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin diff --git a/Interfaces/English.lproj/ContentFilterManager.xib b/Interfaces/English.lproj/ContentFilterManager.xib index 774453df..0c6c417e 100644 --- a/Interfaces/English.lproj/ContentFilterManager.xib +++ b/Interfaces/English.lproj/ContentFilterManager.xib @@ -2,10 +2,10 @@ 1050 - 10D573 + 10F569 762 1038.29 - 460.00 + 461.00 YES @@ -21,6 +21,7 @@ YES + YES @@ -58,7 +59,7 @@ {3.40282e+38, 3.40282e+38} {500, 371} - + 256 YES @@ -463,7 +464,7 @@ 292 - {{16, 199}, {187, 18}} + {{16, 199}, {252, 18}} YES @@ -547,7 +548,7 @@ 292 - {{20, 165}, {124, 25}} + {{20, 165}, {146, 25}} YES @@ -871,7 +872,7 @@ 289 - {{196, 13}, {70, 28}} + {{187, 13}, {84, 28}} 1 YES @@ -897,7 +898,7 @@ 289 - {{126, 13}, {70, 28}} + {{105, 13}, {84, 28}} YES @@ -979,6 +980,7 @@ {500, 371} + {{0, 0}, {1680, 1028}} {500, 393} @@ -1495,7 +1497,6 @@ - @@ -1503,6 +1504,7 @@ + @@ -3184,7 +3186,7 @@ YES - {15, 15} + {10, 10} {9, 8} {7, 2} {15, 15} diff --git a/Source/SPTableRelations.m b/Source/SPTableRelations.m index 4aa6d17c..cca7f213 100644 --- a/Source/SPTableRelations.m +++ b/Source/SPTableRelations.m @@ -106,7 +106,7 @@ * Add a new relation using the selected values. */ - (IBAction)confirmAddRelation:(id)sender -{ +{ [self closeRelationSheet:self]; NSString *thisTable = [tablesListInstance tableName]; @@ -137,11 +137,11 @@ SPBeginAlertSheet(NSLocalizedString(@"Error creating relation", @"error creating relation message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [NSApp mainWindow], nil, nil, nil, - [NSString stringWithFormat:NSLocalizedString(@"The specified relation was unable to be created.\n\nMySQL said: %@", @"error creating relation informative message"), [connection getLastErrorMessage]]); + [NSString stringWithFormat:NSLocalizedString(@"The specified relation was unable to be created.\n\nMySQL said: %@", @"error creating relation informative message"), [connection getLastErrorMessage]]); } else { [self _refreshRelationDataForcingCacheRefresh:YES]; - } + } } /** @@ -164,7 +164,7 @@ * Called whenever the user selected to add a new relation. */ - (IBAction)addRelation:(id)sender -{ +{ // Set up the controls [addRelationTableBox setTitle:[NSString stringWithFormat:@"Table: %@", [tablesListInstance tableName]]]; @@ -179,7 +179,7 @@ [result dataSeek:0]; for (NSInteger i = 0; i < [result numOfRows]; i++) - { + { [refTablePopUpButton addItemWithTitle:[[result fetchRowAsArray] objectAtIndex:0]]; } @@ -198,22 +198,22 @@ - (IBAction)removeRelation:(id)sender { if ([relationsTableView numberOfSelectedRows] > 0) { - + NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Delete relation", @"delete relation message") defaultButton:NSLocalizedString(@"Delete", @"delete button") alternateButton:NSLocalizedString(@"Cancel", @"cancel button") otherButton:nil informativeTextWithFormat:NSLocalizedString(@"Are you sure you want to delete the selected relations? This action cannot be undone.", @"delete selected relation informative message")]; - + [alert setAlertStyle:NSCriticalAlertStyle]; - + NSArray *buttons = [alert buttons]; - + // Change the alert's cancel button to have the key equivalent of return [[buttons objectAtIndex:0] setKeyEquivalent:@"d"]; [[buttons objectAtIndex:0] setKeyEquivalentModifierMask:NSCommandKeyMask]; [[buttons objectAtIndex:1] setKeyEquivalent:@"\r"]; - + [alert beginSheetModalForWindow:[tableDocumentInstance parentWindow] modalDelegate:self didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) contextInfo:@"removeRelation"]; } } @@ -234,30 +234,29 @@ BOOL enableInteraction = ![[tableDocumentInstance selectedToolbarItemIdentifier] isEqualToString:SPMainToolbarTableRelations] || ![tableDocumentInstance isWorking]; // To begin enable all interface elements - [addRelationButton setEnabled:enableInteraction]; + [addRelationButton setEnabled:enableInteraction]; [refreshRelationsButton setEnabled:enableInteraction]; [relationsTableView setEnabled:YES]; // Get the current table's storage engine NSString *engine = [tableDataInstance statusValueForKey:@"Engine"]; - + if (([tablesListInstance tableType] == SPTableTypeTable) && ([[engine lowercaseString] isEqualToString:@"innodb"])) { - + // Update the text label [labelTextField setStringValue:[NSString stringWithFormat:@"Relations for table: %@", [tablesListInstance tableName]]]; - + [addRelationButton setEnabled:enableInteraction]; [refreshRelationsButton setEnabled:enableInteraction]; [relationsTableView setEnabled:YES]; - } - else { - [addRelationButton setEnabled:NO]; - [refreshRelationsButton setEnabled:NO]; + } else { + [addRelationButton setEnabled:NO]; + [refreshRelationsButton setEnabled:NO]; [relationsTableView setEnabled:NO]; - - [labelTextField setStringValue:([tablesListInstance tableType] == SPTableTypeTable) ? @"This table currently does not support relations. Only tables that use the InnoDB storage engine support them." : @""]; - } - + + [labelTextField setStringValue:([tablesListInstance tableType] == SPTableTypeTable) ? NSLocalizedString(@"This table currently does not support relations. Only tables that use the InnoDB storage engine support them.", @"This table currently does not support relations. Only tables that use the InnoDB storage engine support them.") : @""]; + } + [self _refreshRelationDataForcingCacheRefresh:NO]; } @@ -359,21 +358,21 @@ [data addObject:headings]; [headings release]; - + // Get the relation data for (NSDictionary *relation in relationData) { NSMutableArray *temp = [[NSMutableArray alloc] init]; - + [temp addObject:[relation objectForKey:@"name"]]; [temp addObject:[relation objectForKey:@"columns"]]; [temp addObject:[relation objectForKey:@"fk_table"]]; [temp addObject:[relation objectForKey:@"fk_columns"]]; [temp addObject:([relation objectForKey:@"on_update"]) ? [relation objectForKey:@"on_update"] : @""]; [temp addObject:([relation objectForKey:@"on_delete"]) ? [relation objectForKey:@"on_delete"] : @""]; - + [data addObject:temp]; - + [temp release]; } @@ -386,35 +385,35 @@ - (void)alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo { if ([contextInfo isEqualToString:@"removeRelation"]) { - + if (returnCode == NSAlertDefaultReturn) { - + NSString *thisTable = [tablesListInstance tableName]; NSIndexSet *selectedSet = [relationsTableView selectedRowIndexes]; - + NSUInteger row = [selectedSet lastIndex]; - + while (row != NSNotFound) { NSString *relationName = [[relationData objectAtIndex:row] objectForKey:@"name"]; NSString *query = [NSString stringWithFormat:@"ALTER TABLE %@ DROP FOREIGN KEY %@", [thisTable backtickQuotedString], [relationName backtickQuotedString]]; - + [connection queryString:query]; - + if ([connection queryErrored]) { - + SPBeginAlertSheet(NSLocalizedString(@"Unable to delete relation", @"error deleting relation message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [NSApp mainWindow], nil, nil, nil, - [NSString stringWithFormat:NSLocalizedString(@"The selected relation couldn't be deleted.\n\nMySQL said: %@", @"error deleting relation informative message"), [connection getLastErrorMessage]]); - + [NSString stringWithFormat:NSLocalizedString(@"The selected relation couldn't be deleted.\n\nMySQL said: %@", @"error deleting relation informative message"), [connection getLastErrorMessage]]); + // Abort loop break; } - + row = [selectedSet indexLessThanIndex:row]; } - + [self _refreshRelationDataForcingCacheRefresh:YES]; } } @@ -424,21 +423,21 @@ * This method is called as part of Key Value Observing which is used to watch for prefernce changes which effect the interface. */ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context -{ +{ // Display table veiew vertical gridlines preference changed if ([keyPath isEqualToString:SPDisplayTableViewVerticalGridlines]) { [relationsTableView setGridStyleMask:([[change objectForKey:NSKeyValueChangeNewKey] boolValue]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; } // Use monospaced fonts preference changed else if ([keyPath isEqualToString:SPUseMonospacedFonts]) { - + BOOL useMonospacedFont = [[change objectForKey:NSKeyValueChangeNewKey] boolValue]; - + for (NSTableColumn *column in [relationsTableView tableColumns]) { [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; } - + [relationsTableView reloadData]; } } @@ -451,7 +450,7 @@ // Remove row if ([menuItem action] == @selector(removeRelation:)) { [menuItem setTitle:([relationsTableView numberOfSelectedRows] > 1) ? NSLocalizedString(@"Delete Relations", @"delete relations menu item") : NSLocalizedString(@"Delete Relation", @"delete relation menu item")]; - + return ([relationsTableView numberOfSelectedRows] > 0); } @@ -464,12 +463,12 @@ * Dealloc. */ - (void)dealloc -{ +{ [[NSNotificationCenter defaultCenter] removeObserver:self]; [[NSUserDefaults standardUserDefaults] removeObserver:self forKeyPath:SPUseMonospacedFonts]; [relationData release], relationData = nil; - + [super dealloc]; } @@ -485,11 +484,11 @@ [relationData removeAllObjects]; if ([tablesListInstance tableType] == SPTableTypeTable) { - + if (clearAllCaches) [tableDataInstance updateInformationForCurrentTable]; - + NSArray *constraints = [tableDataInstance getConstraints]; - + for (NSDictionary *constraint in constraints) { [relationData addObject:[NSDictionary dictionaryWithObjectsAndKeys: @@ -500,7 +499,7 @@ ([constraint objectForKey:@"update"] ? [constraint objectForKey:@"update"] : @""), @"on_update", ([constraint objectForKey:@"delete"] ? [constraint objectForKey:@"delete"] : @""), @"on_delete", nil]]; - + } } @@ -515,40 +514,40 @@ { NSString *column = [columnPopUpButton titleOfSelectedItem]; NSString *table = [refTablePopUpButton titleOfSelectedItem]; - + [tableDataInstance resetAllData]; [tableDataInstance updateInformationForCurrentTable]; - + NSDictionary *columnInfo = [[tableDataInstance columnWithName:column] copy]; - + [refColumnPopUpButton setEnabled:NO]; [confirmAddRelationButton setEnabled:NO]; - + [refColumnPopUpButton removeAllItems]; - + [tableDataInstance resetAllData]; NSDictionary *tableInfo = [tableDataInstance informationForTable:table]; - + NSArray *columns = [tableInfo objectForKey:@"columns"]; - + NSMutableArray *validColumns = [NSMutableArray array]; - + // Only add columns of the same data type for (NSDictionary *aColumn in columns) - { + { if ([[columnInfo objectForKey:@"type"] isEqualToString:[aColumn objectForKey:@"type"]]) { - [validColumns addObject:[aColumn objectForKey:@"name"]]; + [validColumns addObject:[aColumn objectForKey:@"name"]]; } } - + // Add the valid columns if ([validColumns count] > 0) { [refColumnPopUpButton addItemsWithTitles:validColumns]; - + [refColumnPopUpButton setEnabled:YES]; [confirmAddRelationButton setEnabled:YES]; } - + [columnInfo release]; } diff --git a/Source/SPTablesList.m b/Source/SPTablesList.m index 509e3b83..d0d39eec 100644 --- a/Source/SPTablesList.m +++ b/Source/SPTablesList.m @@ -869,9 +869,10 @@ [separatorTableMenuItem setHidden:YES]; [separatorTableMenuItem2 setHidden:YES]; [showCreateSyntaxMenuItem setHidden:YES]; - - NSMenu *tableSubMenu = [[[NSApp mainMenu] itemWithTitle:@"Table"] submenu]; - + + // Get main menu "Table"'s submenu + NSMenu *tableSubMenu = [[[NSApp mainMenu] itemWithTag:SPMainMenuTable] submenu]; + [[tableSubMenu itemAtIndex:6] setTitle:NSLocalizedString(@"Check Selected Items", @"check selected items menu item")]; [[tableSubMenu itemAtIndex:7] setTitle:NSLocalizedString(@"Repair Selected Items", @"repair selected items menu item")]; @@ -926,7 +927,7 @@ // Set gear menu items Remove/Duplicate table/view and mainMenu > Table items // according to the table types - NSMenu *tableSubMenu = [[[NSApp mainMenu] itemWithTitle:@"Table"] submenu]; + NSMenu *tableSubMenu = [[[NSApp mainMenu] itemWithTag:SPMainMenuTable] submenu]; // 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. -- cgit v1.2.3