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

Sign up
Appearance settings

Commit 633fd9c

Browse files
author
Akos Kitta
committed
Show 'progress' indicator during verify/upload.
Closes #575 Closes #1175 Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
1 parent f22be3c commit 633fd9c

File tree

13 files changed

+530
-406
lines changed

13 files changed

+530
-406
lines changed

‎arduino-ide-extension/src/browser/contributions/add-zip-library.ts‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@ import URI from '@theia/core/lib/common/uri';
44
import { ConfirmDialog } from '@theia/core/lib/browser/dialogs';
55
import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
66
import { ArduinoMenus } from '../menu/arduino-menus';
7-
import {
8-
Installable,
9-
LibraryService,
10-
ResponseServiceClient,
11-
} from '../../common/protocol';
7+
import { LibraryService, ResponseServiceClient } from '../../common/protocol';
8+
import { ExecuteWithProgress } from '../../common/protocol/progressible';
129
import {
1310
SketchContribution,
1411
Command,
@@ -88,7 +85,7 @@ export class AddZipLibrary extends SketchContribution {
8885

8986
private async doInstall(zipUri: string, overwrite?: boolean): Promise<void> {
9087
try {
91-
await Installable.doWithProgress({
88+
await ExecuteWithProgress.doWithProgress({
9289
messageService: this.messageService,
9390
progressText:
9491
nls.localize('arduino/common/processing', 'Processing') +

‎arduino-ide-extension/src/browser/contributions/burn-bootloader.ts‎

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
1-
import { inject, injectable } from '@theia/core/shared/inversify';
1+
import { nls } from '@theia/core/lib/common';
2+
import { injectable } from '@theia/core/shared/inversify';
3+
import { CoreService } from '../../common/protocol';
24
import { ArduinoMenus } from '../menu/arduino-menus';
3-
import { BoardsDataStore } from '../boards/boards-data-store';
4-
import { BoardsServiceProvider } from '../boards/boards-service-provider';
55
import {
6-
CoreServiceContribution,
76
Command,
87
CommandRegistry,
8+
CoreServiceContribution,
99
MenuModelRegistry,
1010
} from './contribution';
11-
import { nls } from '@theia/core/lib/common';
1211

1312
@injectable()
1413
export class BurnBootloader extends CoreServiceContribution {
15-
@inject(BoardsDataStore)
16-
protected readonly boardsDataStore: BoardsDataStore;
17-
18-
@inject(BoardsServiceProvider)
19-
protected readonly boardsServiceClientImpl: BoardsServiceProvider;
20-
2114
override registerCommands(registry: CommandRegistry): void {
2215
registry.registerCommand(BurnBootloader.Commands.BURN_BOOTLOADER, {
2316
execute: () => this.burnBootloader(),
@@ -35,32 +28,19 @@ export class BurnBootloader extends CoreServiceContribution {
3528
});
3629
}
3730

38-
async burnBootloader(): Promise<void> {
31+
private async burnBootloader(): Promise<void> {
32+
const options = await this.options();
3933
try {
40-
const { boardsConfig } = this.boardsServiceClientImpl;
41-
const port = boardsConfig.selectedPort;
42-
const [fqbn, { selectedProgrammer: programmer }, verify, verbose] =
43-
await Promise.all([
44-
this.boardsDataStore.appendConfigToFqbn(
45-
boardsConfig.selectedBoard?.fqbn
46-
),
47-
this.boardsDataStore.getData(boardsConfig.selectedBoard?.fqbn),
48-
this.preferences.get('arduino.upload.verify'),
49-
this.preferences.get('arduino.upload.verbose'),
50-
]);
51-
52-
const board = {
53-
...boardsConfig.selectedBoard,
54-
name: boardsConfig.selectedBoard?.name || '',
55-
fqbn,
56-
};
57-
this.outputChannelManager.getChannel('Arduino').clear();
58-
await this.coreService.burnBootloader({
59-
board,
60-
programmer,
61-
port,
62-
verify,
63-
verbose,
34+
await this.doWithProgress({
35+
progressText: nls.localize(
36+
'arduino/bootloader/burningBootloader',
37+
'Burning bootloader...'
38+
),
39+
task: (progressId, coreService) =>
40+
coreService.burnBootloader({
41+
...options,
42+
progressId,
43+
}),
6444
});
6545
this.messageService.info(
6646
nls.localize(
@@ -75,6 +55,27 @@ export class BurnBootloader extends CoreServiceContribution {
7555
this.handleError(e);
7656
}
7757
}
58+
59+
private async options(): Promise<CoreService.Options.Bootloader> {
60+
const { boardsConfig } = this.boardsServiceProvider;
61+
const port = boardsConfig.selectedPort;
62+
const [fqbn, { selectedProgrammer: programmer }, verify, verbose] =
63+
await Promise.all([
64+
this.boardsDataStore.appendConfigToFqbn(
65+
boardsConfig.selectedBoard?.fqbn
66+
),
67+
this.boardsDataStore.getData(boardsConfig.selectedBoard?.fqbn),
68+
this.preferences.get('arduino.upload.verify'),
69+
this.preferences.get('arduino.upload.verbose'),
70+
]);
71+
return {
72+
fqbn,
73+
programmer,
74+
port,
75+
verify,
76+
verbose,
77+
};
78+
}
7879
}
7980

8081
export namespace BurnBootloader {

‎arduino-ide-extension/src/browser/contributions/contribution.ts‎

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,16 @@ import {
4949
Sketch,
5050
CoreService,
5151
CoreError,
52+
ResponseServiceClient,
5253
} from '../../common/protocol';
5354
import { ArduinoPreferences } from '../arduino-preferences';
5455
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
55-
import { CoreErrorHandler } from './core-error-handler';
5656
import { nls } from '@theia/core';
5757
import { OutputChannelManager } from '../theia/output/output-channel';
5858
import { ClipboardService } from '@theia/core/lib/browser/clipboard-service';
59+
import { ExecuteWithProgress } from '../../common/protocol/progressible';
60+
import { BoardsServiceProvider } from '../boards/boards-service-provider';
61+
import { BoardsDataStore } from '../boards/boards-data-store';
5962

6063
export {
6164
Command,
@@ -167,18 +170,23 @@ export abstract class SketchContribution extends Contribution {
167170
}
168171

169172
@injectable()
170-
export class CoreServiceContribution extends SketchContribution {
171-
@inject(CoreService)
172-
protected readonly coreService: CoreService;
173+
export abstract class CoreServiceContribution extends SketchContribution {
174+
@inject(BoardsDataStore)
175+
protected readonly boardsDataStore: BoardsDataStore;
176+
177+
@inject(BoardsServiceProvider)
178+
protected readonly boardsServiceProvider: BoardsServiceProvider;
173179

174-
@inject(CoreErrorHandler)
175-
protected readonly coreErrorHandler: CoreErrorHandler;
180+
@inject(CoreService)
181+
private readonly coreService: CoreService;
176182

177183
@inject(ClipboardService)
178184
private readonly clipboardService: ClipboardService;
179185

186+
@inject(ResponseServiceClient)
187+
private readonly responseService: ResponseServiceClient;
188+
180189
protected handleError(error: unknown): void {
181-
this.coreErrorHandler.tryHandle(error);
182190
this.tryToastErrorMessage(error);
183191
}
184192

@@ -214,6 +222,25 @@ export class CoreServiceContribution extends SketchContribution {
214222
throw error;
215223
}
216224
}
225+
226+
protected async doWithProgress<T>(options: {
227+
progressText: string;
228+
keepOutput?: boolean;
229+
task: (progressId: string, coreService: CoreService) => Promise<T>;
230+
}): Promise<T> {
231+
const { progressText, keepOutput, task } = options;
232+
this.outputChannelManager
233+
.getChannel('Arduino')
234+
.show({ preserveFocus: true });
235+
const result = await ExecuteWithProgress.doWithProgress({
236+
messageService: this.messageService,
237+
responseService: this.responseService,
238+
progressText,
239+
run: ({ progressId }) => task(progressId, this.coreService),
240+
keepOutput,
241+
});
242+
return result;
243+
}
217244
}
218245

219246
export namespace Contribution {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /