import java.awt.event.*;
import javax.swing.*;

/**
 * A "cut action" for an Editor.
 *
 * @author  Prof. David Bernstein, James Madison University
 */
public class CutAction extends EditorAction
{
  private static final long serialVersionUID = 1L;

  /**
   * Explicit Value Constructor
   *
   * @param editor    The editor to cut from
   */
  public CutAction(TextEditor editor)
  {
    super(editor, "Cut", new ImageIcon("cut.gif"));

    putValue(Action.SHORT_DESCRIPTION, "Cut the selected text");
  }

  /**
   * Handle actionPerformed messages.
   *
   * @param ae    The event that caused the message to be generated
   */
  public void actionPerformed(ActionEvent ae)
  {
    getEditor().cut();
  }

  /**
   * Set the enabled state of this Action based on whether
   * text is selected and whether the "clipboard" is populated.
   *
   * @param textIsSelected     true if there is text selected
   * @param textIsOnClipboard  true if the "clipboard" is populated
   */
  protected void setEnabled(boolean textIsSelected, boolean textIsOnClipboard)
  {
    setEnabled(textIsSelected);
  }
}
