OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 /** | 68 /** |
69 * @param {boolean} locked | 69 * @param {boolean} locked |
70 */ | 70 */ |
71 setCurrentTabLocked: function(locked) | 71 setCurrentTabLocked: function(locked) |
72 { | 72 { |
73 this._currentTabLocked = locked; | 73 this._currentTabLocked = locked; |
74 this._headerElement.classList.toggle("locked", this._currentTabLocked); | 74 this._headerElement.classList.toggle("locked", this._currentTabLocked); |
75 }, | 75 }, |
76 | 76 |
77 /** | 77 /** |
78 * @return {?WebInspector.View} | 78 * @return {?WebInspector.Widget} |
79 */ | 79 */ |
80 get visibleView() | 80 get visibleView() |
81 { | 81 { |
82 return this._currentTab ? this._currentTab.view : null; | 82 return this._currentTab ? this._currentTab.view : null; |
83 }, | 83 }, |
84 | 84 |
85 /** | 85 /** |
86 * @return {!Array.<!WebInspector.View>} | 86 * @return {!Array.<!WebInspector.Widget>} |
87 */ | 87 */ |
88 tabViews: function() | 88 tabViews: function() |
89 { | 89 { |
90 /** | 90 /** |
91 * @param {!WebInspector.TabbedPaneTab} tab | 91 * @param {!WebInspector.TabbedPaneTab} tab |
92 * @return {!WebInspector.View} | 92 * @return {!WebInspector.Widget} |
93 */ | 93 */ |
94 function tabToView(tab) | 94 function tabToView(tab) |
95 { | 95 { |
96 return tab.view; | 96 return tab.view; |
97 } | 97 } |
98 return this._tabs.map(tabToView); | 98 return this._tabs.map(tabToView); |
99 }, | 99 }, |
100 | 100 |
101 /** | 101 /** |
102 * @return {?string} | 102 * @return {?string} |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 { | 184 { |
185 var tabs = this._tabs.slice(); | 185 var tabs = this._tabs.slice(); |
186 for (var i = 0; i < tabs.length; ++i) | 186 for (var i = 0; i < tabs.length; ++i) |
187 tabs[i].setDelegate(delegate); | 187 tabs[i].setDelegate(delegate); |
188 this._delegate = delegate; | 188 this._delegate = delegate; |
189 }, | 189 }, |
190 | 190 |
191 /** | 191 /** |
192 * @param {string} id | 192 * @param {string} id |
193 * @param {string} tabTitle | 193 * @param {string} tabTitle |
194 * @param {!WebInspector.View} view | 194 * @param {!WebInspector.Widget} view |
195 * @param {string=} tabTooltip | 195 * @param {string=} tabTooltip |
196 * @param {boolean=} userGesture | 196 * @param {boolean=} userGesture |
197 * @param {boolean=} isCloseable | 197 * @param {boolean=} isCloseable |
198 */ | 198 */ |
199 appendTab: function(id, tabTitle, view, tabTooltip, userGesture, isCloseable
) | 199 appendTab: function(id, tabTitle, view, tabTooltip, userGesture, isCloseable
) |
200 { | 200 { |
201 isCloseable = typeof isCloseable === "boolean" ? isCloseable : this._clo
seableTabs; | 201 isCloseable = typeof isCloseable === "boolean" ? isCloseable : this._clo
seableTabs; |
202 var tab = new WebInspector.TabbedPaneTab(this, id, tabTitle, isCloseable
, view, tabTooltip); | 202 var tab = new WebInspector.TabbedPaneTab(this, id, tabTitle, isCloseable
, view, tabTooltip); |
203 tab.setDelegate(this._delegate); | 203 tab.setDelegate(this._delegate); |
204 this._tabsById[id] = tab; | 204 this._tabsById[id] = tab; |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 { | 415 { |
416 var tab = this._tabsById[id]; | 416 var tab = this._tabsById[id]; |
417 if (tab.title === tabTitle) | 417 if (tab.title === tabTitle) |
418 return; | 418 return; |
419 tab.title = tabTitle; | 419 tab.title = tabTitle; |
420 this._updateTabElements(); | 420 this._updateTabElements(); |
421 }, | 421 }, |
422 | 422 |
423 /** | 423 /** |
424 * @param {string} id | 424 * @param {string} id |
425 * @param {!WebInspector.View} view | 425 * @param {!WebInspector.Widget} view |
426 */ | 426 */ |
427 changeTabView: function(id, view) | 427 changeTabView: function(id, view) |
428 { | 428 { |
429 var tab = this._tabsById[id]; | 429 var tab = this._tabsById[id]; |
430 if (this._currentTab && this._currentTab.id === tab.id) { | 430 if (this._currentTab && this._currentTab.id === tab.id) { |
431 if (tab.view !== view) | 431 if (tab.view !== view) |
432 this._hideTab(tab); | 432 this._hideTab(tab); |
433 tab.view = view; | 433 tab.view = view; |
434 this._showTab(tab); | 434 this._showTab(tab); |
435 } else | 435 } else |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 | 806 |
807 __proto__: WebInspector.VBox.prototype | 807 __proto__: WebInspector.VBox.prototype |
808 } | 808 } |
809 | 809 |
810 /** | 810 /** |
811 * @constructor | 811 * @constructor |
812 * @param {!WebInspector.TabbedPane} tabbedPane | 812 * @param {!WebInspector.TabbedPane} tabbedPane |
813 * @param {string} id | 813 * @param {string} id |
814 * @param {string} title | 814 * @param {string} title |
815 * @param {boolean} closeable | 815 * @param {boolean} closeable |
816 * @param {!WebInspector.View} view | 816 * @param {!WebInspector.Widget} view |
817 * @param {string=} tooltip | 817 * @param {string=} tooltip |
818 */ | 818 */ |
819 WebInspector.TabbedPaneTab = function(tabbedPane, id, title, closeable, view, to
oltip) | 819 WebInspector.TabbedPaneTab = function(tabbedPane, id, title, closeable, view, to
oltip) |
820 { | 820 { |
821 this._closeable = closeable; | 821 this._closeable = closeable; |
822 this._tabbedPane = tabbedPane; | 822 this._tabbedPane = tabbedPane; |
823 this._id = id; | 823 this._id = id; |
824 this._title = title; | 824 this._title = title; |
825 this._tooltip = tooltip; | 825 this._tooltip = tooltip; |
826 this._view = view; | 826 this._view = view; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 var element = this.tabElement; | 893 var element = this.tabElement; |
894 var hasClass = element.classList.contains(className); | 894 var hasClass = element.classList.contains(className); |
895 if (hasClass === force) | 895 if (hasClass === force) |
896 return false; | 896 return false; |
897 element.classList.toggle(className, force); | 897 element.classList.toggle(className, force); |
898 delete this._measuredWidth; | 898 delete this._measuredWidth; |
899 return true; | 899 return true; |
900 }, | 900 }, |
901 | 901 |
902 /** | 902 /** |
903 * @return {!WebInspector.View} | 903 * @return {!WebInspector.Widget} |
904 */ | 904 */ |
905 get view() | 905 get view() |
906 { | 906 { |
907 return this._view; | 907 return this._view; |
908 }, | 908 }, |
909 | 909 |
910 set view(view) | 910 set view(view) |
911 { | 911 { |
912 this._view = view; | 912 this._view = view; |
913 }, | 913 }, |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1178 * @param {!WebInspector.TabbedPane} tabbedPane | 1178 * @param {!WebInspector.TabbedPane} tabbedPane |
1179 * @param {!Array.<string>} ids | 1179 * @param {!Array.<string>} ids |
1180 */ | 1180 */ |
1181 closeTabs: function(tabbedPane, ids) { } | 1181 closeTabs: function(tabbedPane, ids) { } |
1182 } | 1182 } |
1183 | 1183 |
1184 /** | 1184 /** |
1185 * @constructor | 1185 * @constructor |
1186 * @param {!WebInspector.TabbedPane} tabbedPane | 1186 * @param {!WebInspector.TabbedPane} tabbedPane |
1187 * @param {string} extensionPoint | 1187 * @param {string} extensionPoint |
1188 * @param {function(string, !WebInspector.View)=} viewCallback | 1188 * @param {function(string, !WebInspector.Widget)=} viewCallback |
1189 */ | 1189 */ |
1190 WebInspector.ExtensibleTabbedPaneController = function(tabbedPane, extensionPoin
t, viewCallback) | 1190 WebInspector.ExtensibleTabbedPaneController = function(tabbedPane, extensionPoin
t, viewCallback) |
1191 { | 1191 { |
1192 this._tabbedPane = tabbedPane; | 1192 this._tabbedPane = tabbedPane; |
1193 this._extensionPoint = extensionPoint; | 1193 this._extensionPoint = extensionPoint; |
1194 this._viewCallback = viewCallback; | 1194 this._viewCallback = viewCallback; |
1195 this._tabOrders = {}; | 1195 this._tabOrders = {}; |
1196 /** @type {!Object.<string, !Promise.<?WebInspector.View>>} */ | 1196 /** @type {!Object.<string, !Promise.<?WebInspector.Widget>>} */ |
1197 this._promiseForId = {}; | 1197 this._promiseForId = {}; |
1198 | 1198 |
1199 this._tabbedPane.setRetainTabOrder(true, this._tabOrderComparator.bind(this)
); | 1199 this._tabbedPane.setRetainTabOrder(true, this._tabOrderComparator.bind(this)
); |
1200 this._tabbedPane.addEventListener(WebInspector.TabbedPane.EventTypes.TabSele
cted, this._tabSelected, this); | 1200 this._tabbedPane.addEventListener(WebInspector.TabbedPane.EventTypes.TabSele
cted, this._tabSelected, this); |
1201 /** @type {!Map.<string, ?WebInspector.View>} */ | 1201 /** @type {!Map.<string, ?WebInspector.Widget>} */ |
1202 this._views = new Map(); | 1202 this._views = new Map(); |
1203 this._initialize(); | 1203 this._initialize(); |
1204 } | 1204 } |
1205 | 1205 |
1206 WebInspector.ExtensibleTabbedPaneController.prototype = { | 1206 WebInspector.ExtensibleTabbedPaneController.prototype = { |
1207 _initialize: function() | 1207 _initialize: function() |
1208 { | 1208 { |
1209 /** @type {!Map.<string, !Runtime.Extension>} */ | 1209 /** @type {!Map.<string, !Runtime.Extension>} */ |
1210 this._extensions = new Map(); | 1210 this._extensions = new Map(); |
1211 var extensions = self.runtime.extensions(this._extensionPoint); | 1211 var extensions = self.runtime.extensions(this._extensionPoint); |
1212 | 1212 |
1213 for (var i = 0; i < extensions.length; ++i) { | 1213 for (var i = 0; i < extensions.length; ++i) { |
1214 var descriptor = extensions[i].descriptor(); | 1214 var descriptor = extensions[i].descriptor(); |
1215 var id = descriptor["name"]; | 1215 var id = descriptor["name"]; |
1216 this._tabOrders[id] = i; | 1216 this._tabOrders[id] = i; |
1217 var title = WebInspector.UIString(descriptor["title"]); | 1217 var title = WebInspector.UIString(descriptor["title"]); |
1218 | 1218 |
1219 this._extensions.set(id, extensions[i]); | 1219 this._extensions.set(id, extensions[i]); |
1220 this._tabbedPane.appendTab(id, title, new WebInspector.View()); | 1220 this._tabbedPane.appendTab(id, title, new WebInspector.Widget()); |
1221 } | 1221 } |
1222 }, | 1222 }, |
1223 | 1223 |
1224 /** | 1224 /** |
1225 * @param {string} id | 1225 * @param {string} id |
1226 * @param {string} title | 1226 * @param {string} title |
1227 * @param {number} order | 1227 * @param {number} order |
1228 * @param {!WebInspector.View} view | 1228 * @param {!WebInspector.Widget} view |
1229 */ | 1229 */ |
1230 appendView: function(id, title, order, view) | 1230 appendView: function(id, title, order, view) |
1231 { | 1231 { |
1232 this._tabOrders[id] = order; | 1232 this._tabOrders[id] = order; |
1233 this._views.set(id, view); | 1233 this._views.set(id, view); |
1234 this._tabbedPane.appendTab(id, title, new WebInspector.View()); | 1234 this._tabbedPane.appendTab(id, title, new WebInspector.Widget()); |
1235 }, | 1235 }, |
1236 | 1236 |
1237 /** | 1237 /** |
1238 * @param {!WebInspector.Event} event | 1238 * @param {!WebInspector.Event} event |
1239 */ | 1239 */ |
1240 _tabSelected: function(event) | 1240 _tabSelected: function(event) |
1241 { | 1241 { |
1242 var tabId = /** @type {string} */ (event.data.tabId); | 1242 var tabId = /** @type {string} */ (event.data.tabId); |
1243 this.viewForId(tabId).then(viewLoaded.bind(this)); | 1243 this.viewForId(tabId).then(viewLoaded.bind(this)); |
1244 | 1244 |
1245 /** | 1245 /** |
1246 * @this {WebInspector.ExtensibleTabbedPaneController} | 1246 * @this {WebInspector.ExtensibleTabbedPaneController} |
1247 * @param {?WebInspector.View} view | 1247 * @param {?WebInspector.Widget} view |
1248 */ | 1248 */ |
1249 function viewLoaded(view) | 1249 function viewLoaded(view) |
1250 { | 1250 { |
1251 if (!view) | 1251 if (!view) |
1252 return; | 1252 return; |
1253 this._tabbedPane.changeTabView(tabId, view); | 1253 this._tabbedPane.changeTabView(tabId, view); |
1254 var shouldFocus = this._tabbedPane.visibleView.element.isSelfOrAnces
tor(WebInspector.currentFocusElement()); | 1254 var shouldFocus = this._tabbedPane.visibleView.element.isSelfOrAnces
tor(WebInspector.currentFocusElement()); |
1255 if (shouldFocus) | 1255 if (shouldFocus) |
1256 view.focus(); | 1256 view.focus(); |
1257 } | 1257 } |
1258 }, | 1258 }, |
1259 | 1259 |
1260 /** | 1260 /** |
1261 * @return {!Array.<string>} | 1261 * @return {!Array.<string>} |
1262 */ | 1262 */ |
1263 viewIds: function() | 1263 viewIds: function() |
1264 { | 1264 { |
1265 return this._extensions.keysArray(); | 1265 return this._extensions.keysArray(); |
1266 }, | 1266 }, |
1267 | 1267 |
1268 /** | 1268 /** |
1269 * @param {string} id | 1269 * @param {string} id |
1270 * @return {!Promise.<?WebInspector.View>} | 1270 * @return {!Promise.<?WebInspector.Widget>} |
1271 */ | 1271 */ |
1272 viewForId: function(id) | 1272 viewForId: function(id) |
1273 { | 1273 { |
1274 if (this._views.has(id)) | 1274 if (this._views.has(id)) |
1275 return Promise.resolve(/** @type {?WebInspector.View} */ (this._view
s.get(id))); | 1275 return Promise.resolve(/** @type {?WebInspector.Widget} */ (this._vi
ews.get(id))); |
1276 if (!this._extensions.has(id)) | 1276 if (!this._extensions.has(id)) |
1277 return Promise.resolve(/** @type {?WebInspector.View} */ (null)); | 1277 return Promise.resolve(/** @type {?WebInspector.Widget} */ (null)); |
1278 if (this._promiseForId[id]) | 1278 if (this._promiseForId[id]) |
1279 return this._promiseForId[id]; | 1279 return this._promiseForId[id]; |
1280 | 1280 |
1281 var promise = this._extensions.get(id).instancePromise(); | 1281 var promise = this._extensions.get(id).instancePromise(); |
1282 this._promiseForId[id] = /** @type {!Promise.<?WebInspector.View>} */ (p
romise); | 1282 this._promiseForId[id] = /** @type {!Promise.<?WebInspector.Widget>} */
(promise); |
1283 return promise.then(cacheView.bind(this)); | 1283 return promise.then(cacheView.bind(this)); |
1284 | 1284 |
1285 /** | 1285 /** |
1286 * @param {!Object} object | 1286 * @param {!Object} object |
1287 * @this {WebInspector.ExtensibleTabbedPaneController} | 1287 * @this {WebInspector.ExtensibleTabbedPaneController} |
1288 */ | 1288 */ |
1289 function cacheView(object) | 1289 function cacheView(object) |
1290 { | 1290 { |
1291 var view = /** @type {!WebInspector.View} */ (object); | 1291 var view = /** @type {!WebInspector.Widget} */ (object); |
1292 delete this._promiseForId[id]; | 1292 delete this._promiseForId[id]; |
1293 this._views.set(id, view); | 1293 this._views.set(id, view); |
1294 if (this._viewCallback && view) | 1294 if (this._viewCallback && view) |
1295 this._viewCallback(id, view); | 1295 this._viewCallback(id, view); |
1296 return view; | 1296 return view; |
1297 } | 1297 } |
1298 }, | 1298 }, |
1299 | 1299 |
1300 /** | 1300 /** |
1301 * @param {string} id1 | 1301 * @param {string} id1 |
1302 * @param {string} id2 | 1302 * @param {string} id2 |
1303 * @return {number} | 1303 * @return {number} |
1304 */ | 1304 */ |
1305 _tabOrderComparator: function(id1, id2) | 1305 _tabOrderComparator: function(id1, id2) |
1306 { | 1306 { |
1307 return this._tabOrders[id2] = this._tabOrders[id1]; | 1307 return this._tabOrders[id2] = this._tabOrders[id1]; |
1308 } | 1308 } |
1309 } | 1309 } |
OLD | NEW |