Skip to content

Commit 313c96c

Browse files
author
Akos Kitta
committed
Do not explicitly initialize the layout on start.
It should be handled by the layout restorer. Signed-off-by: Akos Kitta <[email protected]>
1 parent bc3aee6 commit 313c96c

File tree

1 file changed

+43
-82
lines changed

1 file changed

+43
-82
lines changed

arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx

Lines changed: 43 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
1+
import {
2+
inject,
3+
injectable,
4+
postConstruct,
5+
} from '@theia/core/shared/inversify';
26
import * as React from '@theia/core/shared/react';
37
import * as remote from '@theia/core/electron-shared/@electron/remote';
48
import {
@@ -45,19 +49,13 @@ import {
4549
EditorManager,
4650
EditorOpenerOptions,
4751
} from '@theia/editor/lib/browser';
48-
import { ProblemContribution } from '@theia/markers/lib/browser/problem/problem-contribution';
4952
import { MonacoMenus } from '@theia/monaco/lib/browser/monaco-menu';
50-
import { FileNavigatorCommands, FileNavigatorContribution } from '@theia/navigator/lib/browser/navigator-contribution';
51-
import { OutlineViewContribution } from '@theia/outline-view/lib/browser/outline-view-contribution';
52-
import { OutputContribution } from '@theia/output/lib/browser/output-contribution';
53-
import { ScmContribution } from '@theia/scm/lib/browser/scm-contribution';
54-
import { SearchInWorkspaceFrontendContribution } from '@theia/search-in-workspace/lib/browser/search-in-workspace-frontend-contribution';
53+
import { FileNavigatorCommands } from '@theia/navigator/lib/browser/navigator-contribution';
5554
import { TerminalMenus } from '@theia/terminal/lib/browser/terminal-frontend-contribution';
5655
import { HostedPluginSupport } from '@theia/plugin-ext/lib/hosted/browser/hosted-plugin';
5756
import { FileService } from '@theia/filesystem/lib/browser/file-service';
5857
import { FileChangeType } from '@theia/filesystem/lib/browser';
5958
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
60-
import { ConfigService } from '../common/protocol/config-service';
6159
import { ArduinoCommands } from './arduino-commands';
6260
import { BoardsConfig } from './boards/boards-config';
6361
import { BoardsConfigDialog } from './boards/boards-config-dialog';
@@ -70,7 +68,6 @@ import { ArduinoToolbar } from './toolbar/arduino-toolbar';
7068
import { ArduinoPreferences } from './arduino-preferences';
7169
import { SketchesServiceClientImpl } from '../common/protocol/sketches-service-client-impl';
7270
import { SaveAsSketch } from './contributions/save-as-sketch';
73-
import { SketchbookWidgetContribution } from './widgets/sketchbook/sketchbook-widget-contribution';
7471
import { IDEUpdaterDialog } from './dialogs/ide-updater/ide-updater-dialog';
7572
import { IDEUpdater } from '../common/protocol/ide-updater';
7673
import { FileSystemFrontendContribution } from '@theia/filesystem/lib/browser/filesystem-frontend-contribution';
@@ -85,96 +82,73 @@ export class ArduinoFrontendContribution
8582
TabBarToolbarContribution,
8683
CommandContribution,
8784
MenuContribution,
88-
ColorContribution {
85+
ColorContribution
86+
{
8987
@inject(ILogger)
90-
protected logger: ILogger;
88+
private readonly logger: ILogger;
9189

9290
@inject(MessageService)
93-
protected readonly messageService: MessageService;
91+
private readonly messageService: MessageService;
9492

9593
@inject(BoardsService)
96-
protected readonly boardsService: BoardsService;
94+
private readonly boardsService: BoardsService;
9795

9896
@inject(LibraryService)
99-
protected readonly libraryService: LibraryService;
97+
private readonly libraryService: LibraryService;
10098

10199
@inject(BoardsServiceProvider)
102-
protected readonly boardsServiceClientImpl: BoardsServiceProvider;
100+
private readonly boardsServiceClientImpl: BoardsServiceProvider;
103101

104102
@inject(EditorManager)
105-
protected readonly editorManager: EditorManager;
103+
private readonly editorManager: EditorManager;
106104

107105
@inject(FileService)
108-
protected readonly fileService: FileService;
106+
private readonly fileService: FileService;
109107

110108
@inject(SketchesService)
111-
protected readonly sketchService: SketchesService;
109+
private readonly sketchService: SketchesService;
112110

113111
@inject(BoardsConfigDialog)
114-
protected readonly boardsConfigDialog: BoardsConfigDialog;
112+
private readonly boardsConfigDialog: BoardsConfigDialog;
115113

116114
@inject(CommandRegistry)
117-
protected readonly commandRegistry: CommandRegistry;
115+
private readonly commandRegistry: CommandRegistry;
118116

119117
@inject(StatusBar)
120-
protected readonly statusBar: StatusBar;
121-
122-
@inject(FileNavigatorContribution)
123-
protected readonly fileNavigatorContributions: FileNavigatorContribution;
124-
125-
@inject(OutputContribution)
126-
protected readonly outputContribution: OutputContribution;
127-
128-
@inject(OutlineViewContribution)
129-
protected readonly outlineContribution: OutlineViewContribution;
130-
131-
@inject(ProblemContribution)
132-
protected readonly problemContribution: ProblemContribution;
133-
134-
@inject(ScmContribution)
135-
protected readonly scmContribution: ScmContribution;
136-
137-
@inject(SearchInWorkspaceFrontendContribution)
138-
protected readonly siwContribution: SearchInWorkspaceFrontendContribution;
139-
140-
@inject(SketchbookWidgetContribution)
141-
protected readonly sketchbookWidgetContribution: SketchbookWidgetContribution;
118+
private readonly statusBar: StatusBar;
142119

143120
@inject(EditorMode)
144-
protected readonly editorMode: EditorMode;
145-
146-
@inject(ConfigService)
147-
protected readonly configService: ConfigService;
121+
private readonly editorMode: EditorMode;
148122

149123
@inject(HostedPluginSupport)
150-
protected hostedPluginSupport: HostedPluginSupport;
124+
private readonly hostedPluginSupport: HostedPluginSupport;
151125

152126
@inject(ExecutableService)
153-
protected executableService: ExecutableService;
127+
private readonly executableService: ExecutableService;
154128

155129
@inject(ArduinoPreferences)
156-
protected readonly arduinoPreferences: ArduinoPreferences;
130+
private readonly arduinoPreferences: ArduinoPreferences;
157131

158132
@inject(SketchesServiceClientImpl)
159-
protected readonly sketchServiceClient: SketchesServiceClientImpl;
133+
private readonly sketchServiceClient: SketchesServiceClientImpl;
160134

161135
@inject(FrontendApplicationStateService)
162-
protected readonly appStateService: FrontendApplicationStateService;
136+
private readonly appStateService: FrontendApplicationStateService;
163137

164138
@inject(LocalStorageService)
165-
protected readonly localStorageService: LocalStorageService;
139+
private readonly localStorageService: LocalStorageService;
166140

167141
@inject(FileSystemFrontendContribution)
168-
protected readonly fileSystemFrontendContribution: FileSystemFrontendContribution;
142+
private readonly fileSystemFrontendContribution: FileSystemFrontendContribution;
169143

170144
@inject(IDEUpdater)
171-
protected readonly updater: IDEUpdater;
145+
private readonly updater: IDEUpdater;
172146

173147
@inject(IDEUpdaterDialog)
174-
protected readonly updaterDialog: IDEUpdaterDialog;
148+
private readonly updaterDialog: IDEUpdaterDialog;
175149

176150
@inject(ArduinoDaemon)
177-
protected readonly daemon: ArduinoDaemon;
151+
private readonly daemon: ArduinoDaemon;
178152

179153
protected invalidConfigPopup:
180154
| Promise<void | 'No' | 'Yes' | undefined>
@@ -271,21 +245,6 @@ export class ArduinoFrontendContribution
271245
}
272246

273247
async onStart(app: FrontendApplication): Promise<void> {
274-
// Initialize all `pro-mode` widgets. This is a NOOP if in normal mode.
275-
for (const viewContribution of [
276-
this.fileNavigatorContributions,
277-
this.outputContribution,
278-
this.outlineContribution,
279-
this.problemContribution,
280-
this.scmContribution,
281-
this.siwContribution,
282-
this.sketchbookWidgetContribution,
283-
] as Array<FrontendApplicationContribution>) {
284-
if (viewContribution.initializeLayout) {
285-
viewContribution.initializeLayout(app);
286-
}
287-
}
288-
289248
this.updater
290249
.init(
291250
this.arduinoPreferences.get('arduino.ide.updateChannel'),
@@ -349,16 +308,18 @@ export class ArduinoFrontendContribution
349308

350309
app.shell.leftPanelHandler.removeBottomMenu('settings-menu');
351310

352-
this.fileSystemFrontendContribution.onDidChangeEditorFile(e => {
353-
if (e.type === FileChangeType.DELETED) {
354-
const editorWidget = e.editor;
355-
if (SaveableWidget.is(editorWidget)) {
356-
editorWidget.closeWithoutSaving();
357-
} else {
358-
editorWidget.close();
311+
this.fileSystemFrontendContribution.onDidChangeEditorFile(
312+
({ type, editor }) => {
313+
if (type === FileChangeType.DELETED) {
314+
const editorWidget = editor;
315+
if (SaveableWidget.is(editorWidget)) {
316+
editorWidget.closeWithoutSaving();
317+
} else {
318+
editorWidget.close();
319+
}
359320
}
360321
}
361-
});
322+
);
362323
}
363324

364325
onStop(): void {
@@ -501,13 +462,13 @@ export class ArduinoFrontendContribution
501462
EditorCommands.SPLIT_EDITOR_UP,
502463
EditorCommands.SPLIT_EDITOR_VERTICAL,
503464
EditorCommands.SPLIT_EDITOR_HORIZONTAL,
504-
FileNavigatorCommands.REVEAL_IN_NAVIGATOR
465+
FileNavigatorCommands.REVEAL_IN_NAVIGATOR,
505466
]) {
506467
registry.unregisterCommand(command);
507468
}
508469
}
509470

510-
registerMenus(registry: MenuModelRegistry) {
471+
registerMenus(registry: MenuModelRegistry): void {
511472
const menuId = (menuPath: string[]): string => {
512473
const index = menuPath.length - 1;
513474
const menuId = menuPath[index];
@@ -576,7 +537,7 @@ export class ArduinoFrontendContribution
576537
uri: string,
577538
forceOpen = false,
578539
options?: EditorOpenerOptions | undefined
579-
): Promise<any> {
540+
): Promise<unknown> {
580541
const widget = this.editorManager.all.find(
581542
(widget) => widget.editor.uri.toString() === uri
582543
);

0 commit comments

Comments
 (0)