aboutsummaryrefslogtreecommitdiffstats
path: root/Source/TableDocument.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-08-21 13:01:46 +0000
committerBibiko <bibiko@eva.mpg.de>2009-08-21 13:01:46 +0000
commitabbd5a52c00538ef93f4222a3e2489ee5e4c23aa (patch)
tree1520555ae7c9761c9dd2e059d5098e94c7f7b34e /Source/TableDocument.m
parent68bbc4aae63e38eae25236c80dbc08896537755e (diff)
downloadsequelpro-abbd5a52c00538ef93f4222a3e2489ee5e4c23aa.tar.gz
sequelpro-abbd5a52c00538ef93f4222a3e2489ee5e4c23aa.tar.bz2
sequelpro-abbd5a52c00538ef93f4222a3e2489ee5e4c23aa.zip
• first preparations to save the current connection window as SPF file
• added to TableContent's method filterSettings the dict key 'filterComparisonTag' in order to be able to rely on menu item tags instead on the title strings
Diffstat (limited to 'Source/TableDocument.m')
-rw-r--r--Source/TableDocument.m70
1 files changed, 69 insertions, 1 deletions
diff --git a/Source/TableDocument.m b/Source/TableDocument.m
index ea1b418a..3abd32aa 100644
--- a/Source/TableDocument.m
+++ b/Source/TableDocument.m
@@ -1806,7 +1806,75 @@
return;
}
else if(contextInfo == @"saveSPFfile") {
- NSLog(@"Save SPF file");
+
+ NSMutableDictionary *spf = [NSMutableDictionary dictionary];
+
+ NSIndexSet *contentSelectedIndexSet = [tableContentInstance selectedRowIndexes];
+ NSIndexSet *customQuerySelectedIndexSet = [[customQueryInstance valueForKeyPath:@"customQueryView"] selectedRowIndexes];
+
+ [spf setObject:[NSNumber numberWithInt:1] forKey:@"version"];
+
+ [spf setObject:[self name] forKey:@"name"];
+ [spf setObject:[self host] forKey:@"host"];
+ [spf setObject:[self user] forKey:@"user"];
+
+ [spf setObject:[NSNumber numberWithInt:[connectionController type]] forKey:@"connectionType"];
+ if([connectionController type] == 2) {
+ [spf setObject:[connectionController sshHost] forKey:@"sshHost"];
+ [spf setObject:[connectionController sshUser] forKey:@"sshUser"];
+ [spf setObject:[connectionController sshPort] forKey:@"sshPort"];
+ }
+
+ if([connectionController port] &&[[connectionController port] length])
+ [spf setObject:[connectionController port] forKey:@"port"];
+
+ if([[self database] length])
+ [spf setObject:[self database] forKey:@"selectedDatabase"];
+ if([[self table] length])
+ [spf setObject:[self table] forKey:@"selectedTable"];
+ if([tableContentInstance sortColumnName])
+ [spf setObject:[tableContentInstance sortColumnName] forKey:@"contentSortCol"];
+
+ [spf setObject:[NSNumber numberWithInt:[spHistoryControllerInstance currentlySelectedView]] forKey:@"view"];
+ [spf setObject:[NSNumber numberWithBool:[tableContentInstance sortColumnIsAscending]] forKey:@"contentSortColIsAsc"];
+ [spf setObject:[NSNumber numberWithInt:[tableContentInstance limitStart]] forKey:@"contentLimitStartPosition"];
+ [spf setObject:NSStringFromRect([tableContentInstance viewport]) forKey:@"contentViewport"];
+ if([tableContentInstance filterSettings])
+ [spf setObject:[tableContentInstance filterSettings] forKey:@"contentFilter"];
+
+ if([[[[customQueryInstance valueForKeyPath:@"textView"] textStorage] string] length])
+ [spf setObject:[[[customQueryInstance valueForKeyPath:@"textView"] textStorage] string] forKey:@"queries"];
+
+ if (contentSelectedIndexSet && [contentSelectedIndexSet count])
+ [spf setObject:contentSelectedIndexSet forKey:@"contentSelectedIndexSet"];
+ if (customQuerySelectedIndexSet && [customQuerySelectedIndexSet count])
+ [spf setObject:customQuerySelectedIndexSet forKey:@"customQuerySelectedIndexSet"];
+
+ NSString *err = nil;
+ NSData *plist = [NSPropertyListSerialization dataFromPropertyList:spf
+ format:NSPropertyListBinaryFormat_v1_0
+ errorDescription:&err];
+
+ if(err != nil) {
+ NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Error while converting connection data", @"error while converting connection data")]
+ defaultButton:NSLocalizedString(@"OK", @"OK button")
+ alternateButton:nil
+ otherButton:nil
+ informativeTextWithFormat:err];
+
+ [alert setAlertStyle:NSCriticalAlertStyle];
+ [alert runModal];
+ return;
+ }
+
+ NSError *error = nil;
+ [plist writeToFile:fileName options:NSAtomicWrite error:&error];
+ if(error != nil){
+ NSAlert *errorAlert = [NSAlert alertWithError:error];
+ [errorAlert runModal];
+ return;
+ }
+
return;
}
}