X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignFrame.java;h=69af72bf531b12f502007890c8a33353fd0e3b4c;hb=9f822a04881b453114c051b47e133ac43af23c65;hp=41685169e7ce5a0e028ea3dc0cf4720e74d15324;hpb=bbd829dc088612ca1ad505c412455573289522fa;p=jalview.git diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 4168516..69af72b 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -334,7 +334,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, setMenusFromViewport(viewport); buildSortByAnnotationScoresMenu(); buildTreeMenu(); - buildShowHideAnnotationMenus(); if (viewport.wrapAlignment) { @@ -507,14 +506,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, case KeyEvent.VK_F1: try { - ClassLoader cl = jalview.gui.Desktop.class.getClassLoader(); - java.net.URL url = javax.help.HelpSet.findHelpSet(cl, - "help/help"); - javax.help.HelpSet hs = new javax.help.HelpSet(cl, url); - - javax.help.HelpBroker hb = hs.createHelpBroker(); - hb.setCurrentID("home"); - hb.setDisplayed(true); + Help.showHelpWindow(); } catch (Exception ex) { ex.printStackTrace(); @@ -731,6 +723,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, scaleLeft.setVisible(av.wrapAlignment); scaleRight.setVisible(av.wrapAlignment); annotationPanelMenuItem.setState(av.showAnnotation); + /* + * Show/hide all annotations only enabled if annotation panel is shown + */ + showAllAnnotations.setEnabled(annotationPanelMenuItem.getState()); + hideAllAnnotations.setEnabled(annotationPanelMenuItem.getState()); viewBoxesMenuItem.setSelected(av.showBoxes); viewTextMenuItem.setSelected(av.showText); showNonconservedMenuItem.setSelected(av.getShowUnconserved()); @@ -2184,17 +2181,27 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, return; } - Vector seqs = new Vector(); + List seqs = new ArrayList(sg.getSize()); SequenceI seq; for (int i = 0; i < sg.getSize(); i++) { seq = sg.getSequenceAt(i); - seqs.addElement(seq); + seqs.add(seq); } - // If the cut affects all sequences, remove highlighted columns + // If the cut affects all sequences, warn, remove highlighted columns if (sg.getSize() == viewport.getAlignment().getHeight()) { + int confirm = JOptionPane.showConfirmDialog(this, + MessageManager.getString("warn.delete_all"), // $NON-NLS-1$ + MessageManager.getString("label.delete_all"), // $NON-NLS-1$ + JOptionPane.OK_CANCEL_OPTION); + + if (confirm == JOptionPane.CANCEL_OPTION + || confirm == JOptionPane.CLOSED_OPTION) + { + return; + } viewport.getColumnSelection().removeElements(sg.getStartRes(), sg.getEndRes() + 1); } @@ -2202,7 +2209,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, SequenceI[] cut = new SequenceI[seqs.size()]; for (int i = 0; i < seqs.size(); i++) { - cut[i] = (SequenceI) seqs.elementAt(i); + cut[i] = seqs.get(i); } /* @@ -3039,16 +3046,22 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } /** - * DOCUMENT ME! + * Action on toggle of the 'Show annotations' menu item. This shows or hides + * the annotations panel as a whole. + * + * The options to show/hide all annotations should be enabled when the panel + * is shown, and disabled when the panel is hidden. * * @param e - * DOCUMENT ME! */ @Override public void annotationPanelMenuItem_actionPerformed(ActionEvent e) { - viewport.setShowAnnotation(annotationPanelMenuItem.isSelected()); - alignPanel.setAnnotationVisible(annotationPanelMenuItem.isSelected()); + final boolean setVisible = annotationPanelMenuItem.isSelected(); + viewport.setShowAnnotation(setVisible); + alignPanel.setAnnotationVisible(setVisible); + this.showAllAnnotations.setEnabled(setVisible); + this.hideAllAnnotations.setEnabled(setVisible); } @Override @@ -5709,16 +5722,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } /** - * On menu option, open a panel to allow choice of annotation types to - * show/hide. - */ - @Override - protected void chooseAnnotations_actionPerformed() - { - new AnnotationChooser(this.alignPanel); - } - - /** * Get a list of unique annotation types for the alignment, optionally * restricted to sequence-specific annotations. */ @@ -5743,59 +5746,20 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } /** - * Action on selection of an annotation type to Show or Hide. + * Action on selection of menu option to Show or Hide all annotations. * - * @param type - * @param doShow + * @param visibile */ @Override - protected void showHideAnnotation_actionPerformed(String type, boolean doShow) + protected void setAllAnnotationsVisibility(boolean visible) { for (AlignmentAnnotation aa : alignPanel.getAlignment() .getAlignmentAnnotation()) { - if (type.equals(aa.label)) - { - aa.visible = doShow; - } + aa.visible = visible; } this.alignPanel.paintAlignment(true); } - - /** - * Dynamically build the list of annotation types to show or hide. - */ - @Override - protected void buildShowHideAnnotationMenus() - { - showAnnotations.removeAll(); - hideAnnotations.removeAll(); - - List types = getAnnotationTypes(false); - for (final String type : types) - { - final JMenuItem showitem = new JMenuItem(type); - showitem.addActionListener(new java.awt.event.ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - showHideAnnotation_actionPerformed(type, true); - } - }); - showAnnotations.add(showitem); - final JMenuItem hideitem = new JMenuItem(type); - hideitem.addActionListener(new java.awt.event.ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - showHideAnnotation_actionPerformed(type, false); - } - }); - hideAnnotations.add(hideitem); - } - } } class PrintThread extends Thread