aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2009-06-15 18:45:58 +0000
committerstuconnolly <stuart02@gmail.com>2009-06-15 18:45:58 +0000
commit37cae99ed1ace10a7d106255efdc104d1af760e9 (patch)
tree6071c9c1756819a0f4b68b79de108a4a972b5e11
parent70d15ff4ecdfd3c6996b3b8b2259674f9e9c9345 (diff)
downloadsequelpro-37cae99ed1ace10a7d106255efdc104d1af760e9.tar.gz
sequelpro-37cae99ed1ace10a7d106255efdc104d1af760e9.tar.bz2
sequelpro-37cae99ed1ace10a7d106255efdc104d1af760e9.zip
Implementation of enhancement #273: Allow user to truncate table by right clicking.
-rw-r--r--Interfaces/English.lproj/DBView.xib68
-rw-r--r--Interfaces/English.lproj/Localizable.stringsbin51956 -> 58774 bytes
-rw-r--r--Source/TablesList.h3
-rw-r--r--Source/TablesList.m139
4 files changed, 151 insertions, 59 deletions
diff --git a/Interfaces/English.lproj/DBView.xib b/Interfaces/English.lproj/DBView.xib
index 3373c38c..0b503445 100644
--- a/Interfaces/English.lproj/DBView.xib
+++ b/Interfaces/English.lproj/DBView.xib
@@ -2,12 +2,13 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03">
<data>
<int key="IBDocument.SystemTarget">1050</int>
- <string key="IBDocument.SystemVersion">9G55</string>
+ <string key="IBDocument.SystemVersion">9J61</string>
<string key="IBDocument.InterfaceBuilderVersion">677</string>
- <string key="IBDocument.AppKitVersion">949.43</string>
+ <string key="IBDocument.AppKitVersion">949.46</string>
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
+ <integer value="4811"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -45,7 +46,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>
@@ -386,7 +387,10 @@
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSImage" ref="197220008"/>
+ <object class="NSCustomResource" key="NSImage" id="174245091">
+ <string key="NSClassName">NSImage</string>
+ <string key="NSResourceName">button_action</string>
+ </object>
<string key="NSAction">_popUpItemAction:</string>
<reference key="NSTarget" ref="753352469"/>
</object>
@@ -434,11 +438,20 @@
<string key="NSAction">_popUpItemAction:</string>
<reference key="NSTarget" ref="753352469"/>
</object>
+ <object class="NSMenuItem" id="390856790">
+ <reference key="NSMenu" ref="23713489"/>
+ <string key="NSTitle">Truncate Table</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="285877316"/>
+ <reference key="NSMixedImage" ref="800099743"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <reference key="NSTarget" ref="753352469"/>
+ </object>
<object class="NSMenuItem" id="831803264">
<reference key="NSMenu" ref="23713489"/>
<string key="NSTitle">Remove Table</string>
<string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="285877316"/>
<reference key="NSMixedImage" ref="800099743"/>
@@ -447,6 +460,7 @@
</object>
</object>
</object>
+ <int key="NSSelectedIndex">4</int>
<bool key="NSPullDown">YES</bool>
<int key="NSPreferredEdge">1</int>
<bool key="NSUsesItemFromMenu">YES</bool>
@@ -2950,7 +2964,7 @@
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSImage" ref="197220008"/>
+ <reference key="NSImage" ref="174245091"/>
<string key="NSAction">_popUpItemAction:</string>
<reference key="NSTarget" ref="984501775"/>
</object>
@@ -4388,6 +4402,7 @@
</object>
</object>
<string key="NSFrameSize">{944, 550}</string>
+ <reference key="NSSuperview"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
<string key="NSMinSize">{780, 502}</string>
@@ -12289,7 +12304,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
<string key="NSClassName">NSView</string>
</object>
<object class="NSCustomView" id="730777562">
- <reference key="NSNextResponder"/>
+ <nil key="NSNextResponder"/>
<int key="NSvFlags">265</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -12310,7 +12325,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
</object>
<string key="NSFrame">{{14, 0}, {22, 22}}</string>
<reference key="NSSuperview" ref="730777562"/>
- <reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSImageCell" key="NSCell" id="1052485434">
<int key="NSCellFlags">130560</int>
@@ -12324,8 +12338,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
</object>
</object>
<string key="NSFrameSize">{50, 22}</string>
- <reference key="NSSuperview"/>
- <reference key="NSWindow"/>
<string key="NSClassName">NSView</string>
</object>
<object class="NSUserDefaultsController" id="461189245">
@@ -16109,6 +16121,22 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
</object>
<int key="connectionID">6003</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">truncateTableButton</string>
+ <reference key="source" ref="438574515"/>
+ <reference key="destination" ref="390856790"/>
+ </object>
+ <int key="connectionID">6005</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">truncateTable:</string>
+ <reference key="source" ref="438574515"/>
+ <reference key="destination" ref="390856790"/>
+ </object>
+ <int key="connectionID">6006</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -19045,6 +19073,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
<reference ref="684779453"/>
<reference ref="924446696"/>
<reference ref="938900701"/>
+ <reference ref="390856790"/>
</object>
<reference key="parent" ref="753352469"/>
</object>
@@ -22794,6 +22823,11 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
<reference key="object" ref="1052485434"/>
<reference key="parent" ref="346676398"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">6004</int>
+ <reference key="object" ref="390856790"/>
+ <reference key="parent" ref="23713489"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -24158,6 +24192,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
<string>6.ImportedFromIB2</string>
<string>6000.IBPluginDependency</string>
<string>6001.IBPluginDependency</string>
+ <string>6004.IBPluginDependency</string>
<string>604.IBEditorWindowLastContentRect</string>
<string>604.IBWindowTemplateEditedContentRect</string>
<string>604.ImportedFromIB2</string>
@@ -25408,7 +25443,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{71, 99}, {175, 93}}</string>
+ <string>{{476, -4}, {175, 113}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSMutableDictionary">
@@ -25430,8 +25465,8 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{171, 147}, {944, 550}}</string>
- <string>{{171, 147}, {944, 550}}</string>
+ <string>{{467, 84}, {944, 550}}</string>
+ <string>{{467, 84}, {944, 550}}</string>
<reference ref="9"/>
<reference ref="9"/>
<string>{{62, 352}, {845, 504}}</string>
@@ -26071,6 +26106,7 @@ aGUgYWN0aXZlIHNlbGVjdGlvbiAo4oyl4oyYUik</string>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{67, 340}, {667, 416}}</string>
<string>{{67, 340}, {667, 416}}</string>
<reference ref="9"/>
@@ -26323,7 +26359,7 @@ Y2hhbmdlIHRoZSBvcmRlcg</string>
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">6003</int>
+ <int key="maxID">6006</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -27530,6 +27566,7 @@ Y2hhbmdlIHRoZSBvcmRlcg</string>
<string>copyTable:</string>
<string>removeTable:</string>
<string>renameTable:</string>
+ <string>truncateTable:</string>
<string>updateTables:</string>
</object>
<object class="NSMutableArray" key="dict.values">
@@ -27541,6 +27578,7 @@ Y2hhbmdlIHRoZSBvcmRlcg</string>
<string>id</string>
<string>id</string>
<string>id</string>
+ <string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
@@ -27575,6 +27613,7 @@ Y2hhbmdlIHRoZSBvcmRlcg</string>
<string>tableTypeButton</string>
<string>tableWindow</string>
<string>tablesListView</string>
+ <string>truncateTableButton</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -27606,6 +27645,7 @@ Y2hhbmdlIHRoZSBvcmRlcg</string>
<string>id</string>
<string>id</string>
<string>id</string>
+ <string>id</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
diff --git a/Interfaces/English.lproj/Localizable.strings b/Interfaces/English.lproj/Localizable.strings
index 5e8aaa32..50e87373 100644
--- a/Interfaces/English.lproj/Localizable.strings
+++ b/Interfaces/English.lproj/Localizable.strings
Binary files differ
diff --git a/Source/TablesList.h b/Source/TablesList.h
index 6fd86c56..574f9c18 100644
--- a/Source/TablesList.h
+++ b/Source/TablesList.h
@@ -64,6 +64,7 @@ enum sp_table_types
IBOutlet id tableRenameField;
IBOutlet id tableRenameText;
IBOutlet id renameTableButton;
+ IBOutlet id truncateTableButton;
IBOutlet NSMenuItem *removeTableMenuItem;
IBOutlet NSMenuItem *duplicateTableMenuItem;
@@ -85,12 +86,14 @@ enum sp_table_types
- (IBAction)removeTable:(id)sender;
- (IBAction)copyTable:(id)sender;
- (IBAction)renameTable:(id)sender;
+- (IBAction)truncateTable:(id)sender;
// copyTableSheet methods
- (IBAction)closeCopyTableSheet:(id)sender;
// Additional methods
- (void)removeTable;
+- (void)truncateTable;
- (void)setConnection:(CMMCPConnection *)theConnection;
- (void)doPerformQueryService:(NSString *)query;
diff --git a/Source/TablesList.m b/Source/TablesList.m
index d90f7972..98b67904 100644
--- a/Source/TablesList.m
+++ b/Source/TablesList.m
@@ -396,15 +396,9 @@
- (IBAction)copyTable:(id)sender
{
CMMCPResult *queryResult;
-// NSArray *fieldNames;
-// NSArray *theRow;
-// NSMutableString *rowValue = [NSMutableString string];
-// NSMutableArray *fieldValues;
int code;
NSString *tableType;
int tblType;
-// int rowCount, i, j;
-// BOOL errors = NO;
if ( [tablesListView numberOfSelectedRows] != 1 ) {
return;
@@ -672,6 +666,32 @@
[tableDocumentInstance name], [tableDocumentInstance database], [tableRenameField stringValue]]];
}
+/**
+ * Truncates the currently selected table(s).
+ */
+- (IBAction)truncateTable:(id)sender
+{
+ if (![tablesListView numberOfSelectedRows])
+ return;
+
+ [tableWindow endEditingFor:nil];
+
+ NSAlert *alert = [NSAlert alertWithMessageText:@"" defaultButton:NSLocalizedString(@"Truncate", @"truncate button") alternateButton:NSLocalizedString(@"Cancel", @"cancel button") otherButton:nil informativeTextWithFormat:@""];
+
+ [alert setAlertStyle:NSCriticalAlertStyle];
+
+ if ([tablesListView numberOfSelectedRows] == 1) {
+ [alert setMessageText:[NSString stringWithFormat:NSLocalizedString(@"Truncate table '%@'?", @"truncate table message"), [tables objectAtIndex:[tablesListView selectedRow]]]];
+ [alert setInformativeText:[NSString stringWithFormat:NSLocalizedString(@"Are you sure you want to truncate the table '%@'. This operation cannot be undone.", @"truncate table informative message"), [tables objectAtIndex:[tablesListView selectedRow]]]];
+ }
+ else {
+ [alert setMessageText:NSLocalizedString(@"Truncate selected tables?", @"truncate tables message")];
+ [alert setInformativeText:NSLocalizedString(@"Are you sure you want to truncate the selected tables. This operation cannot be undone.", @"truncate tables informative message")];
+ }
+
+ [alert beginSheetModalForWindow:tableWindow modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:@"truncateTable"];
+}
+
#pragma mark Alert sheet methods
/**
@@ -679,15 +699,23 @@
*/
- (void)sheetDidEnd:(NSAlert *)sheet returnCode:(int)returnCode contextInfo:(NSString *)contextInfo
{
-
- if ( [contextInfo isEqualToString:@"addRow"] ) {
+ if ([contextInfo isEqualToString:@"addRow"]) {
alertSheetOpened = NO;
- } else if ( [contextInfo isEqualToString:@"removeRow"] ) {
+ }
+ else if ([contextInfo isEqualToString:@"removeRow"]) {
[[sheet window] orderOut:nil];
- if ( returnCode == NSAlertDefaultReturn ) {
+
+ if (returnCode == NSAlertDefaultReturn) {
[self removeTable];
}
}
+ else if ([contextInfo isEqualToString:@"truncateTable"]) {
+ [[sheet window] orderOut:nil];
+
+ if (returnCode == NSAlertDefaultReturn) {
+ [self truncateTable];
+ }
+ }
}
/**
@@ -701,7 +729,7 @@
#pragma mark Additional methods
/**
- * Removes selected table(s) or view(s) from mysql-db and tableView
+ * Removes the selected table(s) or view(s) from mysql-db and tableView
*/
- (void)removeTable
{
@@ -746,11 +774,6 @@
currentIndex = [indexes indexLessThanIndex:currentIndex];
}
- //[tablesListView deselectAll:self];
-
- //[tableSourceInstance loadTable:nil];
- //[tableContentInstance loadTable:nil];
- //[tableStatusInstance loadTable:nil];
[tablesListView reloadData];
// set window title
@@ -760,18 +783,38 @@
if ( error ) {
NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil,
[NSString stringWithFormat:NSLocalizedString(@"Couldn't remove '%@'.\nMySQL said: %@", @"message of panel when an item cannot be removed"), [tables objectAtIndex:currentIndex], errorText]);
-
- /*
- NSRunAlertPanel(NSLocalizedString(@"Error", @"error"),
- [NSString stringWithFormat:NSLocalizedString(@"Couldn't remove table.\nMySQL said: %@", @"message of panel when table cannot be removed"), errorText],
- NSLocalizedString(@"OK", @"OK button"), nil, nil, nil );
- */
}
[tablesListView deselectAll:self];
}
/**
+ * Trucates the selected table(s).
+ */
+- (void)truncateTable
+{
+ NSIndexSet *indexes = [tablesListView selectedRowIndexes];
+
+ // Get last index
+ unsigned currentIndex = [indexes lastIndex];
+
+ while (currentIndex != NSNotFound)
+ {
+ [mySQLConnection queryString:[NSString stringWithFormat: @"TRUNCATE TABLE %@", [[tables objectAtIndex:currentIndex] backtickQuotedString]]];
+
+ // Couldn't truncate table
+ if (![[mySQLConnection getLastErrorMessage] isEqualTo:@""]) {
+ NSBeginAlertSheet(NSLocalizedString(@"Error truncating table", @"error truncating table message"),
+ NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil,
+ [NSString stringWithFormat:NSLocalizedString(@"An error occurred while trying to truncate the table '%@'.\n\nMySQL said: %@", @"error truncating table informative message"), [tables objectAtIndex:currentIndex], [mySQLConnection getLastErrorMessage]]);
+ }
+
+ // Get next index (beginning from the end)
+ currentIndex = [indexes indexLessThanIndex:currentIndex];
+ }
+}
+
+/**
* Sets the connection (received from TableDocument) and makes things that have to be done only once
*/
- (void)setConnection:(CMMCPConnection *)theConnection
@@ -1095,8 +1138,7 @@
* Loads a table in content or source view (if tab selected)
*/
- (void)tableViewSelectionDidChange:(NSNotification *)aNotification
-{
-
+{
if ( [tablesListView numberOfSelectedRows] == 1 && [[self tableName] length] ) {
// Reset the table information caches
@@ -1155,6 +1197,7 @@
// Set gear menu items Remove/Duplicate table/view and mainMenu > Table items
// according to the table types
NSMenu *tableSubMenu = [[[NSApp mainMenu] itemAtIndex:5] submenu];
+
if([[tableTypes objectAtIndex:[tablesListView selectedRow]] intValue] == SP_TABLETYPE_VIEW)
{
// Change mainMenu > Table > ... according to table type
@@ -1172,10 +1215,11 @@
[[tableSubMenu itemAtIndex:9] setHidden:YES]; // checksum
[renameTableMenuItem setHidden:NO]; // we don't have to check the mysql version
- [renameTableMenuItem setTitle:NSLocalizedString(@"Rename view", @"rename view menu title")];
+ [renameTableMenuItem setTitle:NSLocalizedString(@"Rename View", @"rename view menu title")];
[duplicateTableMenuItem setHidden:NO];
- [duplicateTableMenuItem setTitle:NSLocalizedString(@"Duplicate view", @"duplicate view menu title")];
- [removeTableMenuItem setTitle:NSLocalizedString(@"Remove view", @"remove view menu title")];
+ [duplicateTableMenuItem setTitle:NSLocalizedString(@"Duplicate View", @"duplicate view menu title")];
+ [truncateTableButton setHidden:YES];
+ [removeTableMenuItem setTitle:NSLocalizedString(@"Remove View", @"remove view menu title")];
}
else if([[tableTypes objectAtIndex:[tablesListView selectedRow]] intValue] == SP_TABLETYPE_TABLE) {
[[tableSubMenu itemAtIndex:0] setTitle:NSLocalizedString(@"Copy Create Table Syntax", @"copy create table syntax menu item")];
@@ -1192,10 +1236,12 @@
[[tableSubMenu itemAtIndex:9] setHidden:NO];
[renameTableMenuItem setHidden:NO];
- [renameTableMenuItem setTitle:NSLocalizedString(@"Rename table", @"rename table menu title")];
+ [renameTableMenuItem setTitle:NSLocalizedString(@"Rename Table", @"rename table menu title")];
[duplicateTableMenuItem setHidden:NO];
- [duplicateTableMenuItem setTitle:NSLocalizedString(@"Duplicate table", @"duplicate table menu title")];
- [removeTableMenuItem setTitle:NSLocalizedString(@"Remove table", @"remove table menu title")];
+ [duplicateTableMenuItem setTitle:NSLocalizedString(@"Duplicate Table", @"duplicate table menu title")];
+ [truncateTableButton setHidden:NO];
+ [truncateTableButton setTitle:NSLocalizedString(@"Truncate Table", @"truncate table menu title")];
+ [removeTableMenuItem setTitle:NSLocalizedString(@"Remove Table", @"remove table menu title")];
}
else if([[tableTypes objectAtIndex:[tablesListView selectedRow]] intValue] == SP_TABLETYPE_PROC) {
[[tableSubMenu itemAtIndex:0] setTitle:NSLocalizedString(@"Copy Create Procedure Syntax", @"copy create proc syntax menu item")];
@@ -1210,10 +1256,11 @@
[[tableSubMenu itemAtIndex:9] setHidden:YES];
[renameTableMenuItem setHidden:NO];
- [renameTableMenuItem setTitle:NSLocalizedString(@"Rename procedure", @"rename proc menu title")];
+ [renameTableMenuItem setTitle:NSLocalizedString(@"Rename Procedure", @"rename proc menu title")];
[duplicateTableMenuItem setHidden:NO];
- [duplicateTableMenuItem setTitle:NSLocalizedString(@"Duplicate procedure", @"duplicate proc menu title")];
- [removeTableMenuItem setTitle:NSLocalizedString(@"Remove procedure", @"remove proc menu title")];
+ [duplicateTableMenuItem setTitle:NSLocalizedString(@"Duplicate Procedure", @"duplicate proc menu title")];
+ [truncateTableButton setHidden:YES];
+ [removeTableMenuItem setTitle:NSLocalizedString(@"Remove Procedure", @"remove proc menu title")];
}
else if([[tableTypes objectAtIndex:[tablesListView selectedRow]] intValue] == SP_TABLETYPE_FUNC) {
[[tableSubMenu itemAtIndex:0] setTitle:NSLocalizedString(@"Copy Create Function Syntax", @"copy create func syntax menu item")];
@@ -1228,10 +1275,11 @@
[[tableSubMenu itemAtIndex:9] setHidden:YES];
[renameTableMenuItem setHidden:NO];
- [renameTableMenuItem setTitle:NSLocalizedString(@"Rename function", @"rename func menu title")];
+ [renameTableMenuItem setTitle:NSLocalizedString(@"Rename Function", @"rename func menu title")];
[duplicateTableMenuItem setHidden:NO];
- [duplicateTableMenuItem setTitle:NSLocalizedString(@"Duplicate function", @"duplicate func menu title")];
- [removeTableMenuItem setTitle:NSLocalizedString(@"Remove function", @"remove func menu title")];
+ [duplicateTableMenuItem setTitle:NSLocalizedString(@"Duplicate Function", @"duplicate func menu title")];
+ [truncateTableButton setHidden:YES];
+ [removeTableMenuItem setTitle:NSLocalizedString(@"Remove Function", @"remove func menu title")];
}
// set window title
[tableWindow setTitle:[NSString stringWithFormat:@"(MySQL %@) %@/%@/%@", [tableDocumentInstance mySQLVersion],
@@ -1270,21 +1318,22 @@
{
switch(lastType) {
case SP_TABLETYPE_TABLE:
- [removeTableMenuItem setTitle:NSLocalizedString(@"Remove tables", @"remove tables menu title")];
+ [removeTableMenuItem setTitle:NSLocalizedString(@"Remove Tables", @"remove tables menu title")];
+ [truncateTableButton setTitle:NSLocalizedString(@"Truncate Tables", @"truncate tables menu item")];
break;
case SP_TABLETYPE_VIEW:
- [removeTableMenuItem setTitle:NSLocalizedString(@"Remove views", @"remove views menu title")];
+ [removeTableMenuItem setTitle:NSLocalizedString(@"Remove Views", @"remove views menu title")];
break;
case SP_TABLETYPE_PROC:
- [removeTableMenuItem setTitle:NSLocalizedString(@"Remove procedures", @"remove procedures menu title")];
+ [removeTableMenuItem setTitle:NSLocalizedString(@"Remove Procedures", @"remove procedures menu title")];
break;
case SP_TABLETYPE_FUNC:
- [removeTableMenuItem setTitle:NSLocalizedString(@"Remove functions", @"remove functions menu title")];
+ [removeTableMenuItem setTitle:NSLocalizedString(@"Remove Functions", @"remove functions menu title")];
break;
}
} else {
- [removeTableMenuItem setTitle:NSLocalizedString(@"Remove items", @"remove items menu title")];
+ [removeTableMenuItem setTitle:NSLocalizedString(@"Remove Items", @"remove items menu title")];
}
}
[renameTableMenuItem setHidden:YES];
@@ -1393,15 +1442,15 @@
{
// popup button below table list
if ([menuItem action] == @selector(copyTable:)) {
- return ([tablesListView numberOfSelectedRows] == 1) && [[self tableName] length] && [tablesListView numberOfSelectedRows] > 0;
+ return (([tablesListView numberOfSelectedRows] == 1) && [[self tableName] length] && [tablesListView numberOfSelectedRows] > 0);
}
- if ([menuItem action] == @selector(removeTable:) ) {
- return [tablesListView numberOfSelectedRows] > 0;
+ if ([menuItem action] == @selector(removeTable:) || [menuItem action] == @selector(truncateTable:)) {
+ return ([tablesListView numberOfSelectedRows] > 0);
}
if ([menuItem action] == @selector(renameTable:)) {
- return ([tablesListView numberOfSelectedRows] == 1) && [[self tableName] length];
+ return (([tablesListView numberOfSelectedRows] == 1) && [[self tableName] length]);
}
return [super validateMenuItem:menuItem];