set the some default preferences if file not found

This commit is contained in:
Andreas Billmann
2016-02-16 17:18:37 +01:00
parent 028af43510
commit 3b220c3fd5
2 changed files with 6 additions and 1 deletions

View File

@@ -457,6 +457,8 @@ public class SmartCSVController extends FXMLController {
if (PREFERENCES_FILE.exists()) { if (PREFERENCES_FILE.exists()) {
useLoadFileService(preferencesLoader, PREFERENCES_FILE, useLoadFileService(preferencesLoader, PREFERENCES_FILE,
event -> setCsvPreference(preferencesLoader.getCSVpreference())); event -> setCsvPreference(preferencesLoader.getCSVpreference()));
} else {
setCsvPreference(CsvPreference.EXCEL_NORTH_EUROPE_PREFERENCE);
} }
} }

View File

@@ -66,6 +66,8 @@ public class PreferencesController extends FXMLController {
@FXML @FXML
private ComboBox<String> quoteMode; private ComboBox<String> quoteMode;
private String endOfLineSymbols;
private BooleanProperty valid = new SimpleBooleanProperty(true); private BooleanProperty valid = new SimpleBooleanProperty(true);
@@ -104,10 +106,11 @@ public class PreferencesController extends FXMLController {
surroundingSpacesNeedQuotes.setSelected(csvPreference.isSurroundingSpacesNeedQuotes()); surroundingSpacesNeedQuotes.setSelected(csvPreference.isSurroundingSpacesNeedQuotes());
ignoreEmptyLines.setSelected(csvPreference.isIgnoreEmptyLines()); ignoreEmptyLines.setSelected(csvPreference.isIgnoreEmptyLines());
quoteMode.getSelectionModel().select(getQuoteModeName(csvPreference.getQuoteMode())); quoteMode.getSelectionModel().select(getQuoteModeName(csvPreference.getQuoteMode()));
endOfLineSymbols = csvPreference.getEndOfLineSymbols();
} }
public CsvPreference getCsvPreference() { public CsvPreference getCsvPreference() {
return new CsvPreference.Builder(quoteChar.getText().charAt(0), delimiterChar.getText().charAt(0), "\n") return new CsvPreference.Builder(quoteChar.getText().charAt(0), delimiterChar.getText().charAt(0), endOfLineSymbols)
.useQuoteMode(getQuoteMode(quoteMode.getSelectionModel().getSelectedItem())) .useQuoteMode(getQuoteMode(quoteMode.getSelectionModel().getSelectedItem()))
.surroundingSpacesNeedQuotes(surroundingSpacesNeedQuotes.isSelected()) .surroundingSpacesNeedQuotes(surroundingSpacesNeedQuotes.isSelected())
.ignoreEmptyLines(ignoreEmptyLines.isSelected()) .ignoreEmptyLines(ignoreEmptyLines.isSelected())