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