/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import { Registry } from '../../../../platform/registry/common/platform.js'; import { ViewContainerLocation, IViewContainersRegistry, IViewsRegistry, Extensions } from '../../../common/views.js'; import { ILocalizedString, localize } from '../../../../nls.js'; import { SyncDescriptor } from '../../../../platform/instantiation/common/descriptors.js'; import { registerIcon } from '../../../../platform/theme/common/iconRegistry.js'; import { Codicon } from '../../../../base/common/codicons.js'; import { ExampleViewContainer } from './views/exampleViewContainer.js'; import { ExampleView } from './views/exampleView.js'; import { IViewPaneOptions } from '../../../browser/parts/views/viewPane.js'; import { EditorPaneDescriptor, IEditorPaneRegistry } from '../../../browser/editor.js'; import { EditorExtensions } from '../../../common/editor.js'; import { StockDetailsEditor } from './editors/StockDetailsEditor.js'; import { StockDetailsInput } from './editors/StockDetailsInput.js'; // 如果需要为 Extensions 使用别名,可以在此处赋值 const ViewContainerExtensions = Extensions; const ViewExtensions = Extensions; // 注册图标 const exampleIcon = registerIcon( 'example-view-icon', Codicon.beaker, localize('exampleViewIcon', 'Example View 的图标') ); // 注册视图容器 const viewContainer = Registry.as(ViewContainerExtensions.ViewContainersRegistry).registerViewContainer( { id: 'workbench.view.example', title: { value: localize('example', '侧边栏'), original: 'Example' }, ctorDescriptor: new SyncDescriptor(ExampleViewContainer), icon: exampleIcon, order: 6, }, ViewContainerLocation.Sidebar ); // 定义视图选项 const exampleViewOptions: IViewPaneOptions = { id: 'exampleView', title: '示例视图', }; function localizedString(key: string, defaultMessage: string, original: string): ILocalizedString { console.log('Registering Example View Container...'); // eslint-disable-next-line local/code-no-unexternalized-strings return { value: localize(key, defaultMessage), original }; } // 注册视图 Registry.as(ViewExtensions.ViewsRegistry).registerViews( [ { id: 'exampleView', name: localizedString('exampleView', '示例视图', 'Example View'), ctorDescriptor: new SyncDescriptor(ExampleView, [exampleViewOptions]), }, ], viewContainer ); // 注册 EditorPane Registry.as(EditorExtensions.EditorPane).registerEditorPane( EditorPaneDescriptor.create( StockDetailsEditor, // 编辑器的类 StockDetailsEditor.ID, // 编辑器唯一标识符 localize('stockDetails', 'Stock Details') // 编辑器的本地化名称 ), [new SyncDescriptor(StockDetailsInput)] // 绑定的 EditorInput 类型 ); console.log('StockDetailsEditor 注册完成'); console.log('初始化完成');