get rid of empty space when a smaller tab selected
authorSergey Simonchik <sergey.simonchik@jetbrains.com>
Wed, 4 May 2016 15:25:17 +0000 (18:25 +0300)
committerSergey Simonchik <sergey.simonchik@jetbrains.com>
Wed, 4 May 2016 15:25:17 +0000 (18:25 +0300)
platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditor.java
platform/lang-impl/src/com/intellij/execution/ui/AdjustingTabSettingsEditor.java [new file with mode: 0644]

index d40bb736a36ce71277d081a96ef2bcdf1f03f360..99cb84c7009783b2483a796694fa308b551d12bf 100644 (file)
@@ -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
diff --git a/platform/lang-impl/src/com/intellij/execution/ui/AdjustingTabSettingsEditor.java b/platform/lang-impl/src/com/intellij/execution/ui/AdjustingTabSettingsEditor.java
new file mode 100644 (file)
index 0000000..e5b465d
--- /dev/null
@@ -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 {
+}