<commit_before>package org.jetbrains.plugins.scala.debugger.filters;

import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;
import org.jetbrains.annotations.Nls;
import org.jetbrains.plugins.scala.ScalaBundle;
import org.jetbrains.plugins.scala.icons.Icons;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.reflect.Method;
import java.util.ResourceBundle;

/**
 * @author ilyas
 */
public class ScalaDebuggerSettingsConfigurable implements Configurable {
    private JPanel myPanel;
    private JLabel startIndexLabel;
    private JSpinner myStartIndexSpinner;
    private JSpinner myEndIndexSpinner;
    private JLabel endIndexLabel;
    private JCheckBox friendlyDisplayOfScalaCheckBox;
    private JCheckBox dontShowRuntimeRefs;
    private JCheckBox doNotExpandStreamsCheckBox;
    private JCheckBox showOuterVariables;
    private final ScalaDebuggerSettings mySettings;

    public ScalaDebuggerSettingsConfigurable(final ScalaDebuggerSettings settings) {
        mySettings = settings;
        friendlyDisplayOfScalaCheckBox.setSelected(settings.FRIENDLY_COLLECTION_DISPLAY_ENABLED);
        doNotExpandStreamsCheckBox.setSelected(settings.DO_NOT_DISPLAY_STREAMS);
        dontShowRuntimeRefs.setSelected(settings.DONT_SHOW_RUNTIME_REFS);
        friendlyDisplayOfScalaCheckBox.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                final boolean collectionsSettingsEnabled = friendlyDisplayOfScalaCheckBox.isSelected();
                myStartIndexSpinner.setEnabled(collectionsSettingsEnabled);
                myEndIndexSpinner.setEnabled(collectionsSettingsEnabled);
                doNotExpandStreamsCheckBox.setEnabled(collectionsSettingsEnabled);
            }
        });
        showOuterVariables.setSelected(settings.SHOW_VARIABLES_FROM_OUTER_SCOPES);
    }

    @Nls
    public String getDisplayName() {
        return ScalaBundle.message("scala.debug.caption");
    }

    public Icon getIcon() {
        return Icons.SCALA_SMALL_LOGO;
    }

    public String getHelpTopic() {
        return null;
    }

    public JComponent createComponent() {
        myStartIndexSpinner.setModel(new SpinnerNumberModel(1, 1, null, 1));
        myEndIndexSpinner.setModel(new SpinnerNumberModel(1, 1, null, 1));

        myStartIndexSpinner.setValue(mySettings.COLLECTION_START_INDEX);
        myEndIndexSpinner.setValue(mySettings.COLLECTION_END_INDEX);

        return myPanel;
    }

    public boolean isModified() {
        return mySettings.COLLECTION_START_INDEX != (int) myStartIndexSpinner.getValue() ||
                mySettings.COLLECTION_END_INDEX != (int) myEndIndexSpinner.getValue() ||
                mySettings.FRIENDLY_COLLECTION_DISPLAY_ENABLED != friendlyDisplayOfScalaCheckBox.isSelected() ||
                mySettings.DONT_SHOW_RUNTIME_REFS != dontShowRuntimeRefs.isSelected() ||
                mySettings.DO_NOT_DISPLAY_STREAMS != doNotExpandStreamsCheckBox.isSelected() ||
                mySettings.SHOW_VARIABLES_FROM_OUTER_SCOPES != showOuterVariables.isSelected();
    }

    public void apply() throws ConfigurationException {
        mySettings.FRIENDLY_COLLECTION_DISPLAY_ENABLED = friendlyDisplayOfScalaCheckBox.isSelected();
        mySettings.DONT_SHOW_RUNTIME_REFS = dontShowRuntimeRefs.isSelected();
        mySettings.COLLECTION_START_INDEX = intFromObject(myStartIndexSpinner.getValue());
        mySettings.COLLECTION_END_INDEX = intFromObject(myEndIndexSpinner.getValue());
        mySettings.DO_NOT_DISPLAY_STREAMS = doNotExpandStreamsCheckBox.isSelected();<commit_msg>Fix a bug with start index spinner model #SCL-20047<commit_after>package org.jetbrains.plugins.scala.debugger.filters;

import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;
import org.jetbrains.annotations.Nls;
import org.jetbrains.plugins.scala.ScalaBundle;
import org.jetbrains.plugins.scala.icons.Icons;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.reflect.Method;
import java.util.ResourceBundle;

/**
 * @author ilyas
 */
public class ScalaDebuggerSettingsConfigurable implements Configurable {
    private JPanel myPanel;
    private JLabel startIndexLabel;
    private JSpinner myStartIndexSpinner;
    private JSpinner myEndIndexSpinner;
    private JLabel endIndexLabel;
    private JCheckBox friendlyDisplayOfScalaCheckBox;
    private JCheckBox dontShowRuntimeRefs;
    private JCheckBox doNotExpandStreamsCheckBox;
    private JCheckBox showOuterVariables;
    private final ScalaDebuggerSettings mySettings;

    public ScalaDebuggerSettingsConfigurable(final ScalaDebuggerSettings settings) {
        mySettings = settings;
        friendlyDisplayOfScalaCheckBox.setSelected(settings.FRIENDLY_COLLECTION_DISPLAY_ENABLED);
        doNotExpandStreamsCheckBox.setSelected(settings.DO_NOT_DISPLAY_STREAMS);
        dontShowRuntimeRefs.setSelected(settings.DONT_SHOW_RUNTIME_REFS);
        friendlyDisplayOfScalaCheckBox.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                final boolean collectionsSettingsEnabled = friendlyDisplayOfScalaCheckBox.isSelected();
                myStartIndexSpinner.setEnabled(collectionsSettingsEnabled);
                myEndIndexSpinner.setEnabled(collectionsSettingsEnabled);
                doNotExpandStreamsCheckBox.setEnabled(collectionsSettingsEnabled);
            }
        });
        showOuterVariables.setSelected(settings.SHOW_VARIABLES_FROM_OUTER_SCOPES);
    }

    @Nls
    public String getDisplayName() {
        return ScalaBundle.message("scala.debug.caption");
    }

    public Icon getIcon() {
        return Icons.SCALA_SMALL_LOGO;
    }

    public String getHelpTopic() {
        return null;
    }

    public JComponent createComponent() {
        myStartIndexSpinner.setModel(new SpinnerNumberModel(0, 0, null, 1));
        myEndIndexSpinner.setModel(new SpinnerNumberModel(49, 1, null, 1));

        myStartIndexSpinner.setValue(mySettings.COLLECTION_START_INDEX);
        myEndIndexSpinner.setValue(mySettings.COLLECTION_END_INDEX);

        return myPanel;
    }

    public boolean isModified() {
        return mySettings.COLLECTION_START_INDEX != (int) myStartIndexSpinner.getValue() ||
                mySettings.COLLECTION_END_INDEX != (int) myEndIndexSpinner.getValue() ||
                mySettings.FRIENDLY_COLLECTION_DISPLAY_ENABLED != friendlyDisplayOfScalaCheckBox.isSelected() ||
                mySettings.DONT_SHOW_RUNTIME_REFS != dontShowRuntimeRefs.isSelected() ||
                mySettings.DO_NOT_DISPLAY_STREAMS != doNotExpandStreamsCheckBox.isSelected() ||
                mySettings.SHOW_VARIABLES_FROM_OUTER_SCOPES != showOuterVariables.isSelected();
    }

    public void apply() throws ConfigurationException {
        mySettings.FRIENDLY_COLLECTION_DISPLAY_ENABLED = friendlyDisplayOfScalaCheckBox.isSelected();
        mySettings.DONT_SHOW_RUNTIME_REFS = dontShowRuntimeRefs.isSelected();
        mySettings.COLLECTION_START_INDEX = intFromObject(myStartIndexSpinner.getValue());
        mySettings.COLLECTION_END_INDEX = intFromObject(myEndIndexSpinner.getValue());
        mySettings.DO_NOT_DISPLAY_STREAMS = doNotExpandStreamsCheckBox.isSelected();
{'fraction_non_alphanumeric': 0.07565495207667731, 'fraction_numerical': 0.0023003194888178914, 'mean_word_length': 4.162269129287599, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4945958', 'n_tokens_mistral': 2281, 'n_tokens_neox': 2240, 'n_words': 323}