-
-
Notifications
You must be signed in to change notification settings - Fork 435
/
Copy pathcloud-sketchbook-composite-widget.tsx
68 lines (61 loc) · 2.58 KB
/
cloud-sketchbook-composite-widget.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import * as React from '@theia/core/shared/react';
import * as ReactDOM from '@theia/core/shared/react-dom';
import { inject, injectable } from '@theia/core/shared/inversify';
import { Widget } from '@theia/core/shared/@phosphor/widgets';
import { Message, MessageLoop } from '@theia/core/shared/@phosphor/messaging';
import { Disposable } from '@theia/core/lib/common/disposable';
import { BaseWidget } from '@theia/core/lib/browser/widgets/widget';
import { UserStatus } from './cloud-user-status';
import { CloudSketchbookTreeWidget } from './cloud-sketchbook-tree-widget';
import { AuthenticationClientService } from '../../auth/authentication-client-service';
import { CloudSketchbookTreeModel } from './cloud-sketchbook-tree-model';
import { nls } from '@theia/core/lib/common';
@injectable()
export class CloudSketchbookCompositeWidget extends BaseWidget {
@inject(AuthenticationClientService)
protected readonly authenticationService: AuthenticationClientService;
@inject(CloudSketchbookTreeWidget)
protected readonly cloudSketchbookTreeWidget: CloudSketchbookTreeWidget;
private compositeNode: HTMLElement;
private cloudUserStatusNode: HTMLElement;
constructor() {
super();
this.compositeNode = document.createElement('div');
this.compositeNode.classList.add('composite-node');
this.cloudUserStatusNode = document.createElement('div');
this.cloudUserStatusNode.classList.add('cloud-status-node');
this.compositeNode.appendChild(this.cloudUserStatusNode);
this.node.appendChild(this.compositeNode);
this.title.caption = nls.localize(
'arduino/cloud/remoteSketchbook',
'Remote Sketchbook'
);
this.title.iconClass = 'cloud-sketchbook-tree-icon';
this.title.closable = false;
this.id = 'cloud-sketchbook-composite-widget';
}
public getTreeWidget(): CloudSketchbookTreeWidget {
return this.cloudSketchbookTreeWidget;
}
protected override onAfterAttach(message: Message): void {
super.onAfterAttach(message);
Widget.attach(this.cloudSketchbookTreeWidget, this.compositeNode);
ReactDOM.render(
<UserStatus
model={this.cloudSketchbookTreeWidget.model as CloudSketchbookTreeModel}
authenticationService={this.authenticationService}
/>,
this.cloudUserStatusNode
);
this.toDisposeOnDetach.push(
Disposable.create(() => Widget.detach(this.cloudSketchbookTreeWidget))
);
}
protected override onResize(message: Widget.ResizeMessage): void {
super.onResize(message);
MessageLoop.sendMessage(
this.cloudSketchbookTreeWidget,
Widget.ResizeMessage.UnknownSize
);
}
}