UNPKG

debug-server-next

Version:

Dev server for hippy-core.

70 lines (69 loc) 2.26 kB
// Copyright 2020 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. import * as Common from '../../core/common/common.js'; import * as UI from '../../ui/legacy/legacy.js'; export class ApplicationPanelTreeElement extends UI.TreeOutline.TreeElement { resourcesPanel; constructor(resourcesPanel, title, expandable) { super(title, expandable); this.resourcesPanel = resourcesPanel; UI.ARIAUtils.setAccessibleName(this.listItemElement, title); } get itemURL() { throw new Error('Unimplemented Method'); } onselect(selectedByUser) { if (!selectedByUser) { return false; } const path = []; for (let el = this; el; el = el.parent) { const url = el instanceof ApplicationPanelTreeElement && el.itemURL; if (!url) { break; } path.push(url); } this.resourcesPanel.setLastSelectedItemPath(path); return false; } showView(view) { this.resourcesPanel.showView(view); } } export class ExpandableApplicationPanelTreeElement extends ApplicationPanelTreeElement { expandedSetting; categoryName; categoryLink; constructor(resourcesPanel, categoryName, settingsKey, settingsDefault = false) { super(resourcesPanel, categoryName, false); this.expandedSetting = Common.Settings.Settings.instance().createSetting('resources' + settingsKey + 'Expanded', settingsDefault); this.categoryName = categoryName; this.categoryLink = null; } get itemURL() { return 'category://' + this.categoryName; } setLink(link) { this.categoryLink = link; } onselect(selectedByUser) { super.onselect(selectedByUser); this.resourcesPanel.showCategoryView(this.categoryName, this.categoryLink); return false; } onattach() { super.onattach(); if (this.expandedSetting.get()) { this.expand(); } } onexpand() { this.expandedSetting.set(true); } oncollapse() { this.expandedSetting.set(false); } }