| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 * @param {!Common.ResourceType=} contentType | 173 * @param {!Common.ResourceType=} contentType |
| 174 */ | 174 */ |
| 175 _updateName(name, url, contentType) { | 175 _updateName(name, url, contentType) { |
| 176 var oldURL = this.url(); | 176 var oldURL = this.url(); |
| 177 this._url = this._url.substring(0, this._url.length - this._name.length) + n
ame; | 177 this._url = this._url.substring(0, this._url.length - this._name.length) + n
ame; |
| 178 this._name = name; | 178 this._name = name; |
| 179 if (url) | 179 if (url) |
| 180 this._url = url; | 180 this._url = url; |
| 181 if (contentType) | 181 if (contentType) |
| 182 this._contentType = contentType; | 182 this._contentType = contentType; |
| 183 this.dispatchEventToListeners(Workspace.UISourceCode.Events.TitleChanged, ol
dURL); | 183 this.dispatchEventToListeners(Workspace.UISourceCode.Events.TitleChanged, th
is); |
| 184 } | 184 } |
| 185 | 185 |
| 186 /** | 186 /** |
| 187 * @override | 187 * @override |
| 188 * @return {string} | 188 * @return {string} |
| 189 */ | 189 */ |
| 190 contentURL() { | 190 contentURL() { |
| 191 return this.url(); | 191 return this.url(); |
| 192 } | 192 } |
| 193 | 193 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 this._content = content; | 340 this._content = content; |
| 341 this._contentLoaded = true; | 341 this._contentLoaded = true; |
| 342 | 342 |
| 343 var lastRevision = this.history.length ? this.history[this.history.length -
1] : null; | 343 var lastRevision = this.history.length ? this.history[this.history.length -
1] : null; |
| 344 if (!lastRevision || lastRevision._content !== this._content) { | 344 if (!lastRevision || lastRevision._content !== this._content) { |
| 345 var revision = new Workspace.Revision(this, this._content, new Date()); | 345 var revision = new Workspace.Revision(this, this._content, new Date()); |
| 346 this.history.push(revision); | 346 this.history.push(revision); |
| 347 } | 347 } |
| 348 | 348 |
| 349 this._innerResetWorkingCopy(); | 349 this._innerResetWorkingCopy(); |
| 350 this.dispatchEventToListeners(Workspace.UISourceCode.Events.WorkingCopyCommi
tted, {content: content}); | 350 this.dispatchEventToListeners( |
| 351 Workspace.UISourceCode.Events.WorkingCopyCommitted, {uiSourceCode: this,
content: content}); |
| 351 this._project.workspace().dispatchEventToListeners( | 352 this._project.workspace().dispatchEventToListeners( |
| 352 Workspace.Workspace.Events.WorkingCopyCommitted, {uiSourceCode: this, co
ntent: content}); | 353 Workspace.Workspace.Events.WorkingCopyCommitted, {uiSourceCode: this, co
ntent: content}); |
| 353 if (committedByUser) { | 354 if (committedByUser) { |
| 354 this._project.workspace().dispatchEventToListeners( | 355 this._project.workspace().dispatchEventToListeners( |
| 355 Workspace.Workspace.Events.WorkingCopyCommittedByUser, {uiSourceCode:
this, content: content}); | 356 Workspace.Workspace.Events.WorkingCopyCommittedByUser, {uiSourceCode:
this, content: content}); |
| 356 } | 357 } |
| 357 } | 358 } |
| 358 | 359 |
| 359 saveAs() { | 360 saveAs() { |
| 360 Workspace.fileManager.save(this._url, this.workingCopy(), true, callback.bin
d(this)); | 361 Workspace.fileManager.save(this._url, this.workingCopy(), true, callback.bin
d(this)); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 this._workingCopyChanged(); | 450 this._workingCopyChanged(); |
| 450 } | 451 } |
| 451 | 452 |
| 452 setWorkingCopyGetter(workingCopyGetter) { | 453 setWorkingCopyGetter(workingCopyGetter) { |
| 453 this._workingCopyGetter = workingCopyGetter; | 454 this._workingCopyGetter = workingCopyGetter; |
| 454 this._workingCopyChanged(); | 455 this._workingCopyChanged(); |
| 455 } | 456 } |
| 456 | 457 |
| 457 _workingCopyChanged() { | 458 _workingCopyChanged() { |
| 458 this._removeAllMessages(); | 459 this._removeAllMessages(); |
| 459 this.dispatchEventToListeners(Workspace.UISourceCode.Events.WorkingCopyChang
ed); | 460 this.dispatchEventToListeners(Workspace.UISourceCode.Events.WorkingCopyChang
ed, this); |
| 460 this._project.workspace().dispatchEventToListeners( | 461 this._project.workspace().dispatchEventToListeners( |
| 461 Workspace.Workspace.Events.WorkingCopyChanged, {uiSourceCode: this}); | 462 Workspace.Workspace.Events.WorkingCopyChanged, {uiSourceCode: this}); |
| 462 } | 463 } |
| 463 | 464 |
| 464 removeWorkingCopyGetter() { | 465 removeWorkingCopyGetter() { |
| 465 if (!this._workingCopyGetter) | 466 if (!this._workingCopyGetter) |
| 466 return; | 467 return; |
| 467 this._workingCopy = this._workingCopyGetter(); | 468 this._workingCopy = this._workingCopyGetter(); |
| 468 delete this._workingCopyGetter; | 469 delete this._workingCopyGetter; |
| 469 } | 470 } |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 Workspace.UISourceCodeMetadata = class { | 940 Workspace.UISourceCodeMetadata = class { |
| 940 /** | 941 /** |
| 941 * @param {?Date} modificationTime | 942 * @param {?Date} modificationTime |
| 942 * @param {?number} contentSize | 943 * @param {?number} contentSize |
| 943 */ | 944 */ |
| 944 constructor(modificationTime, contentSize) { | 945 constructor(modificationTime, contentSize) { |
| 945 this.modificationTime = modificationTime; | 946 this.modificationTime = modificationTime; |
| 946 this.contentSize = contentSize; | 947 this.contentSize = contentSize; |
| 947 } | 948 } |
| 948 }; | 949 }; |
| OLD | NEW |