⁠
rednesto: Fix minecraft-dev/mcdev-error-report#290
null cannot be cast to non-null type com.demonwav.mcdev.MinecraftSettings.UnderlineType
null cannot be cast to non-null type com.demonwav.mcdev.MinecraftSettings.UnderlineType
- /*
- * Minecraft Development for IntelliJ
- *
- * https://mcdev.io/
- *
- * Copyright (C) 2023 minecraft-dev
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation, version 3.0 only.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
- package com.demonwav.mcdev
- import com.demonwav.mcdev.update.ConfigurePluginUpdatesDialog
- import com.intellij.openapi.options.Configurable
- import javax.swing.JButton
- import javax.swing.JCheckBox
- import javax.swing.JComboBox
- import javax.swing.JComponent
- import javax.swing.JPanel
- import org.jetbrains.annotations.Nls
- class MinecraftConfigurable : Configurable {
- private lateinit var panel: JPanel
- private lateinit var showProjectPlatformIconsCheckBox: JCheckBox
- private lateinit var showEventListenerGutterCheckBox: JCheckBox
- private lateinit var showChatColorUnderlinesCheckBox: JCheckBox
- private lateinit var chatColorUnderlinesComboBox: JComboBox<MinecraftSettings.UnderlineType>
- private lateinit var showChatGutterIconsCheckBox: JCheckBox
- private lateinit var changePluginUpdateChannelButton: JButton
- @Nls
- override fun getDisplayName() = "Minecraft Development"
- override fun getHelpTopic(): String? = null
- override fun createComponent(): JComponent {
- showChatColorUnderlinesCheckBox.addActionListener { setUnderlineBox() }
- return panel
- }
- private fun init() {
- for (type in MinecraftSettings.UnderlineType.values()) {
- chatColorUnderlinesComboBox.addItem(type)
- }
- val settings = MinecraftSettings.instance
- showProjectPlatformIconsCheckBox.isSelected = settings.isShowProjectPlatformIcons
- showEventListenerGutterCheckBox.isSelected = settings.isShowEventListenerGutterIcons
- showChatGutterIconsCheckBox.isSelected = settings.isShowChatColorGutterIcons
- showChatColorUnderlinesCheckBox.isSelected = settings.isShowChatColorUnderlines
- chatColorUnderlinesComboBox.selectedIndex = settings.underlineTypeIndex
- setUnderlineBox()
- changePluginUpdateChannelButton.addActionListener { ConfigurePluginUpdatesDialog().show() }
- }
- private fun setUnderlineBox() {
- chatColorUnderlinesComboBox.isEnabled = showChatColorUnderlinesCheckBox.isSelected
- }
- override fun isModified(): Boolean {
- val settings = MinecraftSettings.instance
- return showProjectPlatformIconsCheckBox.isSelected != settings.isShowProjectPlatformIcons ||
- showEventListenerGutterCheckBox.isSelected != settings.isShowEventListenerGutterIcons ||
- showChatGutterIconsCheckBox.isSelected != settings.isShowChatColorGutterIcons ||
- showChatColorUnderlinesCheckBox.isSelected != settings.isShowChatColorUnderlines ||
- chatColorUnderlinesComboBox.selectedItem !== settings.underlineType
- }
- override fun apply() {
- val settings = MinecraftSettings.instance
- settings.isShowProjectPlatformIcons = showProjectPlatformIconsCheckBox.isSelected
- settings.isShowEventListenerGutterIcons = showEventListenerGutterCheckBox.isSelected
- settings.isShowChatColorGutterIcons = showChatGutterIconsCheckBox.isSelected
- settings.isShowChatColorUnderlines = showChatColorUnderlinesCheckBox.isSelected
- settings.underlineType = chatColorUnderlinesComboBox.selectedItem as MinecraftSettings.UnderlineType
- }
- override fun reset() {
- init()
- }
- }
- /*
- * Minecraft Development for IntelliJ
- *
- * https://mcdev.io/
- *
- * Copyright (C) 2023 minecraft-dev
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation, version 3.0 only.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
- package com.demonwav.mcdev
- import com.demonwav.mcdev.update.ConfigurePluginUpdatesDialog
- import com.intellij.openapi.options.Configurable
- import javax.swing.JButton
- import javax.swing.JCheckBox
- import javax.swing.JComboBox
- import javax.swing.JComponent
- import javax.swing.JPanel
- import org.jetbrains.annotations.Nls
- class MinecraftConfigurable : Configurable {
- private lateinit var panel: JPanel
- private lateinit var showProjectPlatformIconsCheckBox: JCheckBox
- private lateinit var showEventListenerGutterCheckBox: JCheckBox
- private lateinit var showChatColorUnderlinesCheckBox: JCheckBox
- private lateinit var chatColorUnderlinesComboBox: JComboBox<MinecraftSettings.UnderlineType>
- private lateinit var showChatGutterIconsCheckBox: JCheckBox
- private lateinit var changePluginUpdateChannelButton: JButton
- @Nls
- override fun getDisplayName() = "Minecraft Development"
- override fun getHelpTopic(): String? = null
- override fun createComponent(): JComponent {
- showChatColorUnderlinesCheckBox.addActionListener { setUnderlineBox() }
- return panel
- }
- private fun init() {
- for (type in MinecraftSettings.UnderlineType.values()) {
- chatColorUnderlinesComboBox.addItem(type)
- }
- val settings = MinecraftSettings.instance
- showProjectPlatformIconsCheckBox.isSelected = settings.isShowProjectPlatformIcons
- showEventListenerGutterCheckBox.isSelected = settings.isShowEventListenerGutterIcons
- showChatGutterIconsCheckBox.isSelected = settings.isShowChatColorGutterIcons
- showChatColorUnderlinesCheckBox.isSelected = settings.isShowChatColorUnderlines
- chatColorUnderlinesComboBox.selectedIndex = settings.underlineTypeIndex
- setUnderlineBox()
- changePluginUpdateChannelButton.addActionListener { ConfigurePluginUpdatesDialog().show() }
- }
- private fun setUnderlineBox() {
- chatColorUnderlinesComboBox.isEnabled = showChatColorUnderlinesCheckBox.isSelected
- }
- override fun isModified(): Boolean {
- val settings = MinecraftSettings.instance
- return showProjectPlatformIconsCheckBox.isSelected != settings.isShowProjectPlatformIcons ||
- showEventListenerGutterCheckBox.isSelected != settings.isShowEventListenerGutterIcons ||
- showChatGutterIconsCheckBox.isSelected != settings.isShowChatColorGutterIcons ||
- showChatColorUnderlinesCheckBox.isSelected != settings.isShowChatColorUnderlines ||
- chatColorUnderlinesComboBox.selectedItem !== settings.underlineType
- }
- override fun apply() {
- val settings = MinecraftSettings.instance
- settings.isShowProjectPlatformIcons = showProjectPlatformIconsCheckBox.isSelected
- settings.isShowEventListenerGutterIcons = showEventListenerGutterCheckBox.isSelected
- settings.isShowChatColorGutterIcons = showChatGutterIconsCheckBox.isSelected
- settings.isShowChatColorUnderlines = showChatColorUnderlinesCheckBox.isSelected
- settings.underlineType = chatColorUnderlinesComboBox.selectedItem as? MinecraftSettings.UnderlineType
- ?: MinecraftSettings.UnderlineType.DOTTED
- }
- override fun reset() {
- init()
- }
- }