Skip to content

Commit feb6b89

Browse files
author
Akos Kitta
committed
Made the file dialogs modal.
Signed-off-by: Akos Kitta <[email protected]>
1 parent 6983c5b commit feb6b89

File tree

6 files changed

+68
-54
lines changed

6 files changed

+68
-54
lines changed

Diff for: arduino-ide-extension/src/browser/contributions/add-file.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { CurrentSketch } from '../../common/protocol/sketches-service-client-imp
1515
@injectable()
1616
export class AddFile extends SketchContribution {
1717
@inject(FileDialogService)
18-
protected readonly fileDialogService: FileDialogService;
18+
private readonly fileDialogService: FileDialogService;
1919

2020
override registerCommands(registry: CommandRegistry): void {
2121
registry.registerCommand(AddFile.Commands.ADD_FILE, {
@@ -31,7 +31,7 @@ export class AddFile extends SketchContribution {
3131
});
3232
}
3333

34-
protected async addFile(): Promise<void> {
34+
private async addFile(): Promise<void> {
3535
const sketch = await this.sketchServiceClient.currentSketch();
3636
if (!CurrentSketch.isValid(sketch)) {
3737
return;
@@ -41,6 +41,7 @@ export class AddFile extends SketchContribution {
4141
canSelectFiles: true,
4242
canSelectFolders: false,
4343
canSelectMany: false,
44+
modal: true,
4445
});
4546
if (!toAddUri) {
4647
return;

Diff for: arduino-ide-extension/src/browser/contributions/add-zip-library.ts

+21-18
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ import { nls } from '@theia/core/lib/common';
1717
@injectable()
1818
export class AddZipLibrary extends SketchContribution {
1919
@inject(EnvVariablesServer)
20-
protected readonly envVariableServer: EnvVariablesServer;
20+
private readonly envVariableServer: EnvVariablesServer;
2121

2222
@inject(ResponseServiceClient)
23-
protected readonly responseService: ResponseServiceClient;
23+
private readonly responseService: ResponseServiceClient;
2424

2525
@inject(LibraryService)
26-
protected readonly libraryService: LibraryService;
26+
private readonly libraryService: LibraryService;
2727

2828
override registerCommands(registry: CommandRegistry): void {
2929
registry.registerCommand(AddZipLibrary.Commands.ADD_ZIP_LIBRARY, {
@@ -43,23 +43,26 @@ export class AddZipLibrary extends SketchContribution {
4343
});
4444
}
4545

46-
async addZipLibrary(): Promise<void> {
46+
private async addZipLibrary(): Promise<void> {
4747
const homeUri = await this.envVariableServer.getHomeDirUri();
4848
const defaultPath = await this.fileService.fsPath(new URI(homeUri));
49-
const { canceled, filePaths } = await remote.dialog.showOpenDialog({
50-
title: nls.localize(
51-
'arduino/selectZip',
52-
"Select a zip file containing the library you'd like to add"
53-
),
54-
defaultPath,
55-
properties: ['openFile'],
56-
filters: [
57-
{
58-
name: nls.localize('arduino/library/zipLibrary', 'Library'),
59-
extensions: ['zip'],
60-
},
61-
],
62-
});
49+
const { canceled, filePaths } = await remote.dialog.showOpenDialog(
50+
remote.getCurrentWindow(),
51+
{
52+
title: nls.localize(
53+
'arduino/selectZip',
54+
"Select a zip file containing the library you'd like to add"
55+
),
56+
defaultPath,
57+
properties: ['openFile'],
58+
filters: [
59+
{
60+
name: nls.localize('arduino/library/zipLibrary', 'Library'),
61+
extensions: ['zip'],
62+
},
63+
],
64+
}
65+
);
6366
if (!canceled && filePaths.length) {
6467
const zipUri = await this.fileSystemExt.getUri(filePaths[0]);
6568
try {

Diff for: arduino-ide-extension/src/browser/contributions/archive-sketch.ts

+11-8
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class ArchiveSketch extends SketchContribution {
2828
});
2929
}
3030

31-
protected async archiveSketch(): Promise<void> {
31+
private async archiveSketch(): Promise<void> {
3232
const [sketch, config] = await Promise.all([
3333
this.sketchServiceClient.currentSketch(),
3434
this.configService.getConfiguration(),
@@ -43,13 +43,16 @@ export class ArchiveSketch extends SketchContribution {
4343
const defaultPath = await this.fileService.fsPath(
4444
new URI(config.sketchDirUri).resolve(archiveBasename)
4545
);
46-
const { filePath, canceled } = await remote.dialog.showSaveDialog({
47-
title: nls.localize(
48-
'arduino/sketch/saveSketchAs',
49-
'Save sketch folder as...'
50-
),
51-
defaultPath,
52-
});
46+
const { filePath, canceled } = await remote.dialog.showSaveDialog(
47+
remote.getCurrentWindow(),
48+
{
49+
title: nls.localize(
50+
'arduino/sketch/saveSketchAs',
51+
'Save sketch folder as...'
52+
),
53+
defaultPath,
54+
}
55+
);
5356
if (!filePath || canceled) {
5457
return;
5558
}

Diff for: arduino-ide-extension/src/browser/contributions/open-sketch.ts

+21-18
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,21 @@ import { nls } from '@theia/core/lib/common';
2626
@injectable()
2727
export class OpenSketch extends SketchContribution {
2828
@inject(MenuModelRegistry)
29-
protected readonly menuRegistry: MenuModelRegistry;
29+
private readonly menuRegistry: MenuModelRegistry;
3030

3131
@inject(ContextMenuRenderer)
32-
protected readonly contextMenuRenderer: ContextMenuRenderer;
32+
private readonly contextMenuRenderer: ContextMenuRenderer;
3333

3434
@inject(BuiltInExamples)
35-
protected readonly builtInExamples: BuiltInExamples;
35+
private readonly builtInExamples: BuiltInExamples;
3636

3737
@inject(ExamplesService)
38-
protected readonly examplesService: ExamplesService;
38+
private readonly examplesService: ExamplesService;
3939

4040
@inject(Sketchbook)
41-
protected readonly sketchbook: Sketchbook;
41+
private readonly sketchbook: Sketchbook;
4242

43-
protected readonly toDispose = new DisposableCollection();
43+
private readonly toDispose = new DisposableCollection();
4444

4545
override registerCommands(registry: CommandRegistry): void {
4646
registry.registerCommand(OpenSketch.Commands.OPEN_SKETCH, {
@@ -130,7 +130,7 @@ export class OpenSketch extends SketchContribution {
130130
});
131131
}
132132

133-
async openSketch(
133+
private async openSketch(
134134
toOpen: MaybePromise<Sketch | undefined> = this.selectSketch()
135135
): Promise<void> {
136136
const sketch = await toOpen;
@@ -139,21 +139,24 @@ export class OpenSketch extends SketchContribution {
139139
}
140140
}
141141

142-
protected async selectSketch(): Promise<Sketch | undefined> {
142+
private async selectSketch(): Promise<Sketch | undefined> {
143143
const config = await this.configService.getConfiguration();
144144
const defaultPath = await this.fileService.fsPath(
145145
new URI(config.sketchDirUri)
146146
);
147-
const { filePaths } = await remote.dialog.showOpenDialog({
148-
defaultPath,
149-
properties: ['createDirectory', 'openFile'],
150-
filters: [
151-
{
152-
name: nls.localize('arduino/sketch/sketch', 'Sketch'),
153-
extensions: ['ino', 'pde'],
154-
},
155-
],
156-
});
147+
const { filePaths } = await remote.dialog.showOpenDialog(
148+
remote.getCurrentWindow(),
149+
{
150+
defaultPath,
151+
properties: ['createDirectory', 'openFile'],
152+
filters: [
153+
{
154+
name: nls.localize('arduino/sketch/sketch', 'Sketch'),
155+
extensions: ['ino', 'pde'],
156+
},
157+
],
158+
}
159+
);
157160
if (!filePaths.length) {
158161
return undefined;
159162
}

Diff for: arduino-ide-extension/src/browser/contributions/save-as-sketch.ts

+11-8
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class SaveAsSketch extends SketchContribution {
5050
/**
5151
* Resolves `true` if the sketch was successfully saved as something.
5252
*/
53-
async saveAs(
53+
private async saveAs(
5454
{
5555
execOnlyIfTemp,
5656
openAfterMove,
@@ -82,13 +82,16 @@ export class SaveAsSketch extends SketchContribution {
8282
: sketch.name
8383
);
8484
const defaultPath = await this.fileService.fsPath(defaultUri);
85-
const { filePath, canceled } = await remote.dialog.showSaveDialog({
86-
title: nls.localize(
87-
'arduino/sketch/saveFolderAs',
88-
'Save sketch folder as...'
89-
),
90-
defaultPath,
91-
});
85+
const { filePath, canceled } = await remote.dialog.showSaveDialog(
86+
remote.getCurrentWindow(),
87+
{
88+
title: nls.localize(
89+
'arduino/sketch/saveFolderAs',
90+
'Save sketch folder as...'
91+
),
92+
defaultPath,
93+
}
94+
);
9295
if (!filePath || canceled) {
9396
return false;
9497
}

Diff for: arduino-ide-extension/src/browser/dialogs/settings/settings-component.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ export class SettingsComponent extends React.Component<
502502
canSelectFiles: false,
503503
canSelectMany: false,
504504
canSelectFolders: true,
505+
modal: true,
505506
});
506507
if (uri) {
507508
const sketchbookPath = await this.props.fileService.fsPath(uri);

0 commit comments

Comments
 (0)