From 5064d08a8760c74f8f0d3fb234b56853bf9e7d06 Mon Sep 17 00:00:00 2001 From: Fred Bricon Date: Thu, 22 Jun 2023 15:15:43 +0200 Subject: [PATCH 1/2] fix: set proper borders / alignment in quarkus wizard Signed-off-by: Fred Bricon --- .../QuarkusCodeEndpointChooserStep.java | 2 + .../quarkus/module/QuarkusExtensionsStep.java | 64 ++++++++++--------- .../quarkus/module/QuarkusModuleInfoStep.java | 3 + 3 files changed, 38 insertions(+), 31 deletions(-) diff --git a/src/main/java/com/redhat/devtools/intellij/quarkus/module/QuarkusCodeEndpointChooserStep.java b/src/main/java/com/redhat/devtools/intellij/quarkus/module/QuarkusCodeEndpointChooserStep.java index 98d85d780..425364ff5 100644 --- a/src/main/java/com/redhat/devtools/intellij/quarkus/module/QuarkusCodeEndpointChooserStep.java +++ b/src/main/java/com/redhat/devtools/intellij/quarkus/module/QuarkusCodeEndpointChooserStep.java @@ -21,6 +21,7 @@ import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Comparing; import com.intellij.ui.HyperlinkLabel; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.TextFieldWithStoredHistory; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBRadioButton; @@ -104,6 +105,7 @@ public void actionPerformed(ActionEvent e) { builder.addTooltip("Make sure your network connection is active before continuing."); JPanel panel = new JPanel(new BorderLayout()); panel.add(builder.getPanel(), "North"); + panel.setBorder(JBUI.Borders.empty(20)); return panel; } diff --git a/src/main/java/com/redhat/devtools/intellij/quarkus/module/QuarkusExtensionsStep.java b/src/main/java/com/redhat/devtools/intellij/quarkus/module/QuarkusExtensionsStep.java index 5943349ca..f0ab6da47 100644 --- a/src/main/java/com/redhat/devtools/intellij/quarkus/module/QuarkusExtensionsStep.java +++ b/src/main/java/com/redhat/devtools/intellij/quarkus/module/QuarkusExtensionsStep.java @@ -16,13 +16,7 @@ import com.intellij.openapi.Disposable; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.util.IconLoader; -import com.intellij.ui.CheckboxTree; -import com.intellij.ui.CheckboxTreeListener; -import com.intellij.ui.CheckedTreeNode; -import com.intellij.ui.ColoredListCellRenderer; -import com.intellij.ui.DocumentAdapter; -import com.intellij.ui.JBSplitter; -import com.intellij.ui.SearchTextField; +import com.intellij.ui.*; import com.intellij.ui.components.JBList; import com.intellij.ui.components.JBScrollPane; import com.intellij.util.ui.JBUI; @@ -32,16 +26,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.swing.AbstractListModel; -import javax.swing.BoxLayout; -import javax.swing.Icon; -import javax.swing.JCheckBox; -import javax.swing.JComponent; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.JTextPane; -import javax.swing.JTree; +import javax.swing.*; import javax.swing.event.DocumentEvent; import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; @@ -53,9 +38,7 @@ import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Font; +import java.awt.*; import java.util.ArrayList; import java.util.Enumeration; import java.util.HashSet; @@ -65,12 +48,12 @@ public class QuarkusExtensionsStep extends ModuleWizardStep implements Disposable { private static final Logger LOGGER = LoggerFactory.getLogger(QuarkusExtensionsStep.class); - private static final Icon PLATFORM_ICON = IconLoader.findIcon("/images/platform-icon.svg"); + private static final Icon PLATFORM_ICON = IconLoader.findIcon("/images/platform-icon.svg", QuarkusExtensionsStep.class); - private JPanel panel; + private JPanel outerPanel; private final WizardContext wizardContext; - private class ExtensionsTreeCellRenderer extends CheckboxTree.CheckboxTreeCellRenderer { + private static class ExtensionsTreeCellRenderer extends CheckboxTree.CheckboxTreeCellRenderer { @Override public void customizeRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { @@ -86,14 +69,14 @@ public void customizeRenderer(JTree tree, Object value, boolean selected, boolea } } - private class ExtensionsTree extends CheckboxTree { + private static class ExtensionsTree extends CheckboxTree { public ExtensionsTree(CheckedTreeNode root) { super(new ExtensionsTreeCellRenderer(), root); } } - private class SelectedExtensionsModel extends AbstractListModel { + private static class SelectedExtensionsModel extends AbstractListModel { private final List extensions = new ArrayList<>(); @@ -124,18 +107,23 @@ public QuarkusExtensionsStep(WizardContext wizardContext) { @Override public JComponent getComponent() { - if (panel == null && wizardContext.getUserData(QuarkusConstants.WIZARD_EXTENSIONS_MODEL_KEY) != null) { - panel = new JPanel(); + if (outerPanel == null && wizardContext.getUserData(QuarkusConstants.WIZARD_EXTENSIONS_MODEL_KEY) != null) { + outerPanel = new JPanel(); + outerPanel.setLayout(new BorderLayout()); + + JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); + panel.setBorder(JBUI.Borders.empty(20)); + + JLabel label1 = new JLabel("Filter extensions"); label1.setAlignmentX(Component.LEFT_ALIGNMENT); panel.add(label1); SearchTextField filter = new SearchTextField() { @Override public Dimension getMaximumSize() { - Dimension size = super.getPreferredSize(); - size.height = JBUI.scale(30); - return size; + Dimension maxSize = super.getMaximumSize(); + return new Dimension(maxSize.width, JBUI.scale(30)); } }; filter.setAlignmentX(Component.LEFT_ALIGNMENT); @@ -162,20 +150,33 @@ public Dimension getMaximumSize() { extensionsSplitter.setFirstComponent(new JBScrollPane(extensionsTree)); extensionsSplitter.setSecondComponent(extensionDetailTextPane); extensionsPanel.setFirstComponent(extensionsSplitter); + JBList selectedExtensions = new JBList<>(); + selectedExtensions.setBackground(null); + selectedExtensions.setAlignmentX(Component.LEFT_ALIGNMENT); selectedExtensions.setModel(new SelectedExtensionsModel(categories)); ColoredListCellRenderer selectedExtensionRenderer = new ColoredListCellRenderer() { @Override protected void customizeCellRenderer(@NotNull JList list, QuarkusExtension extension, int index, boolean selected, boolean hasFocus) { append(extension.getName()); } + + @Override + public Component getListCellRendererComponent(JList list, QuarkusExtension value, int index, boolean selected, boolean hasFocus) { + super.getListCellRendererComponent(list, value, index, selected, hasFocus); + setAlignmentX(Component.LEFT_ALIGNMENT); + return this; + } }; selectedExtensions.setCellRenderer(selectedExtensionRenderer); + JPanel selectedExtensionsPanel = new JPanel(); selectedExtensionsPanel.setLayout(new BoxLayout(selectedExtensionsPanel, BoxLayout.Y_AXIS)); + selectedExtensionsPanel.setAlignmentX(Component.LEFT_ALIGNMENT); JLabel label = new JLabel("Selected extensions"); label.setFont(label.getFont().deriveFont(label.getFont().getStyle() | Font.BOLD)); selectedExtensionsPanel.add(label); + selectedExtensionsPanel.add(selectedExtensions); extensionsPanel.setSecondComponent(new JBScrollPane(selectedExtensionsPanel)); panel.add(extensionsPanel); @@ -237,8 +238,9 @@ public void valueChanged(TreeSelectionEvent e) { } } }); + outerPanel.add(panel, BorderLayout.CENTER); } - return panel; + return outerPanel; } private void expandTree(JTree tree) { diff --git a/src/main/java/com/redhat/devtools/intellij/quarkus/module/QuarkusModuleInfoStep.java b/src/main/java/com/redhat/devtools/intellij/quarkus/module/QuarkusModuleInfoStep.java index 2e8465418..7d938606e 100644 --- a/src/main/java/com/redhat/devtools/intellij/quarkus/module/QuarkusModuleInfoStep.java +++ b/src/main/java/com/redhat/devtools/intellij/quarkus/module/QuarkusModuleInfoStep.java @@ -25,6 +25,7 @@ import com.intellij.ui.components.JBLoadingPanel; import com.intellij.ui.components.JBTextField; import com.intellij.util.ui.FormBuilder; +import com.intellij.util.ui.JBUI; import com.redhat.devtools.intellij.quarkus.QuarkusConstants; import com.redhat.devtools.intellij.quarkus.tool.ToolDelegate; import org.jetbrains.annotations.NotNull; @@ -99,6 +100,8 @@ public void dispose() { @Override public void _init() { + panel.setBorder(JBUI.Borders.empty(20)); + ProgressIndicator indicator = new EmptyProgressIndicator() { @Override public void setText(String text) { From caa3eb88192e5bdaa582d5b1cee7cd065ef9088b Mon Sep 17 00:00:00 2001 From: Andre Dietisheim Date: Mon, 26 Jun 2023 10:41:12 +0200 Subject: [PATCH 2/2] made endpoint chooser step have left border only Signed-off-by: Andre Dietisheim --- .../intellij/quarkus/module/QuarkusCodeEndpointChooserStep.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/redhat/devtools/intellij/quarkus/module/QuarkusCodeEndpointChooserStep.java b/src/main/java/com/redhat/devtools/intellij/quarkus/module/QuarkusCodeEndpointChooserStep.java index 425364ff5..17d4a3220 100644 --- a/src/main/java/com/redhat/devtools/intellij/quarkus/module/QuarkusCodeEndpointChooserStep.java +++ b/src/main/java/com/redhat/devtools/intellij/quarkus/module/QuarkusCodeEndpointChooserStep.java @@ -105,7 +105,7 @@ public void actionPerformed(ActionEvent e) { builder.addTooltip("Make sure your network connection is active before continuing."); JPanel panel = new JPanel(new BorderLayout()); panel.add(builder.getPanel(), "North"); - panel.setBorder(JBUI.Borders.empty(20)); + panel.setBorder(JBUI.Borders.emptyLeft(20)); return panel; }