From 88cb14acd9182ac19a1be2e8ad34b2be6b12b939 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Wed, 7 Oct 2009 17:22:22 +0000 Subject: =?UTF-8?q?=E2=80=A2=C2=A0outsourced=20ImportCSV=20accessory=20vie?= =?UTF-8?q?w=20to=20fix=20the=20disappearing=20of=20combobox=20values=20af?= =?UTF-8?q?ter=20re-invoking=20it=20-=20store=20the=20accessory=20settings?= =?UTF-8?q?=20in=20SP's=20preferences?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/TableDump.m | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'Source') diff --git a/Source/TableDump.m b/Source/TableDump.m index 4bc867a8..209cd382 100644 --- a/Source/TableDump.m +++ b/Source/TableDump.m @@ -417,6 +417,21 @@ { // prepare open panel and accessory view NSOpenPanel *openPanel = [NSOpenPanel openPanel]; + + // Load accessory nib each time + if(![NSBundle loadNibNamed:@"ImportAccessory" owner:self]) { + NSBeep(); + NSLog(@"ImportAccessory accessory dialog could not be loaded."); + return; + } + + // Preset the accessory view with prefs defaults + [importFieldsTerminatedField setStringValue:[prefs objectForKey:@"CSVImportFieldTerminator"]]; + [importLinesTerminatedField setStringValue:[prefs objectForKey:@"CSVImportLineTerminator"]]; + [importFieldsEscapedField setStringValue:[prefs objectForKey:@"CSVImportFieldEscapeCharacter"]]; + [importFieldsEnclosedField setStringValue:[prefs objectForKey:@"CSVImportFieldEnclosedBy"]]; + [importFieldNamesSwitch setState:[[prefs objectForKey:@"CSVImportFirstLineIsHeader"] boolValue]]; + [openPanel setAccessoryView:importCSVView]; [openPanel setDelegate:self]; if ([prefs valueForKey:@"importFormatPopupValue"]) { @@ -764,6 +779,13 @@ // other two must therefore be performed where possible. csvParser = [[SPCSVParser alloc] init]; + // Store settings in prefs + [prefs setObject:[importFieldsEnclosedField stringValue] forKey:@"CSVImportFieldEnclosedBy"]; + [prefs setObject:[importFieldsEscapedField stringValue] forKey:@"CSVImportFieldEscapeCharacter"]; + [prefs setObject:[importLinesTerminatedField stringValue] forKey:@"CSVImportLineTerminator"]; + [prefs setObject:[importFieldsTerminatedField stringValue] forKey:@"CSVImportFieldTerminator"]; + [prefs setBool:[importFieldNamesSwitch state] forKey:@"CSVImportFirstLineIsHeader"]; + // Take CSV import setting from accessory view [csvParser setFieldTerminatorString:[importFieldsTerminatedField stringValue] convertDisplayStrings:YES]; [csvParser setLineTerminatorString:[importLinesTerminatedField stringValue] convertDisplayStrings:YES]; -- cgit v1.2.3