@theia/memory-inspector 1.34.1 → 1.34.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/LICENSE +641 -641
  2. package/README.md +71 -71
  3. package/lib/browser/diff-widget/memory-diff-options-widget.d.ts +36 -36
  4. package/lib/browser/diff-widget/memory-diff-options-widget.js +129 -129
  5. package/lib/browser/diff-widget/memory-diff-select-widget.d.ts +50 -50
  6. package/lib/browser/diff-widget/memory-diff-select-widget.js +137 -137
  7. package/lib/browser/diff-widget/memory-diff-table-widget.d.ts +77 -77
  8. package/lib/browser/diff-widget/memory-diff-table-widget.js +314 -314
  9. package/lib/browser/diff-widget/memory-diff-widget-types.d.ts +41 -41
  10. package/lib/browser/diff-widget/memory-diff-widget-types.js +23 -23
  11. package/lib/browser/editable-widget/memory-editable-table-widget.d.ts +64 -64
  12. package/lib/browser/editable-widget/memory-editable-table-widget.js +329 -329
  13. package/lib/browser/memory-inspector-frontend-contribution.d.ts +46 -46
  14. package/lib/browser/memory-inspector-frontend-contribution.js +291 -291
  15. package/lib/browser/memory-inspector-frontend-module.d.ts +21 -21
  16. package/lib/browser/memory-inspector-frontend-module.js +87 -87
  17. package/lib/browser/memory-provider/cdt-gdb-memory-provider.d.ts +35 -35
  18. package/lib/browser/memory-provider/cdt-gdb-memory-provider.js +136 -136
  19. package/lib/browser/memory-provider/memory-provider-service.d.ts +36 -36
  20. package/lib/browser/memory-provider/memory-provider-service.js +101 -101
  21. package/lib/browser/memory-provider/memory-provider.d.ts +65 -65
  22. package/lib/browser/memory-provider/memory-provider.js +96 -96
  23. package/lib/browser/memory-provider/memory-provider.spec.d.ts +16 -16
  24. package/lib/browser/memory-provider/memory-provider.spec.js +23 -23
  25. package/lib/browser/memory-widget/memory-options-widget.d.ts +136 -136
  26. package/lib/browser/memory-widget/memory-options-widget.js +561 -561
  27. package/lib/browser/memory-widget/memory-table-widget.d.ts +145 -145
  28. package/lib/browser/memory-widget/memory-table-widget.js +484 -484
  29. package/lib/browser/memory-widget/memory-widget.d.ts +32 -32
  30. package/lib/browser/memory-widget/memory-widget.js +109 -109
  31. package/lib/browser/register-widget/register-filter-service.d.ts +42 -42
  32. package/lib/browser/register-widget/register-filter-service.js +82 -82
  33. package/lib/browser/register-widget/register-options-widget.d.ts +81 -81
  34. package/lib/browser/register-widget/register-options-widget.js +343 -343
  35. package/lib/browser/register-widget/register-table-widget.d.ts +77 -77
  36. package/lib/browser/register-widget/register-table-widget.js +236 -236
  37. package/lib/browser/register-widget/register-widget-types.d.ts +29 -29
  38. package/lib/browser/register-widget/register-widget-types.js +35 -35
  39. package/lib/browser/utils/memory-commands.d.ts +27 -27
  40. package/lib/browser/utils/memory-commands.js +67 -67
  41. package/lib/browser/utils/memory-hover-renderer.d.ts +33 -33
  42. package/lib/browser/utils/memory-hover-renderer.js +111 -111
  43. package/lib/browser/utils/memory-recents.d.ts +27 -27
  44. package/lib/browser/utils/memory-recents.js +52 -52
  45. package/lib/browser/utils/memory-widget-components.d.ts +58 -58
  46. package/lib/browser/utils/memory-widget-components.js +69 -69
  47. package/lib/browser/utils/memory-widget-manager.d.ts +50 -50
  48. package/lib/browser/utils/memory-widget-manager.js +182 -182
  49. package/lib/browser/utils/memory-widget-utils.d.ts +113 -113
  50. package/lib/browser/utils/memory-widget-utils.js +42 -42
  51. package/lib/browser/utils/memory-widget-variable-utils.d.ts +57 -57
  52. package/lib/browser/utils/memory-widget-variable-utils.js +143 -143
  53. package/lib/browser/utils/multi-select-bar.d.ts +31 -31
  54. package/lib/browser/utils/multi-select-bar.js +34 -34
  55. package/lib/browser/wrapper-widgets/memory-dock-panel.d.ts +24 -24
  56. package/lib/browser/wrapper-widgets/memory-dock-panel.js +48 -48
  57. package/lib/browser/wrapper-widgets/memory-dockpanel-placeholder-widget.d.ts +23 -23
  58. package/lib/browser/wrapper-widgets/memory-dockpanel-placeholder-widget.js +57 -57
  59. package/lib/browser/wrapper-widgets/memory-layout-widget.d.ts +50 -50
  60. package/lib/browser/wrapper-widgets/memory-layout-widget.js +188 -188
  61. package/lib/common/util.d.ts +21 -21
  62. package/lib/common/util.js +30 -30
  63. package/lib/common/utils.spec.d.ts +16 -16
  64. package/lib/common/utils.spec.js +45 -45
  65. package/package.json +4 -4
  66. package/src/browser/diff-widget/memory-diff-options-widget.tsx +152 -152
  67. package/src/browser/diff-widget/memory-diff-select-widget.tsx +163 -163
  68. package/src/browser/diff-widget/memory-diff-table-widget.tsx +366 -366
  69. package/src/browser/diff-widget/memory-diff-widget-types.ts +45 -45
  70. package/src/browser/editable-widget/memory-editable-table-widget.tsx +360 -360
  71. package/src/browser/memory-inspector-frontend-contribution.ts +301 -301
  72. package/src/browser/memory-inspector-frontend-module.ts +118 -118
  73. package/src/browser/memory-provider/cdt-gdb-memory-provider.ts +132 -132
  74. package/src/browser/memory-provider/memory-provider-service.ts +86 -86
  75. package/src/browser/memory-provider/memory-provider.spec.ts +23 -23
  76. package/src/browser/memory-provider/memory-provider.ts +119 -119
  77. package/src/browser/memory-widget/memory-options-widget.tsx +738 -738
  78. package/src/browser/memory-widget/memory-table-widget.tsx +621 -621
  79. package/src/browser/memory-widget/memory-widget.ts +110 -110
  80. package/src/browser/register-widget/register-filter-service.ts +77 -77
  81. package/src/browser/register-widget/register-options-widget.tsx +393 -393
  82. package/src/browser/register-widget/register-table-widget.tsx +277 -277
  83. package/src/browser/register-widget/register-widget-types.ts +45 -45
  84. package/src/browser/register-widget/register-widget.css +34 -34
  85. package/src/browser/style/index.css +750 -750
  86. package/src/browser/style/memory-lock.svg +21 -21
  87. package/src/browser/style/memory-view.svg +20 -20
  88. package/src/browser/style/register-lock.svg +29 -29
  89. package/src/browser/style/register-view.svg +28 -28
  90. package/src/browser/utils/memory-commands.ts +76 -76
  91. package/src/browser/utils/memory-hover-renderer.ts +113 -113
  92. package/src/browser/utils/memory-recents.ts +58 -58
  93. package/src/browser/utils/memory-widget-components.tsx +193 -193
  94. package/src/browser/utils/memory-widget-manager.ts +179 -179
  95. package/src/browser/utils/memory-widget-utils.tsx +132 -132
  96. package/src/browser/utils/memory-widget-variable-utils.ts +170 -170
  97. package/src/browser/utils/multi-select-bar.css +62 -62
  98. package/src/browser/utils/multi-select-bar.tsx +75 -75
  99. package/src/browser/wrapper-widgets/memory-dock-panel.ts +51 -51
  100. package/src/browser/wrapper-widgets/memory-dockpanel-placeholder-widget.tsx +38 -38
  101. package/src/browser/wrapper-widgets/memory-layout-widget.tsx +163 -163
  102. package/src/common/util.ts +28 -28
  103. package/src/common/utils.spec.ts +52 -52
@@ -1,51 +1,51 @@
1
- /********************************************************************************
2
- * Copyright (C) 2019 Ericsson and others.
3
- *
4
- * This program and the accompanying materials are made available under the
5
- * terms of the Eclipse Public License v. 2.0 which is available at
6
- * http://www.eclipse.org/legal/epl-2.0.
7
- *
8
- * This Source Code may also be made available under the following Secondary
9
- * Licenses when the conditions for such availability set forth in the Eclipse
10
- * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- * with the GNU Classpath Exception which is available at
12
- * https://www.gnu.org/software/classpath/license.html.
13
- *
14
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
- ********************************************************************************/
16
-
17
- import { DockPanelRendererFactory } from '@theia/core/lib/browser';
18
- import { TheiaDockPanel } from '@theia/core/lib/browser/shell/theia-dock-panel';
19
- import { interfaces } from '@theia/core/shared/inversify';
20
-
21
- export class MemoryDockPanel extends TheiaDockPanel {
22
- override toggleMaximized(): void { /* don't */ }
23
- }
24
-
25
- export namespace MemoryDockPanel {
26
- export const ID = 'memory-dock-panel-widget';
27
- const DOCK_PANEL_ID = 'theia-main-content-panel';
28
- const THEIA_TABBAR_CLASSES = ['theia-app-centers', 'theia-app-main'];
29
- const MEMORY_INSPECTOR_TABBAR_CLASS = 'memory-dock-tabbar';
30
- const DOCK_PANEL_CLASS = 'memory-dock-panel';
31
-
32
- const createDockPanel = (factory: DockPanelRendererFactory): MemoryDockPanel => {
33
- const renderer = factory();
34
- renderer.tabBarClasses.push(...THEIA_TABBAR_CLASSES, MEMORY_INSPECTOR_TABBAR_CLASS);
35
- const dockPanel = new MemoryDockPanel({
36
- mode: 'multiple-document',
37
- renderer,
38
- spacing: 0,
39
- });
40
- dockPanel.addClass(DOCK_PANEL_CLASS);
41
- dockPanel.id = DOCK_PANEL_ID;
42
-
43
- return dockPanel;
44
- };
45
-
46
- export const createWidget = (parent: interfaces.Container): MemoryDockPanel => {
47
- const dockFactory = parent.get<DockPanelRendererFactory>(DockPanelRendererFactory);
48
- const dockPanel = createDockPanel(dockFactory);
49
- return dockPanel;
50
- };
51
- }
1
+ /********************************************************************************
2
+ * Copyright (C) 2019 Ericsson and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the Eclipse Public License v. 2.0 which is available at
6
+ * http://www.eclipse.org/legal/epl-2.0.
7
+ *
8
+ * This Source Code may also be made available under the following Secondary
9
+ * Licenses when the conditions for such availability set forth in the Eclipse
10
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ * with the GNU Classpath Exception which is available at
12
+ * https://www.gnu.org/software/classpath/license.html.
13
+ *
14
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ ********************************************************************************/
16
+
17
+ import { DockPanelRendererFactory } from '@theia/core/lib/browser';
18
+ import { TheiaDockPanel } from '@theia/core/lib/browser/shell/theia-dock-panel';
19
+ import { interfaces } from '@theia/core/shared/inversify';
20
+
21
+ export class MemoryDockPanel extends TheiaDockPanel {
22
+ override toggleMaximized(): void { /* don't */ }
23
+ }
24
+
25
+ export namespace MemoryDockPanel {
26
+ export const ID = 'memory-dock-panel-widget';
27
+ const DOCK_PANEL_ID = 'theia-main-content-panel';
28
+ const THEIA_TABBAR_CLASSES = ['theia-app-centers', 'theia-app-main'];
29
+ const MEMORY_INSPECTOR_TABBAR_CLASS = 'memory-dock-tabbar';
30
+ const DOCK_PANEL_CLASS = 'memory-dock-panel';
31
+
32
+ const createDockPanel = (factory: DockPanelRendererFactory): MemoryDockPanel => {
33
+ const renderer = factory();
34
+ renderer.tabBarClasses.push(...THEIA_TABBAR_CLASSES, MEMORY_INSPECTOR_TABBAR_CLASS);
35
+ const dockPanel = new MemoryDockPanel({
36
+ mode: 'multiple-document',
37
+ renderer,
38
+ spacing: 0,
39
+ });
40
+ dockPanel.addClass(DOCK_PANEL_CLASS);
41
+ dockPanel.id = DOCK_PANEL_ID;
42
+
43
+ return dockPanel;
44
+ };
45
+
46
+ export const createWidget = (parent: interfaces.Container): MemoryDockPanel => {
47
+ const dockFactory = parent.get<DockPanelRendererFactory>(DockPanelRendererFactory);
48
+ const dockPanel = createDockPanel(dockFactory);
49
+ return dockPanel;
50
+ };
51
+ }
@@ -1,38 +1,38 @@
1
- /********************************************************************************
2
- * Copyright (C) 2021 Ericsson and others.
3
- *
4
- * This program and the accompanying materials are made available under the
5
- * terms of the Eclipse Public License v. 2.0 which is available at
6
- * http://www.eclipse.org/legal/epl-2.0.
7
- *
8
- * This Source Code may also be made available under the following Secondary
9
- * Licenses when the conditions for such availability set forth in the Eclipse
10
- * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- * with the GNU Classpath Exception which is available at
12
- * https://www.gnu.org/software/classpath/license.html.
13
- *
14
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
- ********************************************************************************/
16
- import { ReactWidget } from '@theia/core/lib/browser';
17
- import { injectable, postConstruct } from '@theia/core/shared/inversify';
18
- import * as React from '@theia/core/shared/react';
19
-
20
- @injectable()
21
- export class MemoryDockpanelPlaceholder extends ReactWidget {
22
- static ID = 'memory-dockpanel-placeholder';
23
-
24
- @postConstruct()
25
- init(): void {
26
- this.id = MemoryDockpanelPlaceholder.ID;
27
- this.addClass(MemoryDockpanelPlaceholder.ID);
28
- this.update();
29
- }
30
-
31
- render(): React.ReactNode {
32
- return (
33
- <div className='t-mv-memory-fetch-error'>
34
- Click the <i className='memory-view-icon toolbar' /> icon to add a new memory view or the <i className='register-view-icon toolbar' /> icon to add a register view.
35
- </div>
36
- );
37
- }
38
- }
1
+ /********************************************************************************
2
+ * Copyright (C) 2021 Ericsson and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the Eclipse Public License v. 2.0 which is available at
6
+ * http://www.eclipse.org/legal/epl-2.0.
7
+ *
8
+ * This Source Code may also be made available under the following Secondary
9
+ * Licenses when the conditions for such availability set forth in the Eclipse
10
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ * with the GNU Classpath Exception which is available at
12
+ * https://www.gnu.org/software/classpath/license.html.
13
+ *
14
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ ********************************************************************************/
16
+ import { ReactWidget } from '@theia/core/lib/browser';
17
+ import { injectable, postConstruct } from '@theia/core/shared/inversify';
18
+ import * as React from '@theia/core/shared/react';
19
+
20
+ @injectable()
21
+ export class MemoryDockpanelPlaceholder extends ReactWidget {
22
+ static ID = 'memory-dockpanel-placeholder';
23
+
24
+ @postConstruct()
25
+ init(): void {
26
+ this.id = MemoryDockpanelPlaceholder.ID;
27
+ this.addClass(MemoryDockpanelPlaceholder.ID);
28
+ this.update();
29
+ }
30
+
31
+ render(): React.ReactNode {
32
+ return (
33
+ <div className='t-mv-memory-fetch-error'>
34
+ Click the <i className='memory-view-icon toolbar' /> icon to add a new memory view or the <i className='register-view-icon toolbar' /> icon to add a register view.
35
+ </div>
36
+ );
37
+ }
38
+ }
@@ -1,163 +1,163 @@
1
- /********************************************************************************
2
- * Copyright (C) 2021 Ericsson and others.
3
- *
4
- * This program and the accompanying materials are made available under the
5
- * terms of the Eclipse Public License v. 2.0 which is available at
6
- * http://www.eclipse.org/legal/epl-2.0.
7
- *
8
- * This Source Code may also be made available under the following Secondary
9
- * Licenses when the conditions for such availability set forth in the Eclipse
10
- * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- * with the GNU Classpath Exception which is available at
12
- * https://www.gnu.org/software/classpath/license.html.
13
- *
14
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
- ********************************************************************************/
16
-
17
- import { Disposable, DisposableCollection, Emitter, nls } from '@theia/core';
18
- import { ApplicationShell, Message, Panel, Widget, WidgetManager } from '@theia/core/lib/browser';
19
- import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
20
- import { MemoryDiffSelectWidget } from '../diff-widget/memory-diff-select-widget';
21
- import { MemoryWidget } from '../memory-widget/memory-widget';
22
- import { MemoryWidgetManager } from '../utils/memory-widget-manager';
23
- import { MemoryDockPanel } from './memory-dock-panel';
24
- import { MemoryDockpanelPlaceholder } from './memory-dockpanel-placeholder-widget';
25
-
26
- @injectable()
27
- export class MemoryLayoutWidget extends Panel implements Disposable, ApplicationShell.TrackableWidgetProvider {
28
- static readonly ID = 'memory-layout-widget';
29
- static readonly LABEL = nls.localize('theia/memory-inspector/memoryInspector', 'Memory Inspector');
30
-
31
- // Necessary to inherit theia's tabbar styling
32
- static readonly DOCK_PANEL_ID = 'theia-main-content-panel';
33
- static readonly THEIA_TABBAR_CLASSES = ['theia-app-centers', 'theia-app-main'];
34
- static readonly MEMORY_INSPECTOR_TABBAR_CLASS = 'memory-dock-tabbar';
35
- static readonly DOCK_PANEL_CLASS = 'memory-dock-panel';
36
-
37
- @inject(WidgetManager) protected readonly widgetManager: WidgetManager;
38
- @inject(MemoryWidgetManager) protected readonly memoryWidgetManager: MemoryWidgetManager;
39
- @inject(MemoryDiffSelectWidget) protected readonly diffSelectWidget: MemoryDiffSelectWidget;
40
- @inject(MemoryDockpanelPlaceholder) protected readonly placeholderWidget: MemoryDockpanelPlaceholder;
41
- @inject(ApplicationShell) protected readonly shell: ApplicationShell;
42
-
43
- protected readonly onDidChangeTrackableWidgetsEmitter = new Emitter<Widget[]>();
44
- readonly onDidChangeTrackableWidgets = this.onDidChangeTrackableWidgetsEmitter.event;
45
-
46
- protected readonly toDispose = new DisposableCollection();
47
- protected dockPanel: MemoryDockPanel;
48
- protected hasGeneratedWidgetAutomatically = false;
49
-
50
- @postConstruct()
51
- protected async init(): Promise<void> {
52
- this.id = MemoryLayoutWidget.ID;
53
- this.addClass(MemoryLayoutWidget.ID);
54
- this.title.label = MemoryLayoutWidget.LABEL;
55
- this.title.caption = MemoryLayoutWidget.LABEL;
56
- this.title.closable = true;
57
- this.title.iconClass = 'memory-view-icon';
58
- this.dockPanel = await this.widgetManager.getOrCreateWidget<MemoryDockPanel>(MemoryDockPanel.ID);
59
- this.addWidget(this.dockPanel);
60
- this.addWidget(this.diffSelectWidget);
61
- this.addWidget(this.placeholderWidget);
62
- this.toDispose.push(this.memoryWidgetManager.onDidCreateNewWidget(widget => {
63
- this.dockPanel.addWidget(widget);
64
- this.dockPanel.activateWidget(widget);
65
- this.onDidChangeTrackableWidgetsEmitter.fire([widget]);
66
- }));
67
- this.toDispose.push(this.memoryWidgetManager.onChanged(() => {
68
- if (!this.memoryWidgetManager.canCompare) {
69
- this.diffSelectWidget.hide();
70
- }
71
- }));
72
- this.dockPanel.widgetRemoved.connect(this.handleWidgetRemoved.bind(this), this);
73
- this.dockPanel.widgetAdded.connect(this.handleWidgetsChanged.bind(this), this);
74
- this.toDispose.push(this.onDidChangeTrackableWidgetsEmitter);
75
- this.diffSelectWidget.hide();
76
- this.update();
77
- }
78
-
79
- toggleComparisonVisibility(): void {
80
- if (this.diffSelectWidget.isHidden) {
81
- this.diffSelectWidget.show();
82
- } else {
83
- this.diffSelectWidget.hide();
84
- }
85
- this.update();
86
- }
87
-
88
- override dispose(): void {
89
- this.toDispose.dispose();
90
- super.dispose();
91
- }
92
-
93
- protected dockPanelHoldsWidgets(): boolean {
94
- const iter = this.dockPanel.tabBars();
95
- let tabBar = iter.next();
96
- while (tabBar) {
97
- if (tabBar.titles.length) {
98
- return true;
99
- }
100
- tabBar = iter.next();
101
- }
102
- return false;
103
- }
104
-
105
- protected handleWidgetsChanged(): void {
106
- if (this.dockPanelHoldsWidgets()) {
107
- this.placeholderWidget.hide();
108
- } else {
109
- this.placeholderWidget.show();
110
- }
111
- }
112
-
113
- protected handleWidgetRemoved(_sender: Widget, widgetRemoved: Widget): void {
114
- if (widgetRemoved instanceof MemoryWidget) { // Sometimes it's the tabbar.
115
- this.handleWidgetsChanged();
116
- this.shell.activateWidget(this.id);
117
- }
118
- }
119
-
120
- protected async createAndFocusWidget(): Promise<void> {
121
- const widget = await this.memoryWidgetManager.createNewMemoryWidget();
122
- widget.activate();
123
- }
124
-
125
- protected override async onAfterShow(msg: Message): Promise<void> {
126
- if (!this.hasGeneratedWidgetAutomatically && !this.dockPanelHoldsWidgets()) {
127
- await this.createAndFocusWidget();
128
- this.hasGeneratedWidgetAutomatically = true;
129
- }
130
- super.onAfterShow(msg);
131
- }
132
-
133
- getTrackableWidgets(): Widget[] {
134
- const children: Widget[] = [];
135
- const childIterator = this.dockPanel.children();
136
- let currentChild = childIterator.next();
137
- while (currentChild) {
138
- children.push(currentChild);
139
- currentChild = childIterator.next();
140
- }
141
- return children;
142
- }
143
-
144
- activateWidget(id: string): Widget | undefined {
145
- const widget = this.getTrackableWidgets().find(candidateWidget => candidateWidget.id === id);
146
- if (widget) {
147
- this.dockPanel.activateWidget(widget);
148
- }
149
- return widget;
150
- }
151
-
152
- override onActivateRequest(msg: Message): void {
153
- const displayedWidget = this.dockPanel.currentTabBar?.currentTitle?.owner;
154
- if (displayedWidget) {
155
- displayedWidget.activate();
156
- } else {
157
- // Only happens if you remove all widgets, then close the view.
158
- this.node.tabIndex = -1;
159
- this.node.focus();
160
- }
161
- super.onActivateRequest(msg);
162
- }
163
- }
1
+ /********************************************************************************
2
+ * Copyright (C) 2021 Ericsson and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the Eclipse Public License v. 2.0 which is available at
6
+ * http://www.eclipse.org/legal/epl-2.0.
7
+ *
8
+ * This Source Code may also be made available under the following Secondary
9
+ * Licenses when the conditions for such availability set forth in the Eclipse
10
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ * with the GNU Classpath Exception which is available at
12
+ * https://www.gnu.org/software/classpath/license.html.
13
+ *
14
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ ********************************************************************************/
16
+
17
+ import { Disposable, DisposableCollection, Emitter, nls } from '@theia/core';
18
+ import { ApplicationShell, Message, Panel, Widget, WidgetManager } from '@theia/core/lib/browser';
19
+ import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
20
+ import { MemoryDiffSelectWidget } from '../diff-widget/memory-diff-select-widget';
21
+ import { MemoryWidget } from '../memory-widget/memory-widget';
22
+ import { MemoryWidgetManager } from '../utils/memory-widget-manager';
23
+ import { MemoryDockPanel } from './memory-dock-panel';
24
+ import { MemoryDockpanelPlaceholder } from './memory-dockpanel-placeholder-widget';
25
+
26
+ @injectable()
27
+ export class MemoryLayoutWidget extends Panel implements Disposable, ApplicationShell.TrackableWidgetProvider {
28
+ static readonly ID = 'memory-layout-widget';
29
+ static readonly LABEL = nls.localize('theia/memory-inspector/memoryInspector', 'Memory Inspector');
30
+
31
+ // Necessary to inherit theia's tabbar styling
32
+ static readonly DOCK_PANEL_ID = 'theia-main-content-panel';
33
+ static readonly THEIA_TABBAR_CLASSES = ['theia-app-centers', 'theia-app-main'];
34
+ static readonly MEMORY_INSPECTOR_TABBAR_CLASS = 'memory-dock-tabbar';
35
+ static readonly DOCK_PANEL_CLASS = 'memory-dock-panel';
36
+
37
+ @inject(WidgetManager) protected readonly widgetManager: WidgetManager;
38
+ @inject(MemoryWidgetManager) protected readonly memoryWidgetManager: MemoryWidgetManager;
39
+ @inject(MemoryDiffSelectWidget) protected readonly diffSelectWidget: MemoryDiffSelectWidget;
40
+ @inject(MemoryDockpanelPlaceholder) protected readonly placeholderWidget: MemoryDockpanelPlaceholder;
41
+ @inject(ApplicationShell) protected readonly shell: ApplicationShell;
42
+
43
+ protected readonly onDidChangeTrackableWidgetsEmitter = new Emitter<Widget[]>();
44
+ readonly onDidChangeTrackableWidgets = this.onDidChangeTrackableWidgetsEmitter.event;
45
+
46
+ protected readonly toDispose = new DisposableCollection();
47
+ protected dockPanel: MemoryDockPanel;
48
+ protected hasGeneratedWidgetAutomatically = false;
49
+
50
+ @postConstruct()
51
+ protected async init(): Promise<void> {
52
+ this.id = MemoryLayoutWidget.ID;
53
+ this.addClass(MemoryLayoutWidget.ID);
54
+ this.title.label = MemoryLayoutWidget.LABEL;
55
+ this.title.caption = MemoryLayoutWidget.LABEL;
56
+ this.title.closable = true;
57
+ this.title.iconClass = 'memory-view-icon';
58
+ this.dockPanel = await this.widgetManager.getOrCreateWidget<MemoryDockPanel>(MemoryDockPanel.ID);
59
+ this.addWidget(this.dockPanel);
60
+ this.addWidget(this.diffSelectWidget);
61
+ this.addWidget(this.placeholderWidget);
62
+ this.toDispose.push(this.memoryWidgetManager.onDidCreateNewWidget(widget => {
63
+ this.dockPanel.addWidget(widget);
64
+ this.dockPanel.activateWidget(widget);
65
+ this.onDidChangeTrackableWidgetsEmitter.fire([widget]);
66
+ }));
67
+ this.toDispose.push(this.memoryWidgetManager.onChanged(() => {
68
+ if (!this.memoryWidgetManager.canCompare) {
69
+ this.diffSelectWidget.hide();
70
+ }
71
+ }));
72
+ this.dockPanel.widgetRemoved.connect(this.handleWidgetRemoved.bind(this), this);
73
+ this.dockPanel.widgetAdded.connect(this.handleWidgetsChanged.bind(this), this);
74
+ this.toDispose.push(this.onDidChangeTrackableWidgetsEmitter);
75
+ this.diffSelectWidget.hide();
76
+ this.update();
77
+ }
78
+
79
+ toggleComparisonVisibility(): void {
80
+ if (this.diffSelectWidget.isHidden) {
81
+ this.diffSelectWidget.show();
82
+ } else {
83
+ this.diffSelectWidget.hide();
84
+ }
85
+ this.update();
86
+ }
87
+
88
+ override dispose(): void {
89
+ this.toDispose.dispose();
90
+ super.dispose();
91
+ }
92
+
93
+ protected dockPanelHoldsWidgets(): boolean {
94
+ const iter = this.dockPanel.tabBars();
95
+ let tabBar = iter.next();
96
+ while (tabBar) {
97
+ if (tabBar.titles.length) {
98
+ return true;
99
+ }
100
+ tabBar = iter.next();
101
+ }
102
+ return false;
103
+ }
104
+
105
+ protected handleWidgetsChanged(): void {
106
+ if (this.dockPanelHoldsWidgets()) {
107
+ this.placeholderWidget.hide();
108
+ } else {
109
+ this.placeholderWidget.show();
110
+ }
111
+ }
112
+
113
+ protected handleWidgetRemoved(_sender: Widget, widgetRemoved: Widget): void {
114
+ if (widgetRemoved instanceof MemoryWidget) { // Sometimes it's the tabbar.
115
+ this.handleWidgetsChanged();
116
+ this.shell.activateWidget(this.id);
117
+ }
118
+ }
119
+
120
+ protected async createAndFocusWidget(): Promise<void> {
121
+ const widget = await this.memoryWidgetManager.createNewMemoryWidget();
122
+ widget.activate();
123
+ }
124
+
125
+ protected override async onAfterShow(msg: Message): Promise<void> {
126
+ if (!this.hasGeneratedWidgetAutomatically && !this.dockPanelHoldsWidgets()) {
127
+ await this.createAndFocusWidget();
128
+ this.hasGeneratedWidgetAutomatically = true;
129
+ }
130
+ super.onAfterShow(msg);
131
+ }
132
+
133
+ getTrackableWidgets(): Widget[] {
134
+ const children: Widget[] = [];
135
+ const childIterator = this.dockPanel.children();
136
+ let currentChild = childIterator.next();
137
+ while (currentChild) {
138
+ children.push(currentChild);
139
+ currentChild = childIterator.next();
140
+ }
141
+ return children;
142
+ }
143
+
144
+ activateWidget(id: string): Widget | undefined {
145
+ const widget = this.getTrackableWidgets().find(candidateWidget => candidateWidget.id === id);
146
+ if (widget) {
147
+ this.dockPanel.activateWidget(widget);
148
+ }
149
+ return widget;
150
+ }
151
+
152
+ override onActivateRequest(msg: Message): void {
153
+ const displayedWidget = this.dockPanel.currentTabBar?.currentTitle?.owner;
154
+ if (displayedWidget) {
155
+ displayedWidget.activate();
156
+ } else {
157
+ // Only happens if you remove all widgets, then close the view.
158
+ this.node.tabIndex = -1;
159
+ this.node.focus();
160
+ }
161
+ super.onActivateRequest(msg);
162
+ }
163
+ }
@@ -1,28 +1,28 @@
1
- /********************************************************************************
2
- * Copyright (C) 2019 Ericsson and others.
3
- *
4
- * This program and the accompanying materials are made available under the
5
- * terms of the Eclipse Public License v. 2.0 which is available at
6
- * http://www.eclipse.org/legal/epl-2.0.
7
- *
8
- * This Source Code may also be made available under the following Secondary
9
- * Licenses when the conditions for such availability set forth in the Eclipse
10
- * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- * with the GNU Classpath Exception which is available at
12
- * https://www.gnu.org/software/classpath/license.html.
13
- *
14
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
- ********************************************************************************/
16
-
17
- import * as Long from 'long';
18
-
19
- /**
20
- * Parse `hexStr` as an hexadecimal string (with or without the leading 0x)
21
- * and return the value as a Long.
22
- */
23
- export function hexStrToUnsignedLong(hexStr: string): Long {
24
- if (hexStr.trim().length === 0) {
25
- return new Long(0, 0, true);
26
- }
27
- return Long.fromString(hexStr, true, 16);
28
- }
1
+ /********************************************************************************
2
+ * Copyright (C) 2019 Ericsson and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the Eclipse Public License v. 2.0 which is available at
6
+ * http://www.eclipse.org/legal/epl-2.0.
7
+ *
8
+ * This Source Code may also be made available under the following Secondary
9
+ * Licenses when the conditions for such availability set forth in the Eclipse
10
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ * with the GNU Classpath Exception which is available at
12
+ * https://www.gnu.org/software/classpath/license.html.
13
+ *
14
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ ********************************************************************************/
16
+
17
+ import * as Long from 'long';
18
+
19
+ /**
20
+ * Parse `hexStr` as an hexadecimal string (with or without the leading 0x)
21
+ * and return the value as a Long.
22
+ */
23
+ export function hexStrToUnsignedLong(hexStr: string): Long {
24
+ if (hexStr.trim().length === 0) {
25
+ return new Long(0, 0, true);
26
+ }
27
+ return Long.fromString(hexStr, true, 16);
28
+ }