mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
IJPL-160555 Add separator into DSL ListCellRenderer
- Move the implementation into the impl module GitOrigin-RevId: a46af55f454df812d95c07305c140dd81faab8f7
This commit is contained in:
committed by
intellij-monorepo-bot
parent
31195d51b2
commit
db949dfa12
@@ -9514,14 +9514,6 @@ f:com.intellij.ui.dsl.listCellRenderer.BuilderKt
|
||||
- f:setSpeedSearchHighlighting(Z):V
|
||||
f:com.intellij.ui.dsl.listCellRenderer.LcrUtilsKt
|
||||
- sf:stripHorizontalInsets(javax.swing.JComponent):V
|
||||
com.intellij.ui.dsl.listCellRenderer.UiDslRendererProvider
|
||||
- sf:Companion:com.intellij.ui.dsl.listCellRenderer.UiDslRendererProvider$Companion
|
||||
- s:getEP():com.intellij.openapi.extensions.ExtensionPointName
|
||||
- a:getRenderer(kotlin.jvm.functions.Function1):javax.swing.ListCellRenderer
|
||||
- a:isApplicable():Z
|
||||
f:com.intellij.ui.dsl.listCellRenderer.UiDslRendererProvider$Companion
|
||||
- f:getEP():com.intellij.openapi.extensions.ExtensionPointName
|
||||
- f:getRenderer(kotlin.jvm.functions.Function1):javax.swing.ListCellRenderer
|
||||
com.intellij.ui.dualView.CellWrapper
|
||||
- a:wrap(java.awt.Component,javax.swing.JTable,java.lang.Object,Z,Z,I,I,java.lang.Object):V
|
||||
com.intellij.ui.dualView.DualTreeElement
|
||||
|
||||
@@ -1,33 +1,23 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.ui.dsl.listCellRenderer
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName
|
||||
import com.intellij.ui.dsl.listCellRenderer.impl.LcrRowImpl
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import javax.swing.ListCellRenderer
|
||||
|
||||
/**
|
||||
* Provides cell renderer for DSL UI lists (@see [com.intellij.ui.dsl.listCellRenderer.listCellRenderer]
|
||||
*
|
||||
* Default DSL renderer ([LcrRowImpl]) will be chosen if there are no other suitable renderer providers (@see [isApplicable])
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
interface UiDslRendererProvider {
|
||||
|
||||
companion object {
|
||||
fun <T> getRenderer(renderContent: LcrRow<T>.() -> Unit): ListCellRenderer<T> {
|
||||
val renderer = EP.findFirstSafe { it.isApplicable() }?.getRenderer(renderContent)
|
||||
return renderer ?: LcrRowImpl(renderContent)
|
||||
fun getInstance(): UiDslRendererProvider {
|
||||
return ApplicationManager.getApplication().getService(UiDslRendererProvider::class.java)
|
||||
?: throw IllegalStateException("No UiDslRendererProvider service found")
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
val EP: ExtensionPointName<UiDslRendererProvider> = ExtensionPointName("com.intellij.uiDslRendererProvider")
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the current renderer provider is applicable for the specified situation
|
||||
*
|
||||
* @return true if the provider is able to return its renderer ([getRenderer])
|
||||
*/
|
||||
fun isApplicable(): Boolean
|
||||
|
||||
/**
|
||||
* Retrieves a `ListCellRenderer` for rendering the content of an `LcrRow`.
|
||||
*
|
||||
@@ -35,5 +25,5 @@ interface UiDslRendererProvider {
|
||||
* This function is responsible for providing the content of the row.
|
||||
* @return The `ListCellRenderer` to be used for rendering the content of an `LcrRow`.
|
||||
*/
|
||||
fun <T> getRenderer(renderContent: LcrRow<T>.() -> Unit): ListCellRenderer<T>
|
||||
}
|
||||
fun <T> getLcrRenderer(renderContent: LcrRow<T>.() -> Unit): ListCellRenderer<T>
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ internal annotation class LcrDslMarker
|
||||
* Because of all described nuances, it is hard to write correct own render. So using Kotlin UI DSL is highly recommended
|
||||
*/
|
||||
fun <T> listCellRenderer(init: LcrRow<T>.() -> Unit): ListCellRenderer<T> {
|
||||
return UiDslRendererProvider.getRenderer(init)
|
||||
return UiDslRendererProvider.getInstance().getLcrRenderer(init)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.ui.dsl.listCellRenderer.impl
|
||||
|
||||
import com.intellij.ui.dsl.listCellRenderer.LcrRow
|
||||
import com.intellij.ui.dsl.listCellRenderer.UiDslRendererProvider
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import javax.swing.ListCellRenderer
|
||||
|
||||
@ApiStatus.Internal
|
||||
open class DefaultUiDslRendererProvider : UiDslRendererProvider {
|
||||
|
||||
override fun <T> getLcrRenderer(renderContent: LcrRow<T>.() -> Unit): ListCellRenderer<T> {
|
||||
return LcrRowImpl(renderContent)
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import com.intellij.ui.dsl.gridLayout.HorizontalAlign
|
||||
import com.intellij.ui.dsl.gridLayout.UnscaledGaps
|
||||
import com.intellij.ui.dsl.gridLayout.builders.RowsGridBuilder
|
||||
import com.intellij.ui.dsl.listCellRenderer.*
|
||||
import com.intellij.ui.popup.list.ComboBoxPopup
|
||||
import com.intellij.ui.popup.list.SelectablePanel
|
||||
import com.intellij.ui.render.RenderingUtil
|
||||
import com.intellij.ui.speedSearch.SpeedSearchUtil
|
||||
@@ -156,23 +157,10 @@ open class LcrRowImpl<T>(private val renderer: LcrRow<T>.() -> Unit) : LcrRow<T>
|
||||
}
|
||||
|
||||
private fun isComboBoxPopup(list: JList<*>): Boolean {
|
||||
return isComboBoxPopupClass(list.getClientProperty(JBPopup.KEY)?.javaClass) // isSwingPopup = false
|
||||
return (list.getClientProperty(JBPopup.KEY) is ComboBoxPopup<*>) // isSwingPopup = false
|
||||
|| UIUtil.getParentOfType(BasicComboPopup::class.java, list) != null // isSwingPopup = true
|
||||
}
|
||||
|
||||
// todo move the impl into intellij.platform.ide.impl module and use `is`
|
||||
private fun isComboBoxPopupClass(clazz: Class<*>?): Boolean {
|
||||
var c = clazz
|
||||
while (c != null) {
|
||||
if (c.name == "com.intellij.ui.popup.list.ComboBoxPopup") {
|
||||
return true
|
||||
}
|
||||
c = c.superclass
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses reflection as a workaround, don't call frequently
|
||||
*/
|
||||
@@ -564,7 +564,6 @@
|
||||
</extensionPoint>
|
||||
|
||||
<extensionPoint name="meetNewUiCustomization" interface="com.intellij.ide.ui.experimental.meetNewUi.MeetNewUiCustomization" dynamic="true"/>
|
||||
<extensionPoint name="uiDslRendererProvider" interface="com.intellij.ui.dsl.listCellRenderer.UiDslRendererProvider" dynamic="true"/>
|
||||
|
||||
<extensionPoint name="notificationRouter" interface="com.intellij.notification.NotificationRouter" dynamic="true"/>
|
||||
<extensionPoint name="usageFilteringRuleCustomizer" interface="com.intellij.usages.rules.UsageFilteringRuleCustomizer" dynamic="true"/>
|
||||
|
||||
@@ -156,6 +156,8 @@
|
||||
|
||||
<applicationService serviceInterface="com.intellij.ide.plugins.PluginManagementPolicy"
|
||||
serviceImplementation="com.intellij.ide.plugins.DefaultPluginManagementPolicy"/>
|
||||
<applicationService serviceInterface="com.intellij.ui.dsl.listCellRenderer.UiDslRendererProvider"
|
||||
serviceImplementation="com.intellij.ui.dsl.listCellRenderer.impl.DefaultUiDslRendererProvider"/>
|
||||
|
||||
<experimentalFeature id="wsl.p9.support" percentOfUsers="100">
|
||||
<description>Allow IDE to use the \\wsl$\ paths to access the WSL filesystem using 9P protocol (available since Windows 10 update 1903).</description>
|
||||
|
||||
Reference in New Issue
Block a user