diff --git a/src/main/java/com/couchbase/intellij/tools/cbmigrate/MigrationDialog.java b/src/main/java/com/couchbase/intellij/tools/cbmigrate/MigrationDialog.java index 83063c7b..5c62b796 100644 --- a/src/main/java/com/couchbase/intellij/tools/cbmigrate/MigrationDialog.java +++ b/src/main/java/com/couchbase/intellij/tools/cbmigrate/MigrationDialog.java @@ -89,6 +89,7 @@ private JPanel createMongoDBPanel() { JLabel infoLabel = new JLabel(); infoLabel.setIcon(IconLoader.getIcon("/assets/icons/information_big.svg", DocumentFilterDialog.class)); + infoLabel.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { @@ -96,7 +97,7 @@ public void mouseEntered(MouseEvent e) {

MongoDB Connection URI

- The MongoDB Connection URI is a string that specifies how to connect to a MongoDB database. It contains all the information needed to establish a connection, including: +

The MongoDB Connection URI is a string that specifies how to connect to a MongoDB database.
It contains all the information needed to establish a connection, including:

+
+ Check the CLI tool for additional options here +
+ """; TemplateUtil.showGotItTooltip(e.getComponent(), content); @@ -262,6 +267,9 @@ public void mouseEntered(MouseEvent e) {

Migrate Collections Indexes and Definitions

Check this option if you want to migrate the indexes and definitions of the selected collections. +
+ Check the CLI tool for additional options here +
"""; TemplateUtil.showGotItTooltip(e.getComponent(), content); @@ -376,6 +384,9 @@ public void mouseEntered(MouseEvent e) {

Scope

Select the scope within the chosen bucket where the data will be migrated. +
+ Check the CLI tool for additional options here +
"""; TemplateUtil.showGotItTooltip(e.getComponent(), content); diff --git a/src/main/java/utils/TemplateUtil.java b/src/main/java/utils/TemplateUtil.java index 66350e8f..a85123cd 100644 --- a/src/main/java/utils/TemplateUtil.java +++ b/src/main/java/utils/TemplateUtil.java @@ -14,6 +14,7 @@ import com.intellij.util.ui.UIUtil; import javax.swing.*; +import javax.swing.event.HyperlinkEvent; import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -26,15 +27,35 @@ public class TemplateUtil { public static void showGotItTooltip(Component component, String tooltipText) { Point screenPoint = component.getLocationOnScreen(); Point tooltipPoint = new Point(screenPoint.x + component.getWidth(), screenPoint.y); - JLabel label = new JLabel(tooltipText); + JTextPane label = new JTextPane(); + label.setContentType("text/html"); // Set content type to HTML + label.setText(tooltipText); + label.setEditable(false); + label.setOpaque(false); + label.addHyperlinkListener(e -> { + if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { + try { + Desktop.getDesktop().browse(e.getURL().toURI()); // Open the link in the default browser + } catch (Exception ex) { + ex.printStackTrace(); + } + } + }); label.setBorder(JBUI.Borders.empty(2)); - JBScrollPane scroll = new JBScrollPane(label); - scroll.setOpaque(false); - scroll.setBorder(null); - scroll.getViewport().setOpaque(false); + // Wrap the JTextPane in a JBScrollPane + Dimension preferredSize = new Dimension(600, 200); + JBScrollPane scrollPane = new JBScrollPane(label); + scrollPane.setOpaque(false); + scrollPane.getViewport().setOpaque(false); + scrollPane.setBorder(null); + scrollPane.setPreferredSize(preferredSize); + + SwingUtilities.invokeLater(() -> { + scrollPane.getViewport().setViewPosition(new Point(0, 0)); + }); Balloon balloon = JBPopupFactory.getInstance() - .createBalloonBuilder(scroll) + .createBalloonBuilder(scrollPane) .setFillColor(UIUtil.getToolTipBackground()) .setBorderColor(JBColor.GRAY) .setAnimationCycle(200)