@@ -5,17 +5,14 @@ import {
5
5
postConstruct ,
6
6
} from '@theia/core/shared/inversify' ;
7
7
import * as React from '@theia/core/shared/react' ;
8
- import { SketchesService } from '../common/protocol' ;
9
8
import {
10
9
MAIN_MENU_BAR ,
11
10
MenuContribution ,
12
11
MenuModelRegistry ,
13
12
} from '@theia/core' ;
14
13
import {
15
- Dialog ,
16
14
FrontendApplication ,
17
15
FrontendApplicationContribution ,
18
- OnWillStopAction ,
19
16
} from '@theia/core/lib/browser' ;
20
17
import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution' ;
21
18
import { ColorRegistry } from '@theia/core/lib/browser/color-registry' ;
@@ -34,14 +31,9 @@ import { EditorCommands, EditorMainMenu } from '@theia/editor/lib/browser';
34
31
import { MonacoMenus } from '@theia/monaco/lib/browser/monaco-menu' ;
35
32
import { FileNavigatorCommands } from '@theia/navigator/lib/browser/navigator-contribution' ;
36
33
import { TerminalMenus } from '@theia/terminal/lib/browser/terminal-frontend-contribution' ;
37
- import {
38
- CurrentSketch ,
39
- SketchesServiceClientImpl ,
40
- } from '../common/protocol/sketches-service-client-impl' ;
41
34
import { ArduinoPreferences } from './arduino-preferences' ;
42
35
import { BoardsServiceProvider } from './boards/boards-service-provider' ;
43
36
import { BoardsToolBarItem } from './boards/boards-toolbar-item' ;
44
- import { SaveAsSketch } from './contributions/save-as-sketch' ;
45
37
import { ArduinoMenus } from './menu/arduino-menus' ;
46
38
import { MonitorViewContribution } from './serial/monitor/monitor-view-contribution' ;
47
39
import { ArduinoToolbar } from './toolbar/arduino-toolbar' ;
@@ -63,18 +55,12 @@ export class ArduinoFrontendContribution
63
55
@inject ( BoardsServiceProvider )
64
56
private readonly boardsServiceProvider : BoardsServiceProvider ;
65
57
66
- @inject ( SketchesService )
67
- private readonly sketchService : SketchesService ;
68
-
69
58
@inject ( CommandRegistry )
70
59
private readonly commandRegistry : CommandRegistry ;
71
60
72
61
@inject ( ArduinoPreferences )
73
62
private readonly arduinoPreferences : ArduinoPreferences ;
74
63
75
- @inject ( SketchesServiceClientImpl )
76
- private readonly sketchServiceClient : SketchesServiceClientImpl ;
77
-
78
64
@inject ( FrontendApplicationStateService )
79
65
private readonly appStateService : FrontendApplicationStateService ;
80
66
@@ -91,7 +77,7 @@ export class ArduinoFrontendContribution
91
77
}
92
78
}
93
79
94
- async onStart ( app : FrontendApplication ) : Promise < void > {
80
+ onStart ( app : FrontendApplication ) : void {
95
81
this . arduinoPreferences . onPreferenceChanged ( ( event ) => {
96
82
if ( event . newValue !== event . oldValue ) {
97
83
switch ( event . preferenceName ) {
@@ -303,58 +289,4 @@ export class ArduinoFrontendContribution
303
289
}
304
290
) ;
305
291
}
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
- }
360
292
}
0 commit comments