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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 var resolverExtension = resolverExtensions[0]; | 373 var resolverExtension = resolverExtensions[0]; |
374 return resolverExtension.instance().then( | 374 return resolverExtension.instance().then( |
375 resolver => /** @type {?UI.ViewManager._Location} */ (resolver.resolveLo
cation(location))); | 375 resolver => /** @type {?UI.ViewManager._Location} */ (resolver.resolveLo
cation(location))); |
376 } | 376 } |
377 | 377 |
378 /** | 378 /** |
379 * @param {function()=} revealCallback | 379 * @param {function()=} revealCallback |
380 * @param {string=} location | 380 * @param {string=} location |
381 * @param {boolean=} restoreSelection | 381 * @param {boolean=} restoreSelection |
382 * @param {boolean=} allowReorder | 382 * @param {boolean=} allowReorder |
| 383 * @param {?string=} defaultTab |
383 * @return {!UI.TabbedViewLocation} | 384 * @return {!UI.TabbedViewLocation} |
384 */ | 385 */ |
385 createTabbedLocation(revealCallback, location, restoreSelection, allowReorder)
{ | 386 createTabbedLocation(revealCallback, location, restoreSelection, allowReorder,
defaultTab) { |
386 return new UI.ViewManager._TabbedLocation(this, revealCallback, location, re
storeSelection, allowReorder); | 387 return new UI.ViewManager._TabbedLocation( |
| 388 this, revealCallback, location, restoreSelection, allowReorder, defaultT
ab); |
387 } | 389 } |
388 | 390 |
389 /** | 391 /** |
390 * @param {function()=} revealCallback | 392 * @param {function()=} revealCallback |
391 * @param {string=} location | 393 * @param {string=} location |
392 * @return {!UI.ViewLocation} | 394 * @return {!UI.ViewLocation} |
393 */ | 395 */ |
394 createStackLocation(revealCallback, location) { | 396 createStackLocation(revealCallback, location) { |
395 return new UI.ViewManager._StackLocation(this, revealCallback, location); | 397 return new UI.ViewManager._StackLocation(this, revealCallback, location); |
396 } | 398 } |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 * @implements {UI.TabbedViewLocation} | 560 * @implements {UI.TabbedViewLocation} |
559 * @unrestricted | 561 * @unrestricted |
560 */ | 562 */ |
561 UI.ViewManager._TabbedLocation = class extends UI.ViewManager._Location { | 563 UI.ViewManager._TabbedLocation = class extends UI.ViewManager._Location { |
562 /** | 564 /** |
563 * @param {!UI.ViewManager} manager | 565 * @param {!UI.ViewManager} manager |
564 * @param {function()=} revealCallback | 566 * @param {function()=} revealCallback |
565 * @param {string=} location | 567 * @param {string=} location |
566 * @param {boolean=} restoreSelection | 568 * @param {boolean=} restoreSelection |
567 * @param {boolean=} allowReorder | 569 * @param {boolean=} allowReorder |
| 570 * @param {?string=} defaultTab |
568 */ | 571 */ |
569 constructor(manager, revealCallback, location, restoreSelection, allowReorder)
{ | 572 constructor(manager, revealCallback, location, restoreSelection, allowReorder,
defaultTab) { |
570 var tabbedPane = new UI.TabbedPane(); | 573 var tabbedPane = new UI.TabbedPane(); |
571 if (allowReorder) | 574 if (allowReorder) |
572 tabbedPane.setAllowTabReorder(true); | 575 tabbedPane.setAllowTabReorder(true); |
573 | 576 |
574 super(manager, tabbedPane, revealCallback); | 577 super(manager, tabbedPane, revealCallback); |
575 this._tabbedPane = tabbedPane; | 578 this._tabbedPane = tabbedPane; |
576 this._allowReorder = allowReorder; | 579 this._allowReorder = allowReorder; |
577 | 580 |
578 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabSelected, this._ta
bSelected, this); | 581 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabSelected, this._ta
bSelected, this); |
579 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabClosed, this._tabC
losed, this); | 582 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabClosed, this._tabC
losed, this); |
580 this._closeableTabSetting = Common.settings.createSetting(location + '-close
ableTabs', {}); | 583 this._closeableTabSetting = Common.settings.createSetting(location + '-close
ableTabs', {}); |
581 this._tabOrderSetting = Common.settings.createSetting(location + '-tabOrder'
, {}); | 584 this._tabOrderSetting = Common.settings.createSetting(location + '-tabOrder'
, {}); |
582 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabOrderChanged, this
._persistTabOrder, this); | 585 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabOrderChanged, this
._persistTabOrder, this); |
583 if (restoreSelection) | 586 if (restoreSelection) |
584 this._lastSelectedTabSetting = Common.settings.createSetting(location + '-
selectedTab', ''); | 587 this._lastSelectedTabSetting = Common.settings.createSetting(location + '-
selectedTab', ''); |
| 588 this._defaultTab = defaultTab; |
585 | 589 |
586 /** @type {!Map.<string, !UI.View>} */ | 590 /** @type {!Map.<string, !UI.View>} */ |
587 this._views = new Map(); | 591 this._views = new Map(); |
588 | 592 |
589 if (location) | 593 if (location) |
590 this.appendApplicableItems(location); | 594 this.appendApplicableItems(location); |
591 } | 595 } |
592 | 596 |
593 /** | 597 /** |
594 * @override | 598 * @override |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 var id = view.viewId(); | 637 var id = view.viewId(); |
634 this._views.set(id, view); | 638 this._views.set(id, view); |
635 view[UI.ViewManager._Location.symbol] = this; | 639 view[UI.ViewManager._Location.symbol] = this; |
636 if (view.isTransient()) | 640 if (view.isTransient()) |
637 continue; | 641 continue; |
638 if (!view.isCloseable()) | 642 if (!view.isCloseable()) |
639 this._appendTab(view); | 643 this._appendTab(view); |
640 else if (this._closeableTabSetting.get()[id]) | 644 else if (this._closeableTabSetting.get()[id]) |
641 this._appendTab(view); | 645 this._appendTab(view); |
642 } | 646 } |
643 if (this._lastSelectedTabSetting && this._tabbedPane.hasTab(this._lastSelect
edTabSetting.get())) | 647 if (this._defaultTab && this._tabbedPane.hasTab(this._defaultTab)) |
| 648 this._tabbedPane.selectTab(this._defaultTab); |
| 649 else if (this._lastSelectedTabSetting && this._tabbedPane.hasTab(this._lastS
electedTabSetting.get())) |
644 this._tabbedPane.selectTab(this._lastSelectedTabSetting.get()); | 650 this._tabbedPane.selectTab(this._lastSelectedTabSetting.get()); |
645 } | 651 } |
646 | 652 |
647 /** | 653 /** |
648 * @param {!UI.ContextMenu} contextMenu | 654 * @param {!UI.ContextMenu} contextMenu |
649 */ | 655 */ |
650 _appendTabsToMenu(contextMenu) { | 656 _appendTabsToMenu(contextMenu) { |
651 for (var view of this._views.values()) { | 657 for (var view of this._views.values()) { |
652 var title = Common.UIString(view.title()); | 658 var title = Common.UIString(view.title()); |
653 contextMenu.appendItem(title, this.showView.bind(this, view)); | 659 contextMenu.appendItem(title, this.showView.bind(this, view)); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 appendApplicableItems(locationName) { | 865 appendApplicableItems(locationName) { |
860 for (var view of this._manager._viewsForLocation(locationName)) | 866 for (var view of this._manager._viewsForLocation(locationName)) |
861 this.appendView(view); | 867 this.appendView(view); |
862 } | 868 } |
863 }; | 869 }; |
864 | 870 |
865 /** | 871 /** |
866 * @type {!UI.ViewManager} | 872 * @type {!UI.ViewManager} |
867 */ | 873 */ |
868 UI.viewManager; | 874 UI.viewManager; |
OLD | NEW |