From da08fdb0fe5cef9e4d25e7bd5199b84f472940ba Mon Sep 17 00:00:00 2001 From: Sergey Simonchik Date: Mon, 13 Oct 2014 17:52:27 +0400 Subject: [PATCH] *preserve the old behavior of FormBuilder.setIndent method; *deprecate FormBuilder.setIndent, because it changes the horizontal gap between label and its component (so, calling FormBuilder.setHorizontalGap(10) doesn't set the actual horizontal gap to 10px) --- .../src/com/intellij/util/ui/FormBuilder.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/platform/platform-api/src/com/intellij/util/ui/FormBuilder.java b/platform/platform-api/src/com/intellij/util/ui/FormBuilder.java index 2c6bff621b55..a8821c686fdf 100644 --- a/platform/platform-api/src/com/intellij/util/ui/FormBuilder.java +++ b/platform/platform-api/src/com/intellij/util/ui/FormBuilder.java @@ -41,6 +41,7 @@ public class FormBuilder { private int myVerticalGap; private int myHorizontalGap; + private int myFormLeftIndent; public FormBuilder() { myPanel = new JPanel(new GridBagLayout()); @@ -49,6 +50,7 @@ public class FormBuilder { myAlignLabelOnRight = false; myVerticalGap = DEFAULT_VGAP; myHorizontalGap = DEFAULT_HGAP; + myFormLeftIndent = 0; } public static FormBuilder createFormBuilder() { @@ -143,7 +145,7 @@ public class FormBuilder { c.weighty = 0; c.fill = NONE; c.anchor = getLabelAnchor(component, false); - c.insets = new Insets(topInset, myIndent, DEFAULT_VGAP, 0); + c.insets = new Insets(topInset, myIndent + myFormLeftIndent, DEFAULT_VGAP, 0); if (label != null) myPanel.add(label, c); @@ -153,7 +155,7 @@ public class FormBuilder { c.weighty = getWeightY(component); c.fill = getFill(component); c.anchor = WEST; - c.insets = new Insets(label == null ? topInset : 0, myIndent, 0, 0); + c.insets = new Insets(label == null ? topInset : 0, myIndent + myFormLeftIndent, 0, 0); myPanel.add(component, c); @@ -167,7 +169,7 @@ public class FormBuilder { c.weighty = 0; c.fill = NONE; c.anchor = getLabelAnchor(component, true); - c.insets = new Insets(topInset, myIndent, 0, myHorizontalGap); + c.insets = new Insets(topInset, myIndent + myFormLeftIndent, 0, myHorizontalGap); myPanel.add(label, c); @@ -176,7 +178,7 @@ public class FormBuilder { c.weighty = getWeightY(component); c.fill = getFill(component); c.anchor = WEST; - c.insets = new Insets(topInset, 0, 0, 0); + c.insets = new Insets(topInset, myIndent, 0, 0); myPanel.add(component, c); @@ -237,8 +239,17 @@ public class FormBuilder { return this; } + /** + * @deprecated use {@code setHorizontalGap} or {@code setFormLeftIndent}, to be removed in IDEA 16 + */ + @Deprecated public FormBuilder setIndent(int indent) { myIndent = indent; return this; } + + public FormBuilder setFormLeftIndent(int formLeftIndent) { + myFormLeftIndent = formLeftIndent; + return this; + } }