From fd5f6d3eed59b5f6d9a7cc09e4ddeb7e78eb2f17 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Thu, 4 Oct 2018 11:45:22 +0100 Subject: [PATCH] JAL-3132 set status message when over sequence id or annotation label --- src/jalview/gui/AlignFrame.java | 5 +++++ src/jalview/gui/AlignViewport.java | 2 +- src/jalview/gui/AnnotationLabels.java | 1 + src/jalview/gui/AnnotationPanel.java | 4 ++-- src/jalview/gui/CutAndPasteTransfer.java | 2 +- src/jalview/gui/IdPanel.java | 21 +++++++++++++-------- src/jalview/gui/SequenceFetcher.java | 2 +- src/jalview/io/FileLoader.java | 2 +- src/jalview/jbgui/GAlignFrame.java | 4 ++-- 9 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 94b38ed..5fa4652 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -963,6 +963,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, return progressBar.operationInProgress(); } + /** + * Sets the text of the status bar. Note that setting a null or empty value + * will cause the status bar to be hidden, with possibly undesirable flicker + * of the screen layout. + */ @Override public void setStatus(String text) { diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 7e77bec..2e2289c 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -795,7 +795,7 @@ public class AlignViewport extends AlignmentViewport AlignFrame newAlignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); newAlignFrame.setTitle(title); - newAlignFrame.statusBar.setText(MessageManager + newAlignFrame.setStatus(MessageManager .formatMessage("label.successfully_loaded_file", new Object[] { title })); diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index 739fc0f..0ff6b73 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -679,6 +679,7 @@ public class AnnotationLabels extends JPanel String desc = getTooltip(aa); this.setToolTipText(desc); + ap.alignFrame.setStatus(aa.label); } } diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index ce37d7e..32950b9 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -717,12 +717,12 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, { setToolTipText(buildToolTip(ann, column, aa)); String msg = getStatusMessage(av.getAlignment(), column, ann); - ap.alignFrame.statusBar.setText(msg); + ap.alignFrame.setStatus(msg); } else { this.setToolTipText(null); - ap.alignFrame.statusBar.setText(" "); + ap.alignFrame.setStatus(" "); } } diff --git a/src/jalview/gui/CutAndPasteTransfer.java b/src/jalview/gui/CutAndPasteTransfer.java index 2a96daf..b3bff0d 100644 --- a/src/jalview/gui/CutAndPasteTransfer.java +++ b/src/jalview/gui/CutAndPasteTransfer.java @@ -322,7 +322,7 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer af.currentFileFormat = format; Desktop.addInternalFrame(af, title, AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); - af.statusBar.setText(MessageManager + af.setStatus(MessageManager .getString("label.successfully_pasted_alignment_file")); try diff --git a/src/jalview/gui/IdPanel.java b/src/jalview/gui/IdPanel.java index 6cb4e17..579229c 100755 --- a/src/jalview/gui/IdPanel.java +++ b/src/jalview/gui/IdPanel.java @@ -95,11 +95,10 @@ public class IdPanel extends JPanel } /** - * Respond to mouse movement by constructing tooltip text for the sequence id - * under the mouse. + * Responds to mouse movement by setting tooltip text for the sequence id + * under the mouse (or possibly annotation label, when in wrapped mode) * * @param e - * DOCUMENT ME! */ @Override public void mouseMoved(MouseEvent e) @@ -114,6 +113,7 @@ public class IdPanel extends JPanel AlignmentAnnotation annotation = av.getAlignment() .getAlignmentAnnotation()[pos.annotationIndex]; setToolTipText(AnnotationLabels.getTooltip(annotation)); + alignPanel.alignFrame.setStatus(annotation.label); } else { @@ -122,10 +122,16 @@ public class IdPanel extends JPanel { SequenceI sequence = av.getAlignment().getSequenceAt(seq); StringBuilder tip = new StringBuilder(64); + tip.append(sequence.getDisplayId(true)).append(" "); seqAnnotReport.createTooltipAnnotationReport(tip, sequence, av.isShowDBRefs(), av.isShowNPFeats(), sp.seqCanvas.fr); - setToolTipText(JvSwingUtils.wrapTooltip(true, - sequence.getDisplayId(true) + " " + tip.toString())); + setToolTipText(JvSwingUtils.wrapTooltip(true, tip.toString())); + + StringBuilder text = new StringBuilder(); + text.append("Sequence ").append(String.valueOf(seq + 1)) + .append(" ID: ") + .append(sequence.getName()); + alignPanel.alignFrame.setStatus(text.toString()); } } } @@ -220,13 +226,12 @@ public class IdPanel extends JPanel } MousePos pos = alignPanel.getSeqPanel().findMousePosition(e); - if (pos.isOverAnnotation()) + int seq = pos.seqIndex; + if (pos.isOverAnnotation() || seq < 0) { - // mouse is over annotation label in wrapped mode return; } - int seq = pos.seqIndex; String id = av.getAlignment().getSequenceAt(seq).getName(); String url = Preferences.sequenceUrlLinks.getPrimaryUrl(id); diff --git a/src/jalview/gui/SequenceFetcher.java b/src/jalview/gui/SequenceFetcher.java index 8754fbb..1c4e6a6 100755 --- a/src/jalview/gui/SequenceFetcher.java +++ b/src/jalview/gui/SequenceFetcher.java @@ -1038,7 +1038,7 @@ public class SequenceFetcher extends JPanel implements Runnable Desktop.addInternalFrame(af, title, AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); - af.statusBar.setText(MessageManager + af.setStatus(MessageManager .getString("label.successfully_pasted_alignment_file")); try diff --git a/src/jalview/io/FileLoader.java b/src/jalview/io/FileLoader.java index f26d6da..90f9e43 100755 --- a/src/jalview/io/FileLoader.java +++ b/src/jalview/io/FileLoader.java @@ -440,7 +440,7 @@ public class FileLoader implements Runnable alignFrame.getViewport() .applyFeaturesStyle(proxyColourScheme); } - alignFrame.statusBar.setText(MessageManager.formatMessage( + alignFrame.setStatus(MessageManager.formatMessage( "label.successfully_loaded_file", new String[] { title })); diff --git a/src/jalview/jbgui/GAlignFrame.java b/src/jalview/jbgui/GAlignFrame.java index 1cf482d..d5c8c01 100755 --- a/src/jalview/jbgui/GAlignFrame.java +++ b/src/jalview/jbgui/GAlignFrame.java @@ -75,7 +75,7 @@ public class GAlignFrame extends JInternalFrame protected JMenu sortByAnnotScore = new JMenu(); - public JLabel statusBar = new JLabel(); + protected JLabel statusBar = new JLabel(); protected JMenu outputTextboxMenu = new JMenu(); @@ -201,7 +201,7 @@ public class GAlignFrame extends JInternalFrame private boolean showAutoCalculatedAbove = false; - private Map accelerators = new HashMap(); + private Map accelerators = new HashMap<>(); private SplitContainerI splitFrame; -- 1.7.10.2