Skip to content

Commit a888594

Browse files
got it working
1 parent f343c7f commit a888594

12 files changed

+144
-119
lines changed

arduino-ide-extension/package.json

-10
Original file line numberDiff line numberDiff line change
@@ -160,16 +160,6 @@
160160
{
161161
"frontend": "lib/browser/theia/core/browser-menu-module",
162162
"frontendElectron": "lib/electron-browser/theia/core/electron-menu-module"
163-
},
164-
{
165-
"frontend": "lib/browser/theia/core/browser-window-module",
166-
"frontendElectron": "lib/electron-browser/theia/core/electron-window-module"
167-
},
168-
{
169-
"frontendElectron": "lib/electron-browser/electron-arduino-module"
170-
},
171-
{
172-
"electronMain": "lib/electron-main/arduino-electron-main-module"
173163
}
174164
],
175165
"arduino": {

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

+22-24
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { ColorContribution } from '@theia/core/lib/browser/color-application-con
22
import { ColorRegistry } from '@theia/core/lib/browser/color-registry';
33
import { CommonMenus } from '@theia/core/lib/browser/common-frontend-contribution';
44
import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application';
5-
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
65
import {
76
TabBarToolbarContribution,
87
TabBarToolbarRegistry,
@@ -24,7 +23,6 @@ import {
2423
import { MessageService } from '@theia/core/lib/common/message-service';
2524
import { nls } from '@theia/core/lib/common/nls';
2625
import { isHighContrast } from '@theia/core/lib/common/theme';
27-
import { ElectronWindowPreferences } from '@theia/core/lib/electron-browser/window/electron-window-preferences';
2826
import {
2927
inject,
3028
injectable,
@@ -62,11 +60,11 @@ export class ArduinoFrontendContribution
6260
@inject(CommandRegistry)
6361
private readonly commandRegistry: CommandRegistry;
6462

65-
@inject(ElectronWindowPreferences)
66-
private readonly electronWindowPreferences: ElectronWindowPreferences;
63+
// @inject(ElectronWindowPreferences)
64+
// private readonly electronWindowPreferences: ElectronWindowPreferences;
6765

68-
@inject(FrontendApplicationStateService)
69-
private readonly appStateService: FrontendApplicationStateService;
66+
// @inject(FrontendApplicationStateService)
67+
// private readonly appStateService: FrontendApplicationStateService;
7068

7169
@postConstruct()
7270
protected init(): void {
@@ -82,24 +80,24 @@ export class ArduinoFrontendContribution
8280
}
8381

8482
onStart(): void {
85-
this.electronWindowPreferences.onPreferenceChanged((event) => {
86-
if (event.newValue !== event.oldValue) {
87-
switch (event.preferenceName) {
88-
case 'window.zoomLevel':
89-
if (typeof event.newValue === 'number') {
90-
window.electronTheiaCore.setZoomLevel(event.newValue || 0);
91-
}
92-
break;
93-
}
94-
}
95-
});
96-
this.appStateService.reachedState('ready').then(() =>
97-
this.electronWindowPreferences.ready.then(() => {
98-
const zoomLevel =
99-
this.electronWindowPreferences.get('window.zoomLevel');
100-
window.electronTheiaCore.setZoomLevel(zoomLevel);
101-
})
102-
);
83+
// this.electronWindowPreferences.onPreferenceChanged((event) => {
84+
// if (event.newValue !== event.oldValue) {
85+
// switch (event.preferenceName) {
86+
// case 'window.zoomLevel':
87+
// if (typeof event.newValue === 'number') {
88+
// window.electronTheiaCore.setZoomLevel(event.newValue || 0);
89+
// }
90+
// break;
91+
// }
92+
// }
93+
// });
94+
// this.appStateService.reachedState('ready').then(() =>
95+
// this.electronWindowPreferences.ready.then(() => {
96+
// const zoomLevel =
97+
// this.electronWindowPreferences.get('window.zoomLevel');
98+
// window.electronTheiaCore.setZoomLevel(zoomLevel);
99+
// })
100+
// );
103101
}
104102

105103
registerToolbarItems(registry: TabBarToolbarRegistry): void {

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

+49-28
Original file line numberDiff line numberDiff line change
@@ -265,17 +265,12 @@ import {
265265
} from './dialogs/user-fields/user-fields-dialog';
266266
import { nls } from '@theia/core/lib/common';
267267
import { IDEUpdaterCommands } from './ide-updater/ide-updater-commands';
268-
import {
269-
IDEUpdater,
270-
IDEUpdaterClient,
271-
IDEUpdaterPath,
272-
} from '../common/protocol/ide-updater';
268+
import { IDEUpdater, IDEUpdaterClient } from '../common/protocol/ide-updater';
273269
import { IDEUpdaterClientImpl } from './ide-updater/ide-updater-client-impl';
274270
import {
275271
IDEUpdaterDialog,
276272
IDEUpdaterDialogProps,
277273
} from './dialogs/ide-updater/ide-updater-dialog';
278-
import { ElectronIpcConnectionProvider } from '@theia/core/lib/electron-browser/messaging/electron-ipc-connection-provider';
279274
import { MonitorModel } from './monitor-model';
280275
import { MonitorManagerProxyClientImpl } from './monitor-manager-proxy-client-impl';
281276
import { EditorManager as TheiaEditorManager } from '@theia/editor/lib/browser/editor-manager';
@@ -295,10 +290,7 @@ import { PreferenceTreeGenerator } from './theia/preferences/preference-tree-gen
295290
import { PreferenceTreeGenerator as TheiaPreferenceTreeGenerator } from '@theia/preferences/lib/browser/util/preference-tree-generator';
296291
import { AboutDialog } from './theia/core/about-dialog';
297292
import { AboutDialog as TheiaAboutDialog } from '@theia/core/lib/browser/about-dialog';
298-
import {
299-
SurveyNotificationService,
300-
SurveyNotificationServicePath,
301-
} from '../common/protocol/survey-service';
293+
import { SurveyNotificationService } from '../common/protocol/survey-service';
302294
import { WindowContribution } from './theia/core/window-contribution';
303295
import { WindowContribution as TheiaWindowContribution } from '@theia/core/lib/browser/window-contribution';
304296
import { CoreErrorHandler } from './contributions/core-error-handler';
@@ -394,6 +386,8 @@ import {
394386
VersionWelcomeDialog,
395387
VersionWelcomeDialogProps,
396388
} from './dialogs/version-welcome-dialog';
389+
import { DialogService } from './dialog-service';
390+
import { AppInfo, AppService } from './app-service';
397391

398392
// Hack to fix copy/cut/paste issue after electron version update in Theia.
399393
// https://github.com/eclipse-theia/theia/issues/12487
@@ -574,14 +568,15 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
574568
WorkspaceVariableContribution
575569
);
576570

577-
bind(SurveyNotificationService)
578-
.toDynamicValue((context) => {
579-
return ElectronIpcConnectionProvider.createProxy(
580-
context.container,
581-
SurveyNotificationServicePath
582-
);
583-
})
584-
.inSingletonScope();
571+
bind(SurveyNotificationService).toConstantValue(
572+
{} as SurveyNotificationService
573+
);
574+
// return ElectronIpcConnectionProvider.createProxy(
575+
// context.container,
576+
// SurveyNotificationServicePath
577+
// );
578+
// })
579+
// .inSingletonScope();
585580

586581
// Layout and shell customizations.
587582
rebind(TheiaOutlineViewContribution)
@@ -1039,16 +1034,16 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
10391034
// Frontend binding for the IDE Updater service
10401035
bind(IDEUpdaterClientImpl).toSelf().inSingletonScope();
10411036
bind(IDEUpdaterClient).toService(IDEUpdaterClientImpl);
1042-
bind(IDEUpdater)
1043-
.toDynamicValue((context) => {
1044-
const client = context.container.get(IDEUpdaterClientImpl);
1045-
return ElectronIpcConnectionProvider.createProxy(
1046-
context.container,
1047-
IDEUpdaterPath,
1048-
client
1049-
);
1050-
})
1051-
.inSingletonScope();
1037+
bind(IDEUpdater).toConstantValue({} as IDEUpdater);
1038+
// .toDynamicValue((context) => {
1039+
// const client = context.container.get(IDEUpdaterClientImpl);
1040+
// return ElectronIpcConnectionProvider.createProxy(
1041+
// context.container,
1042+
// IDEUpdaterPath,
1043+
// client
1044+
// );
1045+
// })
1046+
// .inSingletonScope();
10521047

10531048
bind(HostedPluginSupportImpl).toSelf().inSingletonScope();
10541049
bind(HostedPluginSupport).toService(HostedPluginSupportImpl);
@@ -1113,6 +1108,32 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
11131108
);
11141109

11151110
bindViewsWelcome_TheiaGH14309({ bind, widget: TreeViewWidget });
1111+
1112+
bind(DialogService).toConstantValue(<DialogService>{});
1113+
bind(AppService).toConstantValue(<AppService>{
1114+
quit() {
1115+
console.log('Quitting application...');
1116+
// Implement quit logic here
1117+
},
1118+
async info() {
1119+
return {
1120+
name: 'MyApp',
1121+
version: '1.0.0',
1122+
description: 'An example application',
1123+
appVersion: '1.0.0',
1124+
cliVersion: '1.0.0',
1125+
buildDate: new Date().toISOString(),
1126+
} as AppInfo;
1127+
},
1128+
registerStartupTasksHandler(_) {
1129+
console.log('registerStartupTasksHandler', _);
1130+
return { dispose: () => {} };
1131+
},
1132+
scheduleDeletion(_) {
1133+
console.log(`Scheduled deletion for sketch}`, _);
1134+
// Implement deletion logic
1135+
},
1136+
});
11161137
});
11171138

11181139
// Align the viewsWelcome rendering with VS Code (https://github.com/eclipse-theia/theia/issues/14309)

arduino-ide-extension/src/browser/contributions/check-for-updates.ts

+12-13
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { Installable } from '../../common/protocol/installable';
1515
import { ExecuteWithProgress } from '../../common/protocol/progressible';
1616
import { BoardsListWidgetFrontendContribution } from '../boards/boards-widget-frontend-contribution';
1717
import { LibraryListWidgetFrontendContribution } from '../library/library-widget-frontend-contribution';
18-
import { WindowServiceExt } from '../theia/core/window-service-ext';
1918
import type { ListWidget } from '../widgets/component-list/list-widget';
2019
import { Command, CommandRegistry, Contribution } from './contribution';
2120

@@ -53,8 +52,8 @@ const Updatable = { type: 'Updatable' } as const;
5352

5453
@injectable()
5554
export class CheckForUpdates extends Contribution {
56-
@inject(WindowServiceExt)
57-
private readonly windowService: WindowServiceExt;
55+
// @inject(WindowServiceExt)
56+
// private readonly windowService: WindowServiceExt;
5857
@inject(ResponseServiceClient)
5958
private readonly responseService: ResponseServiceClient;
6059
@inject(BoardsService)
@@ -72,16 +71,16 @@ export class CheckForUpdates extends Contribution {
7271
});
7372
}
7473

75-
override async onReady(): Promise<void> {
76-
const checkForUpdates = this.preferences['arduino.checkForUpdates'];
77-
if (checkForUpdates) {
78-
this.windowService.isFirstWindow().then((firstWindow) => {
79-
if (firstWindow) {
80-
this.checkForUpdates();
81-
}
82-
});
83-
}
84-
}
74+
// override async onReady(): Promise<void> {
75+
// const checkForUpdates = this.preferences['arduino.checkForUpdates'];
76+
// if (checkForUpdates) {
77+
// this.windowService.isFirstWindow().then((firstWindow) => {
78+
// if (firstWindow) {
79+
// this.checkForUpdates();
80+
// }
81+
// });
82+
// }
83+
// }
8584

8685
private async checkForUpdates(silent = true) {
8786
const [boardsPackages, libraryPackages] = await Promise.all([

arduino-ide-extension/src/browser/contributions/close.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ import { ApplicationShell } from '@theia/core/lib/browser/shell/application-shel
77
import { nls } from '@theia/core/lib/common/nls';
88
import type { MaybePromise } from '@theia/core/lib/common/types';
99
import { toArray } from '@theia/core/shared/@phosphor/algorithm';
10-
import { inject, injectable } from '@theia/core/shared/inversify';
10+
import { injectable } from '@theia/core/shared/inversify';
1111
import { MonacoEditor } from '@theia/monaco/lib/browser/monaco-editor';
1212
import { ArduinoMenus } from '../menu/arduino-menus';
1313
import { CurrentSketch } from '../sketches-service-client-impl';
14-
import { WindowServiceExt } from '../theia/core/window-service-ext';
1514
import {
1615
Command,
1716
CommandRegistry,
@@ -28,8 +27,8 @@ import { SaveAsSketch } from './save-as-sketch';
2827
*/
2928
@injectable()
3029
export class Close extends SketchContribution {
31-
@inject(WindowServiceExt)
32-
private readonly windowServiceExt: WindowServiceExt;
30+
// @inject(WindowServiceExt)
31+
// private readonly windowServiceExt: WindowServiceExt;
3332

3433
private shell: ApplicationShell | undefined;
3534

@@ -59,7 +58,7 @@ export class Close extends SketchContribution {
5958
}
6059
}
6160
}
62-
return this.windowServiceExt.close();
61+
// return this.windowServiceExt.close();
6362
},
6463
});
6564
}

arduino-ide-extension/src/browser/contributions/update-indexes.ts

+23-26
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ import { nls } from '@theia/core/lib/common/nls';
33
import { inject, injectable } from '@theia/core/shared/inversify';
44
import { CoreService, IndexType } from '../../common/protocol';
55
import { NotificationCenter } from '../notification-center';
6-
import { WindowServiceExt } from '../theia/core/window-service-ext';
76
import { Command, CommandRegistry, Contribution } from './contribution';
87

98
@injectable()
109
export class UpdateIndexes extends Contribution {
11-
@inject(WindowServiceExt)
12-
private readonly windowService: WindowServiceExt;
10+
// @inject(WindowServiceExt)
11+
// private readonly windowService: WindowServiceExt;
1312
@inject(LocalStorageService)
1413
private readonly localStorage: LocalStorageService;
1514
@inject(CoreService)
@@ -53,30 +52,28 @@ export class UpdateIndexes extends Contribution {
5352
return;
5453
}
5554

56-
if (await this.windowService.isFirstWindow()) {
57-
const summary = await this.coreService.indexUpdateSummaryBeforeInit();
58-
if (summary.message) {
59-
this.messageService.error(summary.message);
60-
}
61-
const typesToCheck = IndexType.All.filter((type) => !(type in summary));
62-
if (Object.keys(summary).length) {
63-
console.debug(
64-
`[update-indexes]: Detected an index update summary before the core gRPC client initialization. Updating local storage with ${JSON.stringify(
65-
summary
66-
)}`
67-
);
68-
} else {
69-
console.debug(
70-
'[update-indexes]: No index update summary was available before the core gRPC client initialization. Checking the status of the all the index types.'
71-
);
72-
}
73-
await Promise.allSettled([
74-
...Object.entries(summary).map(([type, updatedAt]) =>
75-
this.setLastUpdateDateTime(type as IndexType, updatedAt)
76-
),
77-
this.updateIndexes(typesToCheck),
78-
]);
55+
const summary = await this.coreService.indexUpdateSummaryBeforeInit();
56+
if (summary.message) {
57+
this.messageService.error(summary.message);
7958
}
59+
const typesToCheck = IndexType.All.filter((type) => !(type in summary));
60+
if (Object.keys(summary).length) {
61+
console.debug(
62+
`[update-indexes]: Detected an index update summary before the core gRPC client initialization. Updating local storage with ${JSON.stringify(
63+
summary
64+
)}`
65+
);
66+
} else {
67+
console.debug(
68+
'[update-indexes]: No index update summary was available before the core gRPC client initialization. Checking the status of the all the index types.'
69+
);
70+
}
71+
await Promise.allSettled([
72+
...Object.entries(summary).map(([type, updatedAt]) =>
73+
this.setLastUpdateDateTime(type as IndexType, updatedAt)
74+
),
75+
this.updateIndexes(typesToCheck),
76+
]);
8077
}
8178

8279
private async updateIndexes(

arduino-ide-extension/src/browser/theia/core/browser-menu-module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
1515
rebind(BrowserMenuBarContribution)
1616
.to(ArduinoMenuContribution)
1717
.inSingletonScope();
18-
});
18+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { DefaultWindowService as TheiaDefaultWindowService } from '@theia/core/lib/browser/window/default-window-service';
2+
import { injectable } from '@theia/core/shared/inversify';
3+
import { WindowServiceExt } from './window-service-ext';
4+
5+
@injectable()
6+
export class DefaultWindowService
7+
extends TheiaDefaultWindowService
8+
implements WindowServiceExt
9+
{
10+
close(): void {
11+
throw new Error('Method not implemented.');
12+
}
13+
/**
14+
* The default implementation always resolves to `true`.
15+
* IDE2 does not use it. It's currently an electron-only app.
16+
*/
17+
async isFirstWindow(): Promise<boolean> {
18+
return true;
19+
}
20+
}

0 commit comments

Comments
 (0)