Debian Codegraph @

closure-library/closure/goog/editor/plugins/undoredostate.js

raw
1 // Copyright 2008 The Closure Library Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS-IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 /**
16 * @fileoverview Code for an UndoRedoState interface representing an undo and
17 * redo action for a particular state change. To be used by
18 * {@link goog.editor.plugins.UndoRedoManager}.
19 *
20 */
21
22
23 goog.provide('goog.editor.plugins.UndoRedoState');
24
25 goog.require('goog.events.EventTarget');
26
27
28
29 /**
30 * Represents an undo and redo action for a particular state transition.
31 *
32 * @param {boolean} asynchronous Whether the undo or redo actions for this
33 * state complete asynchronously. If true, then this state must fire
34 * an ACTION_COMPLETED event when undo or redo is complete.
35 * @constructor
36 * @extends {goog.events.EventTarget}
37 */
38 goog.editor.plugins.UndoRedoState = function(asynchronous) {
39 goog.editor.plugins.UndoRedoState.base(this, 'constructor');
40
41 /**
42 * Indicates if the undo or redo actions for this state complete
43 * asynchronously.
44 * @type {boolean}
45 * @private
46 */
47 this.asynchronous_ = asynchronous;
48 };
49 goog.inherits(goog.editor.plugins.UndoRedoState, goog.events.EventTarget);
50
51
52 /**
53 * Event type for events indicating that this state has completed an undo or
54 * redo operation.
55 */
56 goog.editor.plugins.UndoRedoState.ACTION_COMPLETED = 'action_completed';
57
58
59 /**
60 * @return {boolean} Whether or not the undo and redo actions of this state
61 * complete asynchronously. If true, the state will fire an ACTION_COMPLETED
62 * event when an undo or redo action is complete.
63 */
64 goog.editor.plugins.UndoRedoState.prototype.isAsynchronous = function() {
65 return this.asynchronous_;
66 };
67
68
69 /**
70 * Undoes the action represented by this state.
71 */
72 goog.editor.plugins.UndoRedoState.prototype.undo = goog.abstractMethod;
73
74
75 /**
76 * Redoes the action represented by this state.
77 */
78 goog.editor.plugins.UndoRedoState.prototype.redo = goog.abstractMethod;
79
80
81 /**
82 * Checks if two undo-redo states are the same.
83 * @param {goog.editor.plugins.UndoRedoState} state The state to compare.
84 * @return {boolean} Wether the two states are equal.
85 */
86 goog.editor.plugins.UndoRedoState.prototype.equals = goog.abstractMethod;