X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FIdPanel.java;h=f3db9be7a1b8d9215b6d2d815f5d6583226fac4f;hb=d19f6b27ef8ee7350763cfaa511270bf128e76a9;hp=d5489366affa492ff955a180283543b05f18d63b;hpb=6e71f42b0a3713ddbc3054e7ea9d8f5088130ec9;p=jalview.git diff --git a/src/jalview/appletgui/IdPanel.java b/src/jalview/appletgui/IdPanel.java index d548936..f3db9be 100755 --- a/src/jalview/appletgui/IdPanel.java +++ b/src/jalview/appletgui/IdPanel.java @@ -37,6 +37,7 @@ public class IdPanel int width; int lastid = -1; boolean mouseDragging = false; + java.util.Vector links = new java.util.Vector(); public IdPanel(AlignViewport av, AlignmentPanel parent) { @@ -47,6 +48,22 @@ public class IdPanel add(idCanvas, BorderLayout.CENTER); idCanvas.addMouseListener(this); idCanvas.addMouseMotionListener(this); + + String label, url; + for(int i=1; i<10; i++) + { + label = parent.alignFrame.applet.getParameter("linkLabel_"+i); + url = parent.alignFrame.applet.getParameter("linkURL_"+i); + + if(label!=null && url!=null) + links.addElement(label+"|"+url); + + } + if (links.size() < 1) + { + links = new java.util.Vector(); + links.addElement("SRS|http://srs.ebi.ac.uk/srs7bin/cgi-bin/wgetz?-e+[uniprot-all:$SEQUENCE_ID$]+-vn+2"); + } } public void mouseMoved(MouseEvent e) @@ -83,29 +100,36 @@ public class IdPanel public void mouseClicked(MouseEvent e) { - if (e.getClickCount() == 2) - { - int y = e.getY(); - if (av.getWrapAlignment()) - { - y -= 2 * av.charHeight; - } + if (e.getClickCount() < 2) + return; - int seq = av.getIndex(y); - String id = av.getAlignment().getSequenceAt(seq).getName(); + int y = e.getY(); - try - { - jalview.bin.JalviewLite.showURL( - "http://srs.ebi.ac.uk/srs7bin/cgi-bin/wgetz?-e+[swall-id:" + id + - "]+-vn+2"); - } - catch (Exception ex) - { - ex.printStackTrace(); - } + if (av.getWrapAlignment()) + { + y -= (2 * av.charHeight); } + //DEFAULT LINK IS FIRST IN THE LINK LIST + int seq = av.getIndex(y); + String id = av.getAlignment().getSequenceAt(seq).getName(); + + String target = links.elementAt(0).toString(); + target = target.substring(0, target.indexOf("|")); + 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.bin.JalviewLite.showURL(url, target); + } + catch (Exception ex) + { + ex.printStackTrace(); + } } public void mouseEntered(MouseEvent e) @@ -137,7 +161,7 @@ public class IdPanel public void mousePressed(MouseEvent e) { - if (e.getClickCount() == 2) + if (e.getClickCount() >1 ) { return; } @@ -157,7 +181,7 @@ public class IdPanel if ( (e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) { - APopupMenu popup = new APopupMenu(alignPanel, null); + APopupMenu popup = new APopupMenu(alignPanel, (Sequence) av.getAlignment().getSequenceAt(seq), links); this.add(popup); popup.show(this, e.getX(), e.getY()); return;