| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 /** | 4 /** |
| 5 * @implements {Sources.TabbedEditorContainerDelegate} | 5 * @implements {Sources.TabbedEditorContainerDelegate} |
| 6 * @implements {UI.Searchable} | 6 * @implements {UI.Searchable} |
| 7 * @implements {UI.Replaceable} | 7 * @implements {UI.Replaceable} |
| 8 * @unrestricted | 8 * @unrestricted |
| 9 */ | 9 */ |
| 10 Sources.SourcesView = class extends UI.VBox { | 10 Sources.SourcesView = class extends UI.VBox { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 workspace.addEventListener(Workspace.Workspace.Events.UISourceCodeRemoved, t
his._uiSourceCodeRemoved, this); | 61 workspace.addEventListener(Workspace.Workspace.Events.UISourceCodeRemoved, t
his._uiSourceCodeRemoved, this); |
| 62 workspace.addEventListener(Workspace.Workspace.Events.ProjectRemoved, this._
projectRemoved.bind(this), this); | 62 workspace.addEventListener(Workspace.Workspace.Events.ProjectRemoved, this._
projectRemoved.bind(this), this); |
| 63 | 63 |
| 64 /** | 64 /** |
| 65 * @param {!Event} event | 65 * @param {!Event} event |
| 66 */ | 66 */ |
| 67 function handleBeforeUnload(event) { | 67 function handleBeforeUnload(event) { |
| 68 if (event.returnValue) | 68 if (event.returnValue) |
| 69 return; | 69 return; |
| 70 | 70 |
| 71 var unsavedSourceCodes = []; | 71 var unsavedSourceCodes = |
| 72 var projects = Workspace.workspace.projectsForType(Workspace.projectTypes.
FileSystem); | 72 Persistence.FileSystemWorkspaceBinding.uiSourceCodes(Workspace.workspa
ce).filter(isUnsaved); |
| 73 for (var i = 0; i < projects.length; ++i) | |
| 74 unsavedSourceCodes = unsavedSourceCodes.concat(projects[i].uiSourceCodes
().filter(isUnsaved)); | |
| 75 | |
| 76 if (!unsavedSourceCodes.length) | 73 if (!unsavedSourceCodes.length) |
| 77 return; | 74 return; |
| 78 | 75 |
| 79 event.returnValue = Common.UIString('DevTools have unsaved changes that wi
ll be permanently lost.'); | 76 event.returnValue = Common.UIString('DevTools have unsaved changes that wi
ll be permanently lost.'); |
| 80 UI.viewManager.showView('sources'); | 77 UI.viewManager.showView('sources'); |
| 81 for (var i = 0; i < unsavedSourceCodes.length; ++i) | 78 for (var i = 0; i < unsavedSourceCodes.length; ++i) |
| 82 Common.Revealer.reveal(unsavedSourceCodes[i]); | 79 Common.Revealer.reveal(unsavedSourceCodes[i]); |
| 83 | 80 |
| 84 /** | 81 /** |
| 85 * @param {!Workspace.UISourceCode} sourceCode | 82 * @param {!Workspace.UISourceCode} sourceCode |
| (...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 * @return {boolean} | 758 * @return {boolean} |
| 762 */ | 759 */ |
| 763 handleAction(context, actionId) { | 760 handleAction(context, actionId) { |
| 764 var sourcesView = UI.context.flavor(Sources.SourcesView); | 761 var sourcesView = UI.context.flavor(Sources.SourcesView); |
| 765 if (!sourcesView) | 762 if (!sourcesView) |
| 766 return false; | 763 return false; |
| 767 sourcesView._editorContainer.closeAllFiles(); | 764 sourcesView._editorContainer.closeAllFiles(); |
| 768 return true; | 765 return true; |
| 769 } | 766 } |
| 770 }; | 767 }; |
| OLD | NEW |