@@ -5,9 +5,8 @@ import { EditorWidget } from '@theia/editor/lib/browser/editor-widget';
5
5
import { MessageService } from '@theia/core/lib/common/message-service' ;
6
6
import { CommandContribution , CommandRegistry , Command , CommandHandler } from '@theia/core/lib/common/command' ;
7
7
import { TabBarToolbarContribution , TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar' ;
8
- import { BoardsService } from '../common/protocol/boards-service ' ;
8
+ import { BoardsService , BoardsServiceClient , CoreService , Sketch , SketchesService , ToolOutputServiceClient } from '../common/protocol' ;
9
9
import { ArduinoCommands } from './arduino-commands' ;
10
- import { CoreService } from '../common/protocol/core-service' ;
11
10
import { BoardsServiceClientImpl } from './boards/boards-service-client-impl' ;
12
11
import { WorkspaceRootUriAwareCommandHandler , WorkspaceCommands } from '@theia/workspace/lib/browser/workspace-commands' ;
13
12
import { SelectionService , MenuContribution , MenuModelRegistry , MAIN_MENU_BAR , MenuPath } from '@theia/core' ;
@@ -19,8 +18,6 @@ import {
19
18
} from '@theia/core/lib/browser' ;
20
19
import { OpenFileDialogProps , FileDialogService } from '@theia/filesystem/lib/browser/file-dialog' ;
21
20
import { FileSystem , FileStat } from '@theia/filesystem/lib/common' ;
22
- import { Sketch , SketchesService } from '../common/protocol/sketches-service' ;
23
- import { ToolOutputServiceClient } from '../common/protocol/tool-output-service' ;
24
21
import { CommonCommands , CommonMenus } from '@theia/core/lib/browser/common-frontend-contribution' ;
25
22
import { FileSystemCommands } from '@theia/filesystem/lib/browser/filesystem-frontend-contribution' ;
26
23
import { FileDownloadCommands } from '@theia/filesystem/lib/browser/download/file-download-command-contribution' ;
@@ -45,6 +42,8 @@ import { ColorContribution } from '@theia/core/lib/browser/color-application-con
45
42
import { ColorRegistry } from '@theia/core/lib/browser/color-registry' ;
46
43
import { ArduinoDaemon } from '../common/protocol/arduino-daemon' ;
47
44
import { ConfigService } from '../common/protocol/config-service' ;
45
+ import { BoardsConfigStore } from './boards/boards-config-store' ;
46
+ import { MainMenuManager } from './menu/main-menu-manager' ;
48
47
49
48
export namespace ArduinoMenus {
50
49
export const SKETCH = [ ...MAIN_MENU_BAR , '3_sketch' ] ;
@@ -75,7 +74,11 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
75
74
protected readonly toolOutputServiceClient : ToolOutputServiceClient ;
76
75
77
76
@inject ( BoardsServiceClientImpl )
78
- protected readonly boardsServiceClient : BoardsServiceClientImpl ;
77
+ protected readonly boardsServiceClientImpl : BoardsServiceClientImpl ;
78
+
79
+ // Unused but do not remove it. It's required by DI, otherwise `init` method is not called.
80
+ @inject ( BoardsServiceClient )
81
+ protected readonly boardsServiceClient : BoardsServiceClient ;
79
82
80
83
@inject ( SelectionService )
81
84
protected readonly selectionService : SelectionService ;
@@ -143,6 +146,12 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
143
146
@inject ( ConfigService )
144
147
protected readonly configService : ConfigService ;
145
148
149
+ @inject ( BoardsConfigStore )
150
+ protected readonly boardsConfigStore : BoardsConfigStore ;
151
+
152
+ @inject ( MainMenuManager )
153
+ protected readonly mainMenuManager : MainMenuManager ;
154
+
146
155
protected application : FrontendApplication ;
147
156
protected wsSketchCount : number = 0 ; // TODO: this does not belong here, does it?
148
157
@@ -154,15 +163,10 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
154
163
text : BoardsConfig . Config . toString ( config )
155
164
} ) ;
156
165
}
157
- this . boardsServiceClient . onBoardsConfigChanged ( updateStatusBar ) ;
158
- updateStatusBar ( this . boardsServiceClient . boardsConfig ) ;
166
+ this . boardsServiceClientImpl . onBoardsConfigChanged ( updateStatusBar ) ;
167
+ updateStatusBar ( this . boardsServiceClientImpl . boardsConfig ) ;
159
168
160
169
this . registerSketchesInMenu ( this . menuRegistry ) ;
161
-
162
- Promise . all ( [
163
- this . boardsService . getAttachedBoards ( ) ,
164
- this . boardsService . getAvailablePorts ( )
165
- ] ) . then ( ( [ { boards } , { ports } ] ) => this . boardsServiceClient . tryReconnect ( boards , ports ) ) ;
166
170
}
167
171
168
172
onStart ( app : FrontendApplication ) : void {
@@ -210,8 +214,7 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
210
214
render : ( ) => < BoardsToolBarItem
211
215
key = 'boardsToolbarItem'
212
216
commands = { this . commandRegistry }
213
- boardsServiceClient = { this . boardsServiceClient }
214
- boardService = { this . boardsService } /> ,
217
+ boardsServiceClient = { this . boardsServiceClientImpl } /> ,
215
218
isVisible : widget => ArduinoToolbar . is ( widget ) && widget . side === 'left' ,
216
219
priority : 2
217
220
} ) ;
@@ -276,10 +279,7 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
276
279
} ) ;
277
280
278
281
registry . registerCommand ( ArduinoCommands . TOGGLE_COMPILE_FOR_DEBUG , {
279
- execute : ( ) => {
280
- this . editorMode . toggleCompileForDebug ( ) ;
281
- this . editorMode . menuContentChanged . fire ( ) ;
282
- } ,
282
+ execute : ( ) => this . editorMode . toggleCompileForDebug ( ) ,
283
283
isToggled : ( ) => this . editorMode . compileForDebug
284
284
} ) ;
285
285
@@ -345,7 +345,7 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
345
345
execute : async ( ) => {
346
346
const boardsConfig = await this . boardsConfigDialog . open ( ) ;
347
347
if ( boardsConfig ) {
348
- this . boardsServiceClient . boardsConfig = boardsConfig ;
348
+ this . boardsServiceClientImpl . boardsConfig = boardsConfig ;
349
349
}
350
350
}
351
351
} ) ;
@@ -377,18 +377,18 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
377
377
}
378
378
379
379
try {
380
- const { boardsConfig } = this . boardsServiceClient ;
380
+ const { boardsConfig } = this . boardsServiceClientImpl ;
381
381
if ( ! boardsConfig || ! boardsConfig . selectedBoard ) {
382
382
throw new Error ( 'No boards selected. Please select a board.' ) ;
383
383
}
384
384
if ( ! boardsConfig . selectedBoard . fqbn ) {
385
- throw new Error ( `No core is installed for ${ boardsConfig . selectedBoard . name } . Please install the board .` ) ;
385
+ throw new Error ( `No core is installed for the ' ${ boardsConfig . selectedBoard . name } ' board . Please install the core .` ) ;
386
386
}
387
- // Reveal the Output view asynchronously (don't await it)
387
+ const fqbn = await this . boardsConfigStore . appendConfigToFqbn ( boardsConfig . selectedBoard . fqbn ) ;
388
388
this . outputContribution . openView ( { reveal : true } ) ;
389
389
await this . coreService . compile ( {
390
- uri : uri . toString ( ) ,
391
- board : boardsConfig . selectedBoard ,
390
+ sketchUri : uri . toString ( ) ,
391
+ fqbn ,
392
392
optimizeForDebug : this . editorMode . compileForDebug
393
393
} ) ;
394
394
} catch ( e ) {
@@ -413,19 +413,22 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
413
413
}
414
414
415
415
try {
416
- const { boardsConfig } = this . boardsServiceClient ;
416
+ const { boardsConfig } = this . boardsServiceClientImpl ;
417
417
if ( ! boardsConfig || ! boardsConfig . selectedBoard ) {
418
418
throw new Error ( 'No boards selected. Please select a board.' ) ;
419
419
}
420
420
const { selectedPort } = boardsConfig ;
421
421
if ( ! selectedPort ) {
422
422
throw new Error ( 'No ports selected. Please select a port.' ) ;
423
423
}
424
- // Reveal the Output view asynchronously (don't await it)
424
+ if ( ! boardsConfig . selectedBoard . fqbn ) {
425
+ throw new Error ( `No core is installed for the '${ boardsConfig . selectedBoard . name } ' board. Please install the core.` ) ;
426
+ }
425
427
this . outputContribution . openView ( { reveal : true } ) ;
428
+ const fqbn = await this . boardsConfigStore . appendConfigToFqbn ( boardsConfig . selectedBoard . fqbn ) ;
426
429
await this . coreService . upload ( {
427
- uri : uri . toString ( ) ,
428
- board : boardsConfig . selectedBoard ,
430
+ sketchUri : uri . toString ( ) ,
431
+ fqbn ,
429
432
port : selectedPort . address ,
430
433
optimizeForDebug : this . editorMode . compileForDebug
431
434
} ) ;
0 commit comments