123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- /**
- * Created by Daniel on 21.07.15.
- */
- CmdSetValue = function ( object, attributeName, newValue ) {
- Cmd.call( this );
- this.type = 'CmdSetValue';
- this.name = 'Set ' + attributeName;
- this.updatable = true;
- this.object = object;
- this.attributeName = attributeName;
- this.oldValue = object !== undefined ? object[ attributeName ] : undefined;
- this.newValue = newValue;
- this.objectUuid = object !== undefined ? object.uuid : undefined;
- };
- CmdSetValue.prototype = {
- execute: function () {
- this.object[ this.attributeName ] = this.newValue;
- this.editor.signals.objectChanged.dispatch( this.object );
- this.editor.signals.sceneGraphChanged.dispatch();
- this.editor.signals.updateSidebar.dispatch();
- },
- undo: function () {
- this.object[ this.attributeName ] = this.oldValue;
- this.editor.signals.objectChanged.dispatch( this.object );
- this.editor.signals.sceneGraphChanged.dispatch();
- this.editor.signals.updateSidebar.dispatch();
- },
- update: function ( cmd ) {
- this.newValue = cmd.newValue;
- },
- toJSON: function () {
- var output = Cmd.prototype.toJSON.call( this );
- output.objectUuid = this.objectUuid;
- output.attributeName = this.attributeName;
- output.oldValue = this.oldValue;
- output.newValue = this.newValue;
- return output;
- },
- fromJSON: function ( json ) {
- Cmd.prototype.fromJSON.call( this, json );
- this.objectUuid = json.objectUuid;
- this.attributeName = json.attributeName;
- this.oldValue = json.oldValue;
- this.newValue = json.newValue;
- this.object = this.editor.objectByUuid( json.objectUuid );
- }
- };
|