aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2009-05-17 20:04:00 +0000
committerstuconnolly <stuart02@gmail.com>2009-05-17 20:04:00 +0000
commit769f2adb4e72667e855b2a63d298d711d16e0185 (patch)
tree42a6ddf98ad3a7d19f496f88f88990fb94aaff47 /Source
parentc4ca14a1ba9c6ec7f1f63f5f23208b31560ecd36 (diff)
downloadsequelpro-769f2adb4e72667e855b2a63d298d711d16e0185.tar.gz
sequelpro-769f2adb4e72667e855b2a63d298d711d16e0185.tar.bz2
sequelpro-769f2adb4e72667e855b2a63d298d711d16e0185.zip
Minor enhancements to the server variables sheet, including:
- Allow saving the variables to a file in MySQLs config format. - Truncate variable names and values instead of clipping them. Expect live filtering as future enhancements.
Diffstat (limited to 'Source')
-rw-r--r--Source/TableDocument.h4
-rw-r--r--Source/TableDocument.m34
2 files changed, 35 insertions, 3 deletions
diff --git a/Source/TableDocument.h b/Source/TableDocument.h
index b24977f5..7f7c2297 100644
--- a/Source/TableDocument.h
+++ b/Source/TableDocument.h
@@ -123,9 +123,6 @@
- (NSString *)getHTMLforPrint;
-//alert sheets method
-- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(NSString *)contextInfo;
-
//connection getter
- (CMMCPConnection *)sharedConnection;
@@ -136,6 +133,7 @@
- (IBAction)closeDatabaseSheet:(id)sender;
- (IBAction)removeDatabase:(id)sender;
- (IBAction)showMySQLHelp:(id)sender;
+- (IBAction)saveServerVariables:(id)sender;
//encoding methods
- (void)setConnectionEncoding:(NSString *)mysqlEncoding reloadingViews:(BOOL)reloadViews;
diff --git a/Source/TableDocument.m b/Source/TableDocument.m
index 80aac913..1af4043b 100644
--- a/Source/TableDocument.m
+++ b/Source/TableDocument.m
@@ -1512,6 +1512,21 @@ NSString *TableDocumentFavoritesControllerSelectionIndexDidChange = @"TableDocum
[[customQueryInstance helpWebViewWindow] makeKeyWindow];
}
+/**
+ * Saves the server variables to the selected file.
+ */
+- (IBAction)saveServerVariables:(id)sender
+{
+ NSSavePanel *panel = [NSSavePanel savePanel];
+
+ [panel setRequiredFileType:@"cnf"];
+
+ [panel setExtensionHidden:NO];
+ [panel setAllowsOtherFileTypes:YES];
+ [panel setCanSelectHiddenExtension:YES];
+
+ [panel beginSheetForDirectory:nil file:@"Variables" modalForWindow:variablesSheet modalDelegate:self didEndSelector:@selector(savePanelDidEnd:returnCode:contextInfo:) contextInfo:NULL];
+}
/**
* Menu validation
@@ -1661,6 +1676,25 @@ NSString *TableDocumentFavoritesControllerSelectionIndexDidChange = @"TableDocum
[self connectSheetAddToFavorites:self];
}
+/**
+ * Called when the NSSavePanel sheet ends. Writes the server variables to the selected file if required.
+ */
+- (void)savePanelDidEnd:(NSSavePanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
+{
+ if (returnCode == NSOKButton) {
+ if (variables) {
+ NSMutableString *variablesString = [NSMutableString stringWithFormat:@"# MySQL server variables for %@\n\n", [self host]];
+
+ for (NSDictionary *variable in variables)
+ {
+ [variablesString appendString:[NSString stringWithFormat:@"%@ = %@\n", [variable objectForKey:@"Variable_name"], [variable objectForKey:@"Value"]]];
+ }
+
+ [variablesString writeToFile:[sheet filename] atomically:YES encoding:NSUTF8StringEncoding error:NULL];
+ }
+ }
+}
+
#pragma mark Toolbar Methods
/**