- Notifications
You must be signed in to change notification settings - Fork 440
/
Copy pathboards-list-widget.ts
91 lines (86 loc) · 2.43 KB
/
boards-list-widget.ts
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import{
inject,
injectable,
postConstruct,
}from'@theia/core/shared/inversify';
import{
BoardSearch,
BoardsPackage,
BoardsService,
}from'../../common/protocol/boards-service';
import{ListWidget}from'../widgets/component-list/list-widget';
import{ListItemRenderer}from'../widgets/component-list/list-item-renderer';
import{nls}from'@theia/core/lib/common';
import{BoardsFilterRenderer}from'../widgets/component-list/filter-renderer';
@injectable()
exportclassBoardsListWidgetextendsListWidget<BoardsPackage,BoardSearch>{
staticWIDGET_ID='boards-list-widget';
staticWIDGET_LABEL=nls.localize('arduino/boardsManager','Boards Manager');
constructor(
@inject(BoardsService)service: BoardsService,
@inject(ListItemRenderer)itemRenderer: ListItemRenderer<BoardsPackage>,
@inject(BoardsFilterRenderer)filterRenderer: BoardsFilterRenderer
){
super({
id: BoardsListWidget.WIDGET_ID,
label: BoardsListWidget.WIDGET_LABEL,
iconClass: 'fa fa-arduino-boards',
searchable: service,
installable: service,
itemLabel: (item: BoardsPackage)=>item.name,
itemRenderer,
filterRenderer,
defaultSearchOptions: {query: '',type: 'All'},
});
}
@postConstruct()
protectedoverrideinit(): void{
super.init();
this.toDispose.pushAll([
this.notificationCenter.onPlatformDidInstall(()=>
this.refresh(undefined)
),
this.notificationCenter.onPlatformDidUninstall(()=>
this.refresh(undefined)
),
]);
}
protectedoverrideasyncinstall({
item,
progressId,
version,
}: {
item: BoardsPackage;
progressId: string;
version: string;
}): Promise<void>{
awaitsuper.install({ item, progressId, version });
this.messageService.info(
nls.localize(
'arduino/board/succesfullyInstalledPlatform',
'Successfully installed platform {0}:{1}',
item.name,
version
),
{timeout: 3000}
);
}
protectedoverrideasyncuninstall({
item,
progressId,
}: {
item: BoardsPackage;
progressId: string;
}): Promise<void>{
awaitsuper.uninstall({ item, progressId });
this.messageService.info(
nls.localize(
'arduino/board/succesfullyUninstalledPlatform',
'Successfully uninstalled platform {0}:{1}',
item.name,
item.installedVersion!
),
{timeout: 3000}
);
}
}