mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ui: show all available test panels in internal showcase dialog
GitOrigin-RevId: 0333401d33f0cc0584f8e51ac2190627981640c0
This commit is contained in:
committed by
intellij-monorepo-bot
parent
964a09d371
commit
0911f16950
@@ -1,24 +1,38 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.ui.layout
|
||||
|
||||
import com.google.common.base.CaseFormat
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.project.DumbAwareAction
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.ui.components.dialog
|
||||
import com.intellij.ui.tabs.JBTabsFactory
|
||||
import com.intellij.ui.tabs.TabInfo
|
||||
import javax.swing.JPanel
|
||||
import kotlin.reflect.jvm.kotlinFunction
|
||||
|
||||
// not easy to replicate the same LaF outside of IDEA app, so, to be sure, showcase available as an IDE action
|
||||
internal class ShowcaseUiDslAction : DumbAwareAction() {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val disposable = Disposer.newDisposable()
|
||||
val tabs = JBTabsFactory.createEditorTabs(e.project, disposable)
|
||||
tabs.presentation.setAlphabeticalMode(false)
|
||||
tabs.presentation.setSupportsCompression(false)
|
||||
tabs.presentation.setAlphabeticalMode(true)
|
||||
|
||||
tabs.addTab(TabInfo(secondColumnSmallerPanel()).setText("Second Column Smaller"))
|
||||
tabs.addTab(TabInfo(rowWithIndent()).setText("Row with Indent"))
|
||||
val clazz = Class.forName("com.intellij.ui.layout.TestPanelsKt")
|
||||
for (declaredMethod in clazz.declaredMethods) {
|
||||
val method = declaredMethod.kotlinFunction!!
|
||||
if (method.returnType.classifier == JPanel::class && method.parameters.isEmpty()) {
|
||||
val panel = method.call() as JPanel
|
||||
val text = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, method.name)
|
||||
.replace("_", " ").capitalize().removeSuffix(" Panel")
|
||||
tabs.addTab(TabInfo(panel).setText(text))
|
||||
}
|
||||
}
|
||||
|
||||
val dialog = dialog("UI DSL Showcase", tabs.component)
|
||||
tabs.select(tabs.tabs.first(), false)
|
||||
|
||||
val dialog = dialog("UI DSL Showcase", tabs.component, resizable = true)
|
||||
Disposer.register(dialog.disposable, disposable)
|
||||
dialog.showAndGet()
|
||||
}
|
||||
|
||||
@@ -10,6 +10,10 @@ import java.awt.Dimension
|
||||
import java.awt.GridLayout
|
||||
import javax.swing.*
|
||||
|
||||
/**
|
||||
* See [ShowcaseUiDslAction]
|
||||
*/
|
||||
|
||||
fun labelRowShouldNotGrow(): JPanel {
|
||||
return panel {
|
||||
row("Create Android module") { CheckBox("FooBar module name foo")() }
|
||||
|
||||
Reference in New Issue
Block a user