Java 类android.content.UndoManager 实例源码

项目:Tada    文件:TextView.java   
/**
 * Associate an {@link android.content.UndoManager} with this TextView.  Once
 * done, all edit operations on the TextView will result in appropriate
 * {@link android.content.UndoOperation} objects pushed on the given UndoManager's
 * stack.
 *
 * @param undoManager The {@link android.content.UndoManager} to associate with
 * this TextView, or null to clear any existing association.
 * @param tag String tag identifying this particular TextView owner in the
 * UndoManager.  This is used to keep the correct association with the
 * {@link android.content.UndoOwner} of any operations inside of the UndoManager.
 *
 * @hide
 */
public final void setUndoManager(UndoManager undoManager, String tag) {
    if (undoManager != null) {
        createEditorIfNeeded();
        mEditor.mUndoManager = undoManager;
        mEditor.mUndoOwner = undoManager.getOwner(tag, this);
        mEditor.mUndoInputFilter = new Editor.UndoInputFilter(mEditor);
        if (!(mText instanceof Editable)) {
            setText(mText, BufferType.EDITABLE);
        }

        setFilters((Editable) mText, mFilters);
    } else if (mEditor != null) {
        // XXX need to destroy all associated state.
        mEditor.mUndoManager = null;
        mEditor.mUndoOwner = null;
        mEditor.mUndoInputFilter = null;
    }
}
项目:Tada    文件:TextView.java   
/**
 * Retrieve the {@link android.content.UndoManager} that is currently associated
 * with this TextView.  By default there is no associated UndoManager, so null
 * is returned.  One can be associated with the TextView through
 * {@link #setUndoManager(android.content.UndoManager, String)}
 *
 * @hide
 */
public final UndoManager getUndoManager() {
    return mEditor == null ? null : mEditor.mUndoManager;
}