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

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

Issue 2533483002: [DevTools] Typed events and event listeners. (Closed)
Patch Set: 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 this._tabbedPane = new UI.TabbedPane(); 54 this._tabbedPane = new UI.TabbedPane();
55 this._tabbedPane.setPlaceholderText(placeholderText); 55 this._tabbedPane.setPlaceholderText(placeholderText);
56 this._tabbedPane.setTabDelegate(new Sources.EditorContainerTabDelegate(this) ); 56 this._tabbedPane.setTabDelegate(new Sources.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 60
61 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabClosed, this._tabC losed, this); 61 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabClosed, this._tabC losed, this);
62 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabSelected, this._ta bSelected, this); 62 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabSelected, this._ta bSelected, this);
63 63
64 Persistence.persistence.addEventListener( 64 Persistence.persistence.addEventListener(Persistence.Persistence.BindingChan gedEvent, this._onBindingChanged, this);
65 Persistence.Persistence.Events.BindingCreated, this._onBindingCreated, t his);
66 Persistence.persistence.addEventListener(
67 Persistence.Persistence.Events.BindingRemoved, this._onBindingRemoved, t his);
68 65
69 this._tabIds = new Map(); 66 this._tabIds = new Map();
70 this._files = {}; 67 this._files = {};
71 68
72 this._previouslyViewedFilesSetting = setting; 69 this._previouslyViewedFilesSetting = setting;
73 this._history = Sources.TabbedEditorContainer.History.fromObject(this._previ ouslyViewedFilesSetting.get()); 70 this._history = Sources.TabbedEditorContainer.History.fromObject(this._previ ouslyViewedFilesSetting.get());
74 } 71 }
75 72
76 /** 73 /**
77 * @param {!Common.Event} event 74 * @param {!Persistence.Persistence.BindingChangedEvent} event
78 */ 75 */
79 _onBindingCreated(event) { 76 _onBindingChanged(event) {
80 var binding = /** @type {!Persistence.PersistenceBinding} */ (event.data); 77 if (event.created)
78 this._onBindingCreated(event.binding);
79 else
80 this._onBindingRemoved(event.binding);
81 }
82
83 /**
84 * @param {!Persistence.PersistenceBinding} binding
85 */
86 _onBindingCreated(binding) {
81 this._updateFileTitle(binding.network); 87 this._updateFileTitle(binding.network);
82 88
83 var networkTabId = this._tabIds.get(binding.network); 89 var networkTabId = this._tabIds.get(binding.network);
84 var fileSystemTabId = this._tabIds.get(binding.fileSystem); 90 var fileSystemTabId = this._tabIds.get(binding.fileSystem);
85 if (!fileSystemTabId) 91 if (!fileSystemTabId)
86 return; 92 return;
87 93
88 var wasSelectedInFileSystem = this._currentFile === binding.fileSystem; 94 var wasSelectedInFileSystem = this._currentFile === binding.fileSystem;
89 var currentSelectionRange = this._history.selectionRange(binding.fileSystem. url()); 95 var currentSelectionRange = this._history.selectionRange(binding.fileSystem. url());
90 var currentScrollLineNumber = this._history.scrollLineNumber(binding.fileSys tem.url()); 96 var currentScrollLineNumber = this._history.scrollLineNumber(binding.fileSys tem.url());
91 97
92 var tabIndex = this._tabbedPane.tabIndex(fileSystemTabId); 98 var tabIndex = this._tabbedPane.tabIndex(fileSystemTabId);
93 var tabsToClose = [fileSystemTabId]; 99 var tabsToClose = [fileSystemTabId];
94 if (networkTabId) 100 if (networkTabId)
95 tabsToClose.push(networkTabId); 101 tabsToClose.push(networkTabId);
96 this._closeTabs(tabsToClose, true); 102 this._closeTabs(tabsToClose, true);
97 networkTabId = this._appendFileTab(binding.network, false, tabIndex); 103 networkTabId = this._appendFileTab(binding.network, false, tabIndex);
98 this._updateHistory(); 104 this._updateHistory();
99 105
100 if (wasSelectedInFileSystem) 106 if (wasSelectedInFileSystem)
101 this._tabbedPane.selectTab(networkTabId, false); 107 this._tabbedPane.selectTab(networkTabId, false);
102 108
103 var networkTabView = /** @type {!UI.Widget} */ (this._tabbedPane.tabView(net workTabId)); 109 var networkTabView = /** @type {!UI.Widget} */ (this._tabbedPane.tabView(net workTabId));
104 this._restoreEditorProperties(networkTabView, currentSelectionRange, current ScrollLineNumber); 110 this._restoreEditorProperties(networkTabView, currentSelectionRange, current ScrollLineNumber);
105 } 111 }
106 112
107 /** 113 /**
108 * @param {!Common.Event} event 114 * @param {!Persistence.PersistenceBinding} binding
109 */ 115 */
110 _onBindingRemoved(event) { 116 _onBindingRemoved(binding) {
111 var binding = /** @type {!Persistence.PersistenceBinding} */ (event.data);
112 this._updateFileTitle(binding.network); 117 this._updateFileTitle(binding.network);
113 118
114 var networkTabId = this._tabIds.get(binding.network); 119 var networkTabId = this._tabIds.get(binding.network);
115 if (!networkTabId) 120 if (!networkTabId)
116 return; 121 return;
117 122
118 var tabIndex = this._tabbedPane.tabIndex(networkTabId); 123 var tabIndex = this._tabbedPane.tabIndex(networkTabId);
119 var wasSelected = this._currentFile === binding.network; 124 var wasSelected = this._currentFile === binding.network;
120 var fileSystemTabId = this._appendFileTab(binding.fileSystem, false, tabInde x); 125 var fileSystemTabId = this._appendFileTab(binding.fileSystem, false, tabInde x);
121 this._updateHistory(); 126 this._updateHistory();
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 825
821 /** 826 /**
822 * @override 827 * @override
823 * @param {string} tabId 828 * @param {string} tabId
824 * @param {!UI.ContextMenu} contextMenu 829 * @param {!UI.ContextMenu} contextMenu
825 */ 830 */
826 onContextMenu(tabId, contextMenu) { 831 onContextMenu(tabId, contextMenu) {
827 this._editorContainer._onContextMenu(tabId, contextMenu); 832 this._editorContainer._onContextMenu(tabId, contextMenu);
828 } 833 }
829 }; 834 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698