@@ -5,17 +5,14 @@ import {
55 postConstruct ,
66} from '@theia/core/shared/inversify' ;
77import * as React from '@theia/core/shared/react' ;
8- import { SketchesService } from '../common/protocol' ;
98import {
109 MAIN_MENU_BAR ,
1110 MenuContribution ,
1211 MenuModelRegistry ,
1312} from '@theia/core' ;
1413import {
15- Dialog ,
1614 FrontendApplication ,
1715 FrontendApplicationContribution ,
18- OnWillStopAction ,
1916} from '@theia/core/lib/browser' ;
2017import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution' ;
2118import { ColorRegistry } from '@theia/core/lib/browser/color-registry' ;
@@ -34,14 +31,9 @@ import { EditorCommands, EditorMainMenu } from '@theia/editor/lib/browser';
3431import { MonacoMenus } from '@theia/monaco/lib/browser/monaco-menu' ;
3532import { FileNavigatorCommands } from '@theia/navigator/lib/browser/navigator-contribution' ;
3633import { TerminalMenus } from '@theia/terminal/lib/browser/terminal-frontend-contribution' ;
37- import {
38- CurrentSketch ,
39- SketchesServiceClientImpl ,
40- } from '../common/protocol/sketches-service-client-impl' ;
4134import { ArduinoPreferences } from './arduino-preferences' ;
4235import { BoardsServiceProvider } from './boards/boards-service-provider' ;
4336import { BoardsToolBarItem } from './boards/boards-toolbar-item' ;
44- import { SaveAsSketch } from './contributions/save-as-sketch' ;
4537import { ArduinoMenus } from './menu/arduino-menus' ;
4638import { MonitorViewContribution } from './serial/monitor/monitor-view-contribution' ;
4739import { ArduinoToolbar } from './toolbar/arduino-toolbar' ;
@@ -63,18 +55,12 @@ export class ArduinoFrontendContribution
6355 @inject ( BoardsServiceProvider )
6456 private readonly boardsServiceProvider : BoardsServiceProvider ;
6557
66- @inject ( SketchesService )
67- private readonly sketchService : SketchesService ;
68-
6958 @inject ( CommandRegistry )
7059 private readonly commandRegistry : CommandRegistry ;
7160
7261 @inject ( ArduinoPreferences )
7362 private readonly arduinoPreferences : ArduinoPreferences ;
7463
75- @inject ( SketchesServiceClientImpl )
76- private readonly sketchServiceClient : SketchesServiceClientImpl ;
77-
7864 @inject ( FrontendApplicationStateService )
7965 private readonly appStateService : FrontendApplicationStateService ;
8066
@@ -91,7 +77,7 @@ export class ArduinoFrontendContribution
9177 }
9278 }
9379
94- async onStart ( app : FrontendApplication ) : Promise < void > {
80+ onStart ( app : FrontendApplication ) : void {
9581 this . arduinoPreferences . onPreferenceChanged ( ( event ) => {
9682 if ( event . newValue !== event . oldValue ) {
9783 switch ( event . preferenceName ) {
@@ -303,58 +289,4 @@ export class ArduinoFrontendContribution
303289 }
304290 ) ;
305291 }
306-
307- // TODO: should be handled by `Close` contribution. https://github.com/arduino/arduino-ide/issues/1016
308- onWillStop ( ) : OnWillStopAction {
309- return {
310- reason : 'temp-sketch' ,
311- action : ( ) => {
312- return this . showTempSketchDialog ( ) ;
313- } ,
314- } ;
315- }
316-
317- private async showTempSketchDialog ( ) : Promise < boolean > {
318- const sketch = await this . sketchServiceClient . currentSketch ( ) ;
319- if ( ! CurrentSketch . isValid ( sketch ) ) {
320- return true ;
321- }
322- const isTemp = await this . sketchService . isTemp ( sketch ) ;
323- if ( ! isTemp ) {
324- return true ;
325- }
326- const messageBoxResult = await remote . dialog . showMessageBox (
327- remote . getCurrentWindow ( ) ,
328- {
329- message : nls . localize (
330- 'arduino/sketch/saveTempSketch' ,
331- 'Save your sketch to open it again later.'
332- ) ,
333- title : nls . localize (
334- 'theia/core/quitTitle' ,
335- 'Are you sure you want to quit?'
336- ) ,
337- type : 'question' ,
338- buttons : [
339- Dialog . CANCEL ,
340- nls . localizeByDefault ( 'Save As...' ) ,
341- nls . localizeByDefault ( "Don't Save" ) ,
342- ] ,
343- }
344- ) ;
345- const result = messageBoxResult . response ;
346- if ( result === 2 ) {
347- return true ;
348- } else if ( result === 1 ) {
349- return ! ! ( await this . commandRegistry . executeCommand (
350- SaveAsSketch . Commands . SAVE_AS_SKETCH . id ,
351- {
352- execOnlyIfTemp : false ,
353- openAfterMove : false ,
354- wipeOriginal : true ,
355- }
356- ) ) ;
357- }
358- return false ;
359- }
360292}
0 commit comments