--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.modeling.preferences;\r
+\r
+import java.text.DecimalFormatSymbols;\r
+import java.util.Locale;\r
+\r
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;\r
+import org.eclipse.core.runtime.preferences.DefaultScope;\r
+import org.eclipse.core.runtime.preferences.IScopeContext;\r
+import org.osgi.service.prefs.Preferences;\r
+\r
+/**\r
+ * @author Toni Kalajainen\r
+ */\r
+public class CSVPreferenceInitializer extends AbstractPreferenceInitializer {\r
+\r
+ public void initializeDefaultPreferences() {\r
+ IScopeContext context = DefaultScope.INSTANCE;\r
+ Preferences node = context.getNode(CSVPreferences.P_NODE);\r
+ \r
+ // 1. figure decimal separator\r
+ Locale locale = Locale.getDefault();\r
+ DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance( locale );\r
+ String decimalSeparator = symbols.getDecimalSeparator()+""; \r
+ node.put( CSVPreferences.P_CSV_DECIMAL_SEPARATOR, decimalSeparator );\r
+ \r
+ // 2. Then figure out value separator\r
+ String valueSeparator = decimalSeparator.equals(",")?"\\t":",";\r
+ node.put( CSVPreferences.P_CSV_COLUMN_SEPARATOR, valueSeparator );\r
+ \r
+ node.put( CSVPreferences.P_CSV_FILE_EXTENSION, CSVPreferences.DEFAULT_FILE_EXTENSION );\r
+ \r
+ node.putDouble(CSVPreferences.P_CSV_START_TIME, CSVPreferences.DEFAULT_CSV_START_TIME);\r
+ node.putDouble(CSVPreferences.P_CSV_TIME_STEP, CSVPreferences.DEFAULT_CSV_TIME_STEP);\r
+\r
+ node.putBoolean(CSVPreferences.P_CSV_RESAMPLE, CSVPreferences.DEFAULT_CSV_RESAMPLE);\r
+ \r
+ node.put(CSVPreferences.P_CSV_SAMPLING_MODE, CSVPreferences.DEFAULT_CSV_SAMPLING_MODE);\r
+\r
+ node.putInt(CSVPreferences.P_CSV_TIME_DIGITS, CSVPreferences.DEFAULT_CSV_TIME_DIGITS);\r
+ node.putInt(CSVPreferences.P_CSV_FLOAT_DIGITS, CSVPreferences.DEFAULT_CSV_FLOAT_DIGITS);\r
+ node.putInt(CSVPreferences.P_CSV_DOUBLE_DIGITS, CSVPreferences.DEFAULT_CSV_DOUBLE_DIGITS);\r
+ }\r
+\r
+}\r