@@ -15,23 +15,30 @@ import { QuickPickService } from '@theia/core/lib/common/quick-pick-service';
15
15
import { BoardsListWidgetFrontendContribution } from './boards/boards-widget-frontend-contribution' ;
16
16
import { BoardsNotificationService } from './boards-notification-service' ;
17
17
import { WorkspaceRootUriAwareCommandHandler , WorkspaceCommands } from '@theia/workspace/lib/browser/workspace-commands' ;
18
- import { SelectionService , MenuModelRegistry } from '@theia/core' ;
18
+ import { SelectionService , MenuContribution , MenuModelRegistry , MAIN_MENU_BAR } from '@theia/core' ;
19
19
import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service' ;
20
20
import { SketchFactory } from './sketch-factory' ;
21
21
import { ArduinoToolbar } from './toolbar/arduino-toolbar' ;
22
- import { EditorManager } from '@theia/editor/lib/browser' ;
22
+ import { EditorManager , EditorMainMenu } from '@theia/editor/lib/browser' ;
23
23
import { ContextMenuRenderer , OpenerService , Widget } from '@theia/core/lib/browser' ;
24
24
import { OpenFileDialogProps , FileDialogService } from '@theia/filesystem/lib/browser/file-dialog' ;
25
25
import { FileSystem } from '@theia/filesystem/lib/common' ;
26
26
import { ArduinoToolbarContextMenu } from './arduino-file-menu' ;
27
27
import { Sketch , SketchesService } from '../common/protocol/sketches-service' ;
28
28
import { WindowService } from '@theia/core/lib/browser/window/window-service' ;
29
- import { CommonCommands } from '@theia/core/lib/browser/common-frontend-contribution'
30
- import { BoardsToolBarItem } from './boards/boards-toolbar-item' ;
31
- import { SelectBoardDialog } from './boards/select-board-dialog' ;
29
+ import { CommonCommands , CommonMenus } from '@theia/core/lib/browser/common-frontend-contribution' ;
30
+ import { FileSystemCommands } from '@theia/filesystem/lib/browser/filesystem-frontend-contribution' ;
31
+ import { FileDownloadCommands } from '@theia/filesystem/lib/browser/download/file-download-command-contribution' ;
32
+ import { MonacoMenus } from '@theia/monaco/lib/browser/monaco-menu' ;
33
+ import { TerminalMenus } from '@theia/terminal/lib/browser/terminal-frontend-contribution' ;
34
+
35
+ export namespace ArduinoMenus {
36
+ export const SKETCH = [ ...MAIN_MENU_BAR , '3_sketch' ] ;
37
+ export const TOOLS = [ ...MAIN_MENU_BAR , '4_tools' ] ;
38
+ }
32
39
33
40
@injectable ( )
34
- export class ArduinoFrontendContribution implements TabBarToolbarContribution , CommandContribution {
41
+ export class ArduinoFrontendContribution implements TabBarToolbarContribution , CommandContribution , MenuContribution {
35
42
36
43
@inject ( MessageService )
37
44
protected readonly messageService : MessageService ;
@@ -180,7 +187,7 @@ export class ArduinoFrontendContribution implements TabBarToolbarContribution, C
180
187
registerCommands ( registry : CommandRegistry ) : void {
181
188
registry . registerCommand ( ArduinoCommands . VERIFY , {
182
189
isVisible : widget => this . isArduinoToolbar ( widget ) ,
183
- isEnabled : widget => this . isArduinoToolbar ( widget ) ,
190
+ isEnabled : widget => true ,
184
191
execute : async ( ) => {
185
192
const widget = this . getCurrentWidget ( ) ;
186
193
if ( widget instanceof EditorWidget ) {
@@ -201,7 +208,7 @@ export class ArduinoFrontendContribution implements TabBarToolbarContribution, C
201
208
} ) ;
202
209
registry . registerCommand ( ArduinoCommands . UPLOAD , {
203
210
isVisible : widget => this . isArduinoToolbar ( widget ) ,
204
- isEnabled : widget => this . isArduinoToolbar ( widget ) ,
211
+ isEnabled : widget => true ,
205
212
execute : async ( ) => {
206
213
const widget = this . getCurrentWidget ( ) ;
207
214
if ( widget instanceof EditorWidget ) {
@@ -292,6 +299,46 @@ export class ArduinoFrontendContribution implements TabBarToolbarContribution, C
292
299
}
293
300
this . selectedBoard = board ;
294
301
}
302
+
303
+ registerMenus ( registry : MenuModelRegistry ) {
304
+ registry . unregisterMenuAction ( FileSystemCommands . UPLOAD ) ;
305
+ registry . unregisterMenuAction ( FileDownloadCommands . DOWNLOAD ) ;
306
+
307
+ registry . unregisterMenuAction ( WorkspaceCommands . NEW_FILE ) ;
308
+ registry . unregisterMenuAction ( WorkspaceCommands . NEW_FOLDER ) ;
309
+
310
+ registry . unregisterMenuAction ( WorkspaceCommands . OPEN_FOLDER ) ;
311
+ registry . unregisterMenuAction ( WorkspaceCommands . OPEN_WORKSPACE ) ;
312
+ registry . unregisterMenuAction ( WorkspaceCommands . OPEN_RECENT_WORKSPACE ) ;
313
+ registry . unregisterMenuAction ( WorkspaceCommands . SAVE_WORKSPACE_AS ) ;
314
+ registry . unregisterMenuAction ( WorkspaceCommands . CLOSE ) ;
315
+
316
+ registry . getMenu ( MAIN_MENU_BAR ) . removeNode ( this . getMenuId ( MonacoMenus . SELECTION ) ) ;
317
+ registry . getMenu ( MAIN_MENU_BAR ) . removeNode ( this . getMenuId ( EditorMainMenu . GO ) ) ;
318
+ registry . getMenu ( MAIN_MENU_BAR ) . removeNode ( this . getMenuId ( TerminalMenus . TERMINAL ) ) ;
319
+ registry . getMenu ( MAIN_MENU_BAR ) . removeNode ( this . getMenuId ( CommonMenus . VIEW ) ) ;
320
+ registry . getMenu ( MAIN_MENU_BAR ) . removeNode ( this . getMenuId ( CommonMenus . HELP ) ) ;
321
+
322
+ registry . registerSubmenu ( ArduinoMenus . SKETCH , 'Sketch' ) ;
323
+ registry . registerMenuAction ( ArduinoMenus . SKETCH , {
324
+ commandId : ArduinoCommands . VERIFY . id ,
325
+ label : 'Verify/Compile' ,
326
+ order : '1'
327
+ } ) ;
328
+ registry . registerMenuAction ( ArduinoMenus . SKETCH , {
329
+ commandId : ArduinoCommands . UPLOAD . id ,
330
+ label : 'Upload' ,
331
+ order : '2'
332
+ } ) ;
333
+
334
+ registry . registerSubmenu ( ArduinoMenus . TOOLS , 'Tools' ) ;
335
+ }
336
+
337
+ protected getMenuId ( menuPath : string [ ] ) : string {
338
+ const index = menuPath . length - 1 ;
339
+ const menuId = menuPath [ index ] ;
340
+ return menuId ;
341
+ }
295
342
296
343
protected async openSketchFilesInNewWindow ( uri : string ) {
297
344
const location = new URL ( window . location . href ) ;
0 commit comments