<commit_before>/*
 * $Id$
 *
 * Copyright (c) 2004-2005 by the TeXlapse Team.
 * 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
 */
package net.sourceforge.texlipse.properties;

import java.io.File;

import net.sourceforge.texlipse.PathUtils;
import net.sourceforge.texlipse.TexlipsePlugin;
import net.sourceforge.texlipse.bibeditor.BibColorProvider;
import net.sourceforge.texlipse.builder.BuilderRegistry;
import net.sourceforge.texlipse.builder.ProgramRunner;
import net.sourceforge.texlipse.editor.ColorManager;
import net.sourceforge.texlipse.spelling.SpellChecker;
import net.sourceforge.texlipse.viewer.ViewerAttributeRegistry;
import net.sourceforge.texlipse.viewer.util.FileLocationClient;

import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.swt.graphics.RGB;


/**
 * Initialize the plugin preferences.
 * 
 * @author <NAME>
 */
public class TexlipsePreferenceInitializer extends
        AbstractPreferenceInitializer {

    /**
     * Creates a new preference initializer
     */
    public TexlipsePreferenceInitializer() {
        super();
    }

    /**
     * Save the program paths into preferences.
     * @param pref preferences
     */
    private void initializePaths(IPreferenceStore pref) {
        String path = PathUtils.findInEnvPath("latex", "/usr/bin", "latex.exe", "C:\\texmf\\miktex\\bin");
        
        int size = BuilderRegistry.getNumberOfRunners();
        for (int i = 0; i < size; i++) {
            ProgramRunner runner = BuilderRegistry.getRunner(i);
            File prog = new File(path + File.separator + runner.getProgramName());
            if (prog.exists()) {
                runner.initializeDefaults(pref, prog.getAbsolutePath());
            } else {
                runner.initializeDefaults(pref, "");
            }
        }
    }
    
    /**
     * Initialize all preferences to some default values.
     */
    public void initializeDefaultPreferences() {
        IPreferenceStore pref = TexlipsePlugin.getDefault().getPreferenceStore();
        
        pref.setDefault(TexlipseProperties.BIB_DIR, "");
        pref.setDefault(TexlipseProperties.OUTPUT_FORMAT, TexlipseProperties.OUTPUT_FORMAT_DVI);
        pref.setDefault(TexlipseProperties.BUILDER_NUMBER, 0);
        pref.setDefault(TexlipseProperties.BUILDER_CONSOLE_OUTPUT, true);
        pref.setDefault(TexlipseProperties.BUILDER_PARSE_AUX_FILES, true);
        pref.setDefault(TexlipseProperties.BUILD_BEFORE_VIEW, false);
        pref.setDefault(TexlipseProperties.FILE_LOCATION_PORT, FileLocationClient.DEFAULT_PORTNUMBER);
        
        initializePaths(pref);
        
        ColorManager.initializeDefaults(pref);
        
        BibColorProvider.initializeDefaults(pref);
        
        ViewerAttributeRegistry.initializeDefaults(pref);
        
        SpellChecker.initializeDefaults(pref);
        
        pref.setDefault(TexlipseProperties.BUILD_ENV_SETTINGS, "");
        pref.setDefault(TexlipseProperties.VIEWER_ENV_SETTINGS, "");
        pref.setDefault(TexlipseProperties.TEMP_FILE_EXTS, ".aux,.log,.toc,.ind,.ilg,.bbl,.blg,.lot,.lof,.snm,.nav,.out,.vrb,.run.xml,.bcf");
        pref.setDefault(TexlipseProperties.DERIVED_FILES, ".synctex.gz,.pdfsync");
        
        pref.setDefault(TexlipseProperties.BIB_COMPLETION, true);
        pref.setDefault(TexlipseProperties.BIB_COMPLETION_DELAY, 500);
        pref.setDefault(TexlipseProperties.TEX_COMPLETION, true);
        pref.setDefault(TexlipseProperties.TEX_COMPLETION_DELAY, 500);
        pref.setDefault(TexlipseProperties.AUTO_PARSING, true);
        pref.setDefault(TexlipseProperties.AUTO_PARSING_DELAY, 2000);
        pref.setDefault(TexlipseProperties.SECTION_CHECK, true);
        
        pref.setDefault(TexlipseProperties.BIB_CODE_FOLDING, true);
        pref.setDefault(TexlipseProperties.BIB_FOLD_INITIAL, false);
        pref.setDefault(TexlipseProperties.BIB_STRING, false);
        
        pref.setDefault(TexlipseProperties.CODE_FOLDING, true);
        pref.setDefault(TexlipseProperties.CODE_FOLDING_PREAMBLE, false);
        pref.setDefault(TexlipseProperties.CODE_FOLDING_PART, false);
        pref.setDefault(TexlipseProperties.CODE_FOLDING_CHAPTER, false);
        pref.setDefault(TexlipseProperties.CODE_FOLDING_SECTION, false);
        pref.setDefault(TexlipseProperties.CODE_FOLDING_SUBSECTION, false);
        pref.setDefault(TexlipseProperties.CODE_FOLDING_SUBSUBSECTION, false);
        pref.setDefault(TexlipseProperties.CODE_FOLDING_PARAGRAPH, false);
        pref.setDefault(TexlipseProperties.CODE_FOLDING_ENVS, "");
        
        pref.setDefault(TexlipseProperties.MATCHING_BRACKETS, true);<commit_msg>Add .synctex to derived extension.<commit_after>/*
 * $Id$
 *
 * Copyright (c) 2004-2005 by the TeXlapse Team.
 * 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
 */
package net.sourceforge.texlipse.properties;

import java.io.File;

import net.sourceforge.texlipse.PathUtils;
import net.sourceforge.texlipse.TexlipsePlugin;
import net.sourceforge.texlipse.bibeditor.BibColorProvider;
import net.sourceforge.texlipse.builder.BuilderRegistry;
import net.sourceforge.texlipse.builder.ProgramRunner;
import net.sourceforge.texlipse.editor.ColorManager;
import net.sourceforge.texlipse.spelling.SpellChecker;
import net.sourceforge.texlipse.viewer.ViewerAttributeRegistry;
import net.sourceforge.texlipse.viewer.util.FileLocationClient;

import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.swt.graphics.RGB;


/**
 * Initialize the plugin preferences.
 * 
 * @author <NAME>
 */
public class TexlipsePreferenceInitializer extends
        AbstractPreferenceInitializer {

    /**
     * Creates a new preference initializer
     */
    public TexlipsePreferenceInitializer() {
        super();
    }

    /**
     * Save the program paths into preferences.
     * @param pref preferences
     */
    private void initializePaths(IPreferenceStore pref) {
        String path = PathUtils.findInEnvPath("latex", "/usr/bin", "latex.exe", "C:\\texmf\\miktex\\bin");
        
        int size = BuilderRegistry.getNumberOfRunners();
        for (int i = 0; i < size; i++) {
            ProgramRunner runner = BuilderRegistry.getRunner(i);
            File prog = new File(path + File.separator + runner.getProgramName());
            if (prog.exists()) {
                runner.initializeDefaults(pref, prog.getAbsolutePath());
            } else {
                runner.initializeDefaults(pref, "");
            }
        }
    }
    
    /**
     * Initialize all preferences to some default values.
     */
    public void initializeDefaultPreferences() {
        IPreferenceStore pref = TexlipsePlugin.getDefault().getPreferenceStore();
        
        pref.setDefault(TexlipseProperties.BIB_DIR, "");
        pref.setDefault(TexlipseProperties.OUTPUT_FORMAT, TexlipseProperties.OUTPUT_FORMAT_DVI);
        pref.setDefault(TexlipseProperties.BUILDER_NUMBER, 0);
        pref.setDefault(TexlipseProperties.BUILDER_CONSOLE_OUTPUT, true);
        pref.setDefault(TexlipseProperties.BUILDER_PARSE_AUX_FILES, true);
        pref.setDefault(TexlipseProperties.BUILD_BEFORE_VIEW, false);
        pref.setDefault(TexlipseProperties.FILE_LOCATION_PORT, FileLocationClient.DEFAULT_PORTNUMBER);
        
        initializePaths(pref);
        
        ColorManager.initializeDefaults(pref);
        
        BibColorProvider.initializeDefaults(pref);
        
        ViewerAttributeRegistry.initializeDefaults(pref);
        
        SpellChecker.initializeDefaults(pref);
        
        pref.setDefault(TexlipseProperties.BUILD_ENV_SETTINGS, "");
        pref.setDefault(TexlipseProperties.VIEWER_ENV_SETTINGS, "");
        pref.setDefault(TexlipseProperties.TEMP_FILE_EXTS, ".aux,.log,.toc,.ind,.ilg,.bbl,.blg,.lot,.lof,.snm,.nav,.out,.vrb,.run.xml,.bcf");
        pref.setDefault(TexlipseProperties.DERIVED_FILES, ".synctex.gz,.synctex,.pdfsync");
        
        pref.setDefault(TexlipseProperties.BIB_COMPLETION, true);
        pref.setDefault(TexlipseProperties.BIB_COMPLETION_DELAY, 500);
        pref.setDefault(TexlipseProperties.TEX_COMPLETION, true);
        pref.setDefault(TexlipseProperties.TEX_COMPLETION_DELAY, 500);
        pref.setDefault(TexlipseProperties.AUTO_PARSING, true);
        pref.setDefault(TexlipseProperties.AUTO_PARSING_DELAY, 2000);
        pref.setDefault(TexlipseProperties.SECTION_CHECK, true);
        
        pref.setDefault(TexlipseProperties.BIB_CODE_FOLDING, true);
        pref.setDefault(TexlipseProperties.BIB_FOLD_INITIAL, false);
        pref.setDefault(TexlipseProperties.BIB_STRING, false);
        
        pref.setDefault(TexlipseProperties.CODE_FOLDING, true);
        pref.setDefault(TexlipseProperties.CODE_FOLDING_PREAMBLE, false);
        pref.setDefault(TexlipseProperties.CODE_FOLDING_PART, false);
        pref.setDefault(TexlipseProperties.CODE_FOLDING_CHAPTER, false);
        pref.setDefault(TexlipseProperties.CODE_FOLDING_SECTION, false);
        pref.setDefault(TexlipseProperties.CODE_FOLDING_SUBSECTION, false);
        pref.setDefault(TexlipseProperties.CODE_FOLDING_SUBSUBSECTION, false);
        pref.setDefault(TexlipseProperties.CODE_FOLDING_PARAGRAPH, false);
        pref.setDefault(TexlipseProperties.CODE_FOLDING_ENVS, "");
        
        pref.setDefault(TexlipseProperties.MATCHING_BRACKETS, true);
{'fraction_non_alphanumeric': 0.09923969587835134, 'fraction_numerical': 0.004801920768307323, 'mean_word_length': 3.6069124423963133, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4629978', 'n_tokens_mistral': 3132, 'n_tokens_neox': 2963, 'n_words': 419}