From: gmungoc Date: Mon, 25 Jan 2016 10:43:06 +0000 (+0000) Subject: JAL-1997 database browser support tooltip if available X-Git-Tag: Release_2_10_0~296^2~60 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=16848e28863ed4b50713939adb525e1d85ff7575;p=jalview.git JAL-1997 database browser support tooltip if available --- diff --git a/src/jalview/gui/JDatabaseTree.java b/src/jalview/gui/JDatabaseTree.java index a886723..6f602ad 100644 --- a/src/jalview/gui/JDatabaseTree.java +++ b/src/jalview/gui/JDatabaseTree.java @@ -46,6 +46,7 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTree; +import javax.swing.ToolTipManager; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import javax.swing.tree.DefaultMutableTreeNode; @@ -244,6 +245,7 @@ public class JDatabaseTree extends JalviewDialog implements KeyListener public DbTreeRenderer(JDatabaseTree me) { us = me; + ToolTipManager.sharedInstance().registerComponent(dbviews); } private Component returnLabel(String txt) @@ -265,19 +267,23 @@ public class JDatabaseTree extends JalviewDialog implements KeyListener value = vl.getUserObject(); if (value instanceof DbSourceProxy) { - val = (((DbSourceProxy) value).getDbName()); + val = ((DbSourceProxy) value).getDbName(); + if (((DbSourceProxy) value).getDescription() != null) + { // getName() + this.setToolTipText(((DbSourceProxy) value).getDescription()); + } } else { if (value instanceof String) { - val = ((String) value); + val = (String) value; } } } if (value == null) { - val = (""); + val = ""; } return super.getTreeCellRendererComponent(tree, val, selected, expanded, leaf, row, hasFocus); diff --git a/src/jalview/ws/seqfetcher/DbSourceProxy.java b/src/jalview/ws/seqfetcher/DbSourceProxy.java index 9fd0c64..fba9e83 100644 --- a/src/jalview/ws/seqfetcher/DbSourceProxy.java +++ b/src/jalview/ws/seqfetcher/DbSourceProxy.java @@ -161,4 +161,12 @@ public interface DbSourceProxy * @return */ public boolean isAlignmentSource(); + + /** + * Returns an (optional) description of the source, suitable for display as a + * tooltip, or null + * + * @return + */ + public String getDescription(); } \ No newline at end of file diff --git a/src/jalview/ws/seqfetcher/DbSourceProxyImpl.java b/src/jalview/ws/seqfetcher/DbSourceProxyImpl.java index 1e1468f..0a4d9a8 100644 --- a/src/jalview/ws/seqfetcher/DbSourceProxyImpl.java +++ b/src/jalview/ws/seqfetcher/DbSourceProxyImpl.java @@ -147,4 +147,10 @@ public abstract class DbSourceProxyImpl implements DbSourceProxy { return false; } + + @Override + public String getDescription() + { + return null; + } }