2
2
import { injectable , inject } from 'inversify' ;
3
3
import { EditorWidget } from '@theia/editor/lib/browser' ;
4
4
import { CommandService } from '@theia/core/lib/common/command' ;
5
+ import { MessageService } from '@theia/core/lib/common/message-service' ;
5
6
import { OutputWidget } from '@theia/output/lib/browser/output-widget' ;
7
+ import { ConnectionStatusService , ConnectionStatus } from '@theia/core/lib/browser/connection-status-service' ;
6
8
import { ApplicationShell as TheiaApplicationShell , Widget } from '@theia/core/lib/browser' ;
7
9
import { Sketch } from '../../../common/protocol' ;
8
10
import { EditorMode } from '../../editor-mode' ;
@@ -18,9 +20,15 @@ export class ApplicationShell extends TheiaApplicationShell {
18
20
@inject ( CommandService )
19
21
protected readonly commandService : CommandService ;
20
22
23
+ @inject ( MessageService )
24
+ protected readonly messageService : MessageService ;
25
+
21
26
@inject ( SketchesServiceClientImpl )
22
27
protected readonly sketchesServiceClient : SketchesServiceClientImpl ;
23
28
29
+ @inject ( ConnectionStatusService )
30
+ protected readonly connectionStatusService : ConnectionStatusService ;
31
+
24
32
protected track ( widget : Widget ) : void {
25
33
super . track ( widget ) ;
26
34
if ( widget instanceof OutputWidget ) {
@@ -60,6 +68,10 @@ export class ApplicationShell extends TheiaApplicationShell {
60
68
}
61
69
62
70
async saveAll ( ) : Promise < void > {
71
+ if ( this . connectionStatusService . currentStatus === ConnectionStatus . OFFLINE ) {
72
+ this . messageService . error ( 'Could not save the sketch. Please copy your unsaved work into your favorite text editor, and restart the IDE.' ) ;
73
+ return ; // Theia does not reject on failed save: https://github.com/eclipse-theia/theia/pull/8803
74
+ }
63
75
await super . saveAll ( ) ;
64
76
const options = { execOnlyIfTemp : true , openAfterMove : true } ;
65
77
await this . commandService . executeCommand ( SaveAsSketch . Commands . SAVE_AS_SKETCH . id , options ) ;
0 commit comments