diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-02-22 17:25:16 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-02-22 17:25:16 +0000 |
commit | 0d39a10771ae048d49d413ac1baf1d8f485190e0 (patch) | |
tree | 5aa39da9173d24caa1f8f78c31e8c58905cbddc4 | |
parent | 6d018a4e2eb0505776092e6f626d70b1ad3d5295 (diff) | |
download | sequelpro-0d39a10771ae048d49d413ac1baf1d8f485190e0.tar.gz sequelpro-0d39a10771ae048d49d413ac1baf1d8f485190e0.tar.bz2 sequelpro-0d39a10771ae048d49d413ac1baf1d8f485190e0.zip |
• implemented chance to reset AUTO_INCREMENT of the PRIMARY KEY field in Structure Pane via right-click at the index tableView
- implementation in the Table Info follows soon
-rw-r--r-- | Interfaces/English.lproj/DBView.xib | 43 | ||||
-rw-r--r-- | Source/TableDocument.m | 3 | ||||
-rw-r--r-- | Source/TableSource.h | 1 | ||||
-rw-r--r-- | Source/TableSource.m | 21 |
4 files changed, 53 insertions, 15 deletions
diff --git a/Interfaces/English.lproj/DBView.xib b/Interfaces/English.lproj/DBView.xib index 0b372e69..5079c841 100644 --- a/Interfaces/English.lproj/DBView.xib +++ b/Interfaces/English.lproj/DBView.xib @@ -23,7 +23,8 @@ </object> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="500"/> + <integer value="6833"/> + <integer value="25"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -62,7 +63,7 @@ <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> <string key="NSWindowContentMinSize">{780, 480}</string> <object class="NSView" key="NSWindowView" id="579726586"> - <nil key="NSNextResponder"/> + <reference key="NSNextResponder"/> <int key="NSvFlags">256</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -5308,6 +5309,7 @@ </object> </object> <string key="NSFrameSize">{944, 550}</string> + <reference key="NSSuperview"/> </object> <string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string> <string key="NSMinSize">{780, 502}</string> @@ -6276,6 +6278,7 @@ <int key="NSvFlags">266</int> <string key="NSFrame">{{17, 93}, {226, 14}}</string> <reference key="NSSuperview" ref="653204527"/> + <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSTextFieldCell" key="NSCell" id="604072019"> <int key="NSCellFlags">67239488</int> @@ -6292,6 +6295,7 @@ <int key="NSvFlags">258</int> <string key="NSFrame">{{20, 67}, {220, 18}}</string> <reference key="NSSuperview" ref="653204527"/> + <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSTextFieldCell" key="NSCell" id="870160310"> <int key="NSCellFlags">-1804468671</int> @@ -6309,6 +6313,7 @@ <int key="NSvFlags">292</int> <string key="NSFrame">{{19, 43}, {189, 18}}</string> <reference key="NSSuperview" ref="653204527"/> + <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="575635343"> <int key="NSCellFlags">67239424</int> @@ -6330,6 +6335,7 @@ <int key="NSvFlags">289</int> <string key="NSFrame">{{158, 13}, {87, 28}}</string> <reference key="NSSuperview" ref="653204527"/> + <reference key="NSWindow"/> <int key="NSTag">1</int> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="834960254"> @@ -6353,6 +6359,7 @@ <int key="NSvFlags">289</int> <string key="NSFrame">{{80, 13}, {80, 28}}</string> <reference key="NSSuperview" ref="653204527"/> + <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="1048025876"> <int key="NSCellFlags">67239424</int> @@ -6372,6 +6379,7 @@ </object> <string key="NSFrameSize">{260, 127}</string> <reference key="NSSuperview"/> + <reference key="NSWindow"/> </object> <string key="NSScreenRect">{{0, 0}, {1440, 878}}</string> <string key="NSMinSize">{260, 149}</string> @@ -6848,7 +6856,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> <string key="NSWindowContentMinSize">{255, 95}</string> <object class="NSView" key="NSWindowView" id="748618982"> - <nil key="NSNextResponder"/> + <reference key="NSNextResponder"/> <int key="NSvFlags">301</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -6932,18 +6940,20 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string>negativeInfinitySymbol</string> <string>nilSymbol</string> <string>numberStyle</string> + <string>paddingPosition</string> <string>positiveInfinitySymbol</string> </object> <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> <boolean value="NO"/> <integer value="1040"/> - <boolean value="NO"/> - <real value="0.0"/> + <boolean value="YES"/> + <real value="1"/> <integer value="1"/> <string>-∞</string> <string/> <integer value="0"/> + <integer value="0"/> <string>+∞</string> </object> </object> @@ -6965,7 +6975,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> </object> </object> - <real value="0.0" key="NS.min"/> + <real value="1" key="NS.min"/> <object class="NSDecimalNumberPlaceholder" key="NS.max"> <int key="NS.exponent">0</int> <int key="NS.length">0</int> @@ -7016,6 +7026,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> </object> <string key="NSFrameSize">{255, 95}</string> + <reference key="NSSuperview"/> </object> <string key="NSScreenRect">{{0, 0}, {1280, 1002}}</string> <string key="NSMinSize">{255, 117}</string> @@ -15650,6 +15661,14 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> <int key="connectionID">6851</int> </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">tableInfoInstance</string> + <reference key="source" ref="103234030"/> + <reference key="destination" ref="622219357"/> + </object> + <int key="connectionID">6853</int> + </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> <object class="NSArray" key="orderedObjects"> @@ -24221,10 +24240,10 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <integer value="1"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{62, 156}, {944, 550}}</string> + <string>{{386, 124}, {944, 550}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <boolean value="NO"/> - <string>{{62, 156}, {944, 550}}</string> + <string>{{386, 124}, {944, 550}}</string> <integer value="1"/> <integer value="1"/> <string>{{62, 352}, {845, 504}}</string> @@ -25341,9 +25360,9 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{580, 784}, {255, 95}}</string> + <string>{{580, 661}, {255, 95}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{580, 784}, {255, 95}}</string> + <string>{{580, 661}, {255, 95}}</string> <boolean value="NO"/> <boolean value="NO"/> <boolean value="YES"/> @@ -25506,7 +25525,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> </object> <nil key="sourceID"/> - <int key="maxID">6852</int> + <int key="maxID">6853</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> @@ -27174,6 +27193,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string>structureGrabber</string> <string>tableDataInstance</string> <string>tableDocumentInstance</string> + <string>tableInfoInstance</string> <string>tableSourceView</string> <string>tableWindow</string> <string>tablesListInstance</string> @@ -27203,6 +27223,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string>id</string> <string>id</string> <string>id</string> + <string>id</string> </object> </object> <object class="IBClassDescriptionSource" key="sourceIdentifier"> diff --git a/Source/TableDocument.m b/Source/TableDocument.m index b8261a8e..1565a477 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -3613,7 +3613,7 @@ - (NSRect)window:(NSWindow *)window willPositionSheet:(NSWindow *)sheet usingRect:(NSRect)rect { - // Locate the sheet "Reset Auto Increment" just beneath the chosen index row + // Locate the sheet "Reset Auto Increment" just centered beneath the chosen index row if([[sheet title] isEqualToString:@"Reset Auto Increment"]) { id it = [tableSourceInstance valueForKeyPath:@"indexView"]; @@ -3622,6 +3622,7 @@ NSRect rowrect = [it rectOfRow:[it selectedRow]]; rowrect.size.width = mwrect.size.width - ltrect.size.width; rowrect.origin.y -= [it rowHeight]/2.0f+2; + rowrect.origin.x -= 8; return [it convertRect:rowrect toView:nil]; } else diff --git a/Source/TableSource.h b/Source/TableSource.h index e09dd16b..6904b875 100644 --- a/Source/TableSource.h +++ b/Source/TableSource.h @@ -31,6 +31,7 @@ IBOutlet id tablesListInstance; IBOutlet id tableDataInstance; IBOutlet id tableDocumentInstance; + IBOutlet id tableInfoInstance; IBOutlet id tableWindow; IBOutlet id indexSheet; diff --git a/Source/TableSource.m b/Source/TableSource.m index f704dcec..6dd3f7fb 100644 --- a/Source/TableSource.m +++ b/Source/TableSource.m @@ -25,6 +25,7 @@ #import "TableSource.h" #import "TableDocument.h" +#import "SPTableInfo.h" #import "TablesList.h" #import "SPTableData.h" #import "SPSQLParser.h" @@ -941,8 +942,9 @@ fetches the result as an array with a dictionary for each row in it // Reset AUTO_INCREMENT if ([menuItem action] == @selector(resetAutoIncrement:)) { - return NO; - return ([indexView numberOfSelectedRows] == 1 ); + return ([indexView numberOfSelectedRows] == 1 + && [[indexes objectAtIndex:[indexView selectedRow]] objectForKey:@"Key_name"] + && [[[indexes objectAtIndex:[indexView selectedRow]] objectForKey:@"Key_name"] isEqualToString:@"PRIMARY"]); } return YES; @@ -1010,7 +1012,20 @@ fetches the result as an array with a dictionary for each row in it } else if ([contextInfo isEqualToString:@"resetAutoIncrement"]) { if (returnCode == NSAlertDefaultReturn) { - // ALTER TABLE tbl_name AUTO_INCREMENT = N + + [mySQLConnection queryString:[NSString stringWithFormat:@"ALTER TABLE %@ AUTO_INCREMENT = %@", [selectedTable backtickQuotedString], [[resetAutoIncrementValue stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]]]; + + if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) { + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), + NSLocalizedString(@"OK", @"OK button"), + nil, nil, [NSApp mainWindow], nil, nil, nil, nil, + [NSString stringWithFormat:NSLocalizedString(@"An error occurred while trying to reset AUTO_INCREMENT of table '%@'.\n\nMySQL said: %@", @"error resetting auto_increment informative message"), selectedTable, [mySQLConnection getLastErrorMessage]]); + } else { + [tableDataInstance resetAllData]; + [tablesListInstance setStatusRequiresReload:YES]; + [self loadTable:selectedTable]; + [tableInfoInstance tableChanged:nil]; + } } } else |