| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 /** | 4 /** |
| 5 * @interface | 5 * @interface |
| 6 */ | 6 */ |
| 7 UI.View = function() {}; | 7 UI.View = function() {}; |
| 8 | 8 |
| 9 UI.View.prototype = { | 9 UI.View.prototype = { |
| 10 /** | 10 /** |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 var resolverExtension = resolverExtensions[0]; | 368 var resolverExtension = resolverExtensions[0]; |
| 369 return resolverExtension.instance().then( | 369 return resolverExtension.instance().then( |
| 370 resolver => /** @type {?UI.ViewManager._Location} */ (resolver.resolveLo
cation(location))); | 370 resolver => /** @type {?UI.ViewManager._Location} */ (resolver.resolveLo
cation(location))); |
| 371 } | 371 } |
| 372 | 372 |
| 373 /** | 373 /** |
| 374 * @param {function()=} revealCallback | 374 * @param {function()=} revealCallback |
| 375 * @param {string=} location | 375 * @param {string=} location |
| 376 * @param {boolean=} restoreSelection | 376 * @param {boolean=} restoreSelection |
| 377 * @param {boolean=} allowReorder | 377 * @param {boolean=} allowReorder |
| 378 * @param {?string=} defaultTab |
| 378 * @return {!UI.TabbedViewLocation} | 379 * @return {!UI.TabbedViewLocation} |
| 379 */ | 380 */ |
| 380 createTabbedLocation(revealCallback, location, restoreSelection, allowReorder)
{ | 381 createTabbedLocation(revealCallback, location, restoreSelection, allowReorder,
defaultTab) { |
| 381 return new UI.ViewManager._TabbedLocation(this, revealCallback, location, re
storeSelection, allowReorder); | 382 return new UI.ViewManager._TabbedLocation( |
| 383 this, revealCallback, location, restoreSelection, allowReorder, defaultT
ab); |
| 382 } | 384 } |
| 383 | 385 |
| 384 /** | 386 /** |
| 385 * @param {function()=} revealCallback | 387 * @param {function()=} revealCallback |
| 386 * @param {string=} location | 388 * @param {string=} location |
| 387 * @return {!UI.ViewLocation} | 389 * @return {!UI.ViewLocation} |
| 388 */ | 390 */ |
| 389 createStackLocation(revealCallback, location) { | 391 createStackLocation(revealCallback, location) { |
| 390 return new UI.ViewManager._StackLocation(this, revealCallback, location); | 392 return new UI.ViewManager._StackLocation(this, revealCallback, location); |
| 391 } | 393 } |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 * @implements {UI.TabbedViewLocation} | 555 * @implements {UI.TabbedViewLocation} |
| 554 * @unrestricted | 556 * @unrestricted |
| 555 */ | 557 */ |
| 556 UI.ViewManager._TabbedLocation = class extends UI.ViewManager._Location { | 558 UI.ViewManager._TabbedLocation = class extends UI.ViewManager._Location { |
| 557 /** | 559 /** |
| 558 * @param {!UI.ViewManager} manager | 560 * @param {!UI.ViewManager} manager |
| 559 * @param {function()=} revealCallback | 561 * @param {function()=} revealCallback |
| 560 * @param {string=} location | 562 * @param {string=} location |
| 561 * @param {boolean=} restoreSelection | 563 * @param {boolean=} restoreSelection |
| 562 * @param {boolean=} allowReorder | 564 * @param {boolean=} allowReorder |
| 565 * @param {?string=} defaultTab |
| 563 */ | 566 */ |
| 564 constructor(manager, revealCallback, location, restoreSelection, allowReorder)
{ | 567 constructor(manager, revealCallback, location, restoreSelection, allowReorder,
defaultTab) { |
| 565 var tabbedPane = new UI.TabbedPane(); | 568 var tabbedPane = new UI.TabbedPane(); |
| 566 if (allowReorder) | 569 if (allowReorder) |
| 567 tabbedPane.setAllowTabReorder(true); | 570 tabbedPane.setAllowTabReorder(true); |
| 568 | 571 |
| 569 super(manager, tabbedPane, revealCallback); | 572 super(manager, tabbedPane, revealCallback); |
| 570 this._tabbedPane = tabbedPane; | 573 this._tabbedPane = tabbedPane; |
| 571 this._allowReorder = allowReorder; | 574 this._allowReorder = allowReorder; |
| 572 | 575 |
| 573 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabSelected, this._ta
bSelected, this); | 576 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabSelected, this._ta
bSelected, this); |
| 574 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabClosed, this._tabC
losed, this); | 577 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabClosed, this._tabC
losed, this); |
| 575 this._closeableTabSetting = Common.settings.createSetting(location + '-close
ableTabs', {}); | 578 this._closeableTabSetting = Common.settings.createSetting(location + '-close
ableTabs', {}); |
| 576 this._tabOrderSetting = Common.settings.createSetting(location + '-tabOrder'
, {}); | 579 this._tabOrderSetting = Common.settings.createSetting(location + '-tabOrder'
, {}); |
| 577 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabOrderChanged, this
._persistTabOrder, this); | 580 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabOrderChanged, this
._persistTabOrder, this); |
| 578 if (restoreSelection) | 581 if (restoreSelection) |
| 579 this._lastSelectedTabSetting = Common.settings.createSetting(location + '-
selectedTab', ''); | 582 this._lastSelectedTabSetting = Common.settings.createSetting(location + '-
selectedTab', ''); |
| 583 this._defaultTab = defaultTab; |
| 580 | 584 |
| 581 /** @type {!Map.<string, !UI.View>} */ | 585 /** @type {!Map.<string, !UI.View>} */ |
| 582 this._views = new Map(); | 586 this._views = new Map(); |
| 583 | 587 |
| 584 if (location) | 588 if (location) |
| 585 this.appendApplicableItems(location); | 589 this.appendApplicableItems(location); |
| 586 } | 590 } |
| 587 | 591 |
| 588 /** | 592 /** |
| 589 * @override | 593 * @override |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 var id = view.viewId(); | 632 var id = view.viewId(); |
| 629 this._views.set(id, view); | 633 this._views.set(id, view); |
| 630 view[UI.ViewManager._Location.symbol] = this; | 634 view[UI.ViewManager._Location.symbol] = this; |
| 631 if (view.isTransient()) | 635 if (view.isTransient()) |
| 632 continue; | 636 continue; |
| 633 if (!view.isCloseable()) | 637 if (!view.isCloseable()) |
| 634 this._appendTab(view); | 638 this._appendTab(view); |
| 635 else if (this._closeableTabSetting.get()[id]) | 639 else if (this._closeableTabSetting.get()[id]) |
| 636 this._appendTab(view); | 640 this._appendTab(view); |
| 637 } | 641 } |
| 638 if (this._lastSelectedTabSetting && this._tabbedPane.hasTab(this._lastSelect
edTabSetting.get())) | 642 if (this._defaultTab && this._tabbedPane.hasTab(this._defaultTab)) |
| 643 this._tabbedPane.selectTab(this._defaultTab); |
| 644 else if (this._lastSelectedTabSetting && this._tabbedPane.hasTab(this._lastS
electedTabSetting.get())) |
| 639 this._tabbedPane.selectTab(this._lastSelectedTabSetting.get()); | 645 this._tabbedPane.selectTab(this._lastSelectedTabSetting.get()); |
| 640 } | 646 } |
| 641 | 647 |
| 642 /** | 648 /** |
| 643 * @param {!UI.ContextMenu} contextMenu | 649 * @param {!UI.ContextMenu} contextMenu |
| 644 */ | 650 */ |
| 645 _appendTabsToMenu(contextMenu) { | 651 _appendTabsToMenu(contextMenu) { |
| 646 for (var view of this._views.values()) { | 652 for (var view of this._views.values()) { |
| 647 var title = Common.UIString(view.title()); | 653 var title = Common.UIString(view.title()); |
| 648 contextMenu.appendItem(title, this.showView.bind(this, view)); | 654 contextMenu.appendItem(title, this.showView.bind(this, view)); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 appendApplicableItems(locationName) { | 860 appendApplicableItems(locationName) { |
| 855 for (var view of this._manager._viewsForLocation(locationName)) | 861 for (var view of this._manager._viewsForLocation(locationName)) |
| 856 this.appendView(view); | 862 this.appendView(view); |
| 857 } | 863 } |
| 858 }; | 864 }; |
| 859 | 865 |
| 860 /** | 866 /** |
| 861 * @type {!UI.ViewManager} | 867 * @type {!UI.ViewManager} |
| 862 */ | 868 */ |
| 863 UI.viewManager; | 869 UI.viewManager; |
| OLD | NEW |