public interface UndoableEdit 
      UndoableEdit代表一个编辑。 
       编辑可能会被撤消,或者如果已经撤消,编辑可能会被重做。 
        UndoableEdit被设计为与UndoManager一起使用。 由于UndoableEdit是由UndoableEditListener它们通常被添加到UndoManager 。 当一个UndoableEdit添加到一个UndoManager发生以下情况(假设end尚未在UndoManager上UndoManager ): 
UndoManager包含编辑,它将在当前编辑中调用addEdit ,传递新的编辑作为参数。 如果addEdit返回true,则假设新编辑已被并入当前编辑,并且新编辑将不会添加到当前编辑列表中。 编辑可以使用addEdit作为更小的编辑被并入更大的编辑并被视为单个编辑的方式。 addEdit返回false replaceEdit被调用新编辑,当前编辑作为参数传入。 这是addEdit的倒数? 如果新编辑从replaceEdit返回true,则新编辑将替换当前编辑。 UndoManager使用isSignificant来确定应该撤消或重做多少个编辑。 
       UndoManager将撤消或重做当前编辑和上一个或下一个重要编辑之间的所有无关紧要的编辑( isSignificant返回false)。 
       addEdit和replaceEdit可以用于将多个编辑作为单个编辑进行处理,从isSignificant返回false可以使用,可以一次使用多个较小的编辑撤消或重做。 
       也可以使用addEdit方法来完成类似的addEdit 。 
      | Modifier and Type | Method and Description | 
|---|---|
| boolean | addEdit(UndoableEdit anEdit)
              添加一个 
              UndoableEdit到这个UndoableEdit。 | 
| boolean | canRedo()
              如果可以重做此修改,则返回true。 
             | 
| boolean | canUndo()
              如果该编辑可能被撤销,则返回true。 
             | 
| void | die()
              通知编辑它不应再被使用。 
             | 
| String | getPresentationName()
              例如,返回适用于更改日志的本编辑的本地化,可读取的描述。 
             | 
| String | getRedoPresentationName()
              返回适用于例如Redo菜单项的本编辑的可重写形式的本地化,可读的描述。 
             | 
| String | getUndoPresentationName()
              返回适用于例如撤消菜单项的此编辑的可撤销形式的本地化,可读的描述。 
             | 
| boolean | isSignificant()
              如果此编辑被认为是重要的,则返回true。 
             | 
| void | redo()
              重新应用编辑。 
             | 
| boolean | replaceEdit(UndoableEdit anEdit)
              如果 
              UndoableEdit应该取代anEdit则返回true。 | 
| void | undo()
              撤消编辑。 
             | 
void undo() throws CannotUndoException
CannotUndoException - 如果此编辑无法撤消 
           boolean canUndo()
void redo() throws CannotRedoException
CannotRedoException - 如果此编辑无法重做 
           boolean canRedo()
void die()
UndoableEdit被标记为死亡,它将无法再被撤销或重做。 
            这是一个有用的钩子,用于清除状态,一旦撤消或重做是不可能的,就不再需要 - 例如,删除不再被删除的对象使用的文件资源。 UndoManager调用它之前,它出UndoManager编辑。 
请注意,这是单向操作。 没有“不死”的方法。
CompoundEdit.die() 
           boolean addEdit(UndoableEdit anEdit)
UndoableEdit到这个UndoableEdit 。 
           该方法可用于将较小的编辑合并为较大的复合编辑。 
           例如,文本编辑器通常允许撤销操作适用于单词或句子。 
           文本编辑器可以选择在每个键事件上生成编辑,但允许将这些编辑合并到更加用户友好的单元中,例如单词。 
           在这种情况下,当编辑可能合并时, UndoableEdit将覆盖addEdit以返回true。 
            返回值为true表示anEdit被并入此编辑。 返回值为false表示anEdit可能未被并入此编辑。 
 通常,接收器已经在UndoManager (或其他UndoableEditListener )的队列中,并且有机会合并anEdit而不是依次添加到队列中。 
 如果返回true,从现在起anEdit必须从canUndo和canRedo返回false,并且必须在undo或redo上undo redo 。 
anEdit - 要添加的编辑 
           anEdit可以并入此编辑,则为true 
           boolean replaceEdit(UndoableEdit anEdit)
UndoableEdit应该取代anEdit则返回true。 
           此方法由CompoundEdit和UndoManager ; 
           如果anEdit无法添加到当前编辑( addEdit返回false),则调用它。 
           此方法提供了编辑以替换现有编辑的方式。
 这个消息与addEdit相反 - anEdit通常已经在UndoManager (或其他UndoableEditListener)中排队,并且接收者被给予一个机会取代它。 
如果返回true,从现在起,anEdit必须从canUndo()和canRedo()返回false,并且必须在undo()或redo()上抛出适当的异常。
anEdit - 替换当前编辑的编辑 
           anEdit 
           boolean isSignificant()
UndoManager将撤消或重做,对下一个重要编辑进行的所有无关紧要的编辑。 
          String getPresentationName()
String getUndoPresentationName()
getPresentationName 。 
          String getRedoPresentationName()
getPresentationName 。 
           Submit a bug or feature 
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
 Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.