• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 */
16import {Component, Input} from '@angular/core';
17import {TraceType} from 'trace/trace_type';
18import {CollapsibleSections} from 'viewers/common/collapsible_sections';
19import {CollapsibleSectionType} from 'viewers/common/collapsible_section_type';
20import {ImeUiData} from 'viewers/common/ime_ui_data';
21import {ViewerComponent} from 'viewers/components/viewer_component';
22import {viewerCardStyle} from './styles/viewer_card.styles';
23
24@Component({
25  selector: 'viewer-input-method',
26  template: `
27    <div class="card-grid">
28      <collapsed-sections
29        [class.empty]="sections.areAllSectionsExpanded()"
30        [sections]="sections"
31        (sectionChange)="sections.onCollapseStateChange($event, false)">
32      </collapsed-sections>
33
34      <div class="left-views" *ngIf="!areLeftViewsCollapsed()">
35        <hierarchy-view
36          class="hierarchy-view"
37          [trees]="this.inputData?.hierarchyTrees ?? []"
38          [dependencies]="inputData ? [inputData.traceType] : []"
39          [highlightedItem]="inputData?.highlightedItem"
40          [pinnedItems]="inputData?.pinnedItems ?? []"
41          [tableProperties]="inputData?.hierarchyTableProperties"
42          [textFilter]="inputData?.hierarchyFilter"
43          [store]="store"
44          [userOptions]="inputData?.hierarchyUserOptions ?? {}"
45          (collapseButtonClicked)="sections.onCollapseStateChange(CollapsibleSectionType.HIERARCHY, true)"
46          [class.collapsed]="sections.isSectionCollapsed(CollapsibleSectionType.HIERARCHY)"
47          placeholderText="No IME entry found."></hierarchy-view>
48        <ime-additional-properties
49          class="ime-additional-properties"
50          [isImeManagerService]="isImeManagerService()"
51          [highlightedItem]="inputData?.highlightedItem ?? ''"
52          [additionalProperties]="inputData?.additionalProperties"
53          (collapseButtonClicked)="sections.onCollapseStateChange(CollapsibleSectionType.IME_ADDITIONAL_PROPERTIES, true)"
54          [class.collapsed]="sections.isSectionCollapsed(CollapsibleSectionType.IME_ADDITIONAL_PROPERTIES)"></ime-additional-properties>
55      </div>
56
57      <properties-view
58        class="properties-view"
59        [store]="store"
60        [userOptions]="inputData?.propertiesUserOptions ?? {}"
61        [propertiesTree]="inputData?.propertiesTree"
62        [traceType]="inputData?.traceType"
63        [textFilter]="inputData?.propertiesFilter"
64        (collapseButtonClicked)="sections.onCollapseStateChange(CollapsibleSectionType.PROPERTIES, true)"
65        [class.collapsed]="sections.isSectionCollapsed(CollapsibleSectionType.PROPERTIES)"
66        placeholderText="No selected item."></properties-view>
67    </div>
68  `,
69  styles: [
70    `
71      .left-views {
72        flex: 1;
73        display: flex;
74        flex-direction: column;
75        overflow: auto;
76      }
77    `,
78    viewerCardStyle,
79  ],
80})
81export class ViewerInputMethodComponent extends ViewerComponent<ImeUiData> {
82  @Input() active = false;
83
84  CollapsibleSectionType = CollapsibleSectionType;
85  sections = new CollapsibleSections([
86    {
87      type: CollapsibleSectionType.HIERARCHY,
88      label: CollapsibleSectionType.HIERARCHY,
89      isCollapsed: false,
90    },
91    {
92      type: CollapsibleSectionType.IME_ADDITIONAL_PROPERTIES,
93      label: CollapsibleSectionType.IME_ADDITIONAL_PROPERTIES,
94      isCollapsed: false,
95    },
96    {
97      type: CollapsibleSectionType.PROPERTIES,
98      label: CollapsibleSectionType.PROPERTIES,
99      isCollapsed: false,
100    },
101  ]);
102
103  isImeManagerService(): boolean {
104    return this.inputData?.traceType === TraceType.INPUT_METHOD_MANAGER_SERVICE;
105  }
106
107  areLeftViewsCollapsed() {
108    return (
109      this.sections.isSectionCollapsed(CollapsibleSectionType.HIERARCHY) &&
110      this.sections.isSectionCollapsed(
111        CollapsibleSectionType.IME_ADDITIONAL_PROPERTIES,
112      )
113    );
114  }
115}
116