Module java.desktop
Package javax.swing.undo

Class AbstractUndoableEdit

java.lang.Object
javax.swing.undo.AbstractUndoableEdit
所有已实现的接口:
Serializable, UndoableEdit
直接已知的子类:
AbstractDocument.ElementEdit, CompoundEdit, DefaultStyledDocument.AttributeUndoableEdit, StateEdit

public class AbstractUndoableEdit extends Object implements UndoableEdit, Serializable
UndoableEdit的抽象实现,实现了该接口中所有布尔方法的简单响应。
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final String
    getRedoPresentationName返回的字符串;从Java 2平台v1.3.1开始,此字段不再使用。
    protected static final String
    getUndoPresentationName返回的字符串;从Java 2平台v1.3.1开始,此字段不再使用。
  • Constructor Summary

    Constructors
    Constructor
    Description
    创建一个AbstractUndoableEdit,将hasBeenDonealive默认设置为true
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    此默认实现返回false。
    boolean
    如果此编辑处于alive状态且hasBeenDonefalse,则返回true
    boolean
    如果此编辑处于alive状态且hasBeenDonetrue,则返回true。
    void
    die()
    alive设置为false。
    此默认实现返回""。
    从具有键AbstractUndoableEdit.redoText的默认表中检索值,并返回该值,后跟一个空格,再跟上getPresentationName
    从具有键AbstractUndoableEdit.undoText的默认表中检索值,并返回该值,后跟一个空格,再跟上getPresentationName
    boolean
    此默认实现返回true。
    void
    redo()
    如果canRedo返回false,则抛出CannotRedoException
    boolean
    此默认实现返回false。
    返回显示并标识此对象属性的字符串。
    void
    undo()
    如果canUndo返回false,则抛出CannotUndoException

    Methods declared in class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • UndoName

      protected static final String UndoName
      getUndoPresentationName返回的字符串;从Java 2平台v1.3.1开始,此字段不再使用。此值现在已本地化,并来自具有键AbstractUndoableEdit.undoText的默认表。
      参见:
    • RedoName

      protected static final String RedoName
      getRedoPresentationName返回的字符串;从Java 2平台v1.3.1开始,此字段不再使用。此值现在已本地化,并来自具有键AbstractUndoableEdit.redoText的默认表。
      参见:
  • Constructor Details

    • AbstractUndoableEdit

      public AbstractUndoableEdit()
      创建一个AbstractUndoableEdit,将hasBeenDonealive默认设置为true
  • Method Details

    • die

      public void die()
      alive设置为false。请注意,这是一个单向操作;死编辑无法复活。对死编辑执行undoredo将导致抛出异常。

      通常,当编辑被另一个编辑的addEditreplaceEdit方法合并时,或者当编辑从UndoManager中出列时,编辑会被删除。

      指定者:
      die 在接口 UndoableEdit
      参见:
    • undo

      public void undo() throws CannotUndoException
      如果canUndo返回false,则抛出CannotUndoException。将hasBeenDone设置为false。子类应该重写以撤消此编辑所代表的操作。重写应该以调用super开始。
      指定者:
      undo 在接口 UndoableEdit
      抛出:
      CannotUndoException - 如果canUndo返回false
      参见:
    • canUndo

      public boolean canUndo()
      如果此编辑处于alive状态且hasBeenDonetrue,则返回true。
      指定者:
      canUndo 在接口 UndoableEdit
      返回:
      如果此编辑处于alive状态且hasBeenDonetrue,则返回true
      参见:
    • redo

      public void redo() throws CannotRedoException
      如果canRedo返回false,则抛出CannotRedoException。将hasBeenDone设置为true。子类应该重写以重做此编辑所代表的操作。重写应该以调用super开始。
      指定者:
      redo 在接口 UndoableEdit
      抛出:
      CannotRedoException - 如果canRedo返回false
      参见:
    • canRedo

      public boolean canRedo()
      如果此编辑处于alive状态且hasBeenDonefalse,则返回true
      指定者:
      canRedo 在接口 UndoableEdit
      返回:
      如果此编辑处于alive状态且hasBeenDonefalse,则返回true
      参见:
    • addEdit

      public boolean addEdit(UndoableEdit anEdit)
      此默认实现返回false。
      指定者:
      addEdit 在接口 UndoableEdit
      参数:
      anEdit - 要添加的编辑
      返回:
      false
      参见:
    • replaceEdit

      public boolean replaceEdit(UndoableEdit anEdit)
      此默认实现返回false。
      指定者:
      replaceEdit 在接口 UndoableEdit
      参数:
      anEdit - 要替换的编辑
      返回:
      false
      参见:
    • isSignificant

      public boolean isSignificant()
      此默认实现返回true。
      指定者:
      isSignificant 在接口 UndoableEdit
      返回:
      true
      参见:
    • getPresentationName

      public String getPresentationName()
      此默认实现返回""。由getUndoPresentationNamegetRedoPresentationName使用以构造它们返回的字符串。子类应该重写以返回此编辑代表的操作的适当描述。
      指定者:
      getPresentationName 在接口 UndoableEdit
      返回:
      空字符串""
      参见:
    • getUndoPresentationName

      public String getUndoPresentationName()
      从具有键AbstractUndoableEdit.undoText的默认表中检索值,并返回该值,后跟一个空格,再跟上getPresentationName。如果getPresentationName返回"",则仅返回默认值。
      指定者:
      getUndoPresentationName 在接口 UndoableEdit
      返回值:
      从默认表中使用键AbstractUndoableEdit.undoText检索值,后跟一个空格,再跟随getPresentationName,除非getPresentationName为"",在这种情况下,仅返回默认值。
      参见:
    • getRedoPresentationName

      public String getRedoPresentationName()
      从默认表中检索键为AbstractUndoableEdit.redoText的值,并返回该值,后跟一个空格,再跟随getPresentationName。如果getPresentationName返回"",则仅返回默认值。
      指定者:
      getRedoPresentationName 在接口 UndoableEdit
      返回值:
      从默认表中使用键AbstractUndoableEdit.redoText检索值,后跟一个空格,再跟随getPresentationName,除非getPresentationName为"",在这种情况下,仅返回默认值。
      参见:
    • toString

      public String toString()
      返回一个显示和标识此对象属性的字符串。
      覆盖:
      toString 在类 Object
      返回值:
      此对象的字符串表示形式