setMenusFromViewport(viewport);
buildSortByAnnotationScoresMenu();
buildTreeMenu();
- buildShowHideAnnotationMenus();
if (viewport.wrapAlignment)
{
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();
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());
return;
}
- Vector seqs = new Vector();
+ List<SequenceI> seqs = new ArrayList<SequenceI>(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);
}
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);
}
/*
}
/**
- * 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
}
/**
- * 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.
*/
}
/**
- * 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<String> 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