X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.modeling%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fpreferences%2FCSVPreferenceInitializer.java;h=a2daff328647ae43b3790ea7671ea7df48028dac;hb=06ee0c4c71cd9e372969da1570e7fcac2c4397a5;hp=a94bb3ace741c98334e749cce598c982406f3c2d;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/preferences/CSVPreferenceInitializer.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/preferences/CSVPreferenceInitializer.java index a94bb3ace..a2daff328 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/preferences/CSVPreferenceInitializer.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/preferences/CSVPreferenceInitializer.java @@ -1,55 +1,55 @@ -/******************************************************************************* - * Copyright (c) 2011 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.modeling.preferences; - -import java.text.DecimalFormatSymbols; -import java.util.Locale; - -import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; -import org.eclipse.core.runtime.preferences.DefaultScope; -import org.eclipse.core.runtime.preferences.IScopeContext; -import org.osgi.service.prefs.Preferences; - -/** - * @author Toni Kalajainen - */ -public class CSVPreferenceInitializer extends AbstractPreferenceInitializer { - - public void initializeDefaultPreferences() { - IScopeContext context = DefaultScope.INSTANCE; - Preferences node = context.getNode(CSVPreferences.P_NODE); - - // 1. figure decimal separator - Locale locale = Locale.getDefault(); - DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance( locale ); - String decimalSeparator = symbols.getDecimalSeparator()+""; - node.put( CSVPreferences.P_CSV_DECIMAL_SEPARATOR, decimalSeparator ); - - // 2. Then figure out value separator - String valueSeparator = decimalSeparator.equals(",")?"\\t":","; - node.put( CSVPreferences.P_CSV_COLUMN_SEPARATOR, valueSeparator ); - - node.put( CSVPreferences.P_CSV_FILE_EXTENSION, CSVPreferences.DEFAULT_FILE_EXTENSION ); - - node.putDouble(CSVPreferences.P_CSV_START_TIME, CSVPreferences.DEFAULT_CSV_START_TIME); - node.putDouble(CSVPreferences.P_CSV_TIME_STEP, CSVPreferences.DEFAULT_CSV_TIME_STEP); - - node.putBoolean(CSVPreferences.P_CSV_RESAMPLE, CSVPreferences.DEFAULT_CSV_RESAMPLE); - - node.put(CSVPreferences.P_CSV_SAMPLING_MODE, CSVPreferences.DEFAULT_CSV_SAMPLING_MODE); - - node.putInt(CSVPreferences.P_CSV_TIME_DIGITS, CSVPreferences.DEFAULT_CSV_TIME_DIGITS); - node.putInt(CSVPreferences.P_CSV_FLOAT_DIGITS, CSVPreferences.DEFAULT_CSV_FLOAT_DIGITS); - node.putInt(CSVPreferences.P_CSV_DOUBLE_DIGITS, CSVPreferences.DEFAULT_CSV_DOUBLE_DIGITS); - } - -} +/******************************************************************************* + * Copyright (c) 2011 Association for Decentralized Information Management in + * Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.modeling.preferences; + +import java.text.DecimalFormatSymbols; +import java.util.Locale; + +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.core.runtime.preferences.DefaultScope; +import org.eclipse.core.runtime.preferences.IScopeContext; +import org.osgi.service.prefs.Preferences; + +/** + * @author Toni Kalajainen + */ +public class CSVPreferenceInitializer extends AbstractPreferenceInitializer { + + public void initializeDefaultPreferences() { + IScopeContext context = DefaultScope.INSTANCE; + Preferences node = context.getNode(CSVPreferences.P_NODE); + + // 1. figure decimal separator + Locale locale = Locale.getDefault(); + DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance( locale ); + String decimalSeparator = symbols.getDecimalSeparator()+""; + node.put( CSVPreferences.P_CSV_DECIMAL_SEPARATOR, decimalSeparator ); + + // 2. Then figure out value separator + String valueSeparator = decimalSeparator.equals(",")?"\\t":","; + node.put( CSVPreferences.P_CSV_COLUMN_SEPARATOR, valueSeparator ); + + node.put( CSVPreferences.P_CSV_FILE_EXTENSION, CSVPreferences.DEFAULT_FILE_EXTENSION ); + + node.putDouble(CSVPreferences.P_CSV_START_TIME, CSVPreferences.DEFAULT_CSV_START_TIME); + node.putDouble(CSVPreferences.P_CSV_TIME_STEP, CSVPreferences.DEFAULT_CSV_TIME_STEP); + + node.putBoolean(CSVPreferences.P_CSV_RESAMPLE, CSVPreferences.DEFAULT_CSV_RESAMPLE); + + node.put(CSVPreferences.P_CSV_SAMPLING_MODE, CSVPreferences.DEFAULT_CSV_SAMPLING_MODE); + + node.putInt(CSVPreferences.P_CSV_TIME_DIGITS, CSVPreferences.DEFAULT_CSV_TIME_DIGITS); + node.putInt(CSVPreferences.P_CSV_FLOAT_DIGITS, CSVPreferences.DEFAULT_CSV_FLOAT_DIGITS); + node.putInt(CSVPreferences.P_CSV_DOUBLE_DIGITS, CSVPreferences.DEFAULT_CSV_DOUBLE_DIGITS); + } + +}