From da1616e9c31fd922fef7ed567a28dfdd788bcb0c Mon Sep 17 00:00:00 2001 From: Bibiko Date: Sun, 7 Jun 2009 21:40:06 +0000 Subject: =?UTF-8?q?=E2=80=A2=20improved=20"Copy=20as=20SQL=20INSERT"=20(st?= =?UTF-8?q?ill=20hidden)=20=E2=80=A2=20disabled=20"Copy=20with=20Column=20?= =?UTF-8?q?Names"=20if=20Custom=20Query=20editor=20is=20active?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/CMCopyTable.h | 3 ++- Source/CMCopyTable.m | 5 +++-- Source/CMTextView.m | 9 ++++++++- Source/TableContent.m | 3 ++- 4 files changed, 15 insertions(+), 5 deletions(-) (limited to 'Source') diff --git a/Source/CMCopyTable.h b/Source/CMCopyTable.h index f31e3575..0676267d 100644 --- a/Source/CMCopyTable.h +++ b/Source/CMCopyTable.h @@ -36,6 +36,7 @@ { NSArray* columnDefinitions; + NSString* selectedTable; } @@ -91,7 +92,7 @@ - (NSString *)selectedRowsAsSqlInserts; -- (void)setColumnDefinitions:(NSArray *)columnDefs; +- (void)setTableInfoWithColumns:(NSArray *)columnDefs withTable:(NSString *)aTable; @end diff --git a/Source/CMCopyTable.m b/Source/CMCopyTable.m index ed1e5439..7bb66da7 100644 --- a/Source/CMCopyTable.m +++ b/Source/CMCopyTable.m @@ -189,7 +189,7 @@ int MENU_EDIT_COPY_AS_SQL = 2002; } [result appendString:[NSString stringWithFormat:@"INSERT INTO `%@` (%@)\nVALUES\n", - @"", [tbHeader componentsJoinedAndBacktickQuoted]]]; + (selectedTable == nil)?@"
":selectedTable, [tbHeader componentsJoinedAndBacktickQuoted]]]; int c; id rowData = nil; @@ -310,9 +310,10 @@ int MENU_EDIT_COPY_AS_SQL = 2002; } } -- (void)setColumnDefinitions:(NSArray *)columnDefs +- (void)setTableInfoWithColumns:(NSArray *)columnDefs withTable:(NSString *)aTable { columnDefinitions = [[NSArray arrayWithArray:columnDefs] retain]; + selectedTable = aTable; } @end diff --git a/Source/CMTextView.m b/Source/CMTextView.m index d15a9f5b..ddb26f32 100644 --- a/Source/CMTextView.m +++ b/Source/CMTextView.m @@ -2382,7 +2382,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) long stringSize = [self getRangeForCurrentWord].length; return (stringSize || stringSize > 64); } - // Enable Copy as RTF if soemthing is selected + // Enable Copy as RTF if something is selected if ([menuItem action] == @selector(copyAsRTF)) { return ([self selectedRange].length>0); } @@ -2390,6 +2390,13 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) if ([menuItem action] == @selector(selectCurrentQuery)) { return ([self isEditable]); } + // Disable "Copy with Column Names" and "Copy as SQL INSERT" + // in the main menu + if ( [menuItem tag] == MENU_EDIT_COPY_WITH_COLUMN + || [menuItem tag] == MENU_EDIT_COPY_AS_SQL ) { + return NO; + } + return YES; } diff --git a/Source/TableContent.m b/Source/TableContent.m index a5e17db4..7c548307 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -154,7 +154,8 @@ theColumns = [tableDataInstance columns]; columnNames = [tableDataInstance columnNames]; - [tableContentView setColumnDefinitions:theColumns]; + // Init copyTable with necessary information for copying selected rows as SQL INSERT + [tableContentView setTableInfoWithColumns:theColumns withTable:selectedTable]; // Retrieve the total number of rows of the current table // to adjustify "Limit From:" -- cgit v1.2.3