| /******************************************************************************* |
| * Copyright (c) 2018 Agence spatiale canadienne / Canadian Space Agency |
| * 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: |
| * Pierre Allard, |
| * Regent L'Archeveque, |
| <<<<<<< HEAD |
| * Sebastien Gemme |
| * |
| ======= |
| * Sebastien Gemme - initial API and implementation |
| * |
| >>>>>>> refs/heads/eclipse_pa |
| * SPDX-License-Identifier: EPL-1.0 |
| * |
| *******************************************************************************/ |
| package org.eclipse.apogy.common.topology.ui.preferences; |
| |
| import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; |
| import org.eclipse.core.runtime.preferences.DefaultScope; |
| import org.eclipse.core.runtime.preferences.IEclipsePreferences; |
| import org.eclipse.jface.preference.IPreferenceStore; |
| import org.eclipse.jface.preference.PreferenceConverter; |
| import org.eclipse.ui.preferences.ScopedPreferenceStore; |
| import org.osgi.service.prefs.BackingStoreException; |
| import org.slf4j.Logger; |
| import org.slf4j.LoggerFactory; |
| |
| public class PreferenceInitializer extends AbstractPreferenceInitializer { |
| |
| private static final Logger Logger = LoggerFactory.getLogger(PreferenceInitializer.class); |
| |
| /* |
| * (non-Javadoc) |
| * |
| * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer# |
| * initializeDefaultPreferences() |
| */ |
| @Override |
| public void initializeDefaultPreferences() { |
| |
| // We populate the default scope. |
| IEclipsePreferences prefs = DefaultScope.INSTANCE.getNode(Activator.PLUGIN_ID); |
| |
| // Back light |
| prefs.putFloat(PreferenceConstants.P_BACK_LIGHT_AZIMUTH, PreferenceConstants.P_BACK_LIGHT_AZIMUTH_DEFAULT); |
| |
| prefs.putFloat(PreferenceConstants.P_BACK_LIGHT_ELEVATION, PreferenceConstants.P_BACK_LIGHT_ELEVATION_DEFAULT); |
| |
| prefs.putFloat(PreferenceConstants.P_BACK_LIGHT_WARMTH, PreferenceConstants.P_BACK_LIGHT_WARMTH_DEFAULT); |
| |
| // Fill light |
| prefs.putFloat(PreferenceConstants.P_FILL_LIGHT_AZIMUTH, PreferenceConstants.P_FILL_LIGHT_AZIMUTH_DEFAULT); |
| |
| prefs.putFloat(PreferenceConstants.P_FILL_LIGHT_ELEVATION, PreferenceConstants.P_FILL_LIGHT_ELEVATION_DEFAULT); |
| |
| prefs.putFloat(PreferenceConstants.P_FILL_LIGHT_WARMTH, PreferenceConstants.P_FILL_LIGHT_WARMTH_DEFAULT); |
| |
| // Head light |
| prefs.putFloat(PreferenceConstants.P_HEAD_LIGHT_WARMTH, PreferenceConstants.P_HEAD_LIGHT_WARMTH_DEFAULT); |
| |
| // Key light |
| prefs.putFloat(PreferenceConstants.P_KEY_LIGHT_AZIMUTH, PreferenceConstants.P_KEY_LIGHT_AZIMUTH_DEFAULT); |
| |
| prefs.putFloat(PreferenceConstants.P_KEY_LIGHT_ELEVATION, PreferenceConstants.P_KEY_LIGHT_ELEVATION_DEFAULT); |
| |
| prefs.putFloat(PreferenceConstants.P_KEY_LIGHT_WARMTH, PreferenceConstants.P_KEY_LIGHT_WARMTH_DEFAULT); |
| |
| prefs.putFloat(PreferenceConstants.P_KEY_LIGHT_INTENSITY, PreferenceConstants.P_KEY_LIGHT_INTENSITY_DEFAULT); |
| |
| // Key to ratios |
| prefs.putFloat(PreferenceConstants.P_KEY_TO_BACK_RATIO, PreferenceConstants.P_KEY_TO_BACK_RATIO_DEFAULT); |
| |
| prefs.putFloat(PreferenceConstants.P_KEY_TO_FILL_RATIO, PreferenceConstants.P_KEY_TO_FILL_RATIO_DEFAULT); |
| |
| prefs.putFloat(PreferenceConstants.P_KEY_TO_HEAD_RATIO, PreferenceConstants.P_KEY_TO_HEAD_RATIO_DEFAULT); |
| |
| IPreferenceStore defaultStore = new ScopedPreferenceStore(DefaultScope.INSTANCE, Activator.PLUGIN_ID); |
| |
| // Colors |
| PreferenceConverter.setValue(defaultStore, PreferenceConstants.P_FILL_LIGHT_COLOR, |
| PreferenceConstants.P_FILL_LIGHT_COLOR_DEFAULT); |
| |
| PreferenceConverter.setValue(defaultStore, PreferenceConstants.P_KEY_LIGHT_COLOR, |
| PreferenceConstants.P_KEY_LIGHT_COLOR_DEFAULT); |
| |
| PreferenceConverter.setValue(defaultStore, PreferenceConstants.P_BACK_LIGHT_COLOR, |
| PreferenceConstants.P_BACK_LIGHT_COLOR_DEFAULT); |
| |
| PreferenceConverter.setValue(defaultStore, PreferenceConstants.P_HEAD_LIGHT_COLOR, |
| PreferenceConstants.P_HEAD_LIGHT_COLOR_DEFAULT); |
| |
| // Enabled / disable |
| prefs.putBoolean(PreferenceConstants.P_KEY_LIGHT_ENABLED, PreferenceConstants.P_KEY_LIGHT_ENABLED_DEFAULT); |
| |
| prefs.putBoolean(PreferenceConstants.P_FILL_LIGHT_ENABLED, PreferenceConstants.P_KEY_LIGHT_ENABLED_DEFAULT); |
| |
| prefs.putBoolean(PreferenceConstants.P_BACK_LIGHT_ENABLED, PreferenceConstants.P_BACK_LIGHT_ENABLED_DEFAULT); |
| |
| prefs.putBoolean(PreferenceConstants.P_HEAD_LIGHT_ENABLED, PreferenceConstants.P_HEAD_LIGHT_ENABLED_DEFAULT); |
| |
| try { |
| prefs.flush(); |
| } catch (BackingStoreException e) { |
| Logger.error(e.getMessage(), e); |
| } |
| |
| } |
| |
| } |