<commit_before>package com.redhat.ceylon.eclipse.code.style;

import static com.redhat.ceylon.eclipse.code.style.CeylonFormatterConstants.FORMATTER_space_AroundImportAliasEqualsSign;

import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
import java.util.List;
import java.util.Observable;
import java.util.Observer;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
import org.eclipse.jdt.internal.ui.util.SWTUtil;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.StatusDialog;
import org.eclipse.jface.layout.PixelConverter;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

import ceylon.formatter.options.loadProfile_;
import ceylon.formatter.options.saveProfile_;

import com.redhat.ceylon.common.Constants;
import com.redhat.ceylon.eclipse.code.style.FormatterProfileManager.Profile;

/**
 * The Ceylon code formatter preference page.
 */

public class FormatterConfigurationBlock extends StyleBlock {

    public static final String FORMATTER_PROFILE_SUFFIX = ".format";

    private Combo fProfileCombo;
    private Button fEditButton;
    private Button fDeleteButton;
    private Button fNewButton;
    private Button fLoadButton;
    private Button fExportButton;
    private PixelConverter fPixConv;

    private FormatterProfileManager fFormatterProfileManager = null;

    /**
     * Some Ceylon source code used for preview.
     */
    protected final String PREVIEW = "\"" + "Preview" + "\"\n\n"
            + "import ceylon.collection { MutableList, freq=frequencies}\n\n\n"
            + "shared abstract class LineBreak(text, string) of os {"
            + "shared String text;"
            + "\"The name of the object, i.e., one of"
            + "`os`, `lf`, `crlf`.\""
            + "shared actual String string; }"
            + "shared object os extends LineBreak(operatingSystem.newline, \"os\") {"
            + "void test() {class Test() { } value t => Test();}}";

    private class PreviewController implements Observer {

        public PreviewController(FormatterProfileManager profileManager) {
            profileManager.addObserver(this);
            ceylonPreview.setWorkingValues(new FormatterPreferences(
                    profileManager.getSelected().getSettings()));
            ceylonPreview.update();
        }

        public void update(Observable o, Object arg) {
            final int value = ((Integer) arg).intValue();
            switch (value) {
            case FormatterProfileManager.PROFILE_CREATED_EVENT:
            case FormatterProfileManager.PROFILE_DELETED_EVENT:
            case FormatterProfileManager.SELECTION_CHANGED_EVENT:<commit_msg>Small fixes to formatter preview text<commit_after>package com.redhat.ceylon.eclipse.code.style;

import static com.redhat.ceylon.eclipse.code.style.CeylonFormatterConstants.FORMATTER_space_AroundImportAliasEqualsSign;

import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
import java.util.List;
import java.util.Observable;
import java.util.Observer;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
import org.eclipse.jdt.internal.ui.util.SWTUtil;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.StatusDialog;
import org.eclipse.jface.layout.PixelConverter;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

import ceylon.formatter.options.loadProfile_;
import ceylon.formatter.options.saveProfile_;

import com.redhat.ceylon.common.Constants;
import com.redhat.ceylon.eclipse.code.style.FormatterProfileManager.Profile;

/**
 * The Ceylon code formatter preference page.
 */

public class FormatterConfigurationBlock extends StyleBlock {

    public static final String FORMATTER_PROFILE_SUFFIX = ".format";

    private Combo fProfileCombo;
    private Button fEditButton;
    private Button fDeleteButton;
    private Button fNewButton;
    private Button fLoadButton;
    private Button fExportButton;
    private PixelConverter fPixConv;

    private FormatterProfileManager fFormatterProfileManager = null;

    /**
     * Some Ceylon source code used for preview.
     */
    protected final String PREVIEW = "\"" + "Preview" + "\"\n\n"
            + "import ceylon.collection { MutableList, freq=frequencies}\n\n\n"
            + "shared abstract class LineBreak(text, string) of os {"
            + "shared String text;"
            + "\"The name of the object, i. e., one of "
            + "`os`, `lf`, `crlf`.\""
            + "shared actual String string; }"
            + "shared object os extends LineBreak(operatingSystem.newline, \"os\") {"
            + "void test() {class Test() { } value t => Test();}}";

    private class PreviewController implements Observer {

        public PreviewController(FormatterProfileManager profileManager) {
            profileManager.addObserver(this);
            ceylonPreview.setWorkingValues(new FormatterPreferences(
                    profileManager.getSelected().getSettings()));
            ceylonPreview.update();
        }

        public void update(Observable o, Object arg) {
            final int value = ((Integer) arg).intValue();
            switch (value) {
            case FormatterProfileManager.PROFILE_CREATED_EVENT:
            case FormatterProfileManager.PROFILE_DELETED_EVENT:
            case FormatterProfileManager.SELECTION_CHANGED_EVENT:
{'fraction_non_alphanumeric': 0.10175763182238667, 'fraction_numerical': 0.0, 'mean_word_length': 3.65351506456241, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '2021987', 'n_tokens_mistral': 1890, 'n_tokens_neox': 1822, 'n_words': 393}