From c6c669073c9b92f037d59b5d3ee7aa2b17f520fa Mon Sep 17 00:00:00 2001 From: Bibiko Date: Tue, 25 Aug 2009 13:02:58 +0000 Subject: =?UTF-8?q?=E2=80=A2=20outsourced=20Save=20SPF=20accessory=20xib?= =?UTF-8?q?=20=E2=80=A2=20updated=20save=20SPF=20accessory=20xib=20due=20t?= =?UTF-8?q?o=20SPF=20structure=20changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NOTES: - The view in DBView.xib will be deleted after stuart02's commit. - Still after clicking at the encrypt text field a warning will be shown in the Console: NSSecureTextFieldCell detected a field editor that is not a NSTextView subclass... WHY? --- Source/TableDocument.h | 2 ++ Source/TableDocument.m | 62 ++++++++++++++++++++++++-------------------------- 2 files changed, 32 insertions(+), 32 deletions(-) (limited to 'Source') diff --git a/Source/TableDocument.h b/Source/TableDocument.h index 04dfe8f8..3c890a40 100644 --- a/Source/TableDocument.h +++ b/Source/TableDocument.h @@ -94,7 +94,9 @@ IBOutlet id saveConnectionAccessory; IBOutlet id saveConnectionIncludeData; + IBOutlet id saveConnectionIncludeQuery; IBOutlet id saveConnectionSavePassword; + IBOutlet id saveConnectionSavePasswordAlert; IBOutlet id saveConnectionEncrypt; IBOutlet id saveConnectionAutoConnect; IBOutlet NSSecureTextField *saveConnectionEncryptString; diff --git a/Source/TableDocument.m b/Source/TableDocument.m index b89d6fe3..7f64fcc0 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -55,6 +55,7 @@ #import "MGTemplateEngine.h" #import "ICUTemplateMatcher.h" + @interface TableDocument (PrivateAPI) - (void)_updateServerVariablesFilterForFilterString:(NSString *)filterString; @@ -1900,12 +1901,17 @@ // [panel setMessage:NSLocalizedString(@"Save Sequel Pro session", @"Save Sequel Pro session")]; [panel setAllowedFileTypes:[NSArray arrayWithObjects:@"spf", nil]]; // [saveConnectionEncryptString setDelegate:self]; - [saveConnectionEncryptString setEnabled:YES]; - [saveConnectionEncryptString selectText:self]; + + // Load the accessory view everytime + if (![NSBundle loadNibNamed:@"SaveSPFAccessory" owner:self]) { + NSLog(@"Failed to load SaveSPFAccessory.nib"); + return; + } [saveConnectionEncryptString setStringValue:@""]; - [saveConnectionEncryptString setEnabled:NO]; - [saveConnectionSavePassword setState:NSOffState]; + [saveConnectionIncludeQuery setEnabled:([[[[customQueryInstance valueForKeyPath:@"textView"] textStorage] string] length])]; + [self saveConnectionAccessoryPasswordButton:nil]; + [panel setAccessoryView:saveConnectionAccessory]; filename = [NSString stringWithFormat:@"%@", [self name]]; contextInfo = @"saveSPFfile"; @@ -1922,35 +1928,21 @@ contextInfo:contextInfo]; } /** - * Control the save connection panel's encrypt checkbox and text field - • if user changed the status of "Save passwords" and "Encrypt" resp. + * Control the save connection panel's accessory view */ - (IBAction)saveConnectionAccessoryPasswordButton:(id)sender { - if([saveConnectionSavePassword state] == NSOnState) { - [saveConnectionEncrypt setEnabled:YES]; - if([saveConnectionEncrypt state] == NSOnState) { - [saveConnectionEncryptString setEnabled:YES]; - [saveConnectionEncryptString selectText:self]; - } else { - [saveConnectionEncryptString setEnabled:YES]; - [saveConnectionEncryptString selectText:self]; - [saveConnectionEncryptString setStringValue:@""]; - [saveConnectionEncryptString setHidden:YES]; - [saveConnectionEncryptString setHidden:NO]; - [saveConnectionEncryptString setEnabled:NO]; - } - } else { - [saveConnectionEncrypt setEnabled:NO]; - [saveConnectionEncryptString setEnabled:YES]; - [saveConnectionEncryptString selectText:self]; - [saveConnectionEncryptString setStringValue:@""]; + [saveConnectionAutoConnect setEnabled:([saveConnectionSavePassword state] == NSOnState)]; + [saveConnectionSavePasswordAlert setHidden:([saveConnectionSavePassword state] == NSOffState)]; + if(sender == saveConnectionEncrypt && [saveConnectionEncrypt state] == NSOnState) + [saveConnectionEncryptString selectText:sender]; + if(sender == saveConnectionEncrypt && [saveConnectionEncrypt state] == NSOffState) { [saveConnectionEncryptString setHidden:YES]; [saveConnectionEncryptString setHidden:NO]; - [saveConnectionEncryptString setEnabled:NO]; } - + + } - (void)saveConnectionPanelDidEnd:(NSSavePanel *)panel returnCode:(int)returnCode contextInfo:(void *)contextInfo @@ -2087,11 +2079,6 @@ if([tableContentInstance filterSettings]) [session setObject:[tableContentInstance filterSettings] forKey:@"contentFilter"]; - if([[[[customQueryInstance valueForKeyPath:@"textView"] textStorage] string] length]) - if([[[[customQueryInstance valueForKeyPath:@"textView"] textStorage] string] length] > 50000) - [session setObject:[[[[[customQueryInstance valueForKeyPath:@"textView"] textStorage] string] dataUsingEncoding:NSUTF8StringEncoding] compress] forKey:@"queries"]; - else - [session setObject:[[[customQueryInstance valueForKeyPath:@"textView"] textStorage] string] forKey:@"queries"]; if (contentSelectedIndexSet && [contentSelectedIndexSet count]) { NSMutableArray *indices = [NSMutableArray array]; unsigned indexBuffer[[contentSelectedIndexSet count]]; @@ -2103,7 +2090,18 @@ [session setObject:indices forKey:@"contentSelectedIndexSet"]; } } - + + if([[[[customQueryInstance valueForKeyPath:@"textView"] textStorage] string] length] + && [saveConnectionIncludeQuery state] == NSOnState) { + + if(session == nil) + session = [NSMutableDictionary dictionary]; + + if([[[[customQueryInstance valueForKeyPath:@"textView"] textStorage] string] length] > 50000) + [session setObject:[[[[[customQueryInstance valueForKeyPath:@"textView"] textStorage] string] dataUsingEncoding:NSUTF8StringEncoding] compress] forKey:@"queries"]; + else + [session setObject:[[[customQueryInstance valueForKeyPath:@"textView"] textStorage] string] forKey:@"queries"]; + } [data setObject:connection forKey:@"connection"]; if(session != nil) -- cgit v1.2.3