<commit_before>package nl.rubensten.texifyidea.intentions.latexmathtoggle

import com.intellij.openapi.ui.DialogBuilder
import com.intellij.openapi.ui.DialogWrapper
import nl.rubensten.texifyidea.lang.DefaultEnvironment
import nl.rubensten.texifyidea.lang.Package
import javax.swing.*

class MathEnvironmentDialog(private val envName: String?,
                            var result: String? = null) {

    init {
        DialogBuilder().apply {
            setTitle("Convert math environment")

            // Create components.
            val label = JLabel(
                    """|<html>
                        |<table>
                        |<tr><td>Please select a math environment from the list.</tr>
                        |</table>
                        |</html>""".trimMargin(),
                    SwingConstants.LEADING
            )

            // Get all the math environments.
            val environments: Array<String> = arrayOf(DefaultEnvironment.values()
                    .filter { it.dependency == Package.AMSMATH }
                    .map { it.environmentName }
                    .toTypedArray(),
                    // Add the inline and display environments.
                    arrayOf("inline", "display"))
                    .flatten()
                    // Remove split/cases, and current environments.
                    .filter { it != "split" && it != "cases" && it != envName}
                    .toTypedArray()

            val comboBox = JComboBox(environments)

            // Create panel.
            val panel = JPanel()
            panel.layout = BoxLayout(panel, BoxLayout.Y_AXIS)
            panel.add(label)
            panel.add(comboBox)
            setCenterPanel(panel)

            // Dialog stuff.
            addOkAction()<commit_msg>Fiddled with dialog to ask for math environment<commit_after>package nl.rubensten.texifyidea.intentions.latexmathtoggle

import com.intellij.openapi.ui.DialogBuilder
import com.intellij.openapi.ui.DialogWrapper
import nl.rubensten.texifyidea.lang.DefaultEnvironment
import nl.rubensten.texifyidea.lang.Package
import java.awt.BorderLayout
import java.awt.Color
import javax.swing.JComboBox
import javax.swing.JLabel
import javax.swing.JPanel

class MathEnvironmentDialog(private val envName: String?,
                            var result: String? = null) {

    init {
        DialogBuilder().apply {
            setTitle("Convert math environment")

            // Create components.
            val label = JLabel("Please select a math environment from the list.")
            val hint = JLabel("Use Tab, then arrow keys for easy selection.")
            hint.foreground = Color.GRAY

            // Get all the math environments.
            val environments: Array<String> = arrayOf(DefaultEnvironment.values()
                    .filter { it.dependency == Package.AMSMATH }
                    .map { it.environmentName }
                    .toTypedArray(),
                    // Add the inline and display environments.
                    arrayOf("inline", "display"))
                    .flatten()
                    // Remove split/cases, and current environments.
                    .filter { it != "split" && it != "cases" && it != envName}
                    .toTypedArray()

            val comboBox = JComboBox(environments)

            // Create panel.
            val panel = JPanel()
            panel.layout = BorderLayout()
            panel.add(label, BorderLayout.NORTH)
            panel.add(comboBox, BorderLayout.CENTER)
            panel.add(hint, BorderLayout.SOUTH)
            setCenterPanel(panel)

            // Dialog stuff.
            addOkAction()
{'fraction_non_alphanumeric': 0.09398699891657639, 'fraction_numerical': 0.0, 'mean_word_length': 1.6702819956616053, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '6964112', 'n_tokens_mistral': 935, 'n_tokens_neox': 896, 'n_words': 219}