|
| 1 | +package wu.seal.jsontokotlin |
| 2 | + |
| 3 | +import com.intellij.openapi.ui.DialogWrapper |
| 4 | +import com.intellij.util.ui.JBDimension |
| 5 | +import java.awt.BorderLayout |
| 6 | +import java.awt.ComponentOrientation |
| 7 | +import javax.swing.* |
| 8 | + |
| 9 | +/** |
| 10 | + * |
| 11 | + * Created by LENOVO on 2017/9/13. |
| 12 | + */ |
| 13 | + |
| 14 | +interface IConfigSettingDialog { |
| 15 | + |
| 16 | + fun show() |
| 17 | + |
| 18 | + fun dismiss() |
| 19 | + |
| 20 | +} |
| 21 | + |
| 22 | + |
| 23 | +class ConfigSettingDialog(canBeParent: Boolean) : DialogWrapper(canBeParent), IConfigSettingDialog { |
| 24 | + |
| 25 | + init { |
| 26 | + init() |
| 27 | + title = "Config Settings" |
| 28 | + } |
| 29 | + |
| 30 | + |
| 31 | + override fun createCenterPanel(): JComponent? { |
| 32 | + val tabbedPane = JTabbedPane() |
| 33 | + |
| 34 | + val propertyPane = JPanel(BorderLayout(5, 5)) |
| 35 | + propertyPane.componentOrientation = ComponentOrientation.LEFT_TO_RIGHT |
| 36 | + val radioButtonVal = JRadioButton("Val") |
| 37 | + |
| 38 | + radioButtonVal.addActionListener { |
| 39 | + ConfigManager.isPropertiesVar = false |
| 40 | + } |
| 41 | + val radioButtonVar = JRadioButton("Var") |
| 42 | + radioButtonVar.addActionListener { |
| 43 | + ConfigManager.isPropertiesVar = true |
| 44 | + } |
| 45 | + |
| 46 | + if (ConfigManager.isPropertiesVar) { |
| 47 | + |
| 48 | + radioButtonVar.isSelected = true |
| 49 | + } else { |
| 50 | + radioButtonVal.isSelected = true |
| 51 | + } |
| 52 | + |
| 53 | + val buttonGroupProperty = ButtonGroup() |
| 54 | + buttonGroupProperty.add(radioButtonVal) |
| 55 | + buttonGroupProperty.add(radioButtonVar) |
| 56 | + |
| 57 | + propertyPane.add(radioButtonVal, BorderLayout.NORTH) |
| 58 | + propertyPane.add(radioButtonVar, BorderLayout.CENTER) |
| 59 | + tabbedPane.add("Property Keyword", propertyPane) |
| 60 | + |
| 61 | + tabbedPane.minimumSize = JBDimension(300, 180) |
| 62 | + |
| 63 | + return tabbedPane |
| 64 | + } |
| 65 | + |
| 66 | + |
| 67 | + override fun dismiss() { |
| 68 | + close(CANCEL_EXIT_CODE) |
| 69 | + } |
| 70 | + |
| 71 | + |
| 72 | + override fun createActions(): Array<Action> { |
| 73 | + return arrayOf(okAction) |
| 74 | + } |
| 75 | + |
| 76 | +} |
0 commit comments