From b1d29fac626ddbdcfda3bc034861c3b22e39b548 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Tue, 23 Feb 2010 11:34:58 +0000 Subject: =?UTF-8?q?=E2=80=A2=20Reset=20AUTO=5FINCREMENT=20in=20Table=20Inf?= =?UTF-8?q?o=20Pane=20uses=20inline=20entering=20of=20the=20new=20value=20?= =?UTF-8?q?(no=20sheet)=20=E2=80=A2=20"Delete=20all=20records"=20confirmat?= =?UTF-8?q?ion=20sheet=20shows=20a=20checkbox=20"Reset=20AUTO=5FINCREMENT?= =?UTF-8?q?=20after=20deletion"=20if=20PRI=20key=20is=20given=20for=20that?= =?UTF-8?q?=20table=20=E2=80=A2=20minimized=20table=20data=20querying=20fo?= =?UTF-8?q?r=20auto=5Finc=20=E2=80=A2=20optimized=20auto=5Finc=20change=20?= =?UTF-8?q?notification=20=E2=80=A2=20if=20user=20changes=20tabVIew=20to?= =?UTF-8?q?=20Table=20Info=20Pane=20update=20data=20in=20beforehand=20?= =?UTF-8?q?=E2=80=A2=20TRUNCATE=20query=20updates=20auto=5Finc=20value=20a?= =?UTF-8?q?s=20well=20in=20TABLE=20INFORMATION?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Interfaces/English.lproj/DBView.xib | 449 +++++++++++++++++++++++++++++++++--- Source/SPExtendedTableInfo.h | 1 + Source/SPExtendedTableInfo.m | 35 ++- Source/TableContent.h | 2 + Source/TableContent.m | 24 +- Source/TableDocument.m | 7 + Source/TableSource.m | 9 +- Source/TablesList.h | 1 + Source/TablesList.m | 3 + 9 files changed, 487 insertions(+), 44 deletions(-) diff --git a/Interfaces/English.lproj/DBView.xib b/Interfaces/English.lproj/DBView.xib index 8e168bb3..f2d7eb6d 100644 --- a/Interfaces/English.lproj/DBView.xib +++ b/Interfaces/English.lproj/DBView.xib @@ -23,6 +23,7 @@ YES + @@ -4125,7 +4126,7 @@ 268 - {{106, 499}, {34, 14}} + {{79, 499}, {34, 14}} YES @@ -4141,7 +4142,7 @@ 266 - {{327, 473}, {348, 14}} + {{300, 473}, {375, 14}} YES @@ -4157,7 +4158,7 @@ 266 - {{330, 498}, {345, 14}} + {{303, 498}, {372, 14}} YES @@ -4173,7 +4174,7 @@ 268 - {{83, 473}, {57, 14}} + {{56, 473}, {57, 14}} YES @@ -4189,7 +4190,7 @@ 268 - {{84, 448}, {57, 14}} + {{57, 448}, {57, 14}} YES @@ -4205,7 +4206,7 @@ 268 - {{142, 494}, {161, 22}} + {{115, 494}, {161, 22}} YES @@ -4237,7 +4238,7 @@ 268 - {{142, 469}, {161, 22}} + {{115, 469}, {161, 22}} YES @@ -4269,7 +4270,7 @@ 268 - {{142, 444}, {161, 22}} + {{115, 444}, {161, 22}} YES @@ -4345,7 +4346,7 @@ 270 - {{48, 398}, {251, 14}} + {{49, 398}, {251, 14}} YES @@ -4361,7 +4362,7 @@ 270 - {{72, 376}, {227, 14}} + {{73, 376}, {227, 14}} YES @@ -4377,7 +4378,7 @@ 270 - {{49, 354}, {250, 14}} + {{50, 354}, {250, 14}} YES @@ -4393,14 +4394,85 @@ 270 - {{51, 332}, {248, 14}} + {{140, 332}, {160, 14}} YES 68288064 - 272761856 + -1874721792 Auto increment: + + + YES + + YES + allowsFloats + formatterBehavior + lenient + locale + minimum + negativeInfinitySymbol + nilSymbol + numberStyle + positiveInfinitySymbol + usesGroupingSeparator + + + YES + + + + + + + + -∞ + + + +∞ + + + + #0.### + #0.### + + + + + + + + NaN + + YES + + + YES + + + + + + 0 + 0 + YES + NO + 1 + AAAAAAAAAAAAAAAAAAAAAA + + + 3 + YES + YES + YES + + . + , + NO + NO + NO + @@ -4543,6 +4615,22 @@ YES + + + 268 + {{53, 332}, {90, 14}} + + YES + + 68288064 + 272761856 + Auto increment: + + + + + + {{10, 7}, {706, 544}} @@ -7055,23 +7143,10 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 NaN - - YES - - - YES - - + - - 0 - 0 - YES - NO - 1 - AAAAAAAAAAAAAAAAAAAAAA - + 3 YES @@ -15805,6 +15880,38 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 6876 + + + delegate + + + + 6880 + + + + resetAutoIncrementValueWasEdited: + + + + 6881 + + + + tableSourceInstance + + + + 6882 + + + + tableInfoInstance + + + + 6883 + @@ -17810,6 +17917,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 + @@ -20012,6 +20120,10 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 5782 + + YES + + @@ -22263,6 +22375,25 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 + + 6877 + + + YES + + + + + + 6878 + + + + + 6879 + + + @@ -23621,6 +23752,11 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 6860.IBAttributePlaceholdersKey 6860.IBPluginDependency 6861.IBPluginDependency + 6877.IBPluginDependency + 6878.IBPluginDependency + 6879.IBNumberFormatterBehaviorMetadataKey + 6879.IBNumberFormatterLocalizesFormatMetadataKey + 6879.IBPluginDependency 69.ImportedFromIB2 711.IBPluginDependency 711.ImportedFromIB2 @@ -24431,11 +24567,11 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{118, 138}, {944, 550}} + {{51, 274}, {944, 550}} com.apple.InterfaceBuilder.CocoaPlugin - {{118, 138}, {944, 550}} + {{51, 274}, {944, 550}} {{62, 352}, {845, 504}} @@ -25090,7 +25226,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 com.apple.InterfaceBuilder.CocoaPlugin com.brandonwalkin.BWToolkit com.brandonwalkin.BWToolkit - {{623, 397}, {174, 93}} + {{623, 397}, {171, 93}} com.apple.InterfaceBuilder.CocoaPlugin ToolTip @@ -25583,7 +25719,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{553, 340}, {227, 168}} + {{316, 552}, {218, 72}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -25596,6 +25732,11 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -25740,7 +25881,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 - 6876 + 6883 @@ -27348,6 +27489,17 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 YES + + NSObject + + toggleCollapse: + id + + + IBDocumentRelativeSource + ../../Source/TablesList.h + + SPExtendedTableInfo NSObject @@ -27357,6 +27509,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 YES reloadTable: resetAutoIncrement: + resetAutoIncrementValueWasEdited: updateTableCollation: updateTableEncoding: updateTableType: @@ -27368,6 +27521,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 id id id + id @@ -27426,6 +27580,114 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 ../../Source/SPExtendedTableInfo.h + + TableContent + NSObject + + YES + + YES + addRow: + copyRow: + filterTable: + navigatePaginationFromButton: + reloadTable: + removeRow: + setCompareTypes: + toggleFilterField: + togglePagination: + + + YES + id + id + id + id + id + id + id + id + id + + + + YES + + YES + addButton + argumentField + betweenTextField + compareField + contentFilterManager + contentViewPane + copyButton + countText + fieldField + filterButton + firstBetweenField + limitRowsButton + limitRowsField + limitRowsStepper + multipleLineEditingButton + paginationButton + paginationNextButton + paginationPageField + paginationPageStepper + paginationPreviousButton + paginationView + reloadButton + removeButton + secondBetweenField + spHistoryControllerInstance + tableContentView + tableDataInstance + tableDocumentInstance + tableInfoInstance + tableSourceInstance + tableWindow + tablesListInstance + + + YES + id + id + id + id + id + NSView + id + id + NSPopUpButton + id + id + id + id + id + id + NSButton + NSButton + NSTextField + NSStepper + NSButton + NSView + id + id + id + SPHistoryController + CMCopyTable + id + id + SPTableInfo + id + id + id + + + + IBDocumentRelativeSource + ../../Source/TableContent.h + + TableSource NSObject @@ -27524,6 +27786,127 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 ../../Source/TableSource.h + + TablesList + NSObject + + YES + + YES + addTable: + closeSheet: + copyTable: + removeTable: + renameTable: + togglePaneCollapse: + truncateTable: + updateFilter: + updateTables: + + + YES + id + id + id + id + id + id + id + id + id + + + + YES + + YES + addTableButton + copyTableButton + copyTableContentSwitch + copyTableMessageField + copyTableNameField + copyTableSheet + customQueryInstance + databaseDataInstance + duplicateTableContextMenuItem + duplicateTableMenuItem + extendedTableInfoInstance + listFilterField + removeTableContextMenuItem + removeTableMenuItem + renameTableContextMenuItem + renameTableMenuItem + separatorTableContextMenuItem + separatorTableMenuItem + spHistoryControllerInstance + tabView + tableContentInstance + tableDataInstance + tableDocumentInstance + tableDumpInstance + tableEncodingButton + tableInfoCollapseButton + tableInfoInstance + tableListFilterSplitView + tableListSplitView + tableNameField + tableSheet + tableSourceInstance + tableTypeButton + tableWindow + tablesListView + toolbarActionsButton + toolbarAddButton + toolbarReloadButton + truncateTableButton + truncateTableContextButton + + + YES + id + id + id + id + id + id + id + id + NSMenuItem + NSMenuItem + id + NSSearchField + NSMenuItem + NSMenuItem + NSMenuItem + NSMenuItem + NSMenuItem + NSMenuItem + SPHistoryController + id + id + id + id + id + id + NSButton + id + NSSplitView + NSSplitView + id + id + id + id + id + id + id + id + id + id + id + + + + YES diff --git a/Source/SPExtendedTableInfo.h b/Source/SPExtendedTableInfo.h index 24f38d5d..4c9d1f07 100644 --- a/Source/SPExtendedTableInfo.h +++ b/Source/SPExtendedTableInfo.h @@ -69,6 +69,7 @@ - (IBAction)updateTableEncoding:(id)sender; - (IBAction)updateTableCollation:(id)sender; - (IBAction)resetAutoIncrement:(id)sender; +- (IBAction)resetAutoIncrementValueWasEdited:(id)sender; // Others - (void)loadTable:(NSString *)table; diff --git a/Source/SPExtendedTableInfo.m b/Source/SPExtendedTableInfo.m index f68dca18..00f1fc37 100644 --- a/Source/SPExtendedTableInfo.m +++ b/Source/SPExtendedTableInfo.m @@ -32,6 +32,7 @@ #import "TableDocument.h" #import "TablesList.h" #import "SPAlertSheets.h" +#import "TableSource.h" @interface SPExtendedTableInfo (PrivateAPI) @@ -174,7 +175,31 @@ - (IBAction)resetAutoIncrement:(id)sender { - [tableSourceInstance resetAutoIncrement:sender]; + + if([sender tag] == 1) { + [tableRowAutoIncrement setEditable:YES]; + [tableRowAutoIncrement selectText:nil]; + } else { + [tableRowAutoIncrement setEditable:NO]; + [tableSourceInstance resetAutoIncrement:sender]; + } +} + +- (IBAction)resetAutoIncrementValueWasEdited:(id)sender +{ + [tableRowAutoIncrement setEditable:NO]; + [tableSourceInstance setAutoIncrementTo:[[tableRowAutoIncrement stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]]; +} + +- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command +{ + + // Listen to ESC to abort editing of auto increment input field + if (command == @selector(cancelOperation:) && control == tableRowAutoIncrement) { + [tableRowAutoIncrement abortEditing]; + return YES; + } + return NO; } #pragma mark - @@ -235,7 +260,7 @@ [tableRowNumber setStringValue:@"Number of rows: "]; [tableRowFormat setStringValue:@"Row format: "]; [tableRowAvgLength setStringValue:@"Avg. row length: "]; - [tableRowAutoIncrement setStringValue:@"Auto increment: "]; + [tableRowAutoIncrement setStringValue:@""]; // Set size values [tableDataSize setStringValue:@"Data size: "]; @@ -493,8 +518,10 @@ } } } - - return [NSString stringWithFormat:@"%@: %@", label, ([value length] > 0) ? value : @"Not available"]; + if([key isEqualToString:@"Auto_increment"]) + return ([value length] > 0) ? value : @"Not available"; + else + return [NSString stringWithFormat:@"%@: %@", label, ([value length] > 0) ? value : @"Not available"]; } @end diff --git a/Source/TableContent.h b/Source/TableContent.h index 2e45ac59..b4941912 100644 --- a/Source/TableContent.h +++ b/Source/TableContent.h @@ -35,6 +35,8 @@ IBOutlet id tableDocumentInstance; IBOutlet id tablesListInstance; IBOutlet id tableDataInstance; + IBOutlet id tableSourceInstance; + IBOutlet SPTableInfo *tableInfoInstance; IBOutlet SPHistoryController *spHistoryControllerInstance; diff --git a/Source/TableContent.m b/Source/TableContent.m index 3a736a90..fc12dccf 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -29,6 +29,7 @@ #import "TableContent.h" #import "TableDocument.h" +#import "TableSource.h" #import "SPTableInfo.h" #import "TablesList.h" #import "CMImageView.h" @@ -49,7 +50,6 @@ #import "SPNotLoaded.h" #import "SPConstants.h" #import "SPDataStorage.h" -#import "TableDocument.h" #import "SPAlertSheets.h" @implementation TableContent @@ -1386,13 +1386,25 @@ [[buttons objectAtIndex:0] setKeyEquivalent:@"d"]; [[buttons objectAtIndex:0] setKeyEquivalentModifierMask:NSCommandKeyMask]; [[buttons objectAtIndex:1] setKeyEquivalent:@"\r"]; - + + [alert setShowsSuppressionButton:NO]; + [[alert suppressionButton] setState:NSOffState]; + NSString *contextInfo = @"removerow"; if (([tableContentView numberOfSelectedRows] == [tableContentView numberOfRows]) && !isFiltered && !isLimited && !isInterruptedLoad) { - + contextInfo = @"removeallrows"; + // If table has PRIMARY KEY ask for resetting the auto increment after deletion if given + if(![[tableDataInstance statusValueForKey:@"Auto_increment"] isKindOfClass:[NSNull class]]) { + [alert setShowsSuppressionButton:YES]; + [[alert suppressionButton] setState:NSOffState]; + [[[alert suppressionButton] cell] setControlSize:NSSmallControlSize]; + [[[alert suppressionButton] cell] setFont:[NSFont systemFontOfSize:11]]; + [[alert suppressionButton] setTitle:NSLocalizedString(@"Reset AUTO_INCREMENT after deletion?", @"reset auto_increment after deletion of all rows message")]; + } + [alert setMessageText:NSLocalizedString(@"Delete all rows?", @"delete all rows message")]; [alert setInformativeText:NSLocalizedString(@"Are you sure you want to delete all the rows from this table? This action cannot be undone.", @"delete all rows informative message")]; } @@ -2139,7 +2151,13 @@ if ( returnCode == NSAlertDefaultReturn ) { [mySQLConnection queryString:[NSString stringWithFormat:@"DELETE FROM %@", [selectedTable backtickQuotedString]]]; if ( [[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) { + + // Reset auto increment if suppression button was ticked + if([[sheet suppressionButton] state] == NSOnState) + [tableSourceInstance setAutoIncrementTo:@"1"]; + [self reloadTable:self]; + } else { [self performSelector:@selector(showErrorSheetWith:) withObject:[NSArray arrayWithObjects:NSLocalizedString(@"Error", @"error"), diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 25fa50a0..4d5c5a77 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -3059,6 +3059,13 @@ [tableTabView selectTabViewItemAtIndex:3]; [mainToolbar setSelectedItemIdentifier:SPMainToolbarTableInfo]; [spHistoryControllerInstance updateHistoryEntries]; + + // Refresh data + if([self table] && [[self table] length]) { + [tableDataInstance resetAllData]; + [extendedTableInfoInstance loadTable:[self table]]; + } + [tableWindow makeFirstResponder:[extendedTableInfoInstance valueForKeyPath:@"tableCreateSyntaxTextView"]]; [prefs setInteger:SPTableInfoViewMode forKey:SPLastViewMode]; diff --git a/Source/TableSource.m b/Source/TableSource.m index 6004a4ac..655dffc1 100644 --- a/Source/TableSource.m +++ b/Source/TableSource.m @@ -601,10 +601,11 @@ closes the keySheet [NSString stringWithFormat:NSLocalizedString(@"An error occurred while trying to reset AUTO_INCREMENT of table '%@'.\n\nMySQL said: %@", @"error resetting auto_increment informative message"), selTable, [mySQLConnection getLastErrorMessage]]); } else { - [tableDataInstance resetAllData]; - [tablesListInstance setStatusRequiresReload:YES]; - [self loadTable:selectedTable]; - [extendedTableInfoInstance loadTable:selTable]; + [tableDataInstance resetStatusData]; + if([[tableDocumentInstance valueForKeyPath:@"tableTabView"] indexOfTabViewItem:[[tableDocumentInstance valueForKeyPath:@"tableTabView"] selectedTabViewItem]] == 3) { + [tableDataInstance resetAllData]; + [extendedTableInfoInstance loadTable:selTable]; + } [tableInfoInstance tableChanged:nil]; } } diff --git a/Source/TablesList.h b/Source/TablesList.h index b64e0de0..a730fcf4 100644 --- a/Source/TablesList.h +++ b/Source/TablesList.h @@ -55,6 +55,7 @@ enum sp_table_types IBOutlet id tableDataInstance; IBOutlet id extendedTableInfoInstance; IBOutlet id databaseDataInstance; + IBOutlet id tableInfoInstance; IBOutlet SPHistoryController *spHistoryControllerInstance; IBOutlet id tableWindow; diff --git a/Source/TablesList.m b/Source/TablesList.m index b66af9fb..af7f6fdc 100644 --- a/Source/TablesList.m +++ b/Source/TablesList.m @@ -28,6 +28,7 @@ #import "TableSource.h" #import "TableContent.h" #import "SPTableData.h" +#import "SPTableInfo.h" #import "TableDump.h" #import "ImageAndTextCell.h" #import "SPStringAdditions.h" @@ -1881,6 +1882,8 @@ // Reload the table's content view to show that it has been truncated [tableContentInstance reloadTable:self]; + [tableDataInstance resetStatusData]; + } /** -- cgit v1.2.3