X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FIdPanel.java;h=d6dff1474dc8d3bbee3548b754f0c3e5c8aab0bb;hb=488e3a038c2ba1a3926f2af5eaea97ba76e028d0;hp=310276c5ee63b832f0de1820b8f4ed5bfb67e101;hpb=efc31b4a8d5cee63555586804a2b79c06bdb5a14;p=jalview.git diff --git a/src/jalview/gui/IdPanel.java b/src/jalview/gui/IdPanel.java index 310276c..d6dff14 100755 --- a/src/jalview/gui/IdPanel.java +++ b/src/jalview/gui/IdPanel.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -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,52 @@ public class IdPanel extends JPanel implements MouseListener, */ public void mouseMoved(MouseEvent e) { + int seq = Math.max(0, alignPanel.seqPanel.findSeq(e)); + if(seq>-1 && seq"); + tip.append(sequence.getDisplayId(true)); + if (av.alignment.getSequenceAt(seq).getDescription() != null) + { + tip.append("
"); + tip.append(av.alignment.getSequenceAt(seq).getDescription()); + + //ADD NON POSITIONAL SEQUENCE INFO + SequenceFeature [] features = sequence.getDatasetSequence().getSequenceFeatures(); + if(features!=null) + { + for(int i=0; i"+features[i].featureGroup + +" "+ features[i].getType()+" "+features[i].description); + } + } + } + tip.append("
"); + } + + DBRefEntry[] dbrefs = sequence.getDatasetSequence().getDBRef(); + if (dbrefs != null) + { + tip.append(""); + for (int i = 0; i < dbrefs.length; i++) + { + tip.append("
"); + tip.append(dbrefs[i].getSource() + " " + + dbrefs[i].getAccessionId()); + } + tip.append("
"); + } + + tip.append(""); + setToolTipText(tip.toString()); + } } + /** * DOCUMENT ME! * @@ -79,19 +124,7 @@ public class IdPanel extends JPanel implements MouseListener, { mouseDragging = true; - int y = e.getY(); - - if (av.getWrapAlignment()) - { - y -= (2 * av.charHeight); - } - - int seq = av.getIndex(y); - - if (seq < 0) - { - return; - } + int seq = Math.max(0, alignPanel.seqPanel.findSeq(e)); if (seq < lastid) { @@ -106,6 +139,7 @@ public class IdPanel extends JPanel implements MouseListener, alignPanel.repaint(); } + /** * DOCUMENT ME! * @@ -113,35 +147,40 @@ public class IdPanel extends JPanel implements MouseListener, */ public void mouseClicked(MouseEvent e) { - if (e.getClickCount() == 2) - { - int y = e.getY(); + if (e.getClickCount() < 2) + return; - if (av.getWrapAlignment()) - { - y -= (2 * av.charHeight); - } + java.util.Vector links = Preferences.sequenceURLLinks; + if (links == null || links.size() < 1) + return; - int seq = av.getIndex(y); - String id = av.getAlignment().getSequenceAt(seq).getName(); + int seq = alignPanel.seqPanel.findSeq(e); - 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"); + //DEFAULT LINK IS FIRST IN THE LINK LIST - //ex.printStackTrace(); - } - } + 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(); + } } /** @@ -193,56 +232,29 @@ public class IdPanel extends JPanel implements MouseListener, return; } - int y = e.getY(); + int seq = alignPanel.seqPanel.findSeq(e); - if (av.getWrapAlignment()) - { - y -= (2 * av.charHeight); - } - - int seq = av.getIndex(y); - - if (seq == -1) - { - return; - } if (javax.swing.SwingUtilities.isRightMouseButton(e)) { jalview.gui.PopupMenu pop = new jalview.gui.PopupMenu(alignPanel, - (Sequence) av.getAlignment().getSequenceAt(seq)); - pop.show(this, e.getX(), y); + (Sequence) av.getAlignment().getSequenceAt(seq), + Preferences.sequenceURLLinks); + pop.show(this, e.getX(), e.getY()); return; } - if (!e.isControlDown() && !e.isShiftDown() && - (av.alignment.findGroup(av.alignment.getSequenceAt(seq)) != null)) - { - SequenceGroup selection = new SequenceGroup(); - SequenceGroup sg = av.alignment.findGroup(av.alignment.getSequenceAt( - seq)); - selection.setStartRes(0); - selection.setEndRes(av.alignment.getWidth() - 1); - - for (int i = 0; i < sg.getSize(); i++) - { - selection.addSequence(sg.getSequenceAt(i), true); - } - - av.setSelectionGroup(selection); - return; - } if ((av.getSelectionGroup() == null) || - (!e.isControlDown() && (av.getSelectionGroup() != null))) + ((!e.isControlDown() && !e.isShiftDown()) && av.getSelectionGroup() != null)) { - av.setSelectionGroup(new SequenceGroup()); + av.setSelectionGroup(new SequenceGroup()); + av.getSelectionGroup().setStartRes(0); + av.getSelectionGroup().setEndRes(av.alignment.getWidth() - 1); } - av.getSelectionGroup().setStartRes(0); - av.getSelectionGroup().setEndRes(av.alignment.getWidth() - 1); if (e.isShiftDown() && (lastid != -1)) { @@ -277,6 +289,14 @@ public class IdPanel extends JPanel implements MouseListener, */ void selectSeqs(int start, int end) { + if(av.getSelectionGroup()==null) + return; + + if (end >= av.getAlignment().getHeight()) + { + end = av.getAlignment().getHeight() - 1; + } + lastid = start; if (end < start) @@ -289,7 +309,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); } } @@ -307,7 +327,7 @@ public class IdPanel extends JPanel implements MouseListener, } mouseDragging = false; - PaintRefresher.Refresh(av.alignment); + PaintRefresher.Refresh(this, av.getSequenceSetId()); } /**