Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set proper borders / alignment in quarkus wizard #969

Merged
merged 2 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.emptyLeft(20));
return panel;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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) {
Expand All @@ -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<QuarkusExtension> {
private static class SelectedExtensionsModel extends AbstractListModel<QuarkusExtension> {

private final List<QuarkusExtension> extensions = new ArrayList<>();

Expand Down Expand Up @@ -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));
Comment on lines +125 to +126
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the filter field fill the horizontal space:

Screenshot 2023-06-26 at 10 21 45

}
};
filter.setAlignmentX(Component.LEFT_ALIGNMENT);
Expand All @@ -162,20 +150,33 @@ public Dimension getMaximumSize() {
extensionsSplitter.setFirstComponent(new JBScrollPane(extensionsTree));
extensionsSplitter.setSecondComponent(extensionDetailTextPane);
extensionsPanel.setFirstComponent(extensionsSplitter);

JBList<QuarkusExtension> selectedExtensions = new JBList<>();
selectedExtensions.setBackground(null);
selectedExtensions.setAlignmentX(Component.LEFT_ALIGNMENT);
selectedExtensions.setModel(new SelectedExtensionsModel(categories));
ColoredListCellRenderer<QuarkusExtension> selectedExtensionRenderer = new ColoredListCellRenderer<QuarkusExtension>() {
@Override
protected void customizeCellRenderer(@NotNull JList<? extends QuarkusExtension> list, QuarkusExtension extension, int index, boolean selected, boolean hasFocus) {
append(extension.getName());
}

@Override
public Component getListCellRendererComponent(JList<? extends QuarkusExtension> 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);
Expand Down Expand Up @@ -237,8 +238,9 @@ public void valueChanged(TreeSelectionEvent e) {
}
}
});
outerPanel.add(panel, BorderLayout.CENTER);
}
return panel;
return outerPanel;
}

private void expandTree(JTree tree) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down