Chromium Code Reviews| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 this._tabbedPane.setTabDelegate(new WebInspector.EditorContainerTabDelegate( this)); | 56 this._tabbedPane.setTabDelegate(new WebInspector.EditorContainerTabDelegate( this)); |
| 57 | 57 |
| 58 this._tabbedPane.setCloseableTabs(true); | 58 this._tabbedPane.setCloseableTabs(true); |
| 59 this._tabbedPane.setAllowTabReorder(true, true); | 59 this._tabbedPane.setAllowTabReorder(true, true); |
| 60 this._tabbedPane.insertBeforeTabStrip(createElementWithClass("div", "sources -editor-tabstrip-left")); | 60 this._tabbedPane.insertBeforeTabStrip(createElementWithClass("div", "sources -editor-tabstrip-left")); |
| 61 this._tabbedPane.appendAfterTabStrip(createElementWithClass("div", "sources- editor-tabstrip-right")); | 61 this._tabbedPane.appendAfterTabStrip(createElementWithClass("div", "sources- editor-tabstrip-right")); |
| 62 | 62 |
| 63 this._tabbedPane.addEventListener(WebInspector.TabbedPane.Events.TabClosed, this._tabClosed, this); | 63 this._tabbedPane.addEventListener(WebInspector.TabbedPane.Events.TabClosed, this._tabClosed, this); |
| 64 this._tabbedPane.addEventListener(WebInspector.TabbedPane.Events.TabSelected , this._tabSelected, this); | 64 this._tabbedPane.addEventListener(WebInspector.TabbedPane.Events.TabSelected , this._tabSelected, this); |
| 65 | 65 |
| 66 WebInspector.persistence.addEventListener(WebInspector.Persistence.Events.Bi ndingCreated, this._onBindingCreated, this); | |
| 67 WebInspector.persistence.addEventListener(WebInspector.Persistence.Events.Bi ndingRemoved, this._onBindingRemoved, this); | |
| 68 | |
| 66 this._tabIds = new Map(); | 69 this._tabIds = new Map(); |
| 67 this._files = {}; | 70 this._files = {}; |
| 68 | 71 |
| 69 this._previouslyViewedFilesSetting = setting; | 72 this._previouslyViewedFilesSetting = setting; |
| 70 this._history = WebInspector.TabbedEditorContainer.History.fromObject(this._ previouslyViewedFilesSetting.get()); | 73 this._history = WebInspector.TabbedEditorContainer.History.fromObject(this._ previouslyViewedFilesSetting.get()); |
| 71 } | 74 } |
| 72 | 75 |
| 73 /** @enum {symbol} */ | 76 /** @enum {symbol} */ |
| 74 WebInspector.TabbedEditorContainer.Events = { | 77 WebInspector.TabbedEditorContainer.Events = { |
| 75 EditorSelected: Symbol("EditorSelected"), | 78 EditorSelected: Symbol("EditorSelected"), |
| 76 EditorClosed: Symbol("EditorClosed") | 79 EditorClosed: Symbol("EditorClosed") |
| 77 } | 80 } |
| 78 | 81 |
| 79 WebInspector.TabbedEditorContainer._tabId = 0; | 82 WebInspector.TabbedEditorContainer._tabId = 0; |
| 80 | 83 |
| 81 WebInspector.TabbedEditorContainer.maximalPreviouslyViewedFilesCount = 30; | 84 WebInspector.TabbedEditorContainer.maximalPreviouslyViewedFilesCount = 30; |
| 82 | 85 |
| 83 WebInspector.TabbedEditorContainer.prototype = { | 86 WebInspector.TabbedEditorContainer.prototype = { |
| 87 _onBindingCreated: function(event) | |
|
dgozman
2016/09/22 19:55:54
JSDoc
lushnikov
2016/09/23 21:56:13
Done.
| |
| 88 { | |
| 89 var binding = /** @type {!WebInspector.PersistenceBinding} */(event.data ); | |
| 90 var persistentTab = this._tabIds.get(binding.persistent); | |
| 91 if (!persistentTab) | |
| 92 return; | |
| 93 | |
| 94 this._closeTabs([persistentTab]); | |
| 95 this.addUISourceCode(binding.network); | |
|
dgozman
2016/09/22 19:55:54
Should preserve focus if it was on closed tab.
lushnikov
2016/09/23 21:56:13
Done.
| |
| 96 }, | |
| 97 | |
| 98 _onBindingRemoved: function(event) | |
|
dgozman
2016/09/22 19:55:54
JSDoc
lushnikov
2016/09/23 21:56:13
Done.
| |
| 99 { | |
| 100 var binding = /** @type {!WebInspector.PersistenceBinding} */(event.data ); | |
| 101 var networkTab = this._tabIds.get(binding.network); | |
| 102 if (!networkTab) | |
| 103 return; | |
| 104 this._appendFileTab(binding.persistent, false); | |
| 105 }, | |
| 106 | |
| 84 /** | 107 /** |
| 85 * @return {!WebInspector.Widget} | 108 * @return {!WebInspector.Widget} |
| 86 */ | 109 */ |
| 87 get view() | 110 get view() |
| 88 { | 111 { |
| 89 return this._tabbedPane; | 112 return this._tabbedPane; |
| 90 }, | 113 }, |
| 91 | 114 |
| 92 /** | 115 /** |
| 93 * @type {!WebInspector.Widget} | 116 * @type {!WebInspector.Widget} |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 this._history.updateSelectionRange(this._currentFile.url(), range); | 217 this._history.updateSelectionRange(this._currentFile.url(), range); |
| 195 this._history.save(this._previouslyViewedFilesSetting); | 218 this._history.save(this._previouslyViewedFilesSetting); |
| 196 }, | 219 }, |
| 197 | 220 |
| 198 /** | 221 /** |
| 199 * @param {!WebInspector.UISourceCode} uiSourceCode | 222 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 200 * @param {boolean=} userGesture | 223 * @param {boolean=} userGesture |
| 201 */ | 224 */ |
| 202 _innerShowFile: function(uiSourceCode, userGesture) | 225 _innerShowFile: function(uiSourceCode, userGesture) |
| 203 { | 226 { |
| 227 var binding = WebInspector.persistence.binding(uiSourceCode) | |
|
dgozman
2016/09/22 19:55:54
semicolon
lushnikov
2016/09/23 21:56:13
Done.
| |
| 228 uiSourceCode = binding ? binding.network : uiSourceCode; | |
| 204 if (this._currentFile === uiSourceCode) | 229 if (this._currentFile === uiSourceCode) |
| 205 return; | 230 return; |
| 206 | 231 |
| 207 this._removeViewListeners(); | 232 this._removeViewListeners(); |
| 208 this._currentFile = uiSourceCode; | 233 this._currentFile = uiSourceCode; |
| 209 | 234 |
| 210 var tabId = this._tabIds.get(uiSourceCode) || this._appendFileTab(uiSour ceCode, userGesture); | 235 var tabId = this._tabIds.get(uiSourceCode) || this._appendFileTab(uiSour ceCode, userGesture); |
| 211 | 236 |
| 212 this._tabbedPane.selectTab(tabId, userGesture); | 237 this._tabbedPane.selectTab(tabId, userGesture); |
| 213 if (userGesture) | 238 if (userGesture) |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 227 }, | 252 }, |
| 228 | 253 |
| 229 /** | 254 /** |
| 230 * @param {!WebInspector.UISourceCode} uiSourceCode | 255 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 231 * @return {string} | 256 * @return {string} |
| 232 */ | 257 */ |
| 233 _titleForFile: function(uiSourceCode) | 258 _titleForFile: function(uiSourceCode) |
| 234 { | 259 { |
| 235 var maxDisplayNameLength = 30; | 260 var maxDisplayNameLength = 30; |
| 236 var title = uiSourceCode.displayName(true).trimMiddle(maxDisplayNameLeng th); | 261 var title = uiSourceCode.displayName(true).trimMiddle(maxDisplayNameLeng th); |
| 237 if (uiSourceCode.isDirty() || uiSourceCode.hasUnsavedCommittedChanges()) | 262 if (uiSourceCode.isDirty() || WebInspector.persistence.hasUnsavedCommitt edChanges(uiSourceCode)) |
| 238 title += "*"; | 263 title += "*"; |
| 239 return title; | 264 return title; |
| 240 }, | 265 }, |
| 241 | 266 |
| 242 /** | 267 /** |
| 243 * @param {string} id | 268 * @param {string} id |
| 244 * @param {string} nextTabId | 269 * @param {string} nextTabId |
| 245 */ | 270 */ |
| 246 _maybeCloseTab: function(id, nextTabId) | 271 _maybeCloseTab: function(id, nextTabId) |
| 247 { | 272 { |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 475 | 500 |
| 476 /** | 501 /** |
| 477 * @param {!WebInspector.UISourceCode} uiSourceCode | 502 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 478 */ | 503 */ |
| 479 _updateFileTitle: function(uiSourceCode) | 504 _updateFileTitle: function(uiSourceCode) |
| 480 { | 505 { |
| 481 var tabId = this._tabIds.get(uiSourceCode); | 506 var tabId = this._tabIds.get(uiSourceCode); |
| 482 if (tabId) { | 507 if (tabId) { |
| 483 var title = this._titleForFile(uiSourceCode); | 508 var title = this._titleForFile(uiSourceCode); |
| 484 this._tabbedPane.changeTabTitle(tabId, title); | 509 this._tabbedPane.changeTabTitle(tabId, title); |
| 485 if (uiSourceCode.hasUnsavedCommittedChanges()) | 510 if (WebInspector.persistence.hasUnsavedCommittedChanges(uiSourceCode )) |
| 486 this._tabbedPane.setTabIcon(tabId, "warning-icon", WebInspector. UIString("Changes to this file were not saved to file system.")); | 511 this._tabbedPane.setTabIcon(tabId, "warning-icon", WebInspector. UIString("Changes to this file were not saved to file system.")); |
| 487 else | 512 else |
| 488 this._tabbedPane.setTabIcon(tabId, ""); | 513 this._tabbedPane.setTabIcon(tabId, ""); |
| 489 } | 514 } |
| 490 }, | 515 }, |
| 491 | 516 |
| 492 _uiSourceCodeTitleChanged: function(event) | 517 _uiSourceCodeTitleChanged: function(event) |
| 493 { | 518 { |
| 494 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.targ et); | 519 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.targ et); |
| 495 this._updateFileTitle(uiSourceCode); | 520 this._updateFileTitle(uiSourceCode); |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 748 /** | 773 /** |
| 749 * @override | 774 * @override |
| 750 * @param {string} tabId | 775 * @param {string} tabId |
| 751 * @param {!WebInspector.ContextMenu} contextMenu | 776 * @param {!WebInspector.ContextMenu} contextMenu |
| 752 */ | 777 */ |
| 753 onContextMenu: function(tabId, contextMenu) | 778 onContextMenu: function(tabId, contextMenu) |
| 754 { | 779 { |
| 755 this._editorContainer._onContextMenu(tabId, contextMenu); | 780 this._editorContainer._onContextMenu(tabId, contextMenu); |
| 756 } | 781 } |
| 757 } | 782 } |
| OLD | NEW |