- Notifications
You must be signed in to change notification settings - Fork 440
/
Copy pathupload-firmware.ts
52 lines (47 loc) · 1.49 KB
/
upload-firmware.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
import{inject,injectable}from'@theia/core/shared/inversify';
import{
Command,
MenuModelRegistry,
CommandRegistry,
Contribution,
}from'./contribution';
import{ArduinoMenus}from'../menu/arduino-menus';
import{UploadFirmwareDialog}from'../dialogs/firmware-uploader/firmware-uploader-dialog';
import{nls}from'@theia/core/lib/common';
@injectable()
exportclassUploadFirmwareextendsContribution{
@inject(UploadFirmwareDialog)
protectedreadonlydialog: UploadFirmwareDialog;
protecteddialogOpened=false;
overrideregisterCommands(registry: CommandRegistry): void{
registry.registerCommand(UploadFirmware.Commands.OPEN,{
execute: async()=>{
try{
this.dialogOpened=true;
this.menuManager.update();
awaitthis.dialog.open();
}finally{
this.dialogOpened=false;
this.menuManager.update();
}
},
isEnabled: ()=>!this.dialogOpened,
});
}
overrideregisterMenus(registry: MenuModelRegistry): void{
registry.registerMenuAction(ArduinoMenus.TOOLS__FIRMWARE_UPLOADER_GROUP,{
commandId: UploadFirmware.Commands.OPEN.id,
label: UploadFirmware.Commands.OPEN.label,
order: '0',
});
}
}
exportnamespaceUploadFirmware{
exportnamespaceCommands{
exportconstOPEN: Command={
id: 'arduino-upload-firmware-open',
label: nls.localize('arduino/firmware/updater','Firmware Updater'),
category: 'Arduino',
};
}
}