JComponent (Consent consent, boolean addCheckBox) { //TODO: refactor DocumentationComponent to use external link marker here, there and everywhere final JPanel pane; final boolean dataSharingDisabledExternally = ConsentOptions.getInstance().isUsageStatsConsent(consent) && StatisticsUploadAssistant.isCollectionForceDisabled(); if (addCheckBox) { String checkBoxText = StringUtil.capitalize(StringUtil.toLowerCase(consent.getName())); if (ConsentOptions.getInstance().isEAP()) { if (ConsentOptions.condUsageStatsConsent().test(consent)) { checkBoxText = IdeBundle.message("gdpr.checkbox.when.using.eap.versions", checkBoxText); } } final JCheckBox cb = new JBCheckBox(checkBoxText, consent.isAccepted()); cb.setEnabled(!dataSharingDisabledExternally); //noinspection HardCodedStringLiteral pane = UI.PanelFactory.panel(cb).withComment(getParagraphTag() +StringUtil.replace(consent.getText(), "\n", "</p>"+getParagraphTag())+"</p>").createPanel(); cb.setOpaque(false); consentMapping.add(Pair.create(cb, consent)); } else { pane = new JPanel(new BorderLayout()); final JEditorPane viewer = SwingHelper.createHtmlViewer(true, null, JBColor.WHITE, JBColor.BLACK); viewer.setOpaque(false); viewer.setFocusable(false); UIUtil.doNotScrollToCaret(viewer); viewer.addHyperlinkListener(new HyperlinkAdapter() { @Override protected void hyperlinkActivated(@NotNull HyperlinkEvent e) { final URL url = e.getURL(); if (url != null) { BrowserUtil.browse(url); } } }); viewer.setText("<html><body>" + replaceParagraphs(consent.getText()) + "</body></html>"); StyleSheet styleSheet = ((HTMLDocument)viewer.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:" + JBUI.scaleFontSize(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;}"); styleSheet.addRule("a, a:link {color:#" + ColorUtil.toHex(JBUI.CurrentTheme.Link.Foreground.ENABLED) + ";}"); styleSheet.addRule("a:hover {color:#" + ColorUtil.toHex(JBUI.CurrentTheme.Link.Foreground.HOVERED) + ";}"); styleSheet.addRule("a:active {color:#" + ColorUtil.toHex(JBUI.CurrentTheme.Link.Foreground.PRESSED) + ";}"); viewer.setCaretPosition(0); pane.add(viewer, BorderLayout.CENTER); consentMapping.add(Pair.create(null, consent)); } pane.setOpaque(false); return !dataSharingDisabledExternally ? pane : wrapPanelWithWarning(pane); }