2009-06-07 20:59:43 +02:00
|
|
|
/*
|
2011-07-27 13:25:10 +02:00
|
|
|
* Copyright [2011] [wisemapping]
|
|
|
|
*
|
|
|
|
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
|
|
|
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
|
|
|
* "powered by wisemapping" text requirement on every single page;
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the license at
|
|
|
|
*
|
|
|
|
* http://www.wisemapping.org/license
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2009-06-07 20:59:43 +02:00
|
|
|
|
|
|
|
mindplot.DesignerActionRunner = new Class({
|
2011-08-05 03:12:53 +02:00
|
|
|
initialize: function(commandContext, notifier) {
|
|
|
|
$assert(commandContext, "commandContext can not be null");
|
|
|
|
|
2011-07-27 13:25:10 +02:00
|
|
|
this._undoManager = new mindplot.DesignerUndoManager();
|
2011-08-05 03:12:53 +02:00
|
|
|
this._context = commandContext;
|
|
|
|
this._notifier = notifier;
|
2011-07-27 13:25:10 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
execute:function(command) {
|
2011-07-27 19:33:02 +02:00
|
|
|
$assert(command, "command can not be null");
|
2009-06-07 20:59:43 +02:00
|
|
|
command.execute(this._context);
|
|
|
|
this._undoManager.enqueue(command);
|
2011-08-05 03:12:53 +02:00
|
|
|
this.fireChangeEvent();
|
2009-06-07 20:59:43 +02:00
|
|
|
},
|
2011-07-27 13:25:10 +02:00
|
|
|
|
|
|
|
undo: function() {
|
2009-06-07 20:59:43 +02:00
|
|
|
this._undoManager.execUndo(this._context);
|
2011-08-05 03:12:53 +02:00
|
|
|
this.fireChangeEvent();
|
2009-06-07 20:59:43 +02:00
|
|
|
},
|
2011-07-27 13:25:10 +02:00
|
|
|
|
|
|
|
redo: function() {
|
2009-06-07 20:59:43 +02:00
|
|
|
this._undoManager.execRedo(this._context);
|
2011-08-05 03:12:53 +02:00
|
|
|
this.fireChangeEvent();
|
|
|
|
},
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-08-05 03:12:53 +02:00
|
|
|
fireChangeEvent : function () {
|
|
|
|
var event = this._undoManager.buildEvent();
|
|
|
|
this._notifier.fireEvent("modelUpdate", event);
|
2009-06-07 20:59:43 +02:00
|
|
|
},
|
2011-07-27 13:25:10 +02:00
|
|
|
|
|
|
|
markAsChangeBase: function() {
|
2009-06-07 20:59:43 +02:00
|
|
|
return this._undoManager.markAsChangeBase();
|
|
|
|
},
|
2011-10-02 19:47:54 +02:00
|
|
|
|
2011-07-27 13:25:10 +02:00
|
|
|
hasBeenChanged: function() {
|
2009-06-07 20:59:43 +02:00
|
|
|
return this._undoManager.hasBeenChanged();
|
|
|
|
}
|
|
|
|
});
|