private static void showAgreementText()

in src/main/resources/patch/Agreement.java [140:235]


    private static void showAgreementText(@NotNull String title, @NotNull String htmlText) {
        DialogWrapper dialog = new DialogWrapper(true) {
            private JEditorPane myViewer;

            @Override
            protected JComponent createCenterPanel() {
                JPanel centerPanel = new JPanel(new BorderLayout(0, JBUIScale.scale(8)));
                myViewer = SwingHelper.createHtmlViewer(true, null, JBColor.WHITE, JBColor.BLACK);
                myViewer.setFocusable(true);
                myViewer.addHyperlinkListener(new HyperlinkAdapter() {
                    @Override
                    protected void hyperlinkActivated(@NotNull HyperlinkEvent e) {
                        URL url = e.getURL();
                        if (url != null) {
                            BrowserUtil.browse(url);
                        }
                        else {
                            SwingHelper.scrollToReference(myViewer, e.getDescription());
                        }
                    }
                });
                myViewer.setText(htmlText);
                StyleSheet styleSheet = ((HTMLDocument)myViewer.getDocument()).getStyleSheet();
                styleSheet.addRule("body {font-family: \"Segoe UI\", Tahoma, sans-serif;}");
                styleSheet.addRule("body {margin-top:0;padding-top:0;}");
                styleSheet.addRule("body {font-size:" + JBUIScale.scaleFontSize((float)13) + "pt;}");
                styleSheet.addRule("h2, em {margin-top:" + JBUIScale.scaleFontSize((float)20) + "pt;}");
                styleSheet.addRule("h1, h2, h3, p, h4, em {margin-bottom:0;padding-bottom:0;}");
                styleSheet.addRule("p, h1 {margin-top:0;padding-top:" + JBUIScale.scaleFontSize((float)6) + "pt;}");
                styleSheet.addRule("li {margin-bottom:" + JBUIScale.scaleFontSize((float)6) + "pt;}");
                styleSheet.addRule("h2 {margin-top:0;padding-top:" + JBUIScale.scaleFontSize((float)13) + "pt;}");
                myViewer.setCaretPosition(0);
                myViewer.setBorder(JBUI.Borders.empty(0, 5, 5, 5));
                centerPanel.add(JBUI.Borders.emptyTop(8).wrap(
                        new JLabel("Please read and accept these terms and conditions. Scroll down for full text:")), BorderLayout.NORTH);
                JBScrollPane scrollPane = new JBScrollPane(myViewer, VERTICAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_NEVER);
                centerPanel.add(scrollPane, BorderLayout.CENTER);
                JPanel bottomPanel = new JPanel(new BorderLayout());
                if (ApplicationInfoImpl.getShadowInstance().isEAP()) {
                    JPanel eapPanel = new JPanel(new BorderLayout(8, 8));
                    eapPanel.setBorder(JBUI.Borders.empty(8));
                    //noinspection UseJBColor
                    eapPanel.setBackground(new Color(0xDCE4E8));
                    JLabel label = new JLabel(AllIcons.General.BalloonInformation);
                    label.setVerticalAlignment(SwingConstants.TOP);
                    eapPanel.add(label, BorderLayout.WEST);
                    JEditorPane html = SwingHelper.createHtmlLabel(
                            "EAP builds report usage statistics by default per "+
                                    "the <a href=\"https://www.jetbrains.com/company/privacy.html\">JetBrains Privacy Policy</a>." +
                                    "<br/>No personal or sensitive data are sent. You may disable this in the settings.", null, null
                    );
                    eapPanel.add(html, BorderLayout.CENTER);
                    bottomPanel.add(eapPanel, BorderLayout.NORTH);
                }
                JCheckBox checkBox = new JCheckBox("I confirm that I have read and accept the terms of this User Agreement");
                bottomPanel.add(JBUI.Borders.empty(24, 0, 16, 0).wrap(checkBox), BorderLayout.CENTER);
                centerPanel.add(JBUI.Borders.emptyTop(8).wrap(bottomPanel), BorderLayout.SOUTH);
                checkBox.addActionListener(e -> setOKActionEnabled(checkBox.isSelected()));
                centerPanel.setPreferredSize(JBUI.size(520, 450));
                return centerPanel;
            }

            @Nullable
            @Override
            public JComponent getPreferredFocusedComponent() {
                return myViewer;
            }

            @Override
            protected void createDefaultActions() {
                super.createDefaultActions();
                init();
                setOKButtonText("Continue");
                setOKActionEnabled(false);
                setCancelButtonText("Reject and Exit");
                setAutoAdjustable(false);
            }

            @Override
            public void doCancelAction() {
                super.doCancelAction();
                Application application = ApplicationManager.getApplication();
                if (application == null) {
                    System.exit(PRIVACY_POLICY_REJECTION);
                }
                else {
                    application.exit(true, true, false);
                }
            }
        };
        dialog.setModal(true);
        dialog.setTitle(title);
        dialog.pack();

        SplashManager.executeWithHiddenSplash(dialog.getWindow(), () -> dialog.show());
    }