From b0b688cba2dd745a8332d218a0f94e19c5a1c608 Mon Sep 17 00:00:00 2001 From: tangcent Date: Sun, 12 Nov 2023 11:14:14 +0800 Subject: [PATCH] feat: Improve Layout and Responsiveness of Several UI Forms (#518) --- .../idea/plugin/dialog/ApiCallDialog.form | 439 +++-- .../idea/plugin/dialog/ApiCallDialog.kt | 29 - .../idea/plugin/dialog/ContextDialog.kt | 43 +- .../idea/plugin/dialog/EasyApiSettingGUI.form | 1631 ++++++++--------- .../dialog/EasyApiSettingRecommendGUI.form | 4 +- .../dialog/EasyApiSettingRemoteConfigGUI.form | 56 +- .../plugin/dialog/SuvApiExportDialog.form | 170 +- .../idea/plugin/dialog/SuvApiExportDialog.kt | 20 +- 8 files changed, 1225 insertions(+), 1167 deletions(-) diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/ApiCallDialog.form b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/ApiCallDialog.form index 2a6cb130..f1b80b2e 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/ApiCallDialog.form +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/ApiCallDialog.form @@ -1,278 +1,294 @@ -
- - + + + - + - - + + - - + + - - - + - - + + - + - - + + - + - - - + + + - - + + - + - - + + - - + + + - - - - - + - - + + - + - + - - - - - + - - - + + + - - - - - + - - - + + + - + - + - - + + - - + + + + - - - - - + - - + + - - - - + - + - - + + - - - - - + - - + + - - - - - + - + - - + + + - + - - + + - - - + - + - - + + - + - + - - - + + + - + - + - - + + - + - + - + - - + + - - + + - - - + + + - - + + - + - - + + - + - - + + - - + + - - - - + + + + - + - - + + - + - + - + - + - - + + - - - + + + @@ -280,93 +296,119 @@ - + + - - - + + + - - + + - - + + - + - - + + - - + + - + - - + + - - + + - - + + - - + + - + - - + + - - + + - - + + - - + + - - - + + + - - + + - + - + - + - + - + - + - + - + @@ -375,27 +417,30 @@ - - + + - + - + - + - + - - + + - - + + - + @@ -408,4 +453,4 @@ - + \ No newline at end of file diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/ApiCallDialog.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/ApiCallDialog.kt index b65a7a51..54770c72 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/ApiCallDialog.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/ApiCallDialog.kt @@ -189,35 +189,8 @@ class ApiCallDialog : ContextDialog(), ApiCallUI { initApisModule() LOG.info("init RequestModule") initRequestModule() - resize() - this.onResized { - resize() - } - this.requestPanel.onResized { - resize() - } - this.responsePanel.onResized { - resize() - } } - private val resize = { - actionContext.runInSwingUI { - val rightWidth = this.contentPane.width - this.apisListPanel.width - - val rightPanel = this.rightPanel - rightPanel.setSizeIfNecessary(rightWidth, this.contentPane.height - 6) - - val requestPanel = this.requestPanel - requestPanel.setSizeIfNecessary(rightWidth - 30, requestPanel.height) - - this.responsePanel.let { - it.setSizeIfNecessary(rightWidth - 30, it.height) - it.bottomAlignTo(this.apisJList) - } - } - }.throttle(50, TimeUnit.MILLISECONDS) - //region api module private fun initApisModule() { @@ -268,7 +241,6 @@ class ApiCallDialog : ContextDialog(), ApiCallUI { ?.response?.firstOrNull()?.body?.let { RequestUtils.parseRawBody(it) } ?: "" formatForm(currRequest) - resize() } override fun updateRequestList(requestList: List?) { @@ -293,7 +265,6 @@ class ApiCallDialog : ContextDialog(), ApiCallUI { if (requestRawViewList.isNotEmpty()) { this.apisJList.selectedIndex = 0 } - resize() } } diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/ContextDialog.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/ContextDialog.kt index 078e37b3..e77b74e4 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/ContextDialog.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/ContextDialog.kt @@ -1,6 +1,8 @@ package com.itangcent.idea.plugin.dialog import com.google.inject.Inject +import com.intellij.ide.util.PropertiesComponent +import com.itangcent.common.logger.Log import com.itangcent.common.logger.traceError import com.itangcent.common.utils.safe import com.itangcent.idea.utils.initAfterShown @@ -8,12 +10,19 @@ import com.itangcent.intellij.constant.EventKey import com.itangcent.intellij.context.ActionContext import com.itangcent.intellij.extend.guice.PostConstruct import com.itangcent.intellij.logger.Logger +import java.awt.Dimension import java.awt.event.WindowAdapter import java.awt.event.WindowEvent import javax.swing.JDialog import javax.swing.WindowConstants abstract class ContextDialog : JDialog() { + companion object : Log() { + private const val LAST_SIZE = "com.itangcent.easyapi.suv.last.size" + } + + private val lastSizePropertiesName + get() = "$LAST_SIZE.${this::class.qualifiedName}" @Inject protected lateinit var actionContext: ActionContext @@ -36,6 +45,8 @@ abstract class ContextDialog : JDialog() { } }) + restoreSize() + this.initAfterShown { try { init() @@ -45,6 +56,22 @@ abstract class ContextDialog : JDialog() { } finally { init = true } + + //restore size + restoreSize() + } + } + + private fun restoreSize() { + PropertiesComponent.getInstance().getValue(lastSizePropertiesName)?.let { + val split = it.split(",") + if (split.size == 2) { + val width = split[0].toIntOrNull() + val height = split[1].toIntOrNull() + if (width != null && height != null) { + this.size = Dimension(width, height) + } + } } } @@ -87,12 +114,22 @@ abstract class ContextDialog : JDialog() { if (!disposed) { disposed = true dispose() - safe { onDispose() } + actionContext.runAsync { + safe { + PropertiesComponent.getInstance().setValue( + lastSizePropertiesName, + "${this.size.width},${this.size.height}" + ) + } + safe { onDispose() } + safe { + actionContext.unHold() + actionContext.stop() + } + } } } open fun onDispose() { - actionContext.unHold() - actionContext.stop() } } \ No newline at end of file diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/EasyApiSettingGUI.form b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/EasyApiSettingGUI.form index 911fb80e..5b46fe4c 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/EasyApiSettingGUI.form +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/EasyApiSettingGUI.form @@ -3,118 +3,72 @@ - + - + - + - + - + + + - + - + - - - + - + - + - + + + + + - - + - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + - - - - - + - + - - - - - - - - - - - - @@ -126,513 +80,335 @@ - - - - - - - - - - - - - + - + + + + + - - + - - - - + + + + - - - - - - - - - - - - - - - - + + + + + - - - - + + + + - - - - - - - - - - - - + - + + + + + + + + + + + + + + + + + + + + + + + - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - + - - - - - - - - - - - - - + + + + + - + - + + + + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - + + + + - + - - - + - + - + + + + + + + + + + + + + + + + + + + + + + + - + + + + + - + - + - + - + - + - + - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + - + - - - - - - - - - - - - - + + + + - + - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - - - - - - - - - - - - + + + + - + - + - - + - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - + + + + + - - - - + + + + - + - - - - - - - - - - - - @@ -642,66 +418,37 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - + - + - + - + - + @@ -710,27 +457,49 @@ - + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + @@ -739,20 +508,54 @@ - + - + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -761,7 +564,7 @@ - + @@ -770,25 +573,35 @@ - + - + + - - - - - + - + + + + + + + + + + + + + + - + - + @@ -797,7 +610,7 @@ - + @@ -806,10 +619,10 @@ - + - + @@ -823,382 +636,566 @@ - + - + - + - - + - + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - + + + + + + + + + + + - - - - + + + + - + - + - + - - - - - - - - - - - - - + - + - - - - - - - - - - - - - + - - + + + + + + + + + + + + - + + + + + - + - - + - - - - - + - - - - - - - - - - - - - + + + + + + + + + + + + + - - + + + + + - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + - - + + + + + - - - - + + + + - + - - - - - - - - - - - - - - + + - - - - + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - - - - - - - - - - + + + + + - - - - + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + - + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + - + + + + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + - - + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/EasyApiSettingRecommendGUI.form b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/EasyApiSettingRecommendGUI.form index 2ca8b663..540569bc 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/EasyApiSettingRecommendGUI.form +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/EasyApiSettingRecommendGUI.form @@ -12,7 +12,7 @@ - + @@ -37,7 +37,7 @@ - + diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/EasyApiSettingRemoteConfigGUI.form b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/EasyApiSettingRemoteConfigGUI.form index 6d2ebbcb..8f548de5 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/EasyApiSettingRemoteConfigGUI.form +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/EasyApiSettingRemoteConfigGUI.form @@ -8,25 +8,31 @@ - + - + - + + + + + + + - + - + @@ -38,7 +44,7 @@ - + @@ -50,7 +56,7 @@ - + @@ -64,7 +70,7 @@ - + @@ -74,7 +80,7 @@ - + @@ -87,23 +93,35 @@ - + + - + + + - - - + - - + + + + - + - + + + + + + + + + + - + diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/SuvApiExportDialog.form b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/SuvApiExportDialog.form index f2ba735a..62ff9115 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/SuvApiExportDialog.form +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/SuvApiExportDialog.form @@ -1,132 +1,120 @@
- + - + - + - - - - + + + + - - - + - + - - - - + + + + - - + - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + - - - - - + - - - - - - - - - - - - - + + + + + + + + + + - - + + + + + - - - - + + + + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/SuvApiExportDialog.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/SuvApiExportDialog.kt index 16ec919d..ccda16a3 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/SuvApiExportDialog.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/SuvApiExportDialog.kt @@ -1,7 +1,6 @@ package com.itangcent.idea.plugin.dialog import com.intellij.ide.util.PropertiesComponent -import com.intellij.psi.PsiMethod import com.intellij.ui.components.JBCheckBox import com.itangcent.common.logger.traceError import com.itangcent.common.utils.GsonUtils @@ -9,14 +8,19 @@ import com.itangcent.common.utils.notNullOrEmpty import com.itangcent.idea.icons.EasyIcons import com.itangcent.idea.icons.iconOnly import com.itangcent.idea.utils.SwingUtils +import java.awt.Dimension import java.awt.event.KeyEvent import java.awt.event.WindowAdapter import java.awt.event.WindowEvent import java.awt.event.WindowFocusListener -import java.util.concurrent.TimeUnit import javax.swing.* class SuvApiExportDialog : ContextDialog() { + + companion object { + private const val LAST_USED_CHANNEL = "com.itangcent.easyapi.suv.last.used.channel" + } + private var contentPane: JPanel? = null private var buttonOK: JButton? = null private var buttonCancel: JButton? = null @@ -33,7 +37,9 @@ class SuvApiExportDialog : ContextDialog() { init { this.isUndecorated = false - this.isResizable = false + maximumSize = Dimension(800, 800) + + //this.isResizable = false setContentPane(contentPane) isModal = false getRootPane().defaultButton = buttonOK @@ -92,12 +98,12 @@ class SuvApiExportDialog : ContextDialog() { this.apiList!!.model = DefaultComboBoxModel(requestList.toTypedArray()) } - fun selectAll(){ + fun selectAll() { this.selectAllCheckBox!!.isSelected = true onSelectedAll() } - fun selectMethod(api: Any?){ + fun selectMethod(api: Any?) { this.selectAllCheckBox!!.isSelected = false this.docList?.indexOf(api)?.let { apiList!!.selectedIndex = it @@ -189,8 +195,4 @@ class SuvApiExportDialog : ContextDialog() { dispose() } } - - companion object { - private const val LAST_USED_CHANNEL = "com.itangcent.last.used.channel" - } }