| 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 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * | 10 * |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 WebInspector.TabbedEditorContainer.maximalPreviouslyViewedFilesCount = 30; | 82 WebInspector.TabbedEditorContainer.maximalPreviouslyViewedFilesCount = 30; |
| 83 | 83 |
| 84 WebInspector.TabbedEditorContainer.prototype = { | 84 WebInspector.TabbedEditorContainer.prototype = { |
| 85 /** | 85 /** |
| 86 * @param {!WebInspector.Event} event | 86 * @param {!WebInspector.Event} event |
| 87 */ | 87 */ |
| 88 _onBindingCreated: function(event) | 88 _onBindingCreated: function(event) |
| 89 { | 89 { |
| 90 var binding = /** @type {!WebInspector.PersistenceBinding} */(event.data
); | 90 var binding = /** @type {!WebInspector.PersistenceBinding} */(event.data
); |
| 91 var networkTabId = this._tabIds.get(binding.network); |
| 91 var fileSystemTabId = this._tabIds.get(binding.fileSystem); | 92 var fileSystemTabId = this._tabIds.get(binding.fileSystem); |
| 92 if (!fileSystemTabId) | 93 var wasSelectedInFileSystem = this._currentFile === binding.fileSystem; |
| 93 return; | |
| 94 | 94 |
| 95 var isSelected = this._currentFile === binding.fileSystem; | 95 if (fileSystemTabId) { |
| 96 var tabIndex = this._tabbedPane.tabIndex(fileSystemTabId); | 96 var tabIndex = this._tabbedPane.tabIndex(fileSystemTabId); |
| 97 this._closeTabs([fileSystemTabId]); | 97 this._closeTabs([fileSystemTabId]); |
| 98 var networkTabId = this._tabIds.get(binding.network); | 98 } |
| 99 |
| 99 if (networkTabId) { | 100 if (networkTabId) { |
| 100 if (isSelected) | 101 if (wasSelectedInFileSystem) |
| 101 this._tabbedPane.selectTab(networkTabId, false); | 102 this._tabbedPane.selectTab(networkTabId, false); |
| 103 this._tabbedPane.changeTabTitle(networkTabId, this._titleForFile(bin
ding.fileSystem), this._tooltipForFile(binding.fileSystem)); |
| 102 return; | 104 return; |
| 103 } | 105 } |
| 106 |
| 104 var tabId = this._appendFileTab(binding.network, false, tabIndex); | 107 var tabId = this._appendFileTab(binding.network, false, tabIndex); |
| 105 if (isSelected) | 108 if (wasSelectedInFileSystem) |
| 106 this._tabbedPane.selectTab(tabId, false); | 109 this._tabbedPane.selectTab(tabId, false); |
| 107 }, | 110 }, |
| 108 | 111 |
| 109 /** | 112 /** |
| 110 * @param {!WebInspector.Event} event | 113 * @param {!WebInspector.Event} event |
| 111 */ | 114 */ |
| 112 _onBindingRemoved: function(event) | 115 _onBindingRemoved: function(event) |
| 113 { | 116 { |
| 114 var binding = /** @type {!WebInspector.PersistenceBinding} */(event.data
); | 117 var binding = /** @type {!WebInspector.PersistenceBinding} */(event.data
); |
| 115 var networkTabId = this._tabIds.get(binding.network); | 118 var networkTabId = this._tabIds.get(binding.network); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 }; | 283 }; |
| 281 this.dispatchEventToListeners(WebInspector.TabbedEditorContainer.Events.
EditorSelected, eventData); | 284 this.dispatchEventToListeners(WebInspector.TabbedEditorContainer.Events.
EditorSelected, eventData); |
| 282 }, | 285 }, |
| 283 | 286 |
| 284 /** | 287 /** |
| 285 * @param {!WebInspector.UISourceCode} uiSourceCode | 288 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 286 * @return {string} | 289 * @return {string} |
| 287 */ | 290 */ |
| 288 _titleForFile: function(uiSourceCode) | 291 _titleForFile: function(uiSourceCode) |
| 289 { | 292 { |
| 293 uiSourceCode = WebInspector.persistence.fileSystem(uiSourceCode) || uiSo
urceCode; |
| 290 var maxDisplayNameLength = 30; | 294 var maxDisplayNameLength = 30; |
| 291 var title = uiSourceCode.displayName(true).trimMiddle(maxDisplayNameLeng
th); | 295 var title = uiSourceCode.displayName(true).trimMiddle(maxDisplayNameLeng
th); |
| 292 if (uiSourceCode.isDirty() || WebInspector.persistence.hasUnsavedCommitt
edChanges(uiSourceCode)) | 296 if (uiSourceCode.isDirty() || WebInspector.persistence.hasUnsavedCommitt
edChanges(uiSourceCode)) |
| 293 title += "*"; | 297 title += "*"; |
| 294 return title; | 298 return title; |
| 295 }, | 299 }, |
| 296 | 300 |
| 297 /** | 301 /** |
| 298 * @param {string} id | 302 * @param {string} id |
| 299 * @param {string} nextTabId | 303 * @param {string} nextTabId |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 this._history.update(tabIds.map(tabIdToURI.bind(this))); | 435 this._history.update(tabIds.map(tabIdToURI.bind(this))); |
| 432 this._history.save(this._previouslyViewedFilesSetting); | 436 this._history.save(this._previouslyViewedFilesSetting); |
| 433 }, | 437 }, |
| 434 | 438 |
| 435 /** | 439 /** |
| 436 * @param {!WebInspector.UISourceCode} uiSourceCode | 440 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 437 * @return {string} | 441 * @return {string} |
| 438 */ | 442 */ |
| 439 _tooltipForFile: function(uiSourceCode) | 443 _tooltipForFile: function(uiSourceCode) |
| 440 { | 444 { |
| 445 uiSourceCode = WebInspector.persistence.fileSystem(uiSourceCode) || uiSo
urceCode; |
| 441 return uiSourceCode.url(); | 446 return uiSourceCode.url(); |
| 442 }, | 447 }, |
| 443 | 448 |
| 444 /** | 449 /** |
| 445 * @param {!WebInspector.UISourceCode} uiSourceCode | 450 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 446 * @param {boolean=} userGesture | 451 * @param {boolean=} userGesture |
| 447 * @param {number=} index | 452 * @param {number=} index |
| 448 * @return {string} | 453 * @return {string} |
| 449 */ | 454 */ |
| 450 _appendFileTab: function(uiSourceCode, userGesture, index) | 455 _appendFileTab: function(uiSourceCode, userGesture, index) |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 /** | 809 /** |
| 805 * @override | 810 * @override |
| 806 * @param {string} tabId | 811 * @param {string} tabId |
| 807 * @param {!WebInspector.ContextMenu} contextMenu | 812 * @param {!WebInspector.ContextMenu} contextMenu |
| 808 */ | 813 */ |
| 809 onContextMenu: function(tabId, contextMenu) | 814 onContextMenu: function(tabId, contextMenu) |
| 810 { | 815 { |
| 811 this._editorContainer._onContextMenu(tabId, contextMenu); | 816 this._editorContainer._onContextMenu(tabId, contextMenu); |
| 812 } | 817 } |
| 813 } | 818 } |
| OLD | NEW |