001    /*
002     *  Licensed to the Apache Software Foundation (ASF) under one
003     *  or more contributor license agreements.  See the NOTICE file
004     *  distributed with this work for additional information
005     *  regarding copyright ownership.  The ASF licenses this file
006     *  to you under the Apache License, Version 2.0 (the
007     *  "License"); you may not use this file except in compliance
008     *  with the License.  You may obtain a copy of the License at
009     *  
010     *    http://www.apache.org/licenses/LICENSE-2.0
011     *  
012     *  Unless required by applicable law or agreed to in writing,
013     *  software distributed under the License is distributed on an
014     *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     *  KIND, either express or implied.  See the License for the
016     *  specific language governing permissions and limitations
017     *  under the License. 
018     *  
019     */
020    package org.apache.directory.studio.apacheds;
021    
022    
023    import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
024    import org.eclipse.jface.preference.IPreferenceStore;
025    import org.eclipse.jface.preference.PreferenceConverter;
026    import org.eclipse.swt.SWT;
027    import org.eclipse.swt.graphics.FontData;
028    import org.eclipse.swt.graphics.RGB;
029    import org.eclipse.swt.widgets.Display;
030    
031    
032    /**
033     * This class is used to set default preference values.
034     *
035     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
036     * @version $Rev$, $Date$
037     */
038    public class PreferenceInitializer extends AbstractPreferenceInitializer
039    {
040        /* (non-Javadoc)
041         * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
042         */
043        public void initializeDefaultPreferences()
044        {
045            // The preference store
046            IPreferenceStore store = ApacheDsPlugin.getDefault().getPreferenceStore();
047    
048            // Fonts
049            FontData[] fontData = Display.getDefault().getSystemFont().getFontData();
050            FontData fontDataNormal = new FontData( fontData[0].getName(), fontData[0].getHeight(), SWT.NORMAL );
051            FontData fontDataItalic = new FontData( fontData[0].getName(), fontData[0].getHeight(), SWT.ITALIC );
052            FontData fontDataBold = new FontData( fontData[0].getName(), fontData[0].getHeight(), SWT.BOLD );
053    
054            // Colors
055            RGB rgbBlue = new RGB( 0, 0, 192 );
056            RGB rgbGreen = new RGB( 63, 127, 95 );
057            RGB rgbOrange = new RGB( 255, 127, 0 );
058            RGB rgbRed = new RGB( 255, 0, 0 );
059            RGB rgbDarkRed = new RGB( 127, 0, 0 );
060    
061            // Colors and Font Debug
062            PreferenceConverter.setDefault( store, ApacheDsPluginConstants.PREFS_COLORS_AND_FONTS_DEBUG_FONT,
063                fontDataItalic );
064            PreferenceConverter.setDefault( store, ApacheDsPluginConstants.PREFS_COLORS_AND_FONTS_DEBUG_COLOR, rgbBlue );
065            // Colors and Font Info
066            PreferenceConverter
067                .setDefault( store, ApacheDsPluginConstants.PREFS_COLORS_AND_FONTS_INFO_FONT, fontDataItalic );
068            PreferenceConverter.setDefault( store, ApacheDsPluginConstants.PREFS_COLORS_AND_FONTS_INFO_COLOR, rgbGreen );
069            // Colors and Font Warn
070            PreferenceConverter
071                .setDefault( store, ApacheDsPluginConstants.PREFS_COLORS_AND_FONTS_WARN_FONT, fontDataNormal );
072            PreferenceConverter.setDefault( store, ApacheDsPluginConstants.PREFS_COLORS_AND_FONTS_WARN_COLOR, rgbOrange );
073            // Colors and Font Error
074            PreferenceConverter.setDefault( store, ApacheDsPluginConstants.PREFS_COLORS_AND_FONTS_ERROR_FONT, fontDataBold );
075            PreferenceConverter.setDefault( store, ApacheDsPluginConstants.PREFS_COLORS_AND_FONTS_ERROR_COLOR, rgbRed );
076            // Colors and Font Fatal
077            PreferenceConverter.setDefault( store, ApacheDsPluginConstants.PREFS_COLORS_AND_FONTS_FATAL_FONT, fontDataBold );
078            PreferenceConverter.setDefault( store, ApacheDsPluginConstants.PREFS_COLORS_AND_FONTS_FATAL_COLOR, rgbDarkRed );
079    
080            // Server Logs
081            store.setDefault( ApacheDsPluginConstants.PREFS_SERVER_LOGS_LEVEL,
082                ApacheDsPluginConstants.PREFS_SERVER_LOGS_LEVEL_WARN );
083            store.setDefault( ApacheDsPluginConstants.PREFS_SERVER_LOGS_PATTERN, "[%d{HH:mm:ss}] %p [%c] - %m%n" );
084        }
085    }