1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
18 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
19 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
20 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
21 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
22 | };
|
23 | var __metadata = (this && this.__metadata) || function (k, v) {
|
24 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
25 | };
|
26 | Object.defineProperty(exports, "__esModule", { value: true });
|
27 | exports.WidgetOpenHandler = void 0;
|
28 | const inversify_1 = require("inversify");
|
29 | const common_1 = require("../common");
|
30 | const shell_1 = require("./shell");
|
31 | const widget_manager_1 = require("./widget-manager");
|
32 |
|
33 |
|
34 |
|
35 | let WidgetOpenHandler = class WidgetOpenHandler {
|
36 | constructor() {
|
37 | this.onCreatedEmitter = new common_1.Emitter();
|
38 | |
39 |
|
40 |
|
41 | this.onCreated = this.onCreatedEmitter.event;
|
42 | }
|
43 | init() {
|
44 | this.widgetManager.onDidCreateWidget(({ factoryId, widget }) => {
|
45 | if (factoryId === this.id) {
|
46 | this.onCreatedEmitter.fire(widget);
|
47 | }
|
48 | });
|
49 | }
|
50 | |
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 | async open(uri, options) {
|
59 | const widget = await this.getOrCreateWidget(uri, options);
|
60 | await this.doOpen(widget, options);
|
61 | return widget;
|
62 | }
|
63 | async doOpen(widget, options) {
|
64 | const op = {
|
65 | mode: 'activate',
|
66 | ...options
|
67 | };
|
68 | if (!widget.isAttached) {
|
69 | this.shell.addWidget(widget, op.widgetOptions || { area: 'main' });
|
70 | }
|
71 | if (op.mode === 'activate') {
|
72 | await this.shell.activateWidget(widget.id);
|
73 | }
|
74 | else if (op.mode === 'reveal') {
|
75 | await this.shell.revealWidget(widget.id);
|
76 | }
|
77 | }
|
78 | |
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 | getByUri(uri) {
|
85 | return this.getWidget(uri);
|
86 | }
|
87 | |
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 | getOrCreateByUri(uri) {
|
96 | return this.getOrCreateWidget(uri);
|
97 | }
|
98 | |
99 |
|
100 |
|
101 |
|
102 |
|
103 | get all() {
|
104 | return this.widgetManager.getWidgets(this.id);
|
105 | }
|
106 | tryGetPendingWidget(uri, options) {
|
107 | const factoryOptions = this.createWidgetOptions(uri, options);
|
108 | return this.widgetManager.tryGetPendingWidget(this.id, factoryOptions);
|
109 | }
|
110 | getWidget(uri, options) {
|
111 | const widgetOptions = this.createWidgetOptions(uri, options);
|
112 | return this.widgetManager.getWidget(this.id, widgetOptions);
|
113 | }
|
114 | getOrCreateWidget(uri, options) {
|
115 | const widgetOptions = this.createWidgetOptions(uri, options);
|
116 | return this.widgetManager.getOrCreateWidget(this.id, widgetOptions);
|
117 | }
|
118 | |
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 | async closeAll(options) {
|
125 | return this.shell.closeMany(this.all, options);
|
126 | }
|
127 | };
|
128 | __decorate([
|
129 | (0, inversify_1.inject)(shell_1.ApplicationShell),
|
130 | __metadata("design:type", shell_1.ApplicationShell)
|
131 | ], WidgetOpenHandler.prototype, "shell", void 0);
|
132 | __decorate([
|
133 | (0, inversify_1.inject)(widget_manager_1.WidgetManager),
|
134 | __metadata("design:type", widget_manager_1.WidgetManager)
|
135 | ], WidgetOpenHandler.prototype, "widgetManager", void 0);
|
136 | __decorate([
|
137 | (0, inversify_1.postConstruct)(),
|
138 | __metadata("design:type", Function),
|
139 | __metadata("design:paramtypes", []),
|
140 | __metadata("design:returntype", void 0)
|
141 | ], WidgetOpenHandler.prototype, "init", null);
|
142 | WidgetOpenHandler = __decorate([
|
143 | (0, inversify_1.injectable)()
|
144 | ], WidgetOpenHandler);
|
145 | exports.WidgetOpenHandler = WidgetOpenHandler;
|
146 |
|
\ | No newline at end of file |