JAL-1997 database browser support tooltip if available
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 25 Jan 2016 10:43:06 +0000 (10:43 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 25 Jan 2016 10:43:06 +0000 (10:43 +0000)
src/jalview/gui/JDatabaseTree.java
src/jalview/ws/seqfetcher/DbSourceProxy.java
src/jalview/ws/seqfetcher/DbSourceProxyImpl.java

index a886723..6f602ad 100644 (file)
@@ -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);
index 9fd0c64..fba9e83 100644 (file)
@@ -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
index 1e1468f..0a4d9a8 100644 (file)
@@ -147,4 +147,10 @@ public abstract class DbSourceProxyImpl implements DbSourceProxy
   {
     return false;
   }
+
+  @Override
+  public String getDescription()
+  {
+    return null;
+  }
 }