1 /*******************************************************************************
2 * Copyright (c) 2011 Association for Decentralized Information Management in
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.modeling.preferences;
14 import java.text.DecimalFormatSymbols;
15 import java.util.Locale;
17 import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
18 import org.eclipse.core.runtime.preferences.DefaultScope;
19 import org.eclipse.core.runtime.preferences.IScopeContext;
20 import org.osgi.service.prefs.Preferences;
23 * @author Toni Kalajainen
25 public class CSVPreferenceInitializer extends AbstractPreferenceInitializer {
27 public void initializeDefaultPreferences() {
28 IScopeContext context = DefaultScope.INSTANCE;
29 Preferences node = context.getNode(CSVPreferences.P_NODE);
31 // 1. figure decimal separator
32 Locale locale = Locale.getDefault();
33 DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance( locale );
34 String decimalSeparator = symbols.getDecimalSeparator()+"";
35 node.put( CSVPreferences.P_CSV_DECIMAL_SEPARATOR, decimalSeparator );
37 // 2. Then figure out value separator
38 String valueSeparator = decimalSeparator.equals(",")?"\\t":",";
39 node.put( CSVPreferences.P_CSV_COLUMN_SEPARATOR, valueSeparator );
41 node.put( CSVPreferences.P_CSV_FILE_EXTENSION, CSVPreferences.DEFAULT_FILE_EXTENSION );
43 node.putDouble(CSVPreferences.P_CSV_START_TIME, CSVPreferences.DEFAULT_CSV_START_TIME);
44 node.putDouble(CSVPreferences.P_CSV_TIME_STEP, CSVPreferences.DEFAULT_CSV_TIME_STEP);
46 node.putBoolean(CSVPreferences.P_CSV_RESAMPLE, CSVPreferences.DEFAULT_CSV_RESAMPLE);
48 node.put(CSVPreferences.P_CSV_SAMPLING_MODE, CSVPreferences.DEFAULT_CSV_SAMPLING_MODE);
50 node.putInt(CSVPreferences.P_CSV_TIME_DIGITS, CSVPreferences.DEFAULT_CSV_TIME_DIGITS);
51 node.putInt(CSVPreferences.P_CSV_FLOAT_DIGITS, CSVPreferences.DEFAULT_CSV_FLOAT_DIGITS);
52 node.putInt(CSVPreferences.P_CSV_DOUBLE_DIGITS, CSVPreferences.DEFAULT_CSV_DOUBLE_DIGITS);