aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Interfaces/English.lproj/DBView.xib227
-rw-r--r--Interfaces/English.lproj/MainMenu.xib4
-rw-r--r--Source/MainController.m2
-rw-r--r--Source/TableDocument.h10
-rw-r--r--Source/TableDocument.m135
5 files changed, 364 insertions, 14 deletions
diff --git a/Interfaces/English.lproj/DBView.xib b/Interfaces/English.lproj/DBView.xib
index e3bddb97..6dec45a9 100644
--- a/Interfaces/English.lproj/DBView.xib
+++ b/Interfaces/English.lproj/DBView.xib
@@ -8,8 +8,6 @@
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="6277"/>
- <integer value="835"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -48,7 +46,7 @@
<string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string>
<string key="NSWindowContentMinSize">{780, 480}</string>
<object class="NSView" key="NSWindowView" id="579726586">
- <reference key="NSNextResponder"/>
+ <nil key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -4551,7 +4549,6 @@
</object>
</object>
<string key="NSFrameSize">{944, 550}</string>
- <reference key="NSSuperview"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
<string key="NSMinSize">{780, 502}</string>
@@ -7330,7 +7327,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
<string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string>
<string key="NSWindowContentMinSize">{300, 200}</string>
<object class="NSView" key="NSWindowView" id="226131408">
- <reference key="NSNextResponder"/>
+ <nil key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -7609,7 +7606,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
</object>
</object>
<string key="NSFrameSize">{411, 341}</string>
- <reference key="NSSuperview"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
<string key="NSMinSize">{300, 222}</string>
@@ -11101,6 +11097,102 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
<string key="NSFrameSize">{269, 32}</string>
<string key="NSClassName">NSView</string>
</object>
+ <object class="NSCustomView" id="1012120233">
+ <reference key="NSNextResponder"/>
+ <int key="NSvFlags">268</int>
+ <object class="NSMutableArray" key="NSSubviews">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSTextField" id="561637557">
+ <reference key="NSNextResponder" ref="1012120233"/>
+ <int key="NSvFlags">268</int>
+ <string key="NSFrame">{{6, 10}, {180, 14}}</string>
+ <reference key="NSSuperview" ref="1012120233"/>
+ <reference key="NSWindow"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="176323924">
+ <int key="NSCellFlags">68288064</int>
+ <int key="NSCellFlags2">272761856</int>
+ <string key="NSContents">File Encoding:</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="561637557"/>
+ <reference key="NSBackgroundColor" ref="62854682"/>
+ <reference key="NSTextColor" ref="454249633"/>
+ </object>
+ </object>
+ <object class="NSPopUpButton" id="262386526">
+ <reference key="NSNextResponder" ref="1012120233"/>
+ <int key="NSvFlags">268</int>
+ <string key="NSFrame">{{84, 5}, {180, 22}}</string>
+ <reference key="NSSuperview" ref="1012120233"/>
+ <reference key="NSWindow"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSPopUpButtonCell" key="NSCell" id="169419191">
+ <int key="NSCellFlags">-1539178944</int>
+ <int key="NSCellFlags2">133120</int>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="262386526"/>
+ <int key="NSButtonFlags">109199615</int>
+ <int key="NSButtonFlags2">129</int>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">400</int>
+ <int key="NSPeriodicInterval">75</int>
+ <object class="NSMenuItem" key="NSMenuItem" id="704879172">
+ <reference key="NSMenu" ref="597592082"/>
+ <string key="NSTitle">Item 1</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <int key="NSState">1</int>
+ <reference key="NSOnImage" ref="450876295"/>
+ <reference key="NSMixedImage" ref="414351669"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <reference key="NSTarget" ref="169419191"/>
+ </object>
+ <bool key="NSMenuItemRespectAlignment">YES</bool>
+ <object class="NSMenu" key="NSMenu" id="597592082">
+ <string key="NSTitle">OtherViews</string>
+ <object class="NSMutableArray" key="NSMenuItems">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="704879172"/>
+ <object class="NSMenuItem" id="498019985">
+ <reference key="NSMenu" ref="597592082"/>
+ <string key="NSTitle">Item 2</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="450876295"/>
+ <reference key="NSMixedImage" ref="414351669"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <int key="NSTag">1</int>
+ <reference key="NSTarget" ref="169419191"/>
+ </object>
+ <object class="NSMenuItem" id="384926559">
+ <reference key="NSMenu" ref="597592082"/>
+ <string key="NSTitle">Item 3</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="450876295"/>
+ <reference key="NSMixedImage" ref="414351669"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <int key="NSTag">2</int>
+ <reference key="NSTarget" ref="169419191"/>
+ </object>
+ </object>
+ </object>
+ <int key="NSPreferredEdge">1</int>
+ <bool key="NSUsesItemFromMenu">YES</bool>
+ <bool key="NSAltersState">YES</bool>
+ <int key="NSArrowPosition">2</int>
+ </object>
+ </object>
+ </object>
+ <string key="NSFrameSize">{271, 34}</string>
+ <reference key="NSSuperview"/>
+ <reference key="NSWindow"/>
+ <string key="NSClassName">NSView</string>
+ </object>
<object class="NSCustomView" id="730777562">
<nil key="NSNextResponder"/>
<int key="NSvFlags">265</int>
@@ -14729,6 +14821,22 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
</object>
<int key="connectionID">6323</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">encodingAccessoryView</string>
+ <reference key="source" ref="427689665"/>
+ <reference key="destination" ref="1012120233"/>
+ </object>
+ <int key="connectionID">6331</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">encodingPopUp</string>
+ <reference key="source" ref="427689665"/>
+ <reference key="destination" ref="262386526"/>
+ </object>
+ <int key="connectionID">6338</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -20768,6 +20876,75 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
<reference key="object" ref="164220113"/>
<reference key="parent" ref="168035361"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">6325</int>
+ <reference key="object" ref="1012120233"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="561637557"/>
+ <reference ref="262386526"/>
+ </object>
+ <reference key="parent" ref="1043842561"/>
+ <string key="objectName">Encoding Accessory</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">6328</int>
+ <reference key="object" ref="561637557"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="176323924"/>
+ </object>
+ <reference key="parent" ref="1012120233"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">6329</int>
+ <reference key="object" ref="176323924"/>
+ <reference key="parent" ref="561637557"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">6332</int>
+ <reference key="object" ref="262386526"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="169419191"/>
+ </object>
+ <reference key="parent" ref="1012120233"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">6333</int>
+ <reference key="object" ref="169419191"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="597592082"/>
+ </object>
+ <reference key="parent" ref="262386526"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">6334</int>
+ <reference key="object" ref="597592082"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="704879172"/>
+ <reference ref="498019985"/>
+ <reference ref="384926559"/>
+ </object>
+ <reference key="parent" ref="169419191"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">6335</int>
+ <reference key="object" ref="704879172"/>
+ <reference key="parent" ref="597592082"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">6336</int>
+ <reference key="object" ref="498019985"/>
+ <reference key="parent" ref="597592082"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">6337</int>
+ <reference key="object" ref="384926559"/>
+ <reference key="parent" ref="597592082"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -22008,6 +22185,17 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
<string>6305.IBPluginDependency</string>
<string>6317.IBPluginDependency</string>
<string>6318.IBPluginDependency</string>
+ <string>6325.IBEditorWindowLastContentRect</string>
+ <string>6325.IBPluginDependency</string>
+ <string>6328.IBPluginDependency</string>
+ <string>6329.IBPluginDependency</string>
+ <string>6332.IBPluginDependency</string>
+ <string>6333.IBPluginDependency</string>
+ <string>6334.IBEditorWindowLastContentRect</string>
+ <string>6334.IBPluginDependency</string>
+ <string>6335.IBPluginDependency</string>
+ <string>6336.IBPluginDependency</string>
+ <string>6337.IBPluginDependency</string>
<string>654.IBPluginDependency</string>
<string>654.ImportedFromIB2</string>
<string>655.IBPluginDependency</string>
@@ -23036,9 +23224,9 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{147, -321}, {944, 550}}</string>
+ <string>{{259, 86}, {944, 550}}</string>
<boolean value="NO"/>
- <string>{{147, -321}, {944, 550}}</string>
+ <string>{{259, 86}, {944, 550}}</string>
<reference ref="9"/>
<reference ref="9"/>
<string>{{62, 352}, {845, 504}}</string>
@@ -23795,6 +23983,17 @@ aGUgYWN0aXZlIHNlbGVjdGlvbiAo4oyl4oyYUik</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>{{736, 891}, {271, 34}}</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>{{769, 837}, {180, 54}}</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -23895,7 +24094,7 @@ Y2hhbmdlIHRoZSBvcmRlcg</string>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
- <string>{{160, 280}, {457, 149}}</string>
+ <string>{{193, 780}, {457, 149}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -24015,7 +24214,7 @@ Y2hhbmdlIHRoZSBvcmRlcg</string>
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">6323</int>
+ <int key="maxID">6338</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -25324,9 +25523,11 @@ Y2hhbmdlIHRoZSBvcmRlcg</string>
<string>flushPrivileges:</string>
<string>flushTable:</string>
<string>import:</string>
+ <string>openConnectionSheet:</string>
<string>optimizeTable:</string>
<string>removeDatabase:</string>
<string>repairTable:</string>
+ <string>saveConnectionSheet:</string>
<string>saveServerVariables:</string>
<string>setDatabases:</string>
<string>showCreateTableSyntax:</string>
@@ -25370,6 +25571,8 @@ Y2hhbmdlIHRoZSBvcmRlcg</string>
<string>id</string>
<string>id</string>
<string>id</string>
+ <string>id</string>
+ <string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
@@ -25388,6 +25591,8 @@ Y2hhbmdlIHRoZSBvcmRlcg</string>
<string>databaseNameField</string>
<string>databaseSheet</string>
<string>dbTablesTableView</string>
+ <string>encodingAccessoryView</string>
+ <string>encodingPopUp</string>
<string>extendedTableInfoInstance</string>
<string>favoritesButton</string>
<string>historyControl</string>
@@ -25434,6 +25639,8 @@ Y2hhbmdlIHRoZSBvcmRlcg</string>
<string>id</string>
<string>id</string>
<string>id</string>
+ <string>id</string>
+ <string>id</string>
<string>NSSearchField</string>
<string>id</string>
<string>NSButton</string>
diff --git a/Interfaces/English.lproj/MainMenu.xib b/Interfaces/English.lproj/MainMenu.xib
index 1380f3b9..c19968a2 100644
--- a/Interfaces/English.lproj/MainMenu.xib
+++ b/Interfaces/English.lproj/MainMenu.xib
@@ -242,7 +242,7 @@
<object class="NSMenuItem" id="849728981">
<reference key="NSMenu" ref="709725194"/>
<bool key="NSIsHidden">YES</bool>
- <string key="NSTitle">Open Connection</string>
+ <string key="NSTitle">Open</string>
<string key="NSKeyEquiv">o</string>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
@@ -4355,7 +4355,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{270, 486}, {212, 233}}</string>
+ <string>{{270, 486}, {209, 233}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{180, 535}, {182, 253}}</string>
diff --git a/Source/MainController.m b/Source/MainController.m
index 17aa2652..1cdc0244 100644
--- a/Source/MainController.m
+++ b/Source/MainController.m
@@ -77,6 +77,8 @@
// Pass query to the Query editor of the current document
[[[NSDocumentController sharedDocumentController] currentDocument] doPerformLoadQueryService:[self contentOfFile:filename]];
+
+ break; // open only the first SQL file
}
else if([[[filename pathExtension] lowercaseString] isEqualToString:@"spf"]) {
diff --git a/Source/TableDocument.h b/Source/TableDocument.h
index 4cf4e369..a89a4a69 100644
--- a/Source/TableDocument.h
+++ b/Source/TableDocument.h
@@ -29,6 +29,11 @@
#import <MCPKit/MCPKit.h>
#import <WebKit/WebKit.h>
+enum {
+ NoStringEncoding = 0xFFFFFFFF
+};
+
+
@class SPConnectionController;
/**
@@ -79,6 +84,9 @@
IBOutlet NSSplitView *contentViewSplitter;
IBOutlet id sidebarGrabber;
+ IBOutlet NSPopUpButton *encodingPopUp;
+ IBOutlet id encodingAccessoryView;
+
IBOutlet NSTextView *customQueryTextView;
IBOutlet NSTableView *dbTablesTableView;
@@ -113,6 +121,8 @@
NSMutableArray *allDatabases;
NSString *queryEditorInitString;
+
+ NSArray *encodings;
}
- (NSString *)getHTMLforPrint;
diff --git a/Source/TableDocument.m b/Source/TableDocument.m
index 6978428d..3faa9f94 100644
--- a/Source/TableDocument.m
+++ b/Source/TableDocument.m
@@ -1516,6 +1516,111 @@
#pragma mark Menu methods
/**
+ * Returns the actual enabled list of encodings for open/save SQL files.
+ */
+- (NSArray *)enabledEncodings
+{
+ static const NSInteger plainTextFileStringEncodingsSupported[] = {
+ kCFStringEncodingUTF8,
+ kCFStringEncodingUTF16,
+ kCFStringEncodingUTF16BE,
+ kCFStringEncodingUTF16LE,
+ kCFStringEncodingUTF32,
+ kCFStringEncodingWindowsLatin1,
+ kCFStringEncodingISOLatin1,
+ kCFStringEncodingWindowsLatin2,
+ kCFStringEncodingISOLatin2,
+ kCFStringEncodingISOLatin3,
+ kCFStringEncodingISOLatin4,
+ kCFStringEncodingWindowsLatin5,
+ kCFStringEncodingKOI8_R,
+ kCFStringEncodingKOI8_U,
+ kCFStringEncodingMacRoman,
+ kCFStringEncodingMacJapanese,
+ kCFStringEncodingShiftJIS,
+ kCFStringEncodingEUC_JP,
+ kCFStringEncodingISO_2022_JP,
+ kCFStringEncodingMacChineseTrad,
+ kCFStringEncodingMacChineseSimp,
+ kCFStringEncodingBig5,
+ kCFStringEncodingGB_18030_2000,
+ kCFStringEncodingEUC_CN,
+ kCFStringEncodingEUC_TW,
+ kCFStringEncodingMacKorean,
+ kCFStringEncodingEUC_KR,
+ -1
+ };
+ if (encodings == nil) {
+ NSMutableArray *encs = [[[NSUserDefaults standardUserDefaults] arrayForKey:@"Encodings"] mutableCopy];
+ if (encs == nil) {
+ NSStringEncoding defaultEncoding = [NSString defaultCStringEncoding];
+ NSStringEncoding encoding;
+ BOOL hasDefault = NO;
+ NSInteger cnt = 0;
+ encs = [[NSMutableArray alloc] init];
+ while (plainTextFileStringEncodingsSupported[cnt] != -1) {
+ if ((encoding = CFStringConvertEncodingToNSStringEncoding(plainTextFileStringEncodingsSupported[cnt++])) != kCFStringEncodingInvalidId) {
+ [encs addObject:[NSNumber numberWithUnsignedInteger:encoding]];
+ if (encoding == defaultEncoding) hasDefault = YES;
+ }
+ }
+ if (!hasDefault) [encs addObject:[NSNumber numberWithUnsignedInteger:defaultEncoding]];
+ }
+ encodings = encs;
+ }
+ return encodings;
+}
+
+/**
+ * This method initializes the provided popup with list of encodings;
+ * it also sets up the selected encoding as indicated and if includeDefaultItem is YES,
+ * includes an initial item for selecting "Automatic" choice.
+ * These non-encoding items all have NoStringEncoding as their tags.
+ * Otherwise the tags are set to the NSStringEncoding value for the encoding.
+ */
+- (void)setupPopUp:(NSPopUpButton *)popup selectedEncoding:(NSUInteger)selectedEncoding withDefaultEntry:(BOOL)includeDefaultItem
+{
+ NSArray *encs = [self enabledEncodings];
+ NSUInteger cnt, numEncodings, itemToSelect = 0;
+
+ // Put the encodings in the popup
+ [popup removeAllItems];
+
+ // Put the initial "Automatic" item, if desired
+ if (includeDefaultItem) {
+ [popup addItemWithTitle:NSLocalizedString(@"Automatic", @"Encoding popup entry indicating automatic choice of encoding")];
+ [[popup itemAtIndex:0] setTag:NoStringEncoding];
+ }
+
+ // Make sure the initial selected encoding appears in the list
+ if (!includeDefaultItem && (selectedEncoding != NoStringEncoding) && ![encs containsObject:[NSNumber numberWithUnsignedInteger:selectedEncoding]]) encs = [encs arrayByAddingObject:[NSNumber numberWithUnsignedInteger:selectedEncoding]];
+
+ numEncodings = [encs count];
+
+ // Fill with encodings
+ for (cnt = 0; cnt < numEncodings; cnt++) {
+ NSStringEncoding enc = [[encs objectAtIndex:cnt] unsignedIntegerValue];
+ [popup addItemWithTitle:[NSString localizedNameOfStringEncoding:enc]];
+ [[popup lastItem] setTag:enc];
+ [[popup lastItem] setEnabled:YES];
+ if (enc == selectedEncoding) itemToSelect = [popup numberOfItems] - 1;
+ }
+
+ // Add an optional separator and "customize" item at end
+ // if ([popup numberOfItems] > 0) {
+ // [[popup menu] addItem:[NSMenuItem separatorItem]];
+ // [[popup lastItem] setTag:NoStringEncoding];
+ // }
+ // [popup addItemWithTitle:NSLocalizedString(@"Customize Encodings List\\U2026", @"Encoding popup entry for bringing up the Customize Encodings List panel (this also occurs as the title of the panel itself, they should have the same localization)")];
+ // [[popup lastItem] setAction:@selector(showPanel:)];
+ // [[popup lastItem] setTarget:self];
+ // [[popup lastItem] setTag:NoStringEncoding];
+
+ [popup selectItemAtIndex:itemToSelect];
+}
+
+
+/**
* Opens connection file(s)
*/
- (IBAction)openConnectionSheet:(id)sender
@@ -1523,13 +1628,20 @@
NSOpenPanel *panel = [NSOpenPanel openPanel];
[panel setCanSelectHiddenExtension:YES];
+ [panel setDelegate:self];
[panel setCanChooseDirectories:NO];
[panel setAllowsMultipleSelection:YES];
[panel setResolvesAliases:YES];
+ [panel setAccessoryView:encodingAccessoryView];
+
+ // Set up encoding list
+ // TODO save last used enc in prefs
+ [encodingPopUp setEnabled:NO];
+ [self setupPopUp:encodingPopUp selectedEncoding:4 withDefaultEntry:NO];
[panel beginSheetForDirectory:nil
file:@""
- types:[NSArray arrayWithObjects:@"spf", nil]
+ types:[NSArray arrayWithObjects:@"spf", @"sql", nil]
modalForWindow:tableWindow
modalDelegate:self didEndSelector:@selector(openConnectionPanelDidEnd:returnCode:contextInfo:)
contextInfo:NULL];
@@ -1539,9 +1651,28 @@
{
if ( returnCode ) {
NSArray *fileName = [panel filenames];
- NSLog(@"open: '%@'", [fileName description]);
+ NSLog(@"open: '%@' %d", [fileName description], [[encodingPopUp selectedItem] tag]);
+ }
+}
+
+/**
+ * NSOpenPanel delegate to control encoding popup and allowMultipleSelection
+ */
+- (void)panelSelectionDidChange:(id)sender
+{
+
+ if([sender isKindOfClass:[NSOpenPanel class]]) {
+ if([[[[sender filename] pathExtension] lowercaseString] isEqualToString:@"sql"]) {
+ [encodingPopUp setEnabled:YES];
+ [sender setAllowsMultipleSelection:NO];
+ } else {
+ [encodingPopUp setEnabled:NO];
+ [sender setAllowsMultipleSelection:YES];
+ }
}
+
}
+
/**
* Saves connection(s) to file
*/