public UncrustifySettingsComponent()

in src/main/java/org/jetbrains/uncrustify/settings/UncrustifySettingsComponent.java [41:98]


    public UncrustifySettingsComponent(@Nullable Project project) {
        myMainPanel = new JPanel(new GridBagLayout());
        GridBag bag = new GridBag()
                .setDefaultWeightX(1, 1.0)
                .setDefaultAnchor(GridBagConstraints.CENTER)
                .setDefaultFill(GridBagConstraints.HORIZONTAL)
                .setDefaultInsets(0, UIUtil.DEFAULT_VGAP, UIUtil.DEFAULT_HGAP, 0, UIUtil.DEFAULT_HGAP)
                .setDefaultInsets(UIUtil.DEFAULT_VGAP, 0, 0, 0);
        myMainPanel.add(new JBLabel(UncrustifyBundle.message("uncrustify.settings.executablePath.label")), bag.nextLine().next());
        myMainPanel.add(myExecutablePath, bag.next().fillCell());
        myMainPanel.add(myVersionCheckField, bag.nextLine().next().next().insets(0, 5, -1, -1).fillCell());
        myMainPanel.add(new JBLabel(UncrustifyBundle.message("uncrustify.settings.configPath.label")), bag.nextLine().next());
        myMainPanel.add(myConfigPath, bag.next().fillCell());
        myMainPanel.add(myConfigCheckField, bag.nextLine().next().next().insets(0, 5, -1, -1).fillCell());
        myMainPanel.add(myConfigExplanationLabel, bag.nextLine().next().next().fillCell());
        myMainPanel.add(Box.createVerticalGlue(), bag.nextLine().next().weighty(1.0).fillCell());

        myExecutablePath.addBrowseFolderListener(
                UncrustifyBundle.message("uncrustify.settings.executablePath.title"),
                UncrustifyBundle.message("uncrustify.settings.executablePath.description"),
                project,
                FileChooserDescriptorFactory.createSingleFileOrExecutableAppDescriptor()
        );

        myConfigPath.addBrowseFolderListener(
                UncrustifyBundle.message("uncrustify.settings.configPath.title"),
                UncrustifyBundle.message("uncrustify.settings.configPath.description"),
                project,
                FileChooserDescriptorFactory.createSingleFileDescriptor()
        );

        myVersionCheckField.setFontSize(UIUtil.FontSize.SMALL);
        myConfigCheckField.setFontSize(UIUtil.FontSize.SMALL);
        myConfigExplanationLabel.setForeground(JBUI.CurrentTheme.ContextHelp.FOREGROUND);
        myConfigExplanationLabel.setComponentStyle(UIUtil.ComponentStyle.SMALL);

        String explanationText = UncrustifyBundle.message("uncrustify.settings.config.explanationHtml");
        HtmlChunk explanationHtml = HtmlChunk.raw(explanationText);

        if (explanationText.length() > MAX_LINE_WIDTH) {
            explanationHtml = explanationHtml
                    .wrapWith("div")
                    .attr("width", myConfigExplanationLabel.getFontMetrics(myConfigExplanationLabel.getFont()).stringWidth(explanationText.substring(0, MAX_LINE_WIDTH)));
        } else {
            explanationHtml = explanationHtml.wrapWith("div");
        }

        myConfigExplanationLabel.setText(explanationHtml
                .wrapWith("body")
                .wrapWith("html")
                .toString());

        myVersionCheckField.addPropertyChangeListener(VersionVerifierComponent.DOCUMENT_VALID, evt -> {
            if (myVersionCheckField.isDocumentValid()) {
                myConfigCheckField.verifyDocument();
            }
        });
    }