- Notifications
You must be signed in to change notification settings - Fork 440
/
Copy pathopen-settings.ts
80 lines (74 loc) · 2.27 KB
/
open-settings.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
import{nls}from'@theia/core/lib/common/nls';
import{inject,injectable}from'@theia/core/shared/inversify';
importtype{Settings}from'../dialogs/settings/settings';
import{SettingsDialog}from'../dialogs/settings/settings-dialog';
import{ArduinoMenus}from'../menu/arduino-menus';
import{
Command,
CommandRegistry,
KeybindingRegistry,
MenuModelRegistry,
SketchContribution,
}from'./contribution';
@injectable()
exportclassOpenSettingsextendsSketchContribution{
@inject(SettingsDialog)
privatereadonlysettingsDialog: SettingsDialog;
privatesettingsOpened=false;
overrideregisterCommands(registry: CommandRegistry): void{
registry.registerCommand(OpenSettings.Commands.OPEN,{
execute: async()=>{
letsettings: Settings|undefined=undefined;
try{
this.settingsOpened=true;
this.menuManager.update();
settings=awaitthis.settingsDialog.open();
}finally{
this.settingsOpened=false;
this.menuManager.update();
}
if(settings){
awaitthis.settingsService.update(settings);
awaitthis.settingsService.save();
}else{
awaitthis.settingsService.reset();
}
},
isEnabled: ()=>!this.settingsOpened,
});
}
overrideregisterMenus(registry: MenuModelRegistry): void{
registry.registerMenuAction(ArduinoMenus.FILE__PREFERENCES_GROUP,{
commandId: OpenSettings.Commands.OPEN.id,
label:
nls.localize(
'vscode/preferences.contribution/preferences',
'Preferences'
)+'...',
order: '0',
});
registry.registerSubmenu(
ArduinoMenus.FILE__ADVANCED_SUBMENU,
nls.localize('arduino/menu/advanced','Advanced')
);
}
overrideregisterKeybindings(registry: KeybindingRegistry): void{
registry.registerKeybinding({
command: OpenSettings.Commands.OPEN.id,
keybinding: 'CtrlCmd+,',
});
}
}
exportnamespaceOpenSettings{
exportnamespaceCommands{
exportconstOPEN: Command={
id: 'arduino-settings-open',
label:
nls.localize(
'vscode/preferences.contribution/openSettings2',
'Open Preferences'
)+'...',
category: 'Arduino',
};
}
}