- Notifications
You must be signed in to change notification settings - Fork 440
/
Copy pathopen-sketch-external.ts
56 lines (51 loc) · 1.65 KB
/
open-sketch-external.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
import{injectable}from'@theia/core/shared/inversify';
importURIfrom'@theia/core/lib/common/uri';
import{ArduinoMenus}from'../menu/arduino-menus';
import{
SketchContribution,
Command,
CommandRegistry,
MenuModelRegistry,
KeybindingRegistry,
}from'./contribution';
import{nls}from'@theia/core/lib/common/nls';
@injectable()
exportclassOpenSketchExternalextendsSketchContribution{
overrideregisterCommands(registry: CommandRegistry): void{
registry.registerCommand(OpenSketchExternal.Commands.OPEN_EXTERNAL,{
execute: ()=>this.openExternal(),
});
}
overrideregisterMenus(registry: MenuModelRegistry): void{
registry.registerMenuAction(ArduinoMenus.SKETCH__UTILS_GROUP,{
commandId: OpenSketchExternal.Commands.OPEN_EXTERNAL.id,
label: nls.localize('arduino/sketch/showFolder','Show Sketch Folder'),
order: '0',
});
}
overrideregisterKeybindings(registry: KeybindingRegistry): void{
registry.registerKeybinding({
command: OpenSketchExternal.Commands.OPEN_EXTERNAL.id,
keybinding: 'CtrlCmd+Alt+K',
});
}
protectedasyncopenExternal(): Promise<void>{
consturi=awaitthis.sketchServiceClient.currentSketchFile();
if(uri){
constexists=awaitthis.fileService.exists(newURI(uri));
if(exists){
constfsPath=awaitthis.fileService.fsPath(newURI(uri));
if(fsPath){
window.electronTheiaCore.showItemInFolder(fsPath);
}
}
}
}
}
exportnamespaceOpenSketchExternal{
exportnamespaceCommands{
exportconstOPEN_EXTERNAL: Command={
id: 'arduino-open-sketch-external',
};
}
}