aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CustomQuery.h4
-rw-r--r--Source/CustomQuery.m7
-rw-r--r--Source/TableDocument.m25
3 files changed, 32 insertions, 4 deletions
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);