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