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 c8ac751

Browse files
author
Alberto Iannaccone
committed
always show the correct sketchbook at ide start-up
1 parent 87d5a49 commit c8ac751

File tree

6 files changed

+44
-24
lines changed

6 files changed

+44
-24
lines changed

‎arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts‎

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -420,9 +420,8 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
420420
bind(SerialService)
421421
.toDynamicValue((context) => {
422422
const connection = context.container.get(WebSocketConnectionProvider);
423-
const client = context.container.get<SerialServiceClient>(
424-
SerialServiceClient
425-
);
423+
const client =
424+
context.container.get<SerialServiceClient>(SerialServiceClient);
426425
return connection.createProxy(SerialServicePath, client);
427426
})
428427
.inSingletonScope();
@@ -486,11 +485,12 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
486485
.inSingletonScope();
487486
rebind(TheiaEditorWidgetFactory).to(EditorWidgetFactory).inSingletonScope();
488487
rebind(TabBarToolbarFactory).toFactory(
489-
({ container: parentContainer }) => () => {
490-
const container = parentContainer.createChild();
491-
container.bind(TabBarToolbar).toSelf().inSingletonScope();
492-
return container.get(TabBarToolbar);
493-
}
488+
({ container: parentContainer }) =>
489+
() => {
490+
const container = parentContainer.createChild();
491+
container.bind(TabBarToolbar).toSelf().inSingletonScope();
492+
return container.get(TabBarToolbar);
493+
}
494494
);
495495
bind(OutputWidget).toSelf().inSingletonScope();
496496
rebind(TheiaOutputWidget).toService(OutputWidget);
@@ -655,15 +655,13 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
655655

656656
// Enable the dirty indicator on uncloseable widgets.
657657
rebind(TabBarRendererFactory).toFactory((context) => () => {
658-
const contextMenuRenderer = context.container.get<ContextMenuRenderer>(
659-
ContextMenuRenderer
660-
);
658+
const contextMenuRenderer =
659+
context.container.get<ContextMenuRenderer>(ContextMenuRenderer);
661660
const decoratorService = context.container.get<TabBarDecoratorService>(
662661
TabBarDecoratorService
663662
);
664-
const iconThemeService = context.container.get<IconThemeService>(
665-
IconThemeService
666-
);
663+
const iconThemeService =
664+
context.container.get<IconThemeService>(IconThemeService);
667665
return new TabBarRenderer(
668666
contextMenuRenderer,
669667
decoratorService,
@@ -723,7 +721,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
723721
bindViewContribution(bind, SketchbookWidgetContribution);
724722
bind(FrontendApplicationContribution).toService(SketchbookWidgetContribution);
725723
bind(WidgetFactory).toDynamicValue(({ container }) => ({
726-
id: 'arduino-sketchbook-widget',
724+
id: SketchbookWidget.ID,
727725
createWidget: () => container.get(SketchbookWidget),
728726
}));
729727

‎arduino-ide-extension/src/browser/theia/core/application-shell.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { Sketch } from '../../../common/protocol';
1616
import { SaveAsSketch } from '../../contributions/save-as-sketch';
1717
import { SketchesServiceClientImpl } from '../../../common/protocol/sketches-service-client-impl';
1818
import { nls } from '@theia/core/lib/common';
19+
import { SketchbookWidget } from '../../widgets/sketchbook/sketchbook-widget';
1920

2021
@injectable()
2122
export class ApplicationShell extends TheiaApplicationShell {
@@ -31,6 +32,18 @@ export class ApplicationShell extends TheiaApplicationShell {
3132
@inject(ConnectionStatusService)
3233
protected readonly connectionStatusService: ConnectionStatusService;
3334

35+
async setLayoutData(
36+
layoutData: TheiaApplicationShell.LayoutData
37+
): Promise<void> {
38+
layoutData.activeWidgetId = SketchbookWidget.ID;
39+
layoutData.leftPanel?.items?.forEach((item) => {
40+
if (item?.widget?.id === SketchbookWidget.ID) item.expanded = true;
41+
else item.expanded = false;
42+
});
43+
44+
super.setLayoutData(layoutData);
45+
}
46+
3447
protected track(widget: Widget): void {
3548
super.track(widget);
3649
if (widget instanceof OutputWidget) {

‎arduino-ide-extension/src/browser/theia/core/shell-layout-restorer.ts‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
import { injectable } from 'inversify';
2-
import { FrontendApplication } from '@theia/core/lib/browser/frontend-application';
32
import { ShellLayoutRestorer as TheiaShellLayoutRestorer } from '@theia/core/lib/browser/shell/shell-layout-restorer';
3+
import { inject } from '@theia/core/shared/inversify';
4+
import { ApplicationShell } from '@theia/core/lib/browser/shell/application-shell';
45

56
@injectable()
67
export class ShellLayoutRestorer extends TheiaShellLayoutRestorer {
8+
@inject(ApplicationShell)
9+
protected readonly shell: ApplicationShell;
10+
711
// Workaround for https://github.com/eclipse-theia/theia/issues/6579.
8-
async storeLayoutAsync(app: FrontendApplication): Promise<void> {
12+
async storeLayoutAsync(): Promise<void> {
913
if (this.shouldStoreLayout) {
1014
try {
1115
this.logger.info('>>> Storing the layout...');
12-
const layoutData = app.shell.getLayoutData();
16+
const layoutData = this.shell.getLayoutData();
1317
const serializedLayoutData = this.deflate(layoutData);
1418
await this.storageService.setData(
1519
this.storageKey,
@@ -23,7 +27,7 @@ export class ShellLayoutRestorer extends TheiaShellLayoutRestorer {
2327
}
2428
}
2529

26-
async restoreLayout(app: FrontendApplication): Promise<boolean> {
30+
async restoreLayout(): Promise<boolean> {
2731
this.logger.info('>>> Restoring the layout state...');
2832
const serializedLayoutData = await this.storageService.getData<string>(
2933
this.storageKey
@@ -49,7 +53,7 @@ export class ShellLayoutRestorer extends TheiaShellLayoutRestorer {
4953
});
5054
}
5155

52-
await app.shell.setLayoutData(layoutData);
56+
await this.shell.setLayoutData(layoutData);
5357
this.logger.info('<<< The layout has been successfully restored.');
5458
return true;
5559
}

‎arduino-ide-extension/src/browser/widgets/sketchbook/sketchbook-commands.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,8 @@ export namespace SketchbookCommands {
3232
id: 'arduino-sketchbook--show-files',
3333
label: 'Contextual menu',
3434
};
35+
36+
export const SKETCHBOOK_TOGGLE_VIEW: Command = {
37+
id: 'arduino-sketchbook-widget:toggle',
38+
};
3539
}

‎arduino-ide-extension/src/browser/widgets/sketchbook/sketchbook-widget-contribution.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ export class SketchbookWidgetContribution
6868

6969
constructor() {
7070
super({
71-
widgetId: 'arduino-sketchbook-widget',
71+
widgetId: SketchbookWidget.ID,
7272
widgetName: SketchbookWidget.LABEL,
7373
defaultWidgetOptions: {
7474
area: 'left',
7575
rank: 1,
7676
},
77-
toggleCommandId: 'arduino-sketchbook-widget:toggle',
77+
toggleCommandId: SketchbookCommands.SKETCHBOOK_TOGGLE_VIEW.id,
7878
toggleKeybinding: 'CtrlCmd+Shift+B',
7979
});
8080
}
@@ -191,7 +191,7 @@ export class SketchbookWidgetContribution
191191

192192
// unregister main menu action
193193
registry.unregisterMenuAction({
194-
commandId: 'arduino-sketchbook-widget:toggle',
194+
commandId: SketchbookCommands.SKETCHBOOK_TOGGLE_VIEW.id,
195195
});
196196

197197
registry.registerMenuAction(SKETCHBOOK__CONTEXT__MAIN_GROUP, {

‎arduino-ide-extension/src/browser/widgets/sketchbook/sketchbook-widget.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { nls } from '@theia/core/lib/common';
1111
@injectable()
1212
export class SketchbookWidget extends BaseWidget {
1313
static LABEL = nls.localize('arduino/sketch/titleSketchbook', 'Sketchbook');
14+
static ID = 'arduino-sketchbook-widget';
1415

1516
@inject(SketchbookTreeWidget)
1617
protected readonly localSketchbookTreeWidget: SketchbookTreeWidget;
@@ -19,7 +20,7 @@ export class SketchbookWidget extends BaseWidget {
1920

2021
constructor() {
2122
super();
22-
this.id = 'arduino-sketchbook-widget';
23+
this.id = SketchbookWidget.ID;
2324
this.title.caption = SketchbookWidget.LABEL;
2425
this.title.label = SketchbookWidget.LABEL;
2526
this.title.iconClass = 'fa fa-arduino-folder';

0 commit comments

Comments
(0)

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