Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cff2c95

Browse filesBrowse files
Akos Kittakittaakos
Akos Kitta
authored andcommitted
ATL-667: Warn the user when could not save sketch.
- Log the PID of the backend process. - Aligned the dev startup mode with the production: `--no-cluster`. Signed-off-by: Akos Kitta <kittaakos@typefox.io>
1 parent 1a531db commit cff2c95
Copy full SHA for cff2c95

File tree

Expand file treeCollapse file tree

6 files changed

+1299
-1277
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+1299
-1277
lines changed

‎.vscode/launch.json

Copy file name to clipboardExpand all lines: .vscode/launch.json
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
"args": [
3535
"--log-level=debug",
3636
"--hostname=localhost",
37-
"--no-cluster",
3837
"--remote-debugging-port=9222",
3938
"--no-app-auto-install",
4039
"--plugins=local-dir:plugins"
@@ -61,7 +60,6 @@
6160
"args": [
6261
"--hostname=0.0.0.0",
6362
"--port=3000",
64-
"--no-cluster",
6563
"--no-app-auto-install",
6664
"--plugins=local-dir:plugins"
6765
],

‎arduino-ide-extension/src/browser/theia/core/application-shell.ts

Copy file name to clipboardExpand all lines: arduino-ide-extension/src/browser/theia/core/application-shell.ts
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
import { injectable, inject } from 'inversify';
33
import { EditorWidget } from '@theia/editor/lib/browser';
44
import { CommandService } from '@theia/core/lib/common/command';
5+
import { MessageService } from '@theia/core/lib/common/message-service';
56
import { OutputWidget } from '@theia/output/lib/browser/output-widget';
7+
import { ConnectionStatusService, ConnectionStatus } from '@theia/core/lib/browser/connection-status-service';
68
import { ApplicationShell as TheiaApplicationShell, Widget } from '@theia/core/lib/browser';
79
import { Sketch } from '../../../common/protocol';
810
import { EditorMode } from '../../editor-mode';
@@ -18,9 +20,15 @@ export class ApplicationShell extends TheiaApplicationShell {
1820
@inject(CommandService)
1921
protected readonly commandService: CommandService;
2022

23+
@inject(MessageService)
24+
protected readonly messageService: MessageService;
25+
2126
@inject(SketchesServiceClientImpl)
2227
protected readonly sketchesServiceClient: SketchesServiceClientImpl;
2328

29+
@inject(ConnectionStatusService)
30+
protected readonly connectionStatusService: ConnectionStatusService;
31+
2432
protected track(widget: Widget): void {
2533
super.track(widget);
2634
if (widget instanceof OutputWidget) {
@@ -60,6 +68,10 @@ export class ApplicationShell extends TheiaApplicationShell {
6068
}
6169

6270
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+
}
6375
await super.saveAll();
6476
const options = { execOnlyIfTemp: true, openAfterMove: true };
6577
await this.commandService.executeCommand(SaveAsSketch.Commands.SAVE_AS_SKETCH.id, options);
+28Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { inject, injectable } from 'inversify';
2+
import { remote } from 'electron';
3+
import { ConnectionStatus, ConnectionStatusService } from '@theia/core/lib/browser/connection-status-service';
4+
import { ElectronWindowService as TheiaElectronWindowService } from '@theia/core/lib/electron-browser/window/electron-window-service';
5+
6+
@injectable()
7+
export class ElectronWindowService extends TheiaElectronWindowService {
8+
9+
@inject(ConnectionStatusService)
10+
protected readonly connectionStatusService: ConnectionStatusService;
11+
12+
protected shouldUnload(): boolean {
13+
const offline = this.connectionStatusService.currentStatus === ConnectionStatus.OFFLINE;
14+
const detail = offline
15+
? 'Could not save the sketch. Please copy your unsaved work into your favorite text editor, and restart the IDE.'
16+
: 'Any unsaved changes will not be saved.'
17+
const electronWindow = remote.getCurrentWindow();
18+
const response = remote.dialog.showMessageBoxSync(electronWindow, {
19+
type: 'question',
20+
buttons: ['Yes', 'No'],
21+
title: 'Confirm',
22+
message: 'Are you sure you want to close the sketch?',
23+
detail
24+
});
25+
return response === 0; // 'Yes', close the window.
26+
}
27+
28+
}
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import { ContainerModule } from 'inversify';
2+
import { WindowService } from '@theia/core/lib/browser/window/window-service';
3+
import { ElectronMainMenuFactory as TheiaElectronMainMenuFactory } from '@theia/core/lib/electron-browser/menu/electron-main-menu-factory';
24
import { ElectronMenuContribution as TheiaElectronMenuContribution } from '@theia/core/lib/electron-browser/menu/electron-menu-contribution'
3-
import { ElectronMenuContribution } from './electron-menu-contribution';
45
import { MainMenuManager } from '../../../common/main-menu-manager';
5-
import { ElectronMainMenuFactory as TheiaElectronMainMenuFactory } from '@theia/core/lib/electron-browser/menu/electron-main-menu-factory';
6+
import { ElectronWindowService } from '../../electron-window-service';
67
import { ElectronMainMenuFactory } from './electron-main-menu-factory';
8+
import { ElectronMenuContribution } from './electron-menu-contribution';
79

810
export default new ContainerModule((bind, unbind, isBound, rebind) => {
911
bind(ElectronMenuContribution).toSelf().inSingletonScope();
1012
bind(MainMenuManager).toService(ElectronMenuContribution);
1113
rebind(TheiaElectronMenuContribution).to(ElectronMenuContribution);
1214
bind(ElectronMainMenuFactory).toSelf().inRequestScope();
1315
rebind(TheiaElectronMainMenuFactory).toService(ElectronMainMenuFactory);
16+
bind(ElectronWindowService).toSelf().inSingletonScope()
17+
rebind(WindowService).toService(ElectronWindowService);
1418
});

‎arduino-ide-extension/src/electron-main/theia/electron-main-application.ts

Copy file name to clipboardExpand all lines: arduino-ide-extension/src/electron-main/theia/electron-main-application.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
5757
args,
5858
await this.getForkOptions(),
5959
);
60+
console.log(`Starting backend process. PID: ${backendProcess.pid}`);
6061
return new Promise((resolve, reject) => {
6162
// The backend server main file is also supposed to send the resolved http(s) server port via IPC.
6263
backendProcess.on('message', (address: AddressInfo) => {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.