From 61be95da77d70aaf8f1b954f2eae1454c3304ef9 Mon Sep 17 00:00:00 2001 From: Stephan Janssen Date: Tue, 2 Jul 2024 19:42:37 +0200 Subject: [PATCH 1/2] Feat #142: Show Twitter and Review link in welcome text --- .../devoxx/genie/ui/panel/WelcomePanel.java | 56 ++++++++++++++----- .../com/devoxx/genie/ui/util/WelcomeUtil.java | 2 + src/main/resources/application.properties | 2 +- 3 files changed, 46 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/devoxx/genie/ui/panel/WelcomePanel.java b/src/main/java/com/devoxx/genie/ui/panel/WelcomePanel.java index 0428de23..907cc415 100644 --- a/src/main/java/com/devoxx/genie/ui/panel/WelcomePanel.java +++ b/src/main/java/com/devoxx/genie/ui/panel/WelcomePanel.java @@ -1,31 +1,61 @@ package com.devoxx.genie.ui.panel; import com.devoxx.genie.ui.util.WelcomeUtil; -import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBPanel; +import com.intellij.ui.components.JBScrollPane; +import javax.swing.*; +import javax.swing.event.HyperlinkEvent; import java.awt.*; +import java.awt.Desktop; +import java.net.URI; import java.util.ResourceBundle; public class WelcomePanel extends JBPanel { - private final JBLabel jbLabel; + private final JEditorPane jEditorPane; + private final JBScrollPane scrollPane; - /** - * Create a welcome panel - * - * @param resourceBundle the resource bundle - */ public WelcomePanel(ResourceBundle resourceBundle) { super(new BorderLayout()); - jbLabel = new JBLabel(WelcomeUtil.getWelcomeText(resourceBundle)); - add(jbLabel, BorderLayout.NORTH); + + jEditorPane = new JEditorPane("text/html", WelcomeUtil.getWelcomeText(resourceBundle)); + jEditorPane.setEditable(false); + jEditorPane.setOpaque(false); + jEditorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); + jEditorPane.addHyperlinkListener(e -> { + if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { + if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { + try { + Desktop.getDesktop().browse(new URI(e.getURL().toString())); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + }); + + // Create a JBScrollPane and add the JEditorPane to it + scrollPane = new JBScrollPane(jEditorPane); + scrollPane.setVerticalScrollBarPolicy(JBScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); + scrollPane.setHorizontalScrollBarPolicy(JBScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + scrollPane.setBorder(null); // Remove border for a cleaner look + + // Add the scrollPane to the panel + add(scrollPane, BorderLayout.CENTER); + + // Set a preferred size for the panel + setPreferredSize(new Dimension(600, 400)); // Adjust these values as needed } - /** - * Show the message - */ public void showMsg() { setVisible(true); - jbLabel.setVisible(true); + jEditorPane.setVisible(true); + scrollPane.setVisible(true); + + // Ensure the scroll pane is at the top when shown + SwingUtilities.invokeLater(() -> { + JScrollBar verticalScrollBar = scrollPane.getVerticalScrollBar(); + verticalScrollBar.setValue(verticalScrollBar.getMinimum()); + }); } } diff --git a/src/main/java/com/devoxx/genie/ui/util/WelcomeUtil.java b/src/main/java/com/devoxx/genie/ui/util/WelcomeUtil.java index a7c71e85..0d864998 100644 --- a/src/main/java/com/devoxx/genie/ui/util/WelcomeUtil.java +++ b/src/main/java/com/devoxx/genie/ui/util/WelcomeUtil.java @@ -23,6 +23,7 @@ public static String getWelcomeText(ResourceBundle resourceBundle) {

%s

+

Follow us on 𝕏 : @DevoxxGenie

%s

%s

New features 🚀

@@ -45,6 +46,7 @@ public static String getWelcomeText(ResourceBundle resourceBundle) {

%s

%s

+

BTW If you like this plugin please give us a review ❤️

""".formatted( diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index d3ef79dc..5210c838 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,2 +1,2 @@ -#Tue Jul 02 18:49:47 CEST 2024 +#Tue Jul 02 19:19:10 CEST 2024 version=0.2.1 From b9e41aad14a482539ed2ed4f29ccc77c5460d813 Mon Sep 17 00:00:00 2001 From: Stephan Janssen Date: Tue, 2 Jul 2024 19:43:06 +0200 Subject: [PATCH 2/2] Updated change notes --- src/main/resources/META-INF/plugin.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 398621d4..92a7c9a4 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -40,6 +40,7 @@
  • Code refactorings
  • Feat #140: Show glowing border around chat window when activate
  • Fix #138 : Show editor files in file list panel
  • +
  • Feat #142: Show Twitter and Preview link
  • v0.2.0