mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-04-19 12:57:17 +00:00
fix: use board+port at startup if it's restored (#2242)
- update status bar if board+port is restored, - refresh the debug toolbar if board+port is restored, - init `Include Library` if board+port is ready, and - init library examples if board+port is ready Closes #2237 Closes #2239 Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
parent
8f4bcc83ec
commit
57975f8d91
@ -19,7 +19,7 @@ import {
|
||||
SketchContribution,
|
||||
TabBarToolbarRegistry,
|
||||
} from './contribution';
|
||||
import { MaybePromise, MenuModelRegistry, nls } from '@theia/core/lib/common';
|
||||
import { MenuModelRegistry, nls } from '@theia/core/lib/common';
|
||||
import { CurrentSketch } from '../sketches-service-client-impl';
|
||||
import { ArduinoMenus } from '../menu/arduino-menus';
|
||||
|
||||
@ -99,8 +99,8 @@ export class Debug extends SketchContribution {
|
||||
this.notificationCenter.onPlatformDidUninstall(() => this.refreshState());
|
||||
}
|
||||
|
||||
override onReady(): MaybePromise<void> {
|
||||
this.refreshState();
|
||||
override onReady(): void {
|
||||
this.boardsServiceProvider.ready.then(() => this.refreshState());
|
||||
}
|
||||
|
||||
override registerCommands(registry: CommandRegistry): void {
|
||||
|
@ -300,8 +300,8 @@ export class LibraryExamples extends Examples {
|
||||
this.notificationCenter.onLibraryDidUninstall(() => this.update());
|
||||
}
|
||||
|
||||
override async onReady(): Promise<void> {
|
||||
this.update(); // no `await`
|
||||
override onReady(): void {
|
||||
this.boardsServiceProvider.ready.then(() => this.update());
|
||||
}
|
||||
|
||||
protected override handleBoardChanged(board: Board | undefined): void {
|
||||
|
@ -2,7 +2,6 @@ import PQueue from 'p-queue';
|
||||
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||
import URI from '@theia/core/lib/common/uri';
|
||||
import { MonacoEditor } from '@theia/monaco/lib/browser/monaco-editor';
|
||||
import { EditorManager } from '@theia/editor/lib/browser';
|
||||
import { MenuModelRegistry, MenuPath } from '@theia/core/lib/common/menu';
|
||||
import {
|
||||
Disposable,
|
||||
@ -22,28 +21,25 @@ import { CurrentSketch } from '../sketches-service-client-impl';
|
||||
@injectable()
|
||||
export class IncludeLibrary extends SketchContribution {
|
||||
@inject(CommandRegistry)
|
||||
protected readonly commandRegistry: CommandRegistry;
|
||||
private readonly commandRegistry: CommandRegistry;
|
||||
|
||||
@inject(MenuModelRegistry)
|
||||
protected readonly menuRegistry: MenuModelRegistry;
|
||||
private readonly menuRegistry: MenuModelRegistry;
|
||||
|
||||
@inject(MainMenuManager)
|
||||
protected readonly mainMenuManager: MainMenuManager;
|
||||
|
||||
@inject(EditorManager)
|
||||
protected override readonly editorManager: EditorManager;
|
||||
private readonly mainMenuManager: MainMenuManager;
|
||||
|
||||
@inject(NotificationCenter)
|
||||
protected readonly notificationCenter: NotificationCenter;
|
||||
private readonly notificationCenter: NotificationCenter;
|
||||
|
||||
@inject(BoardsServiceProvider)
|
||||
protected readonly boardsServiceProvider: BoardsServiceProvider;
|
||||
private readonly boardsServiceProvider: BoardsServiceProvider;
|
||||
|
||||
@inject(LibraryService)
|
||||
protected readonly libraryService: LibraryService;
|
||||
private readonly libraryService: LibraryService;
|
||||
|
||||
protected readonly queue = new PQueue({ autoStart: true, concurrency: 1 });
|
||||
protected readonly toDispose = new DisposableCollection();
|
||||
private readonly queue = new PQueue({ autoStart: true, concurrency: 1 });
|
||||
private readonly toDispose = new DisposableCollection();
|
||||
|
||||
override onStart(): void {
|
||||
this.boardsServiceProvider.onBoardsConfigDidChange(() =>
|
||||
@ -56,8 +52,8 @@ export class IncludeLibrary extends SketchContribution {
|
||||
this.notificationCenter.onDidReinitialize(() => this.updateMenuActions());
|
||||
}
|
||||
|
||||
override async onReady(): Promise<void> {
|
||||
this.updateMenuActions();
|
||||
override onReady(): void {
|
||||
this.boardsServiceProvider.ready.then(() => this.updateMenuActions());
|
||||
}
|
||||
|
||||
override registerMenus(registry: MenuModelRegistry): void {
|
||||
@ -93,7 +89,7 @@ export class IncludeLibrary extends SketchContribution {
|
||||
});
|
||||
}
|
||||
|
||||
protected async updateMenuActions(): Promise<void> {
|
||||
private async updateMenuActions(): Promise<void> {
|
||||
return this.queue.add(async () => {
|
||||
this.toDispose.dispose();
|
||||
this.mainMenuManager.update();
|
||||
@ -139,7 +135,7 @@ export class IncludeLibrary extends SketchContribution {
|
||||
});
|
||||
}
|
||||
|
||||
protected registerLibrary(
|
||||
private registerLibrary(
|
||||
libraryOrPlaceholder: LibraryPackage | string,
|
||||
menuPath: MenuPath
|
||||
): Disposable {
|
||||
@ -172,7 +168,7 @@ export class IncludeLibrary extends SketchContribution {
|
||||
);
|
||||
}
|
||||
|
||||
protected async includeLibrary(library: LibraryPackage): Promise<void> {
|
||||
private async includeLibrary(library: LibraryPackage): Promise<void> {
|
||||
const sketch = await this.sketchServiceClient.currentSketch();
|
||||
if (!CurrentSketch.isValid(sketch)) {
|
||||
return;
|
||||
|
@ -19,16 +19,18 @@ export class SelectedBoard extends Contribution {
|
||||
private readonly boardsServiceProvider: BoardsServiceProvider;
|
||||
|
||||
override onStart(): void {
|
||||
this.boardsServiceProvider.onBoardListDidChange(() =>
|
||||
this.update(this.boardsServiceProvider.boardList)
|
||||
this.boardsServiceProvider.onBoardListDidChange((boardList) =>
|
||||
this.update(boardList)
|
||||
);
|
||||
}
|
||||
|
||||
override onReady(): void {
|
||||
this.update(this.boardsServiceProvider.boardList);
|
||||
this.boardsServiceProvider.ready.then(() => this.update());
|
||||
}
|
||||
|
||||
private update(boardList: BoardList): void {
|
||||
private update(
|
||||
boardList: BoardList = this.boardsServiceProvider.boardList
|
||||
): void {
|
||||
const { selectedBoard, selectedPort } = boardList.boardsConfig;
|
||||
this.statusBar.setElement('arduino-selected-board', {
|
||||
alignment: StatusBarAlignment.RIGHT,
|
||||
|
Loading…
x
Reference in New Issue
Block a user