From 94055d8ddc9a7e467704078c9c17e8fc53bc7ff3 Mon Sep 17 00:00:00 2001 From: Rahul Biju Date: Fri, 13 Oct 2023 18:51:33 +0530 Subject: [PATCH 1/5] [#222]Added hover info to entries in the Liberty Tool window --- .../io/openliberty/tools/intellij/LibertyExplorer.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/openliberty/tools/intellij/LibertyExplorer.java b/src/main/java/io/openliberty/tools/intellij/LibertyExplorer.java index 2a4c2afb2..a6e85699d 100644 --- a/src/main/java/io/openliberty/tools/intellij/LibertyExplorer.java +++ b/src/main/java/io/openliberty/tools/intellij/LibertyExplorer.java @@ -305,8 +305,11 @@ public Component getTreeCellRendererComponent( boolean leaf, int row, boolean hasFocus) { + /** + * modification to get tooltiptext for liberty module tree + */ + tree.setToolTipText(getBuildPath(value)); super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); - // assign gear icon to action nodes if (leaf) { setIcon(LibertyPluginIcons.IntelliJGear); @@ -326,6 +329,11 @@ public Component getTreeCellRendererComponent( return this; } } + + private static String getBuildPath(Object value) { + LibertyModuleNode node = (LibertyModuleNode) value; + return node.getFilePath().toString().replace("file://", ""); + } private static void executeAction(Tree tree) { final TreePath path = tree.getSelectionPath(); From 7da95da624f8f6be23ec3130c10e8914471fe30e Mon Sep 17 00:00:00 2001 From: Rahul Biju Date: Tue, 5 Dec 2023 13:56:05 +0530 Subject: [PATCH 2/5] fixed java cast exception --- .../io/openliberty/tools/intellij/LibertyExplorer.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/openliberty/tools/intellij/LibertyExplorer.java b/src/main/java/io/openliberty/tools/intellij/LibertyExplorer.java index a6e85699d..f0fb13cfd 100644 --- a/src/main/java/io/openliberty/tools/intellij/LibertyExplorer.java +++ b/src/main/java/io/openliberty/tools/intellij/LibertyExplorer.java @@ -331,8 +331,11 @@ public Component getTreeCellRendererComponent( } private static String getBuildPath(Object value) { - LibertyModuleNode node = (LibertyModuleNode) value; - return node.getFilePath().toString().replace("file://", ""); + LibertyModuleNode node = null; + if (value instanceof LibertyModuleNode) { + node = (LibertyModuleNode) value; + } + return (node != null) ? node.getFilePath().toString().replace("file://", "") : ""; } private static void executeAction(Tree tree) { From ff32a13225c7045b7e0527020e0f9e4c9ad5c382 Mon Sep 17 00:00:00 2001 From: Rahul Biju Date: Wed, 10 Jan 2024 14:11:45 +0530 Subject: [PATCH 3/5] added tooltip to specific node --- .../tools/intellij/LibertyExplorer.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/openliberty/tools/intellij/LibertyExplorer.java b/src/main/java/io/openliberty/tools/intellij/LibertyExplorer.java index f0fb13cfd..5152ba687 100644 --- a/src/main/java/io/openliberty/tools/intellij/LibertyExplorer.java +++ b/src/main/java/io/openliberty/tools/intellij/LibertyExplorer.java @@ -32,12 +32,14 @@ import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.TreeCellRenderer; import javax.swing.tree.TreePath; import javax.xml.parsers.ParserConfigurationException; import java.awt.*; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; +import java.awt.event.*; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; @@ -220,6 +222,33 @@ public static Tree buildTree(Project project, Color backgroundColor) { } }); + tree.addMouseMotionListener(new MouseMotionAdapter() { + private String currentTooltipText = null; + + @Override + public void mouseMoved(MouseEvent e) { + super.mouseMoved(e); + + TreePath path = tree.getPathForLocation(e.getX(), e.getY()); + if (path == null ) { + if (currentTooltipText != null) { + tree.setToolTipText(null); + currentTooltipText = null; + } + } else { + Object node = path.getLastPathComponent(); + if (node instanceof LibertyModuleNode) { + LibertyModuleNode treeNode = (LibertyModuleNode) node; + String tooltipText = getBuildPath(treeNode); + if (!tooltipText.equals(currentTooltipText)) { + tree.setToolTipText(tooltipText); + currentTooltipText = tooltipText; + } + } + } + } + }); + tree.addMouseListener(new PopupHandler() { @Override public void invokePopup(Component comp, int x, int y) { @@ -308,7 +337,6 @@ public Component getTreeCellRendererComponent( /** * modification to get tooltiptext for liberty module tree */ - tree.setToolTipText(getBuildPath(value)); super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); // assign gear icon to action nodes if (leaf) { From 82c3d36aa70f9f56ffd58e50e7f7cbf03e98853a Mon Sep 17 00:00:00 2001 From: Rahul Biju Date: Wed, 10 Jan 2024 14:16:58 +0530 Subject: [PATCH 4/5] removed spacing --- .../java/io/openliberty/tools/intellij/LibertyExplorer.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/io/openliberty/tools/intellij/LibertyExplorer.java b/src/main/java/io/openliberty/tools/intellij/LibertyExplorer.java index 5152ba687..8a25a3239 100644 --- a/src/main/java/io/openliberty/tools/intellij/LibertyExplorer.java +++ b/src/main/java/io/openliberty/tools/intellij/LibertyExplorer.java @@ -334,10 +334,8 @@ public Component getTreeCellRendererComponent( boolean leaf, int row, boolean hasFocus) { - /** - * modification to get tooltiptext for liberty module tree - */ super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); + // assign gear icon to action nodes if (leaf) { setIcon(LibertyPluginIcons.IntelliJGear); From 31bf40c6470b6635ecbcbc5ebf99bcdacb496960 Mon Sep 17 00:00:00 2001 From: Rahul Biju Date: Wed, 24 Jan 2024 13:33:17 +0530 Subject: [PATCH 5/5] added libertyNode and other changes --- .../tools/intellij/LibertyExplorer.java | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/main/java/io/openliberty/tools/intellij/LibertyExplorer.java b/src/main/java/io/openliberty/tools/intellij/LibertyExplorer.java index 8a25a3239..bbf51f500 100644 --- a/src/main/java/io/openliberty/tools/intellij/LibertyExplorer.java +++ b/src/main/java/io/openliberty/tools/intellij/LibertyExplorer.java @@ -32,14 +32,13 @@ import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeCellRenderer; -import javax.swing.tree.TreeCellRenderer; import javax.swing.tree.TreePath; import javax.xml.parsers.ParserConfigurationException; import java.awt.*; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; -import java.awt.event.*; +import java.awt.event.MouseMotionAdapter; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; @@ -238,8 +237,8 @@ public void mouseMoved(MouseEvent e) { } else { Object node = path.getLastPathComponent(); if (node instanceof LibertyModuleNode) { - LibertyModuleNode treeNode = (LibertyModuleNode) node; - String tooltipText = getBuildPath(treeNode); + LibertyModuleNode libertyNode = (LibertyModuleNode) node; + String tooltipText = libertyNode.getFilePath().getPath(); if (!tooltipText.equals(currentTooltipText)) { tree.setToolTipText(tooltipText); currentTooltipText = tooltipText; @@ -355,14 +354,6 @@ public Component getTreeCellRendererComponent( return this; } } - - private static String getBuildPath(Object value) { - LibertyModuleNode node = null; - if (value instanceof LibertyModuleNode) { - node = (LibertyModuleNode) value; - } - return (node != null) ? node.getFilePath().toString().replace("file://", "") : ""; - } private static void executeAction(Tree tree) { final TreePath path = tree.getSelectionPath();