vcs: properly hide whole toolbar panels in the log and diff preview when toolbars is hidden for particular toolwindow

GitOrigin-RevId: 809b05dc7a7ee45dda181468b01d8b123d0e1510
This commit is contained in:
Dmitry Zhuravlev
2019-12-06 14:39:34 +00:00
committed by intellij-monorepo-bot
parent d603ec12fe
commit 1c69d8b6d6
4 changed files with 32 additions and 2 deletions
@@ -60,6 +60,7 @@ import com.intellij.ui.scale.JBUIScale;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UIUtil;
import com.intellij.vcsUtil.UIVcsUtilKt;
import org.jetbrains.annotations.CalledInAwt;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -67,8 +68,10 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.*;
import java.util.Set;
public abstract class DiffRequestProcessor implements Disposable {
private static final Logger LOG = Logger.getInstance(DiffRequestProcessor.class);
@@ -139,6 +142,7 @@ public abstract class DiffRequestProcessor implements Disposable {
JPanel statusPanel = JBUI.Panels.simplePanel(myToolbarStatusPanel).addToLeft(myProgressBar);
JPanel topPanel = JBUI.Panels.simplePanel(myToolbarWrapper).addToRight(statusPanel);
UIVcsUtilKt.installVisibilityReferent(topPanel, myToolbar.getComponent());
Splitter bottomContentSplitter = new JBSplitter(true, "DiffRequestProcessor.BottomComponentSplitter", 0.8f);
bottomContentSplitter.setFirstComponent(myContentPanel);
@@ -0,0 +1,21 @@
// 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.vcsUtil
import java.awt.event.ComponentAdapter
import java.awt.event.ComponentEvent
import javax.swing.JComponent
object UIVcsUtilKt {
@JvmStatic
fun JComponent.installVisibilityReferent(referent: JComponent) {
referent.addComponentListener(object: ComponentAdapter() {
override fun componentHidden(e: ComponentEvent) = toggleVisibility(e)
override fun componentShown(e: ComponentEvent) = toggleVisibility(e)
private fun toggleVisibility(e: ComponentEvent) {
val component = e.component ?: return
isVisible = component.isVisible
}
})
}
}
@@ -64,6 +64,7 @@ import com.intellij.vcs.log.util.VcsLogUiUtil;
import com.intellij.vcs.log.util.VcsLogUtil;
import com.intellij.vcs.log.visible.VisiblePack;
import com.intellij.vcs.log.visible.filters.VcsLogFiltersKt;
import com.intellij.vcsUtil.UIVcsUtilKt;
import kotlin.Unit;
import net.miginfocom.swing.MigLayout;
import org.jetbrains.annotations.NonNls;
@@ -365,6 +366,7 @@ public class MainFrame extends JPanel implements DataProvider, Disposable {
rightCornerToolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);
JPanel panel = new JPanel(new MigLayout("ins 0, fill", "[left]0[left, fill]push[right]", "center"));
UIVcsUtilKt.installVisibilityReferent(panel, toolbar.getComponent());
panel.add(textFilter);
panel.add(toolbar.getComponent());
panel.add(rightCornerToolbar.getComponent());
@@ -46,6 +46,7 @@ import com.intellij.vcs.log.ui.VcsLogActionPlaces;
import com.intellij.vcs.log.util.StopWatch;
import com.intellij.vcs.log.util.VcsLogUiUtil;
import com.intellij.vcs.log.util.VcsLogUtil;
import com.intellij.vcsUtil.UIVcsUtilKt;
import com.intellij.vcsUtil.VcsFileUtil;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
@@ -104,7 +105,9 @@ public class VcsLogChangesBrowser extends ChangesBrowserBase implements Disposab
Disposer.register(parent, this);
myToolbarWrapper = new Wrapper(getToolbar().getComponent());
JComponent toolbarComponent = getToolbar().getComponent();
myToolbarWrapper = new Wrapper(toolbarComponent);
UIVcsUtilKt.installVisibilityReferent(myToolbarWrapper, toolbarComponent);
init();