mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-09 04:16:38 +00:00
Restored the Settings UI. Deferred model loading.
Closes #1031 Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
parent
7c2843f7fd
commit
a8047660a6
@ -1,16 +1,43 @@
|
||||
import {
|
||||
FrontendApplicationState,
|
||||
FrontendApplicationStateService,
|
||||
} from '@theia/core/lib/browser/frontend-application-state';
|
||||
import { CompositeTreeNode } from '@theia/core/lib/browser/tree/tree';
|
||||
import { injectable } from '@theia/core/shared/inversify';
|
||||
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||
import { PreferenceTreeGenerator as TheiaPreferenceTreeGenerator } from '@theia/preferences/lib/browser/util/preference-tree-generator';
|
||||
|
||||
@injectable()
|
||||
export class PreferenceTreeGenerator extends TheiaPreferenceTreeGenerator {
|
||||
private shouldHandleChangedSchemaOnReady = false;
|
||||
private state: FrontendApplicationState | undefined;
|
||||
|
||||
@inject(FrontendApplicationStateService)
|
||||
private readonly appStateService: FrontendApplicationStateService;
|
||||
|
||||
protected override async init(): Promise<void> {
|
||||
// The IDE2 does not use the default Theia preferences UI.
|
||||
// There is no need to create and keep the the tree model synchronized when there is no UI for it.
|
||||
this.appStateService.onStateChanged((state) => {
|
||||
this.state = state;
|
||||
// manually trigger a model (and UI) refresh if it was requested during the startup phase.
|
||||
if (this.state === 'ready' && this.shouldHandleChangedSchemaOnReady) {
|
||||
this.doHandleChangedSchema();
|
||||
}
|
||||
});
|
||||
return super.init();
|
||||
}
|
||||
|
||||
override doHandleChangedSchema(): void {
|
||||
if (this.state === 'ready') {
|
||||
super.doHandleChangedSchema();
|
||||
}
|
||||
// don't do anything until the app is `ready`, then invoke `doHandleChangedSchema`.
|
||||
this.shouldHandleChangedSchemaOnReady = true;
|
||||
}
|
||||
|
||||
// Just returns with the empty root.
|
||||
override generateTree(): CompositeTreeNode {
|
||||
if (this.state === 'ready') {
|
||||
return super.generateTree();
|
||||
}
|
||||
// always create an empty root when the app is not ready.
|
||||
this._root = this.createRootNode();
|
||||
return this._root;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user