From 60d40172e8ff1a288ec1a11f16e045255de29b22 Mon Sep 17 00:00:00 2001 From: Ivan Semenov Date: Thu, 30 Jan 2020 22:49:17 +0300 Subject: [PATCH] [github] Fix PR timeline width Switch to proper vertical layout and restrict width via layout constraint GitOrigin-RevId: 06cca3ba2be7aa07c53dc84cf7698837dcb98801 --- .../github/pullrequest/GHPREditorProvider.kt | 16 +++++++--------- .../ui/GHPRReviewThreadCommentsPanel.kt | 19 ++++++++----------- .../ui/timeline/GHPRReviewThreadsPanel.kt | 11 ++++++----- .../ui/timeline/GHPRTimelineComponent.kt | 10 +++++----- 4 files changed, 26 insertions(+), 30 deletions(-) diff --git a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/GHPREditorProvider.kt b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/GHPREditorProvider.kt index c91e94ac8fc3..e50253d37ca9 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/GHPREditorProvider.kt +++ b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/GHPREditorProvider.kt @@ -1,4 +1,4 @@ -// 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. +// Copyright 2000-2020 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 org.jetbrains.plugins.github.pullrequest import com.intellij.ide.DataManager @@ -130,21 +130,19 @@ internal class GHPREditorProvider : FileEditorProvider, DumbAware { layout = MigLayout(LC().gridGap("0", "0") .insets("0", "0", "0", "0") .fillX() - .flowY()).apply { - columnConstraints = AC().fill().size("0:$maxWidth:$maxWidth") - } + .flowY(), + AC().size(":$maxWidth:$maxWidth").gap("push")) emptyText.clear() - add(header, CC().width("0:$maxWidth:$maxWidth")) - add(timeline, CC().width("0:$maxWidth:$maxWidth")) - add(loadingIcon, CC().width("0:$maxWidth:$maxWidth").hideMode(2).alignX("center")) + add(header) + add(timeline, CC().growX().minWidth("")) + add(loadingIcon, CC().hideMode(2).alignX("center")) with(context.commentService) { if (canComment()) { val commentServiceAdapter = GHPRCommentServiceAdapter.create(this, dataProvider) - add(createCommentField(project, commentServiceAdapter, avatarIconsProvider, context.currentUser), - CC().width("0:$maxWidth:$maxWidth")) + add(createCommentField(project, commentServiceAdapter, avatarIconsProvider, context.currentUser), CC().growX()) } } } diff --git a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/comment/ui/GHPRReviewThreadCommentsPanel.kt b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/comment/ui/GHPRReviewThreadCommentsPanel.kt index 3f0871c34e0d..6b6a1764e960 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/comment/ui/GHPRReviewThreadCommentsPanel.kt +++ b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/comment/ui/GHPRReviewThreadCommentsPanel.kt @@ -1,14 +1,11 @@ -// 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. +// Copyright 2000-2020 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 org.jetbrains.plugins.github.pullrequest.comment.ui +import com.intellij.ide.plugins.newui.VerticalLayout import com.intellij.ide.ui.laf.darcula.DarculaUIUtil import com.intellij.openapi.util.text.StringUtil import com.intellij.ui.ClickListener -import com.intellij.ui.components.panels.VerticalLayout -import com.intellij.util.ui.JBInsets -import com.intellij.util.ui.JBUI -import com.intellij.util.ui.MacUIUtil -import com.intellij.util.ui.UIUtil +import com.intellij.util.ui.* import com.intellij.util.ui.components.BorderLayoutPanel import org.jetbrains.plugins.github.pullrequest.avatars.GHAvatarIconsProvider import org.jetbrains.plugins.github.ui.util.SingleValueModel @@ -23,7 +20,7 @@ import javax.swing.event.ListDataListener class GHPRReviewThreadCommentsPanel(private val commentsModel: ListModel, private val avatarIconsProvider: GHAvatarIconsProvider) - : JPanel(VerticalLayout(8)) { + : JPanel(VerticalLayout(UI.scale(8))) { private val foldModel = SingleValueModel(true) private val foldThreshold = 2 @@ -54,7 +51,7 @@ class GHPRReviewThreadCommentsPanel(private val commentsModel: ListModel JComponent) - : JPanel(VerticalLayout(12)), ComponentWithEmptyText { + : JPanel(VerticalLayout(UI.scale(12))), ComponentWithEmptyText { private val statusText = object : StatusText(this) { init { @@ -36,7 +37,7 @@ class GHPRReviewThreadsPanel(model: GHPRReviewThreadsModel, private val threadCo override fun intervalAdded(e: ListDataEvent) { for (i in e.index0..e.index1) { - add(threadComponentFactory(model.getElementAt(i)), i) + add(threadComponentFactory(model.getElementAt(i)), VerticalLayout.FILL_HORIZONTAL, i) } revalidate() repaint() @@ -49,7 +50,7 @@ class GHPRReviewThreadsPanel(model: GHPRReviewThreadsModel, private val threadCo }) for (i in 0 until model.size) { - add(threadComponentFactory(model.getElementAt(i)), i) + add(threadComponentFactory(model.getElementAt(i)), VerticalLayout.FILL_HORIZONTAL, i) } } diff --git a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/ui/timeline/GHPRTimelineComponent.kt b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/ui/timeline/GHPRTimelineComponent.kt index 005ae456ac6c..2b35add992cd 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/ui/timeline/GHPRTimelineComponent.kt +++ b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/ui/timeline/GHPRTimelineComponent.kt @@ -1,10 +1,10 @@ -// 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. +// Copyright 2000-2020 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 org.jetbrains.plugins.github.pullrequest.ui.timeline +import com.intellij.ide.plugins.newui.VerticalLayout import com.intellij.openapi.util.text.StringUtil import com.intellij.ui.ColorUtil import com.intellij.ui.JBColor -import com.intellij.ui.components.panels.VerticalLayout import com.intellij.ui.paint.LinePainter2D import com.intellij.util.ui.* import org.jetbrains.plugins.github.api.data.pullrequest.timeline.GHPRTimelineItem @@ -19,7 +19,7 @@ import javax.swing.event.ListDataListener class GHPRTimelineComponent(private val model: ListModel, private val itemComponentFactory: GHPRTimelineItemComponentFactory) - : JPanel(VerticalLayout(20)), ComponentWithEmptyText { + : JPanel(VerticalLayout(UI.scale(20))), ComponentWithEmptyText { private val emptyText = object : StatusText(this) { override fun isStatusVisible() = model.size == 0 @@ -46,7 +46,7 @@ class GHPRTimelineComponent(private val model: ListModel, override fun intervalAdded(e: ListDataEvent) { for (i in e.index0..e.index1) { - add(itemComponentFactory.createComponent(model.getElementAt(i)), i) + add(itemComponentFactory.createComponent(model.getElementAt(i)), VerticalLayout.FILL_HORIZONTAL, i) } revalidate() repaint() @@ -59,7 +59,7 @@ class GHPRTimelineComponent(private val model: ListModel, }) for (i in 0 until model.size) { - add(itemComponentFactory.createComponent(model.getElementAt(i)), i) + add(itemComponentFactory.createComponent(model.getElementAt(i)), VerticalLayout.FILL_HORIZONTAL, i) } }