case KeyEvent.VK_BACK_SPACE:
if (!viewport.cursorMode)
{
- cut_actionPerformed(null);
+ cut_actionPerformed();
}
else
{
* DOCUMENT ME!
*/
@Override
- protected void copy_actionPerformed(ActionEvent e)
+ protected void copy_actionPerformed()
{
if (viewport.getSelectionGroup() == null)
{
}
/**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
+ * Action Cut (delete and copy) the selected region
*/
@Override
- protected void cut_actionPerformed(ActionEvent e)
+ protected void cut_actionPerformed()
{
- copy_actionPerformed(null);
- delete_actionPerformed(null);
+ copy_actionPerformed();
+ delete_actionPerformed();
}
/**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
+ * Performs menu option to Delete the currently selected region
*/
@Override
- protected void delete_actionPerformed(ActionEvent evt)
+ protected void delete_actionPerformed()
{
SequenceGroup sg = viewport.getSelectionGroup();
return;
}
+ Runnable okAction = new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ SequenceI[] cut = sg.getSequences()
+ .toArray(new SequenceI[sg.getSize()]);
+
+ addHistoryItem(new EditCommand(
+ MessageManager.getString("label.cut_sequences"), Action.CUT,
+ cut, sg.getStartRes(), sg.getEndRes() - sg.getStartRes() + 1,
+ viewport.getAlignment()));
+
+ viewport.setSelectionGroup(null);
+ viewport.sendSelection();
+ viewport.getAlignment().deleteGroup(sg);
+
+ viewport.firePropertyChange("alignment", null,
+ viewport.getAlignment().getSequences());
+ if (viewport.getAlignment().getHeight() < 1)
+ {
+ try
+ {
+ AlignFrame.this.setClosed(true);
+ } catch (Exception ex)
+ {
+ }
+ }
+ }};
+
/*
- * If the cut affects all sequences, warn, remove highlighted columns
+ * If the cut affects all sequences, prompt for confirmation
*/
- if (sg.getSize() == viewport.getAlignment().getHeight())
- {
- boolean isEntireAlignWidth = (((sg.getEndRes() - sg.getStartRes())
- + 1) == viewport.getAlignment().getWidth()) ? true : false;
- if (isEntireAlignWidth)
- {
- int confirm = JvOptionPane.showConfirmDialog(this,
- MessageManager.getString("warn.delete_all"), // $NON-NLS-1$
- MessageManager.getString("label.delete_all"), // $NON-NLS-1$
- JvOptionPane.OK_CANCEL_OPTION);
-
- if (confirm == JvOptionPane.CANCEL_OPTION
- || confirm == JvOptionPane.CLOSED_OPTION)
- {
- return;
- }
- }
- viewport.getColumnSelection().removeElements(sg.getStartRes(),
- sg.getEndRes() + 1);
- }
- SequenceI[] cut = sg.getSequences()
- .toArray(new SequenceI[sg.getSize()]);
-
- addHistoryItem(new EditCommand(
- MessageManager.getString("label.cut_sequences"), Action.CUT,
- cut, sg.getStartRes(), sg.getEndRes() - sg.getStartRes() + 1,
- viewport.getAlignment()));
-
- viewport.setSelectionGroup(null);
- viewport.sendSelection();
- viewport.getAlignment().deleteGroup(sg);
-
- viewport.firePropertyChange("alignment", null,
- viewport.getAlignment().getSequences());
- if (viewport.getAlignment().getHeight() < 1)
- {
- try
- {
- this.setClosed(true);
- } catch (Exception ex)
- {
- }
- }
+ boolean wholeHeight = sg.getSize() == viewport.getAlignment().getHeight();
+ boolean wholeWidth = (((sg.getEndRes() - sg.getStartRes())
+ + 1) == viewport.getAlignment().getWidth()) ? true : false;
+ if (wholeHeight && wholeWidth)
+ {
+ JvOptionPane dialog = JvOptionPane.newOptionDialog(Desktop.desktop);
+ dialog.setResponseHandler(0, okAction); // 0 = OK_OPTION
+ Object[] options = new Object[] { MessageManager.getString("action.ok"),
+ MessageManager.getString("action.cancel") };
+ dialog.showDialog(MessageManager.getString("warn.delete_all"),
+ MessageManager.getString("label.delete_all"),
+ JvOptionPane.DEFAULT_OPTION, JvOptionPane.PLAIN_MESSAGE, null,
+ options, options[0]);
+ } else
+ {
+ okAction.run();
+ }
}
/**
@Override
public void actionPerformed(ActionEvent e)
{
- copy_actionPerformed(e);
+ copy_actionPerformed();
}
};
addMenuActionAndAccelerator(keyStroke, copy, al);
@Override
public void actionPerformed(ActionEvent e)
{
- cut_actionPerformed(e);
+ cut_actionPerformed();
}
};
addMenuActionAndAccelerator(keyStroke, cut, al);
@Override
public void actionPerformed(ActionEvent e)
{
- delete_actionPerformed(e);
+ delete_actionPerformed();
}
});
{
}
- protected void copy_actionPerformed(ActionEvent e)
+ protected void copy_actionPerformed()
{
}
- protected void cut_actionPerformed(ActionEvent e)
+ protected void cut_actionPerformed()
{
}
- protected void delete_actionPerformed(ActionEvent e)
+ protected void delete_actionPerformed()
{
}