aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-02-23 11:34:58 +0000
committerBibiko <bibiko@eva.mpg.de>2010-02-23 11:34:58 +0000
commitb1d29fac626ddbdcfda3bc034861c3b22e39b548 (patch)
tree97af06ea1957c982cdc1ab942dd027407ad5d6a3 /Source
parenta24e9c697049bacb587835153e2ebb4764fff008 (diff)
downloadsequelpro-b1d29fac626ddbdcfda3bc034861c3b22e39b548.tar.gz
sequelpro-b1d29fac626ddbdcfda3bc034861c3b22e39b548.tar.bz2
sequelpro-b1d29fac626ddbdcfda3bc034861c3b22e39b548.zip
• Reset AUTO_INCREMENT in Table Info Pane uses inline entering of the new value (no sheet)
• "Delete all records" confirmation sheet shows a checkbox "Reset AUTO_INCREMENT after deletion" if PRI key is given for that table • minimized table data querying for auto_inc • optimized auto_inc change notification • if user changes tabVIew to Table Info Pane update data in beforehand • TRUNCATE query updates auto_inc value as well in TABLE INFORMATION
Diffstat (limited to 'Source')
-rw-r--r--Source/SPExtendedTableInfo.h1
-rw-r--r--Source/SPExtendedTableInfo.m35
-rw-r--r--Source/TableContent.h2
-rw-r--r--Source/TableContent.m24
-rw-r--r--Source/TableDocument.m7
-rw-r--r--Source/TableSource.m9
-rw-r--r--Source/TablesList.h1
-rw-r--r--Source/TablesList.m3
8 files changed, 71 insertions, 11 deletions
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];
+
}
/**