get rid of empty space when a smaller tab selected

This commit is contained in:
Sergey Simonchik
2016-05-04 18:25:17 +03:00
parent e256589755
commit a1bb1795a3
2 changed files with 62 additions and 1 deletions
@@ -21,6 +21,7 @@ import com.intellij.execution.configurations.ConfigurationPerRunnerSettings;
import com.intellij.execution.configurations.RunConfiguration;
import com.intellij.execution.configurations.RunnerSettings;
import com.intellij.execution.runners.ProgramRunner;
import com.intellij.execution.ui.AdjustingTabSettingsEditor;
import com.intellij.openapi.options.*;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Disposer;
@@ -31,6 +32,8 @@ import com.intellij.ui.ScrollingUtil;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.Convertor;
import com.intellij.util.ui.update.Activatable;
import com.intellij.util.ui.update.UiNotifyConnector;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -318,7 +321,36 @@ public class ConfigurationSettingsEditor extends CompositeSettingsEditor<RunnerA
@Override
@NotNull
public JComponent createEditor() {
return myConfigEditor.getComponent();
JComponent component = myConfigEditor.getComponent();
if (myConfigEditor instanceof AdjustingTabSettingsEditor) {
JPanel panel = new JPanel(new BorderLayout());
UiNotifyConnector connector = new UiNotifyConnector(panel, new Activatable() {
private boolean myIsEmpty = true;
@Override
public void showNotify() {
if (myIsEmpty) {
panel.add(component, BorderLayout.CENTER);
panel.revalidate();
panel.repaint();
myIsEmpty = false;
}
}
@Override
public void hideNotify() {
if (!myIsEmpty) {
panel.removeAll();
panel.revalidate();
panel.repaint();
myIsEmpty = true;
}
}
});
Disposer.register(this, connector);
return panel;
}
return component;
}
@Override
@@ -0,0 +1,29 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.execution.ui;
import com.intellij.openapi.options.SettingsEditor;
/**
* Marker interface for {@link SettingsEditor} inheritors.
* Allows to ignore this {@link SettingsEditor#getComponent()} when showing {@link javax.swing.JTabbedPane}, if tab
* represented by this {@code SettingsEditor} instance is not selected.
* As a result, no empty space or scrollbars when smaller tab component selected.
*
* @see {@link com.intellij.openapi.options.SettingsEditorGroup}
*/
public interface AdjustingTabSettingsEditor {
}