diff --git a/src/vs/platform/actions/browser/menusExtensionPoint.ts b/src/vs/platform/actions/browser/menusExtensionPoint.ts index 0f4c6fce494..33888567575 100644 --- a/src/vs/platform/actions/browser/menusExtensionPoint.ts +++ b/src/vs/platform/actions/browser/menusExtensionPoint.ts @@ -15,7 +15,6 @@ import { IExtensionPointUser, IExtensionMessageCollector, ExtensionsRegistry } f import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { MenuId, MenuRegistry } from 'vs/platform/actions/common/actions'; import { Registry } from 'vs/platform/platform'; -import { ViewletRegistry, Extensions as ViewletExtensions, ViewletDescriptor, ToggleViewletAction } from 'vs/workbench/browser/viewlet'; namespace schema { @@ -208,34 +207,6 @@ namespace schema { } ] }; - - // --- treeExplorers contribution point - - export interface IExplorer { - treeExplorerNodeProviderId: string; - treeLabel: string; - icon: IUserFriendlyIcon; - } - - export const explorerContribtion: IJSONSchema = { - description: localize('vscode.extension.contributes.explorer', "Contributes explorer viewlet to the sidebar"), - type: 'object', - properties: { - treeContentProviderId: { - description: localize('vscode.extension.contributes.explorer.treeExplorerNodeProviderId', 'Unique id used to identify provider registered through vscode.workspace.registerTreeExplorerNodeProvider'), - type: 'string' - }, - treeLabel: { - description: localize('vscode.extension.contributes.explorer.treeLabel', 'Human readable string used to render the custom tree Viewlet'), - type: 'string' - }, - icon: { - description: localize('vscode.extension.contributes.explorer.icon', 'Icon to put on activity bar'), - type: 'string' - } - } - }; - } ExtensionsRegistry.registerExtensionPoint('commands', schema.commandsContribution).setHandler(extensions => { @@ -336,35 +307,4 @@ ExtensionsRegistry.registerExtensionPoint<{ [loc: string]: schema.IUserFriendlyM } }); } -}); - -ExtensionsRegistry.registerExtensionPoint('explorer', schema.explorerContribtion).setHandler(extensions => { - let baseOrder = 200; - - for (let extension of extensions) { - const { treeExplorerNodeProviderId, treeLabel, icon } = extension.value; - - const getIconRule = (iconPath) => { return `background-image: url('${iconPath}')`; }; - if (icon) { - if (typeof icon === 'string') { - const iconClass = `.monaco-workbench > .activitybar .monaco-action-bar .action-label.${treeExplorerNodeProviderId}`; - const iconPath = join(extension.description.extensionFolderPath, icon); - createCSSRule(iconClass, getIconRule(iconPath)); - } else { - const lightIconClass = `.monaco-workbench > .activitybar .monaco-action-bar .action-label.${treeExplorerNodeProviderId}`; - const darkIconClass = `.vs-dark .monaco-workbench > .activitybar .monaco-action-bar .action-label.${treeExplorerNodeProviderId}`; - createCSSRule(lightIconClass, getIconRule(icon.light)); - createCSSRule(darkIconClass, getIconRule(icon.dark)); - } - } - - Registry.as(ViewletExtensions.Viewlets).registerViewlet(new ViewletDescriptor( - 'vs/workbench/parts/explorers/browser/treeExplorerViewlet', - 'TreeExplorerViewlet', - 'workbench.view.customTreeExplorerViewlet.' + treeExplorerNodeProviderId, - treeLabel, - treeExplorerNodeProviderId, - baseOrder++ - )); - } }); \ No newline at end of file diff --git a/src/vs/platform/explorers/browser/explorerExtensionPoint.ts b/src/vs/platform/explorers/browser/explorerExtensionPoint.ts new file mode 100644 index 00000000000..375491b3622 --- /dev/null +++ b/src/vs/platform/explorers/browser/explorerExtensionPoint.ts @@ -0,0 +1,74 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +'use strict'; + +import { localize } from 'vs/nls'; +import { join } from 'vs/base/common/paths'; +import { createCSSRule } from 'vs/base/browser/dom'; +import { IJSONSchema } from 'vs/base/common/jsonSchema'; +import { ExtensionsRegistry } from 'vs/platform/extensions/common/extensionsRegistry'; +import { Registry } from 'vs/platform/platform'; +import { ViewletRegistry, Extensions as ViewletExtensions, ViewletDescriptor } from 'vs/workbench/browser/viewlet'; + +namespace schema { + + export type IUserFriendlyIcon = string | { light: string; dark: string; }; + + export interface IExplorer { + treeExplorerNodeProviderId: string; + treeLabel: string; + icon: IUserFriendlyIcon; + } + + export const explorerContribtion: IJSONSchema = { + description: localize('vscode.extension.contributes.explorer', "Contributes explorer viewlet to the sidebar"), + type: 'object', + properties: { + treeContentProviderId: { + description: localize('vscode.extension.contributes.explorer.treeExplorerNodeProviderId', 'Unique id used to identify provider registered through vscode.workspace.registerTreeExplorerNodeProvider'), + type: 'string' + }, + treeLabel: { + description: localize('vscode.extension.contributes.explorer.treeLabel', 'Human readable string used to render the custom tree Viewlet'), + type: 'string' + }, + icon: { + description: localize('vscode.extension.contributes.explorer.icon', 'Icon to put on activity bar'), + type: 'string' + } + } + }; +} + +ExtensionsRegistry.registerExtensionPoint('explorer', schema.explorerContribtion).setHandler(extensions => { + let baseOrder = 200; + + for (let extension of extensions) { + const { treeExplorerNodeProviderId, treeLabel, icon } = extension.value; + + const getIconRule = (iconPath) => { return `background-image: url('${iconPath}')`; }; + if (icon) { + if (typeof icon === 'string') { + const iconClass = `.monaco-workbench > .activitybar .monaco-action-bar .action-label.${treeExplorerNodeProviderId}`; + const iconPath = join(extension.description.extensionFolderPath, icon); + createCSSRule(iconClass, getIconRule(iconPath)); + } else { + const lightIconClass = `.monaco-workbench > .activitybar .monaco-action-bar .action-label.${treeExplorerNodeProviderId}`; + const darkIconClass = `.vs-dark .monaco-workbench > .activitybar .monaco-action-bar .action-label.${treeExplorerNodeProviderId}`; + createCSSRule(lightIconClass, getIconRule(icon.light)); + createCSSRule(darkIconClass, getIconRule(icon.dark)); + } + } + + Registry.as(ViewletExtensions.Viewlets).registerViewlet(new ViewletDescriptor( + 'vs/workbench/parts/explorers/browser/treeExplorerViewlet', + 'TreeExplorerViewlet', + 'workbench.view.customTreeExplorerViewlet.' + treeExplorerNodeProviderId, + treeLabel, + treeExplorerNodeProviderId, + baseOrder++ + )); + } +}) \ No newline at end of file diff --git a/src/vs/workbench/workbench.main.ts b/src/vs/workbench/workbench.main.ts index 648fd248b31..86a40d61df7 100644 --- a/src/vs/workbench/workbench.main.ts +++ b/src/vs/workbench/workbench.main.ts @@ -19,6 +19,9 @@ import 'vs/editor/browser/editor.all'; // Menus/Actions import 'vs/platform/actions/browser/menusExtensionPoint'; +// External Explorers +import "vs/platform/explorers/browser/explorerExtensionPoint"; + // Workbench import 'vs/workbench/browser/actions/toggleStatusbarVisibility'; import 'vs/workbench/browser/actions/toggleSidebarVisibility';