Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sources/TabbedEditorContainer.js

Issue 2551233002: DevTools: show filesystem file by default (Closed)
Patch Set: nit Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 71
72 this._previouslyViewedFilesSetting = setting; 72 this._previouslyViewedFilesSetting = setting;
73 this._history = Sources.TabbedEditorContainer.History.fromObject(this._previ ouslyViewedFilesSetting.get()); 73 this._history = Sources.TabbedEditorContainer.History.fromObject(this._previ ouslyViewedFilesSetting.get());
74 } 74 }
75 75
76 /** 76 /**
77 * @param {!Common.Event} event 77 * @param {!Common.Event} event
78 */ 78 */
79 _onBindingCreated(event) { 79 _onBindingCreated(event) {
80 var binding = /** @type {!Persistence.PersistenceBinding} */ (event.data); 80 var binding = /** @type {!Persistence.PersistenceBinding} */ (event.data);
81 this._updateFileTitle(binding.network); 81 this._updateFileTitle(binding.fileSystem);
82 82
83 var networkTabId = this._tabIds.get(binding.network); 83 var networkTabId = this._tabIds.get(binding.network);
84 var fileSystemTabId = this._tabIds.get(binding.fileSystem); 84 var fileSystemTabId = this._tabIds.get(binding.fileSystem);
85 if (!fileSystemTabId) 85
86 var wasSelectedInNetwork = this._currentFile === binding.network;
87 var currentSelectionRange = this._history.selectionRange(binding.network.url ());
88 var currentScrollLineNumber = this._history.scrollLineNumber(binding.network .url());
89 this._history.remove(binding.network.url());
90
91 if (!networkTabId)
86 return; 92 return;
87 93
88 var wasSelectedInFileSystem = this._currentFile === binding.fileSystem; 94 var tabIndex = this._tabbedPane.tabIndex(networkTabId);
89 var currentSelectionRange = this._history.selectionRange(binding.fileSystem. url()); 95 var tabsToClose = [networkTabId];
90 var currentScrollLineNumber = this._history.scrollLineNumber(binding.fileSys tem.url()); 96 if (fileSystemTabId)
91 97 tabsToClose.push(fileSystemTabId);
92 var tabIndex = this._tabbedPane.tabIndex(fileSystemTabId);
93 var tabsToClose = [fileSystemTabId];
94 if (networkTabId)
95 tabsToClose.push(networkTabId);
96 this._closeTabs(tabsToClose, true); 98 this._closeTabs(tabsToClose, true);
97 networkTabId = this._appendFileTab(binding.network, false, tabIndex); 99 fileSystemTabId = this._appendFileTab(binding.fileSystem, false, tabIndex);
98 this._updateHistory(); 100 this._updateHistory();
99 101
100 if (wasSelectedInFileSystem) 102 if (wasSelectedInNetwork)
101 this._tabbedPane.selectTab(networkTabId, false); 103 this._tabbedPane.selectTab(fileSystemTabId, false);
102 104
103 var networkTabView = /** @type {!UI.Widget} */ (this._tabbedPane.tabView(net workTabId)); 105 var fileSystemTabView = /** @type {!UI.Widget} */ (this._tabbedPane.tabView( fileSystemTabId));
104 this._restoreEditorProperties(networkTabView, currentSelectionRange, current ScrollLineNumber); 106 this._restoreEditorProperties(fileSystemTabView, currentSelectionRange, curr entScrollLineNumber);
105 } 107 }
106 108
107 /** 109 /**
108 * @param {!Common.Event} event 110 * @param {!Common.Event} event
109 */ 111 */
110 _onBindingRemoved(event) { 112 _onBindingRemoved(event) {
111 var binding = /** @type {!Persistence.PersistenceBinding} */ (event.data); 113 var binding = /** @type {!Persistence.PersistenceBinding} */ (event.data);
112 this._updateFileTitle(binding.network); 114 this._updateFileTitle(binding.fileSystem);
113
114 var networkTabId = this._tabIds.get(binding.network);
115 if (!networkTabId)
116 return;
117
118 var tabIndex = this._tabbedPane.tabIndex(networkTabId);
119 var wasSelected = this._currentFile === binding.network;
120 var fileSystemTabId = this._appendFileTab(binding.fileSystem, false, tabInde x);
121 this._updateHistory();
122
123 if (wasSelected)
124 this._tabbedPane.selectTab(fileSystemTabId, false);
125
126 var fileSystemTabView = /** @type {!UI.Widget} */ (this._tabbedPane.tabView( fileSystemTabId));
127 var savedSelectionRange = this._history.selectionRange(binding.network.url() );
128 var savedScrollLineNumber = this._history.scrollLineNumber(binding.network.u rl());
129 this._restoreEditorProperties(fileSystemTabView, savedSelectionRange, savedS crollLineNumber);
130 } 115 }
131 116
132 /** 117 /**
133 * @return {!UI.Widget} 118 * @return {!UI.Widget}
134 */ 119 */
135 get view() { 120 get view() {
136 return this._tabbedPane; 121 return this._tabbedPane;
137 } 122 }
138 123
139 /** 124 /**
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 this._history.updateSelectionRange(this._currentFile.url(), range); 242 this._history.updateSelectionRange(this._currentFile.url(), range);
258 this._history.save(this._previouslyViewedFilesSetting); 243 this._history.save(this._previouslyViewedFilesSetting);
259 } 244 }
260 245
261 /** 246 /**
262 * @param {!Workspace.UISourceCode} uiSourceCode 247 * @param {!Workspace.UISourceCode} uiSourceCode
263 * @param {boolean=} userGesture 248 * @param {boolean=} userGesture
264 */ 249 */
265 _innerShowFile(uiSourceCode, userGesture) { 250 _innerShowFile(uiSourceCode, userGesture) {
266 var binding = Persistence.persistence.binding(uiSourceCode); 251 var binding = Persistence.persistence.binding(uiSourceCode);
267 uiSourceCode = binding ? binding.network : uiSourceCode; 252 uiSourceCode = binding ? binding.fileSystem : uiSourceCode;
268 if (this._currentFile === uiSourceCode) 253 if (this._currentFile === uiSourceCode)
269 return; 254 return;
270 255
271 this._removeViewListeners(); 256 this._removeViewListeners();
272 this._currentFile = uiSourceCode; 257 this._currentFile = uiSourceCode;
273 258
274 var tabId = this._tabIds.get(uiSourceCode) || this._appendFileTab(uiSourceCo de, userGesture); 259 var tabId = this._tabIds.get(uiSourceCode) || this._appendFileTab(uiSourceCo de, userGesture);
275 260
276 this._tabbedPane.selectTab(tabId, userGesture); 261 this._tabbedPane.selectTab(tabId, userGesture);
277 if (userGesture) 262 if (userGesture)
(...skipping 10 matching lines...) Expand all
288 userGesture: userGesture 273 userGesture: userGesture
289 }; 274 };
290 this.dispatchEventToListeners(Sources.TabbedEditorContainer.Events.EditorSel ected, eventData); 275 this.dispatchEventToListeners(Sources.TabbedEditorContainer.Events.EditorSel ected, eventData);
291 } 276 }
292 277
293 /** 278 /**
294 * @param {!Workspace.UISourceCode} uiSourceCode 279 * @param {!Workspace.UISourceCode} uiSourceCode
295 * @return {string} 280 * @return {string}
296 */ 281 */
297 _titleForFile(uiSourceCode) { 282 _titleForFile(uiSourceCode) {
298 var binding = Persistence.persistence.binding(uiSourceCode);
299 var titleUISourceCode = binding ? binding.fileSystem : uiSourceCode;
300 var maxDisplayNameLength = 30; 283 var maxDisplayNameLength = 30;
301 var title = titleUISourceCode.displayName(true).trimMiddle(maxDisplayNameLen gth); 284 var title = uiSourceCode.displayName(true).trimMiddle(maxDisplayNameLength);
302 if (uiSourceCode.isDirty() || Persistence.persistence.hasUnsavedCommittedCha nges(uiSourceCode)) 285 if (uiSourceCode.isDirty() || Persistence.persistence.hasUnsavedCommittedCha nges(uiSourceCode))
303 title += '*'; 286 title += '*';
304 return title; 287 return title;
305 } 288 }
306 289
307 /** 290 /**
308 * @param {string} id 291 * @param {string} id
309 * @param {string} nextTabId 292 * @param {string} nextTabId
310 */ 293 */
311 _maybeCloseTab(id, nextTabId) { 294 _maybeCloseTab(id, nextTabId) {
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 803
821 /** 804 /**
822 * @override 805 * @override
823 * @param {string} tabId 806 * @param {string} tabId
824 * @param {!UI.ContextMenu} contextMenu 807 * @param {!UI.ContextMenu} contextMenu
825 */ 808 */
826 onContextMenu(tabId, contextMenu) { 809 onContextMenu(tabId, contextMenu) {
827 this._editorContainer._onContextMenu(tabId, contextMenu); 810 this._editorContainer._onContextMenu(tabId, contextMenu);
828 } 811 }
829 }; 812 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698