12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- /**
- * Created by Daniel on 21.07.15.
- */
- CmdSetUuid = function ( object, newUuid ) {
- Cmd.call( this );
- this.type = 'CmdSetUuid';
- this.object = object;
- this.oldUuid = object !== undefined ? object.uuid : undefined;
- this.newUuid = newUuid;
- };
- CmdSetUuid.prototype = {
- execute: function () {
- this.object.uuid = this.newUuid;
- this.editor.signals.objectChanged.dispatch( this.object );
- this.editor.signals.sceneGraphChanged.dispatch();
- this.editor.signals.updateSidebar.dispatch();
- },
- undo: function () {
- this.object.uuid = this.oldUuid;
- this.editor.signals.objectChanged.dispatch( this.object );
- this.editor.signals.sceneGraphChanged.dispatch();
- this.editor.signals.updateSidebar.dispatch();
- },
- toJSON: function () {
- var output = Cmd.prototype.toJSON.call( this );
- output.oldUuid = this.oldUuid;
- output.newUuid = this.newUuid;
- return output;
- },
- fromJSON: function ( json ) {
- Cmd.prototype.fromJSON.call( this, json );
- this.oldUuid = json.oldUuid;
- this.newUuid = json.newUuid;
- this.object = this.editor.objectByUuid( json.oldUuid );
- if ( this.object === undefined ) {
- this.object = this.editor.objectByUuid( json.newUuid );
- }
- }
- };
|