mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[collab] Unbreak API for creating vertical and horizontal panels
GitOrigin-RevId: 9da16b05d9e3717b64837e1ed3987935fc5da44d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
210f31790b
commit
2496c9033a
@@ -322,16 +322,16 @@ f:com.intellij.collaboration.api.json.JsonHttpApiHelperKt
|
||||
- sf:setContentPreservingFocus(com.intellij.ui.components.panels.Wrapper,javax.swing.JComponent):V
|
||||
*f:com.intellij.collaboration.ui.ComponentListPanelFactory
|
||||
- sf:INSTANCE:com.intellij.collaboration.ui.ComponentListPanelFactory
|
||||
- f:createHorizontal(kotlinx.coroutines.CoroutineScope,kotlinx.coroutines.flow.StateFlow,kotlin.jvm.functions.Function1,I,kotlin.jvm.functions.Function2):javax.swing.JPanel
|
||||
- bs:createHorizontal$default(com.intellij.collaboration.ui.ComponentListPanelFactory,kotlinx.coroutines.CoroutineScope,kotlinx.coroutines.flow.StateFlow,kotlin.jvm.functions.Function1,I,kotlin.jvm.functions.Function2,I,java.lang.Object):javax.swing.JPanel
|
||||
- f:createHorizontal(kotlinx.coroutines.CoroutineScope,kotlinx.coroutines.flow.Flow,kotlin.jvm.functions.Function1,I,kotlin.jvm.functions.Function2):javax.swing.JPanel
|
||||
- bs:createHorizontal$default(com.intellij.collaboration.ui.ComponentListPanelFactory,kotlinx.coroutines.CoroutineScope,kotlinx.coroutines.flow.Flow,kotlin.jvm.functions.Function1,I,kotlin.jvm.functions.Function2,I,java.lang.Object):javax.swing.JPanel
|
||||
- f:createVertical(javax.swing.ListModel,I,kotlin.jvm.functions.Function1):javax.swing.JPanel
|
||||
- f:createVertical(kotlinx.coroutines.CoroutineScope,javax.swing.ListModel,I,kotlin.jvm.functions.Function2):javax.swing.JPanel
|
||||
- f:createVertical(kotlinx.coroutines.CoroutineScope,kotlinx.coroutines.flow.StateFlow,kotlin.jvm.functions.Function1,I,kotlin.jvm.functions.Function2):javax.swing.JPanel
|
||||
- f:createVertical(kotlinx.coroutines.flow.StateFlow,I,kotlin.jvm.functions.Function2):javax.swing.JPanel
|
||||
- f:createVertical(kotlinx.coroutines.CoroutineScope,kotlinx.coroutines.flow.Flow,kotlin.jvm.functions.Function1,I,kotlin.jvm.functions.Function2):javax.swing.JPanel
|
||||
- f:createVertical(kotlinx.coroutines.flow.Flow,I,kotlin.jvm.functions.Function2):javax.swing.JPanel
|
||||
- bs:createVertical$default(com.intellij.collaboration.ui.ComponentListPanelFactory,javax.swing.ListModel,I,kotlin.jvm.functions.Function1,I,java.lang.Object):javax.swing.JPanel
|
||||
- bs:createVertical$default(com.intellij.collaboration.ui.ComponentListPanelFactory,kotlinx.coroutines.CoroutineScope,javax.swing.ListModel,I,kotlin.jvm.functions.Function2,I,java.lang.Object):javax.swing.JPanel
|
||||
- bs:createVertical$default(com.intellij.collaboration.ui.ComponentListPanelFactory,kotlinx.coroutines.CoroutineScope,kotlinx.coroutines.flow.StateFlow,kotlin.jvm.functions.Function1,I,kotlin.jvm.functions.Function2,I,java.lang.Object):javax.swing.JPanel
|
||||
- bs:createVertical$default(com.intellij.collaboration.ui.ComponentListPanelFactory,kotlinx.coroutines.flow.StateFlow,I,kotlin.jvm.functions.Function2,I,java.lang.Object):javax.swing.JPanel
|
||||
- bs:createVertical$default(com.intellij.collaboration.ui.ComponentListPanelFactory,kotlinx.coroutines.CoroutineScope,kotlinx.coroutines.flow.Flow,kotlin.jvm.functions.Function1,I,kotlin.jvm.functions.Function2,I,java.lang.Object):javax.swing.JPanel
|
||||
- bs:createVertical$default(com.intellij.collaboration.ui.ComponentListPanelFactory,kotlinx.coroutines.flow.Flow,I,kotlin.jvm.functions.Function2,I,java.lang.Object):javax.swing.JPanel
|
||||
*f:com.intellij.collaboration.ui.EditableComponentFactory
|
||||
- sf:INSTANCE:com.intellij.collaboration.ui.EditableComponentFactory
|
||||
- f:create(kotlinx.coroutines.CoroutineScope,javax.swing.JComponent,kotlinx.coroutines.flow.Flow,kotlin.jvm.functions.Function2):javax.swing.JComponent
|
||||
|
||||
+9
-5
@@ -12,7 +12,10 @@ import com.intellij.platform.util.coroutines.childScope
|
||||
import com.intellij.ui.ClientProperty
|
||||
import com.intellij.util.ui.launchOnShow
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.SharingStarted
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.stateIn
|
||||
import javax.swing.JComponent
|
||||
import javax.swing.JPanel
|
||||
import javax.swing.ListModel
|
||||
@@ -135,7 +138,7 @@ object ComponentListPanelFactory {
|
||||
*/
|
||||
fun <T : Any> createVertical(
|
||||
parentCs: CoroutineScope,
|
||||
items: StateFlow<List<T>>,
|
||||
items: Flow<List<T>>,
|
||||
panelInitializer: JPanel.() -> Unit = {},
|
||||
gap: Int = 0,
|
||||
componentFactory: CoroutineScope.(T) -> JComponent,
|
||||
@@ -151,7 +154,7 @@ object ComponentListPanelFactory {
|
||||
* @param T must implement proper equals/hashCode
|
||||
*/
|
||||
fun <T : Any> createVertical(
|
||||
items: StateFlow<List<T>>,
|
||||
items: Flow<List<T>>,
|
||||
gap: Int = 0,
|
||||
componentFactory: CoroutineScope.(T) -> JComponent,
|
||||
): JPanel {
|
||||
@@ -169,7 +172,7 @@ object ComponentListPanelFactory {
|
||||
*/
|
||||
fun <T : Any> createHorizontal(
|
||||
parentCs: CoroutineScope,
|
||||
items: StateFlow<List<T>>,
|
||||
items: Flow<List<T>>,
|
||||
panelInitializer: JPanel.() -> Unit = {},
|
||||
gap: Int = 0,
|
||||
componentFactory: CoroutineScope.(T) -> JComponent,
|
||||
@@ -181,7 +184,7 @@ object ComponentListPanelFactory {
|
||||
return panel
|
||||
}
|
||||
|
||||
private suspend fun <T : Any> JPanel.showItems(items: StateFlow<List<T>>, componentFactory: CoroutineScope.(T) -> JComponent): Nothing {
|
||||
private suspend fun <T : Any> JPanel.showItems(items: Flow<List<T>>, componentFactory: CoroutineScope.(T) -> JComponent): Nothing {
|
||||
coroutineScope {
|
||||
val cs = this
|
||||
fun addComponent(idx: Int, item: T) {
|
||||
@@ -199,7 +202,8 @@ object ComponentListPanelFactory {
|
||||
remove(idx)
|
||||
}
|
||||
|
||||
items.changesFlow().collect { changes ->
|
||||
val itemsState = items as? StateFlow ?: items.stateIn(this, SharingStarted.Eagerly, emptyList())
|
||||
itemsState.changesFlow().collect { changes ->
|
||||
// apply changes. changesFlow should already order them in an applicable way
|
||||
for (change in changes) {
|
||||
when (change) {
|
||||
|
||||
Reference in New Issue
Block a user