X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FIdPanel.java;h=bb6efd799aff8760658425f0a948b88755d6c3e8;hb=0705a85fe0a3d391e5aba360340a0c342c898366;hp=310276c5ee63b832f0de1820b8f4ed5bfb67e101;hpb=efc31b4a8d5cee63555586804a2b79c06bdb5a14;p=jalview.git
diff --git a/src/jalview/gui/IdPanel.java b/src/jalview/gui/IdPanel.java
index 310276c..bb6efd7 100755
--- a/src/jalview/gui/IdPanel.java
+++ b/src/jalview/gui/IdPanel.java
@@ -59,6 +59,7 @@ public class IdPanel extends JPanel implements MouseListener,
add(idCanvas, BorderLayout.CENTER);
addMouseListener(this);
addMouseMotionListener(this);
+ ToolTipManager.sharedInstance().registerComponent(this);
}
/**
@@ -68,8 +69,40 @@ public class IdPanel extends JPanel implements MouseListener,
*/
public void mouseMoved(MouseEvent e)
{
+ int y = e.getY();
+
+ if (av.getWrapAlignment())
+ {
+ y = getWrappedY(y);
+ }
+
+ int seq = av.getIndex(y);
+ if(seq!=-1)
+ {
+ StringBuffer tip = new StringBuffer("");
+ tip.append(av.alignment.getSequenceAt(seq).getDisplayId(true));
+ if (av.alignment.getSequenceAt(seq).getDescription() != null)
+ {
+ tip.append("
");
+ tip.append(av.alignment.getSequenceAt(seq).getDescription());
+ tip.append(" |
");
+ }
+ tip.append("");
+ setToolTipText(tip.toString());
+ }
+
+ }
+
+ int getWrappedY(int y)
+ {
+ int hgap = av.charHeight;
+ if (av.scaleAboveWrapped)
+ hgap += av.charHeight;
+
+ return y - hgap;
}
+
/**
* DOCUMENT ME!
*
@@ -83,7 +116,7 @@ public class IdPanel extends JPanel implements MouseListener,
if (av.getWrapAlignment())
{
- y -= (2 * av.charHeight);
+ y = getWrappedY(y);
}
int seq = av.getIndex(y);
@@ -106,6 +139,7 @@ public class IdPanel extends JPanel implements MouseListener,
alignPanel.repaint();
}
+
/**
* DOCUMENT ME!
*
@@ -113,35 +147,48 @@ public class IdPanel extends JPanel implements MouseListener,
*/
public void mouseClicked(MouseEvent e)
{
- if (e.getClickCount() == 2)
- {
- int y = e.getY();
-
- if (av.getWrapAlignment())
- {
- y -= (2 * av.charHeight);
- }
-
- int seq = av.getIndex(y);
- String id = av.getAlignment().getSequenceAt(seq).getName();
-
- try
- {
- jalview.util.BrowserLauncher.openURL(
- "http://srs.ebi.ac.uk/srs7bin/cgi-bin/wgetz?-e+[uniprot-all:" +
- id + "]+-vn+2");
- }
- catch (Exception ex)
- {
- // TODO: JBPNote : state dependent error message for real browserLaunch problems rather than unix misconfiguration.
- System.err.println(ex.getMessage() +
- "\nUnixers: Try adding this jalview.browser property line \n" +
- "in your jalview.properties file (/usr/local/bin/firefox is an exanmple browser path):\n" +
- "jalview.browser=/usr/local/bin/firefox\n");
-
- //ex.printStackTrace();
- }
- }
+ if (e.getClickCount() < 2)
+ return;
+
+ java.util.Vector links = Preferences.sequenceURLLinks;
+ if (links == null || links.size() < 1)
+ return;
+
+ int y = e.getY();
+
+ if (av.getWrapAlignment())
+ {
+ y = getWrappedY(y);
+ }
+
+ //DEFAULT LINK IS FIRST IN THE LINK LIST
+ int seq = av.getIndex(y);
+ if(seq==-1)
+ return;
+
+ String id = av.getAlignment().getSequenceAt(seq).getName();
+ if (id.indexOf("|") > -1)
+ id = id.substring(id.lastIndexOf("|") + 1);
+
+
+ String url = links.elementAt(0).toString();
+ url = url.substring(url.indexOf("|")+1);
+
+ int index = url.indexOf("$SEQUENCE_ID$");
+ url = url.substring(0, index)+ id + url.substring(index+13);
+
+ try
+ {
+ jalview.util.BrowserLauncher.openURL(url);
+ }
+ catch (Exception ex)
+ {
+ JOptionPane.showInternalMessageDialog(Desktop.desktop,
+ "Unixers: Couldn't find default web browser."
+ +"\nAdd the full path to your browser in Preferences.",
+ "Web browser not found", JOptionPane.WARNING_MESSAGE );
+ ex.printStackTrace();
+ }
}
/**
@@ -197,7 +244,7 @@ public class IdPanel extends JPanel implements MouseListener,
if (av.getWrapAlignment())
{
- y -= (2 * av.charHeight);
+ y = getWrappedY(y);
}
int seq = av.getIndex(y);
@@ -277,6 +324,9 @@ public class IdPanel extends JPanel implements MouseListener,
*/
void selectSeqs(int start, int end)
{
+ if(av.getSelectionGroup()==null)
+ return;
+
lastid = start;
if (end < start)
@@ -289,7 +339,7 @@ public class IdPanel extends JPanel implements MouseListener,
for (int i = start; i <= end; i++)
{
- av.getSelectionGroup().addSequence(av.getAlignment().getSequenceAt(i),
+ av.getSelectionGroup().addSequence(av.getAlignment().getSequenceAt(i),
true);
}
}