55 lines
1.9 KiB
JavaScript
Raw Normal View History

2009-06-07 18:59:43 +00:00
/*
2012-10-04 20:48:01 -03:00
* Copyright [2012] [wisemapping]
2011-07-27 08:25:10 -03:00
*
* 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 18:59:43 +00:00
mindplot.DesignerActionRunner = new Class({
initialize:function (commandContext, notifier) {
2011-08-04 22:12:53 -03:00
$assert(commandContext, "commandContext can not be null");
2011-07-27 08:25:10 -03:00
this._undoManager = new mindplot.DesignerUndoManager();
2011-08-04 22:12:53 -03:00
this._context = commandContext;
this._notifier = notifier;
2011-07-27 08:25:10 -03:00
},
execute:function (command) {
$assert(command, "command can not be null");
2009-06-07 18:59:43 +00:00
command.execute(this._context);
this._undoManager.enqueue(command);
2011-08-04 22:12:53 -03:00
this.fireChangeEvent();
2012-07-07 18:58:42 -03:00
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.DoLayout);
2009-06-07 18:59:43 +00:00
},
2011-07-27 08:25:10 -03:00
undo:function () {
2009-06-07 18:59:43 +00:00
this._undoManager.execUndo(this._context);
2011-08-04 22:12:53 -03:00
this.fireChangeEvent();
2012-07-07 18:58:42 -03:00
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.DoLayout);
2009-06-07 18:59:43 +00:00
},
2011-07-27 08:25:10 -03:00
redo:function () {
2009-06-07 18:59:43 +00:00
this._undoManager.execRedo(this._context);
2011-08-04 22:12:53 -03:00
this.fireChangeEvent();
2012-07-07 18:58:42 -03:00
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.DoLayout);
2011-08-04 22:12:53 -03:00
},
2009-06-07 18:59:43 +00:00
fireChangeEvent:function () {
2011-08-04 22:12:53 -03:00
var event = this._undoManager.buildEvent();
this._notifier.fireEvent("modelUpdate", event);
2009-06-07 18:59:43 +00:00
}
});