mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix inset: VerticalFlowLayout incorrectly uses vertical gap as top inset
This commit is contained in:
+12
-1
@@ -10,6 +10,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
abstract class MergedCompositeConfigurable implements SearchableConfigurable {
|
||||
protected final Configurable[] children;
|
||||
@@ -43,7 +44,7 @@ abstract class MergedCompositeConfigurable implements SearchableConfigurable {
|
||||
rootComponent = children[0].createComponent();
|
||||
}
|
||||
else {
|
||||
JPanel panel = new JPanel(new VerticalFlowLayout(0, isUseTitledBorder() ? 0 : TitledSeparator.TOP_INSET));
|
||||
JPanel panel = createPanel(isUseTitledBorder());
|
||||
for (Configurable child : children) {
|
||||
JComponent component = child.createComponent();
|
||||
assert component != null;
|
||||
@@ -58,6 +59,16 @@ abstract class MergedCompositeConfigurable implements SearchableConfigurable {
|
||||
return rootComponent;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
static JPanel createPanel(boolean isUseTitledBorder) {
|
||||
int verticalGap = TitledSeparator.TOP_INSET;
|
||||
JPanel panel = new JPanel(new VerticalFlowLayout(0, isUseTitledBorder ? 0 : verticalGap));
|
||||
// 1) VerticalFlowLayout incorrectly use vertical gap as top inset
|
||||
// 2) if isUseTitledBorder, created titled border will add gap before component
|
||||
panel.setBorder(new EmptyBorder(-verticalGap, 0, 0, 0));
|
||||
return panel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
for (Configurable child : children) {
|
||||
|
||||
+5
-2
@@ -26,6 +26,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.util.List;
|
||||
|
||||
abstract class SubCompositeConfigurable implements SearchableConfigurable.Parent {
|
||||
@@ -109,9 +110,11 @@ abstract class SubCompositeConfigurable implements SearchableConfigurable.Parent
|
||||
rootComponent = children[0].createComponent();
|
||||
}
|
||||
else {
|
||||
JPanel panel = new JPanel(new VerticalFlowLayout(0, IdeBorderFactory.TITLED_BORDER_BOTTOM_INSET));
|
||||
JPanel panel = new JPanel(new VerticalFlowLayout(0, 0));
|
||||
if (root != null) {
|
||||
panel.add(root.getComponent());
|
||||
JComponent c = root.getComponent();
|
||||
c.setBorder(new EmptyBorder(0, 0, IdeBorderFactory.TITLED_BORDER_BOTTOM_INSET, 0));
|
||||
panel.add(c);
|
||||
}
|
||||
for (Configurable child : children) {
|
||||
JComponent component = child.createComponent();
|
||||
|
||||
Reference in New Issue
Block a user