From be6b947b45c4e7e883c6369316feebfa01ef75c8 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Thu, 20 Aug 2009 11:16:14 +0000 Subject: =?UTF-8?q?=E2=80=A2=20Main=20Menu=20>=20File=20-=20renamed=20"Ope?= =?UTF-8?q?n"=20into=20"Open=E2=80=A6"=20plus=20tooltip=20-=20added=20"Sav?= =?UTF-8?q?e=20Query=E2=80=A6"=20(enabled=20if=20a=20query=20is=20in=20the?= =?UTF-8?q?=20editor=20and=20rename=20'Query'=20to=20'Queries'=20dynamical?= =?UTF-8?q?ly)=20[still=20hidden]=20-=20added=20"Save=20Connection?= =?UTF-8?q?=E2=80=A6"=20[still=20hidden]=20=E2=80=A2=20added=20method=20nu?= =?UTF-8?q?mberOfQueries=20to=20CustomQuery=20=E2=80=A2=20'Save=20Query?= =?UTF-8?q?=E2=80=A6"=20and=20"Save=20Connection=E2=80=A6"=20are=20bound?= =?UTF-8?q?=20to=20the=20same=20connector=20distinguished=20via=20their=20?= =?UTF-8?q?tags?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Interfaces/English.lproj/MainMenu.xib | 73 ++++++++++++++++++++++++++--------- Source/CustomQuery.h | 4 +- Source/CustomQuery.m | 7 ++++ Source/TableDocument.m | 25 ++++++++++-- 4 files changed, 87 insertions(+), 22 deletions(-) diff --git a/Interfaces/English.lproj/MainMenu.xib b/Interfaces/English.lproj/MainMenu.xib index 661d0011..bc93e9cb 100644 --- a/Interfaces/English.lproj/MainMenu.xib +++ b/Interfaces/English.lproj/MainMenu.xib @@ -8,6 +8,7 @@ 353.00 YES + YES @@ -250,23 +251,13 @@ - Open + T3BlbuKApg o 1048576 2147483647 - - - YES - Save - s - 1048576 - 2147483647 - - - YES @@ -287,6 +278,27 @@ + + + YES + U2F2ZSBRdWVyeeKApg + s + 1048576 + 2147483647 + + + + + + YES + U2F2ZSBDb25uZWN0aW9u4oCmA + S + 1048576 + 2147483647 + + + 1 + YES @@ -2583,6 +2595,14 @@ 962 + + + saveConnectionSheet: + + + + 964 + @@ -2806,8 +2826,9 @@ - + + @@ -3845,6 +3866,11 @@ + + 963 + + + @@ -4185,6 +4211,7 @@ 938.IBPluginDependency 940.IBPluginDependency 941.IBPluginDependency + 943.IBAttributePlaceholdersKey 943.IBPluginDependency 944.IBPluginDependency 950.IBPluginDependency @@ -4194,6 +4221,7 @@ 956.IBEditorWindowLastContentRect 956.IBPluginDependency 960.IBPluginDependency + 963.IBPluginDependency YES @@ -4297,7 +4325,7 @@ com.apple.InterfaceBuilder.CocoaPlugin - {{701, 300}, {213, 133}} + {{570, 390}, {213, 133}} com.apple.InterfaceBuilder.CocoaPlugin {{399, 465}, {213, 93}} @@ -4307,7 +4335,7 @@ com.apple.InterfaceBuilder.CocoaPlugin - {{914, 340}, {136, 43}} + {{783, 430}, {136, 43}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -4340,7 +4368,7 @@ com.apple.InterfaceBuilder.CocoaPlugin - {{647, 500}, {235, 203}} + {{436, 500}, {235, 203}} com.apple.InterfaceBuilder.CocoaPlugin {{698, 703}, {184, 133}} @@ -4358,7 +4386,7 @@ com.apple.InterfaceBuilder.CocoaPlugin - {{398, 340}, {218, 253}} + {{256, 450}, {218, 253}} com.apple.InterfaceBuilder.CocoaPlugin {{518, 583}, {218, 253}} @@ -4464,7 +4492,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{350, 470}, {209, 233}} + {{350, 450}, {220, 253}} com.apple.InterfaceBuilder.CocoaPlugin {{180, 535}, {182, 253}} @@ -4574,6 +4602,14 @@ w6gg4oaSIGZhY2FkZV0 com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + + ToolTip + + ToolTip + + Open a connection file (*.spf) or load a SQL file (*.sql) into the Custom Query editor + + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -4583,6 +4619,7 @@ w6gg4oaSIGZhY2FkZV0 {{767, 692}, {166, 23}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin @@ -4605,7 +4642,7 @@ w6gg4oaSIGZhY2FkZV0 - 962 + 964 diff --git a/Source/CustomQuery.h b/Source/CustomQuery.h index c5cb2a30..a874bc15 100644 --- a/Source/CustomQuery.h +++ b/Source/CustomQuery.h @@ -101,6 +101,8 @@ NSNumber *sortField; NSString *fieldIDQueryString; + + unsigned int numberOfQueries; } @@ -157,6 +159,6 @@ - (void)commentOutCurrentQueryTakingSelection:(BOOL)takeSelection; - (NSString *)usedQuery; - (NSString *)argumentForRow:(NSUInteger)rowIndex ofTable:(NSString *)tableForColumn andDatabase:(NSString *)database; - +- (unsigned int)numberOfQueries; @end diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m index 891cb38e..faa86221 100644 --- a/Source/CustomQuery.m +++ b/Source/CustomQuery.m @@ -808,6 +808,7 @@ if([[textView textStorage] editedMask] != 0) { customQueryParser = [[SPSQLParser alloc] initWithString:[textView string]]; queries = [[NSArray alloc] initWithArray:[customQueryParser splitSqlStringIntoRangesByCharacter:';']]; + numberOfQueries = [queries count]; if(currentQueryRanges) [currentQueryRanges release]; currentQueryRanges = [[NSArray arrayWithArray:queries] retain]; @@ -2531,6 +2532,12 @@ #pragma mark - #pragma mark Other + +- (unsigned int)numberOfQueries +{ + return numberOfQueries; +} + /* * This method is called as part of Key Value Observing which is used to watch for prefernce changes which effect the interface. */ diff --git a/Source/TableDocument.m b/Source/TableDocument.m index c36a2e35..341e149a 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -1734,7 +1734,7 @@ [panel setAllowsOtherFileTypes:NO]; [panel setCanSelectHiddenExtension:YES]; - if( [tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == 2 ) { + if( [sender tag] == 0 ) { // Custom Query tab is active thus save the editor's content as SQL file [panel setAccessoryView:encodingAccessoryView]; @@ -1752,13 +1752,15 @@ [encodingPopUp setEnabled:YES]; [self setupPopUp:encodingPopUp selectedEncoding:[prefs integerForKey:@"lastSqlFileEncoding"] withDefaultEntry:NO]; - } else { + } else if([sender tag] == 1){ // Save current session (open connection windows as SPF file) - [panel setMessage:NSLocalizedString(@"Save Sequel Pro session", @"Save Sequel Pro session")]; + // [panel setMessage:NSLocalizedString(@"Save Sequel Pro session", @"Save Sequel Pro session")]; [panel setAllowedFileTypes:[NSArray arrayWithObjects:@"spf", nil]]; filename = [NSString stringWithFormat:@"%@", [self name]]; + } else { + return; } [panel beginSheetForDirectory:nil @@ -1859,6 +1861,23 @@ return ([self database] != nil); } + + // Change "Save Query/Queries" menu item title dynamically + // and disable it if no query in the editor + if ([menuItem action] == @selector(saveConnectionSheet:) && [menuItem tag] == 0) { + if([customQueryInstance numberOfQueries] < 1) { + [menuItem setTitle:NSLocalizedString(@"Save Query…",@"Save Query…")]; + return NO; + } + else if([customQueryInstance numberOfQueries] == 1) + [menuItem setTitle:NSLocalizedString(@"Save Query…",@"Save Query…")]; + else + [menuItem setTitle:NSLocalizedString(@"Save Queries…",@"Save Queries…")]; + + return YES; + } + + if ([menuItem action] == @selector(exportTable:)) { return ([self database] != nil && [self table] != nil); -- cgit v1.2.3