]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling/src/org/simantics/modeling/preferences/CSVPreferenceInitializer.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / preferences / CSVPreferenceInitializer.java
1 /*******************************************************************************\r
2  * Copyright (c) 2011 Association for Decentralized Information Management in\r
3  * Industry THTH ry.\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
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.modeling.preferences;\r
13 \r
14 import java.text.DecimalFormatSymbols;\r
15 import java.util.Locale;\r
16 \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
21 \r
22 /**\r
23  * @author Toni Kalajainen\r
24  */\r
25 public class CSVPreferenceInitializer extends AbstractPreferenceInitializer {\r
26 \r
27     public void initializeDefaultPreferences() {\r
28         IScopeContext context = DefaultScope.INSTANCE;\r
29         Preferences node = context.getNode(CSVPreferences.P_NODE);\r
30         \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
36         \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
40         \r
41         node.put( CSVPreferences.P_CSV_FILE_EXTENSION, CSVPreferences.DEFAULT_FILE_EXTENSION );\r
42         \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
45 \r
46         node.putBoolean(CSVPreferences.P_CSV_RESAMPLE, CSVPreferences.DEFAULT_CSV_RESAMPLE);\r
47         \r
48         node.put(CSVPreferences.P_CSV_SAMPLING_MODE, CSVPreferences.DEFAULT_CSV_SAMPLING_MODE);\r
49 \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
53     }\r
54 \r
55 }\r