@theia/getting-started 1.53.0-next.4 → 1.53.0-next.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -37
- package/lib/browser/getting-started-widget.d.ts +14 -5
- package/lib/browser/getting-started-widget.d.ts.map +1 -1
- package/lib/browser/getting-started-widget.js +71 -27
- package/lib/browser/getting-started-widget.js.map +1 -1
- package/package.json +9 -9
- package/src/browser/getting-started-contribution.ts +126 -126
- package/src/browser/getting-started-frontend-module.ts +33 -33
- package/src/browser/getting-started-preferences.ts +69 -69
- package/src/browser/getting-started-widget.tsx +628 -550
- package/src/browser/style/index.css +129 -109
- package/src/package.spec.ts +28 -28
|
@@ -1,126 +1,126 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2018 Ericsson and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
18
|
-
import { ArrayUtils, CommandRegistry, MenuModelRegistry } from '@theia/core/lib/common';
|
|
19
|
-
import { CommonCommands, CommonMenus, AbstractViewContribution, FrontendApplicationContribution, FrontendApplication, PreferenceService } from '@theia/core/lib/browser';
|
|
20
|
-
import { EditorManager } from '@theia/editor/lib/browser/editor-manager';
|
|
21
|
-
import { GettingStartedWidget } from './getting-started-widget';
|
|
22
|
-
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
|
23
|
-
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
|
|
24
|
-
import { PreviewContribution } from '@theia/preview/lib/browser/preview-contribution';
|
|
25
|
-
import { WorkspaceService } from '@theia/workspace/lib/browser';
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Triggers opening the `GettingStartedWidget`.
|
|
29
|
-
*/
|
|
30
|
-
export const GettingStartedCommand = {
|
|
31
|
-
id: GettingStartedWidget.ID,
|
|
32
|
-
label: GettingStartedWidget.LABEL
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
@injectable()
|
|
36
|
-
export class GettingStartedContribution extends AbstractViewContribution<GettingStartedWidget> implements FrontendApplicationContribution {
|
|
37
|
-
|
|
38
|
-
@inject(CommandRegistry)
|
|
39
|
-
protected readonly commandRegistry: CommandRegistry;
|
|
40
|
-
|
|
41
|
-
@inject(EditorManager)
|
|
42
|
-
protected readonly editorManager: EditorManager;
|
|
43
|
-
|
|
44
|
-
@inject(FileService)
|
|
45
|
-
protected readonly fileService: FileService;
|
|
46
|
-
|
|
47
|
-
@inject(PreferenceService)
|
|
48
|
-
protected readonly preferenceService: PreferenceService;
|
|
49
|
-
|
|
50
|
-
@inject(PreviewContribution)
|
|
51
|
-
protected readonly previewContribution: PreviewContribution;
|
|
52
|
-
|
|
53
|
-
@inject(FrontendApplicationStateService)
|
|
54
|
-
protected readonly stateService: FrontendApplicationStateService;
|
|
55
|
-
|
|
56
|
-
@inject(WorkspaceService)
|
|
57
|
-
protected readonly workspaceService: WorkspaceService;
|
|
58
|
-
|
|
59
|
-
constructor() {
|
|
60
|
-
super({
|
|
61
|
-
widgetId: GettingStartedWidget.ID,
|
|
62
|
-
widgetName: GettingStartedWidget.LABEL,
|
|
63
|
-
defaultWidgetOptions: {
|
|
64
|
-
area: 'main',
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
async onStart(app: FrontendApplication): Promise<void> {
|
|
70
|
-
this.stateService.reachedState('ready').then(async () => {
|
|
71
|
-
if (this.editorManager.all.length === 0) {
|
|
72
|
-
await this.preferenceService.ready;
|
|
73
|
-
const startupEditor = this.preferenceService.get('workbench.startupEditor');
|
|
74
|
-
switch (startupEditor) {
|
|
75
|
-
case 'welcomePage':
|
|
76
|
-
this.openView({ reveal: true, activate: true });
|
|
77
|
-
break;
|
|
78
|
-
case 'welcomePageInEmptyWorkbench':
|
|
79
|
-
if (!this.workspaceService.opened) {
|
|
80
|
-
this.openView({ reveal: true, activate: true });
|
|
81
|
-
}
|
|
82
|
-
break;
|
|
83
|
-
case 'newUntitledFile':
|
|
84
|
-
this.commandRegistry.executeCommand(CommonCommands.NEW_UNTITLED_TEXT_FILE.id);
|
|
85
|
-
break;
|
|
86
|
-
case 'readme':
|
|
87
|
-
await this.openReadme();
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
protected async openReadme(): Promise<void> {
|
|
95
|
-
const roots = await this.workspaceService.roots;
|
|
96
|
-
const readmes = await Promise.all(roots.map(async folder => {
|
|
97
|
-
const folderStat = await this.fileService.resolve(folder.resource);
|
|
98
|
-
const fileArr = folderStat?.children?.sort((a, b) => a.name.localeCompare(b.name)) || [];
|
|
99
|
-
const filePath = fileArr.find(file => file.name.toLowerCase() === 'readme.md') || fileArr.find(file => file.name.toLowerCase().startsWith('readme'));
|
|
100
|
-
return filePath?.resource;
|
|
101
|
-
}));
|
|
102
|
-
const validReadmes = ArrayUtils.coalesce(readmes);
|
|
103
|
-
if (validReadmes.length) {
|
|
104
|
-
for (const readme of validReadmes) {
|
|
105
|
-
await this.previewContribution.open(readme);
|
|
106
|
-
}
|
|
107
|
-
} else {
|
|
108
|
-
// If no readme is found, show the welcome page.
|
|
109
|
-
this.openView({ reveal: true, activate: true });
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
override registerCommands(registry: CommandRegistry): void {
|
|
114
|
-
registry.registerCommand(GettingStartedCommand, {
|
|
115
|
-
execute: () => this.openView({ reveal: true, activate: true }),
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
override registerMenus(menus: MenuModelRegistry): void {
|
|
120
|
-
menus.registerMenuAction(CommonMenus.HELP, {
|
|
121
|
-
commandId: GettingStartedCommand.id,
|
|
122
|
-
label: GettingStartedCommand.label,
|
|
123
|
-
order: 'a10'
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2018 Ericsson and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
18
|
+
import { ArrayUtils, CommandRegistry, MenuModelRegistry } from '@theia/core/lib/common';
|
|
19
|
+
import { CommonCommands, CommonMenus, AbstractViewContribution, FrontendApplicationContribution, FrontendApplication, PreferenceService } from '@theia/core/lib/browser';
|
|
20
|
+
import { EditorManager } from '@theia/editor/lib/browser/editor-manager';
|
|
21
|
+
import { GettingStartedWidget } from './getting-started-widget';
|
|
22
|
+
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
|
23
|
+
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
|
|
24
|
+
import { PreviewContribution } from '@theia/preview/lib/browser/preview-contribution';
|
|
25
|
+
import { WorkspaceService } from '@theia/workspace/lib/browser';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Triggers opening the `GettingStartedWidget`.
|
|
29
|
+
*/
|
|
30
|
+
export const GettingStartedCommand = {
|
|
31
|
+
id: GettingStartedWidget.ID,
|
|
32
|
+
label: GettingStartedWidget.LABEL
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
@injectable()
|
|
36
|
+
export class GettingStartedContribution extends AbstractViewContribution<GettingStartedWidget> implements FrontendApplicationContribution {
|
|
37
|
+
|
|
38
|
+
@inject(CommandRegistry)
|
|
39
|
+
protected readonly commandRegistry: CommandRegistry;
|
|
40
|
+
|
|
41
|
+
@inject(EditorManager)
|
|
42
|
+
protected readonly editorManager: EditorManager;
|
|
43
|
+
|
|
44
|
+
@inject(FileService)
|
|
45
|
+
protected readonly fileService: FileService;
|
|
46
|
+
|
|
47
|
+
@inject(PreferenceService)
|
|
48
|
+
protected readonly preferenceService: PreferenceService;
|
|
49
|
+
|
|
50
|
+
@inject(PreviewContribution)
|
|
51
|
+
protected readonly previewContribution: PreviewContribution;
|
|
52
|
+
|
|
53
|
+
@inject(FrontendApplicationStateService)
|
|
54
|
+
protected readonly stateService: FrontendApplicationStateService;
|
|
55
|
+
|
|
56
|
+
@inject(WorkspaceService)
|
|
57
|
+
protected readonly workspaceService: WorkspaceService;
|
|
58
|
+
|
|
59
|
+
constructor() {
|
|
60
|
+
super({
|
|
61
|
+
widgetId: GettingStartedWidget.ID,
|
|
62
|
+
widgetName: GettingStartedWidget.LABEL,
|
|
63
|
+
defaultWidgetOptions: {
|
|
64
|
+
area: 'main',
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async onStart(app: FrontendApplication): Promise<void> {
|
|
70
|
+
this.stateService.reachedState('ready').then(async () => {
|
|
71
|
+
if (this.editorManager.all.length === 0) {
|
|
72
|
+
await this.preferenceService.ready;
|
|
73
|
+
const startupEditor = this.preferenceService.get('workbench.startupEditor');
|
|
74
|
+
switch (startupEditor) {
|
|
75
|
+
case 'welcomePage':
|
|
76
|
+
this.openView({ reveal: true, activate: true });
|
|
77
|
+
break;
|
|
78
|
+
case 'welcomePageInEmptyWorkbench':
|
|
79
|
+
if (!this.workspaceService.opened) {
|
|
80
|
+
this.openView({ reveal: true, activate: true });
|
|
81
|
+
}
|
|
82
|
+
break;
|
|
83
|
+
case 'newUntitledFile':
|
|
84
|
+
this.commandRegistry.executeCommand(CommonCommands.NEW_UNTITLED_TEXT_FILE.id);
|
|
85
|
+
break;
|
|
86
|
+
case 'readme':
|
|
87
|
+
await this.openReadme();
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
protected async openReadme(): Promise<void> {
|
|
95
|
+
const roots = await this.workspaceService.roots;
|
|
96
|
+
const readmes = await Promise.all(roots.map(async folder => {
|
|
97
|
+
const folderStat = await this.fileService.resolve(folder.resource);
|
|
98
|
+
const fileArr = folderStat?.children?.sort((a, b) => a.name.localeCompare(b.name)) || [];
|
|
99
|
+
const filePath = fileArr.find(file => file.name.toLowerCase() === 'readme.md') || fileArr.find(file => file.name.toLowerCase().startsWith('readme'));
|
|
100
|
+
return filePath?.resource;
|
|
101
|
+
}));
|
|
102
|
+
const validReadmes = ArrayUtils.coalesce(readmes);
|
|
103
|
+
if (validReadmes.length) {
|
|
104
|
+
for (const readme of validReadmes) {
|
|
105
|
+
await this.previewContribution.open(readme);
|
|
106
|
+
}
|
|
107
|
+
} else {
|
|
108
|
+
// If no readme is found, show the welcome page.
|
|
109
|
+
this.openView({ reveal: true, activate: true });
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
override registerCommands(registry: CommandRegistry): void {
|
|
114
|
+
registry.registerCommand(GettingStartedCommand, {
|
|
115
|
+
execute: () => this.openView({ reveal: true, activate: true }),
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
override registerMenus(menus: MenuModelRegistry): void {
|
|
120
|
+
menus.registerMenuAction(CommonMenus.HELP, {
|
|
121
|
+
commandId: GettingStartedCommand.id,
|
|
122
|
+
label: GettingStartedCommand.label,
|
|
123
|
+
order: 'a10'
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2018 Ericsson and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { GettingStartedContribution } from './getting-started-contribution';
|
|
18
|
-
import { ContainerModule, interfaces } from '@theia/core/shared/inversify';
|
|
19
|
-
import { GettingStartedWidget } from './getting-started-widget';
|
|
20
|
-
import { WidgetFactory, FrontendApplicationContribution, bindViewContribution } from '@theia/core/lib/browser';
|
|
21
|
-
import { bindGettingStartedPreferences } from './getting-started-preferences';
|
|
22
|
-
import '../../src/browser/style/index.css';
|
|
23
|
-
|
|
24
|
-
export default new ContainerModule((bind: interfaces.Bind) => {
|
|
25
|
-
bindViewContribution(bind, GettingStartedContribution);
|
|
26
|
-
bind(FrontendApplicationContribution).toService(GettingStartedContribution);
|
|
27
|
-
bind(GettingStartedWidget).toSelf();
|
|
28
|
-
bind(WidgetFactory).toDynamicValue(context => ({
|
|
29
|
-
id: GettingStartedWidget.ID,
|
|
30
|
-
createWidget: () => context.container.get<GettingStartedWidget>(GettingStartedWidget),
|
|
31
|
-
})).inSingletonScope();
|
|
32
|
-
bindGettingStartedPreferences(bind);
|
|
33
|
-
});
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2018 Ericsson and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { GettingStartedContribution } from './getting-started-contribution';
|
|
18
|
+
import { ContainerModule, interfaces } from '@theia/core/shared/inversify';
|
|
19
|
+
import { GettingStartedWidget } from './getting-started-widget';
|
|
20
|
+
import { WidgetFactory, FrontendApplicationContribution, bindViewContribution } from '@theia/core/lib/browser';
|
|
21
|
+
import { bindGettingStartedPreferences } from './getting-started-preferences';
|
|
22
|
+
import '../../src/browser/style/index.css';
|
|
23
|
+
|
|
24
|
+
export default new ContainerModule((bind: interfaces.Bind) => {
|
|
25
|
+
bindViewContribution(bind, GettingStartedContribution);
|
|
26
|
+
bind(FrontendApplicationContribution).toService(GettingStartedContribution);
|
|
27
|
+
bind(GettingStartedWidget).toSelf();
|
|
28
|
+
bind(WidgetFactory).toDynamicValue(context => ({
|
|
29
|
+
id: GettingStartedWidget.ID,
|
|
30
|
+
createWidget: () => context.container.get<GettingStartedWidget>(GettingStartedWidget),
|
|
31
|
+
})).inSingletonScope();
|
|
32
|
+
bindGettingStartedPreferences(bind);
|
|
33
|
+
});
|
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2023 Ericsson and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { interfaces } from '@theia/core/shared/inversify';
|
|
18
|
-
import {
|
|
19
|
-
createPreferenceProxy,
|
|
20
|
-
PreferenceProxy,
|
|
21
|
-
PreferenceService,
|
|
22
|
-
PreferenceSchema,
|
|
23
|
-
PreferenceContribution
|
|
24
|
-
} from '@theia/core/lib/browser/preferences';
|
|
25
|
-
import { FrontendApplicationConfigProvider } from '@theia/core/lib/browser/frontend-application-config-provider';
|
|
26
|
-
import { nls } from '@theia/core/lib/common/nls';
|
|
27
|
-
|
|
28
|
-
export const GettingStartedPreferenceSchema: PreferenceSchema = {
|
|
29
|
-
'type': 'object',
|
|
30
|
-
properties: {
|
|
31
|
-
'workbench.startupEditor': {
|
|
32
|
-
type: 'string',
|
|
33
|
-
enum: ['none', 'welcomePage', 'readme', 'newUntitledFile', 'welcomePageInEmptyWorkbench'],
|
|
34
|
-
enumDescriptions: [
|
|
35
|
-
nls.localizeByDefault('Start without an editor.'),
|
|
36
|
-
nls.localize('theia/getting-started/startup-editor/welcomePage', 'Open the Welcome page, with content to aid in getting started with {0} and extensions.',
|
|
37
|
-
FrontendApplicationConfigProvider.get().applicationName),
|
|
38
|
-
// eslint-disable-next-line max-len
|
|
39
|
-
nls.localizeByDefault("Open the README when opening a folder that contains one, fallback to 'welcomePage' otherwise. Note: This is only observed as a global configuration, it will be ignored if set in a workspace or folder configuration."),
|
|
40
|
-
nls.localizeByDefault('Open a new untitled text file (only applies when opening an empty window).'),
|
|
41
|
-
nls.localizeByDefault('Open the Welcome page when opening an empty workbench.'),
|
|
42
|
-
],
|
|
43
|
-
default: 'welcomePage',
|
|
44
|
-
description: nls.localizeByDefault('Controls which editor is shown at startup, if none are restored from the previous session.')
|
|
45
|
-
},
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export interface GettingStartedConfiguration {
|
|
50
|
-
'workbench.startupEditor': string;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export const GettingStartedPreferenceContribution = Symbol('GettingStartedPreferenceContribution');
|
|
54
|
-
export const GettingStartedPreferences = Symbol('GettingStartedPreferences');
|
|
55
|
-
export type GettingStartedPreferences = PreferenceProxy<GettingStartedConfiguration>;
|
|
56
|
-
|
|
57
|
-
export function createGettingStartedPreferences(preferences: PreferenceService, schema: PreferenceSchema = GettingStartedPreferenceSchema): GettingStartedPreferences {
|
|
58
|
-
return createPreferenceProxy(preferences, schema);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function bindGettingStartedPreferences(bind: interfaces.Bind): void {
|
|
62
|
-
bind(GettingStartedPreferences).toDynamicValue(ctx => {
|
|
63
|
-
const preferences = ctx.container.get<PreferenceService>(PreferenceService);
|
|
64
|
-
const contribution = ctx.container.get<PreferenceContribution>(GettingStartedPreferenceContribution);
|
|
65
|
-
return createGettingStartedPreferences(preferences, contribution.schema);
|
|
66
|
-
}).inSingletonScope();
|
|
67
|
-
bind(GettingStartedPreferenceContribution).toConstantValue({ schema: GettingStartedPreferenceSchema });
|
|
68
|
-
bind(PreferenceContribution).toService(GettingStartedPreferenceContribution);
|
|
69
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 Ericsson and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { interfaces } from '@theia/core/shared/inversify';
|
|
18
|
+
import {
|
|
19
|
+
createPreferenceProxy,
|
|
20
|
+
PreferenceProxy,
|
|
21
|
+
PreferenceService,
|
|
22
|
+
PreferenceSchema,
|
|
23
|
+
PreferenceContribution
|
|
24
|
+
} from '@theia/core/lib/browser/preferences';
|
|
25
|
+
import { FrontendApplicationConfigProvider } from '@theia/core/lib/browser/frontend-application-config-provider';
|
|
26
|
+
import { nls } from '@theia/core/lib/common/nls';
|
|
27
|
+
|
|
28
|
+
export const GettingStartedPreferenceSchema: PreferenceSchema = {
|
|
29
|
+
'type': 'object',
|
|
30
|
+
properties: {
|
|
31
|
+
'workbench.startupEditor': {
|
|
32
|
+
type: 'string',
|
|
33
|
+
enum: ['none', 'welcomePage', 'readme', 'newUntitledFile', 'welcomePageInEmptyWorkbench'],
|
|
34
|
+
enumDescriptions: [
|
|
35
|
+
nls.localizeByDefault('Start without an editor.'),
|
|
36
|
+
nls.localize('theia/getting-started/startup-editor/welcomePage', 'Open the Welcome page, with content to aid in getting started with {0} and extensions.',
|
|
37
|
+
FrontendApplicationConfigProvider.get().applicationName),
|
|
38
|
+
// eslint-disable-next-line max-len
|
|
39
|
+
nls.localizeByDefault("Open the README when opening a folder that contains one, fallback to 'welcomePage' otherwise. Note: This is only observed as a global configuration, it will be ignored if set in a workspace or folder configuration."),
|
|
40
|
+
nls.localizeByDefault('Open a new untitled text file (only applies when opening an empty window).'),
|
|
41
|
+
nls.localizeByDefault('Open the Welcome page when opening an empty workbench.'),
|
|
42
|
+
],
|
|
43
|
+
default: 'welcomePage',
|
|
44
|
+
description: nls.localizeByDefault('Controls which editor is shown at startup, if none are restored from the previous session.')
|
|
45
|
+
},
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export interface GettingStartedConfiguration {
|
|
50
|
+
'workbench.startupEditor': string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const GettingStartedPreferenceContribution = Symbol('GettingStartedPreferenceContribution');
|
|
54
|
+
export const GettingStartedPreferences = Symbol('GettingStartedPreferences');
|
|
55
|
+
export type GettingStartedPreferences = PreferenceProxy<GettingStartedConfiguration>;
|
|
56
|
+
|
|
57
|
+
export function createGettingStartedPreferences(preferences: PreferenceService, schema: PreferenceSchema = GettingStartedPreferenceSchema): GettingStartedPreferences {
|
|
58
|
+
return createPreferenceProxy(preferences, schema);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function bindGettingStartedPreferences(bind: interfaces.Bind): void {
|
|
62
|
+
bind(GettingStartedPreferences).toDynamicValue(ctx => {
|
|
63
|
+
const preferences = ctx.container.get<PreferenceService>(PreferenceService);
|
|
64
|
+
const contribution = ctx.container.get<PreferenceContribution>(GettingStartedPreferenceContribution);
|
|
65
|
+
return createGettingStartedPreferences(preferences, contribution.schema);
|
|
66
|
+
}).inSingletonScope();
|
|
67
|
+
bind(GettingStartedPreferenceContribution).toConstantValue({ schema: GettingStartedPreferenceSchema });
|
|
68
|
+
bind(PreferenceContribution).toService(GettingStartedPreferenceContribution);
|
|
69
|
+
}
|