1/* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17import {Traces} from 'trace/traces'; 18import {TracePosition} from 'trace/trace_position'; 19import {TraceType} from 'trace/trace_type'; 20import {ViewerEvents} from 'viewers/common/viewer_events'; 21import {View, Viewer, ViewType} from 'viewers/viewer'; 22import {Presenter} from './presenter'; 23import {UiData} from './ui_data'; 24 25class ViewerWindowManager implements Viewer { 26 constructor(traces: Traces, storage: Storage) { 27 this.htmlElement = document.createElement('viewer-window-manager'); 28 this.presenter = new Presenter(traces, storage, (uiData: UiData) => { 29 (this.htmlElement as any).inputData = uiData; 30 }); 31 this.htmlElement.addEventListener(ViewerEvents.HierarchyPinnedChange, (event) => 32 this.presenter.updatePinnedItems((event as CustomEvent).detail.pinnedItem) 33 ); 34 this.htmlElement.addEventListener(ViewerEvents.HighlightedChange, (event) => 35 this.presenter.updateHighlightedItems(`${(event as CustomEvent).detail.id}`) 36 ); 37 this.htmlElement.addEventListener(ViewerEvents.HierarchyUserOptionsChange, (event) => 38 this.presenter.updateHierarchyTree((event as CustomEvent).detail.userOptions) 39 ); 40 this.htmlElement.addEventListener(ViewerEvents.HierarchyFilterChange, (event) => 41 this.presenter.filterHierarchyTree((event as CustomEvent).detail.filterString) 42 ); 43 this.htmlElement.addEventListener(ViewerEvents.PropertiesUserOptionsChange, (event) => 44 this.presenter.updatePropertiesTree((event as CustomEvent).detail.userOptions) 45 ); 46 this.htmlElement.addEventListener(ViewerEvents.PropertiesFilterChange, (event) => 47 this.presenter.filterPropertiesTree((event as CustomEvent).detail.filterString) 48 ); 49 this.htmlElement.addEventListener(ViewerEvents.SelectedTreeChange, (event) => 50 this.presenter.newPropertiesTree((event as CustomEvent).detail.selectedItem) 51 ); 52 } 53 54 async onTracePositionUpdate(position: TracePosition) { 55 await this.presenter.onTracePositionUpdate(position); 56 } 57 58 getViews(): View[] { 59 return [ 60 new View( 61 ViewType.TAB, 62 this.getDependencies(), 63 this.htmlElement, 64 'Window Manager', 65 TraceType.WINDOW_MANAGER 66 ), 67 ]; 68 } 69 70 getDependencies(): TraceType[] { 71 return ViewerWindowManager.DEPENDENCIES; 72 } 73 74 static readonly DEPENDENCIES: TraceType[] = [TraceType.WINDOW_MANAGER]; 75 private htmlElement: HTMLElement; 76 private presenter: Presenter; 77} 78 79export {ViewerWindowManager}; 80