提交 e0dd508b 编写于 作者: P Peng Lyu

Register Remote Explorer when there are contributions.

上级 bdb1a49e
......@@ -19,6 +19,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { VIEWLET_ID as EXPLORER } from 'vs/workbench/contrib/files/common/files';
import { VIEWLET_ID as SCM } from 'vs/workbench/contrib/scm/common/scm';
import { VIEWLET_ID as DEBUG } from 'vs/workbench/contrib/debug/common/debug';
import { VIEWLET_ID as REMOTE } from 'vs/workbench/contrib/remote/common/remote.contribution';
import { ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { URI } from 'vs/base/common/uri';
import { ViewletRegistry, Extensions as ViewletExtensions, ViewletDescriptor, ShowViewletAction } from 'vs/workbench/browser/viewlet';
......@@ -79,6 +80,7 @@ interface IUserFriendlyViewDescriptor {
id: string;
name: string;
when?: string;
group?: string;
}
const viewDescriptor: IJSONSchema = {
......@@ -99,6 +101,27 @@ const viewDescriptor: IJSONSchema = {
}
};
const nestableViewDescriptor: IJSONSchema = {
type: 'object',
properties: {
id: {
description: localize('vscode.extension.contributes.view.id', 'Identifier of the view. Use this to register a data provider through `vscode.window.registerTreeDataProviderForView` API. Also to trigger activating your extension by registering `onView:${id}` event to `activationEvents`.'),
type: 'string'
},
name: {
description: localize('vscode.extension.contributes.view.name', 'The human-readable name of the view. Will be shown'),
type: 'string'
},
when: {
description: localize('vscode.extension.contributes.view.when', 'Condition which must be true to show this view'),
type: 'string'
},
group: {
description: localize('vscode.extension.contributes.view.group', 'Nested group in the viewlet'),
type: 'string'
}
}
};
const viewsContribution: IJSONSchema = {
description: localize('vscode.extension.contributes.views', "Contributes views to the editor"),
type: 'object',
......@@ -126,6 +149,12 @@ const viewsContribution: IJSONSchema = {
type: 'array',
items: viewDescriptor,
default: []
},
'remote': {
description: localize('views.remote', "Contributes views to Remote container in the Activity bar"),
type: 'array',
items: nestableViewDescriptor,
default: []
}
},
additionalProperties: {
......@@ -376,6 +405,12 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
return null;
}
const order = ExtensionIdentifier.equals(extension.description.identifier, container.extensionId)
? index + 1
: container.orderDelegate
? container.orderDelegate.getOrder(item.group)
: undefined;
const viewDescriptor = <ICustomViewDescriptor>{
id: item.id,
name: item.name,
......@@ -384,9 +419,10 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
canToggleVisibility: true,
collapsed: this.showCollapsed(container),
treeView: this.instantiationService.createInstance(CustomTreeView, item.id, item.name, container),
order: ExtensionIdentifier.equals(extension.description.identifier, container.extensionId) ? index + 1 : undefined,
order: order,
extensionId: extension.description.identifier,
originalContainerId: entry.key
originalContainerId: entry.key,
group: item.group
};
viewIds.push(viewDescriptor.id);
......@@ -440,6 +476,7 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
case 'explorer': return this.viewContainersRegistry.get(EXPLORER);
case 'debug': return this.viewContainersRegistry.get(DEBUG);
case 'scm': return this.viewContainersRegistry.get(SCM);
case 'remote': return this.viewContainersRegistry.get(REMOTE);
default: return this.viewContainersRegistry.get(`workbench.view.extension.${value}`);
}
}
......
......@@ -382,7 +382,19 @@ export class ContributableViewsModel extends Disposable {
return 0;
}
return (this.getViewOrder(a) - this.getViewOrder(b)) || (a.id < b.id ? -1 : 1);
return (this.getViewOrder(a) - this.getViewOrder(b)) || this.getGroupOrderResult(a, b) || (a.id < b.id ? -1 : 1);
}
private getGroupOrderResult(a: IViewDescriptor, b: IViewDescriptor) {
if (!a.group || !b.group) {
return 0;
}
if (a.group === b.group) {
return 0;
}
return a.group < b.group ? -1 : 1;
}
private getViewOrder(viewDescriptor: IViewDescriptor): number {
......
......@@ -51,7 +51,7 @@ export interface IViewContainersRegistry {
*
* @returns the registered ViewContainer.
*/
registerViewContainer(id: string, hideIfEmpty?: boolean, extensionId?: ExtensionIdentifier): ViewContainer;
registerViewContainer(id: string, hideIfEmpty?: boolean, extensionId?: ExtensionIdentifier, viewOrderDelegate?: ViewOrderDelegate): ViewContainer;
/**
* Deregisters the given view container
......@@ -67,8 +67,12 @@ export interface IViewContainersRegistry {
get(id: string): ViewContainer | undefined;
}
interface ViewOrderDelegate {
getOrder(group?: string): number | undefined;
}
export class ViewContainer {
protected constructor(readonly id: string, readonly hideIfEmpty: boolean, readonly extensionId?: ExtensionIdentifier) { }
protected constructor(readonly id: string, readonly hideIfEmpty: boolean, readonly extensionId?: ExtensionIdentifier, readonly orderDelegate?: ViewOrderDelegate) { }
}
class ViewContainersRegistryImpl extends Disposable implements IViewContainersRegistry {
......@@ -85,7 +89,7 @@ class ViewContainersRegistryImpl extends Disposable implements IViewContainersRe
return values(this.viewContainers);
}
registerViewContainer(id: string, hideIfEmpty?: boolean, extensionId?: ExtensionIdentifier): ViewContainer {
registerViewContainer(id: string, hideIfEmpty?: boolean, extensionId?: ExtensionIdentifier, viewOrderDelegate?: ViewOrderDelegate): ViewContainer {
const existing = this.viewContainers.get(id);
if (existing) {
return existing;
......@@ -93,7 +97,7 @@ class ViewContainersRegistryImpl extends Disposable implements IViewContainersRe
const viewContainer = new class extends ViewContainer {
constructor() {
super(id, !!hideIfEmpty, extensionId);
super(id, !!hideIfEmpty, extensionId, viewOrderDelegate);
}
};
this.viewContainers.set(id, viewContainer);
......@@ -126,6 +130,8 @@ export interface IViewDescriptor {
readonly when?: ContextKeyExpr;
readonly group?: string;
readonly order?: number;
readonly weight?: number;
......
<svg width="16" height="16" viewBox="0 0 16 16" fill="none"
xmlns="http://www.w3.org/2000/svg">
<path d="M8.354 13.854H7.646L6.793 13H1.5L1 12.5V2.5L1.5 2H7L7.354 2.146L8 2.793L8.646 2.146L9 2H14.5L15 2.5V12.5L14.5 13H9.207L8.354 13.854ZM2 12H7L7.354 12.146L8 12.793L8.646 12.146L9 12H14V3H9.207L8.354 3.854H7.646L6.793 3H2V12Z" fill="#C5C5C5"/>
<path d="M8.51101 3.40405H7.53201V13.5001H8.51101V3.40405Z" fill="#C5C5C5"/>
<path d="M6 5H3V6H6V5Z" fill="#C5C5C5"/>
<path d="M6 7H3V8H6V7Z" fill="#C5C5C5"/>
<path d="M6 9H3V10H6V9Z" fill="#C5C5C5"/>
<path d="M13 5H10V6H13V5Z" fill="#C5C5C5"/>
<path d="M13 7H10V8H13V7Z" fill="#C5C5C5"/>
<path d="M13 9H10V10H13V9Z" fill="#C5C5C5"/>
</svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none"
xmlns="http://www.w3.org/2000/svg">
<path d="M8.354 13.854H7.646L6.793 13H1.5L1 12.5V2.5L1.5 2H7L7.354 2.146L8 2.793L8.646 2.146L9 2H14.5L15 2.5V12.5L14.5 13H9.207L8.354 13.854ZM2 12H7L7.354 12.146L8 12.793L8.646 12.146L9 12H14V3H9.207L8.354 3.854H7.646L6.793 3H2V12Z" fill="white"/>
<path d="M8.51101 3.40405H7.53201V13.5001H8.51101V3.40405Z" fill="white"/>
<path d="M6 5H3V6H6V5Z" fill="white"/>
<path d="M6 7H3V8H6V7Z" fill="white"/>
<path d="M6 9H3V10H6V9Z" fill="white"/>
<path d="M13 5H10V6H13V5Z" fill="white"/>
<path d="M13 7H10V8H13V7Z" fill="white"/>
<path d="M13 9H10V10H13V9Z" fill="white"/>
</svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none"
xmlns="http://www.w3.org/2000/svg">
<path d="M8.354 13.854H7.646L6.793 13H1.5L1 12.5V2.5L1.5 2H7L7.354 2.146L8 2.793L8.646 2.146L9 2H14.5L15 2.5V12.5L14.5 13H9.207L8.354 13.854ZM2 12H7L7.354 12.146L8 12.793L8.646 12.146L9 12H14V3H9.207L8.354 3.854H7.646L6.793 3H2V12Z" fill="#424242"/>
<path d="M8.51101 3.40405H7.53201V13.5001H8.51101V3.40405Z" fill="#424242"/>
<path d="M6 5H3V6H6V5Z" fill="#424242"/>
<path d="M6 7H3V8H6V7Z" fill="#424242"/>
<path d="M6 9H3V10H6V9Z" fill="#424242"/>
<path d="M13 5H10V6H13V5Z" fill="#424242"/>
<path d="M13 7H10V8H13V7Z" fill="#424242"/>
<path d="M13 9H10V10H13V9Z" fill="#424242"/>
</svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none"
xmlns="http://www.w3.org/2000/svg">
<path d="M15 3.78418C14.8086 4.07129 14.5921 4.33902 14.3506 4.5874C14.109 4.83577 13.847 5.0625 13.5644 5.26757C13.569 5.33138 13.5724 5.39404 13.5747 5.45556C13.577 5.51709 13.5781 5.57975 13.5781 5.64355C13.5781 6.21777 13.5166 6.78515 13.3935 7.3457C13.2705 7.90624 13.0928 8.44856 12.8603 8.97265C12.5231 9.73372 12.1016 10.4139 11.5957 11.0132C11.0898 11.6125 10.5168 12.1195 9.87646 12.5342C9.23616 12.9489 8.53775 13.2656 7.78125 13.4844C7.02474 13.7031 6.23177 13.8125 5.40234 13.8125C4.61848 13.8125 3.854 13.7043 3.10888 13.4878C2.36377 13.2713 1.6608 12.9489 1 12.5205C1.22331 12.5478 1.45117 12.5615 1.68359 12.5615C2.33529 12.5615 2.96533 12.4567 3.57373 12.2471C4.18212 12.0374 4.74153 11.7321 5.25195 11.331C4.94661 11.3265 4.65266 11.2752 4.37011 11.1772C4.08756 11.0793 3.82893 10.9425 3.59423 10.7671C3.35953 10.5916 3.15445 10.3831 2.979 10.1416C2.80354 9.90006 2.66796 9.63346 2.57226 9.34179C2.6634 9.35546 2.75341 9.36686 2.84228 9.37597C2.93115 9.38509 3.02115 9.38964 3.1123 9.38964C3.36751 9.38964 3.61815 9.35547 3.86425 9.28711C3.52701 9.21875 3.21826 9.09798 2.93798 8.9248C2.65771 8.75162 2.41503 8.54085 2.20996 8.29248C2.00488 8.04411 1.84537 7.76383 1.73144 7.45166C1.61751 7.13948 1.56054 6.8125 1.56054 6.4707V6.43652C1.96158 6.66439 2.3968 6.78515 2.8662 6.79883C2.66568 6.66211 2.48681 6.50602 2.32959 6.33056C2.17236 6.15511 2.03906 5.96484 1.92968 5.75976C1.82031 5.55469 1.736 5.33822 1.67675 5.11035C1.61751 4.88249 1.58789 4.64779 1.58789 4.40625C1.58789 4.15104 1.61979 3.90153 1.68359 3.65772C1.74739 3.4139 1.84537 3.18262 1.97753 2.96387C2.34212 3.41504 2.74772 3.8195 3.19433 4.17725C3.64094 4.53499 4.11604 4.84147 4.61962 5.09668C5.1232 5.35189 5.65071 5.55355 6.20214 5.70166C6.75357 5.84977 7.31868 5.9375 7.89745 5.96484C7.87011 5.86003 7.85074 5.75179 7.83934 5.64014C7.82795 5.52848 7.82225 5.41797 7.82225 5.30859C7.82225 4.91211 7.89745 4.53955 8.04784 4.19092C8.19823 3.84228 8.40331 3.53809 8.66307 3.27832C8.92284 3.01855 9.22704 2.81348 9.57567 2.66309C9.92431 2.5127 10.2969 2.4375 10.6933 2.4375C11.0944 2.4375 11.4761 2.51611 11.8384 2.67334C12.2007 2.83057 12.5185 3.05501 12.792 3.34668C13.1155 3.28288 13.4289 3.19287 13.7319 3.07666C14.035 2.96045 14.3278 2.81803 14.6103 2.64941C14.5055 2.9821 14.3449 3.28516 14.1284 3.55859C13.9119 3.83203 13.6533 4.05762 13.3525 4.23535C13.9267 4.16699 14.4759 4.0166 15 3.78418Z" fill="#C8C8C8"/>
</svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none"
xmlns="http://www.w3.org/2000/svg">
<path d="M15 3.78418C14.8086 4.07129 14.5921 4.33902 14.3506 4.5874C14.109 4.83577 13.847 5.0625 13.5644 5.26757C13.569 5.33138 13.5724 5.39404 13.5747 5.45556C13.577 5.51709 13.5781 5.57975 13.5781 5.64355C13.5781 6.21777 13.5166 6.78515 13.3935 7.3457C13.2705 7.90624 13.0928 8.44856 12.8603 8.97265C12.5231 9.73372 12.1016 10.4139 11.5957 11.0132C11.0898 11.6125 10.5168 12.1195 9.87646 12.5342C9.23616 12.9489 8.53775 13.2656 7.78125 13.4844C7.02474 13.7031 6.23177 13.8125 5.40234 13.8125C4.61848 13.8125 3.854 13.7043 3.10888 13.4878C2.36377 13.2713 1.6608 12.9489 1 12.5205C1.22331 12.5478 1.45117 12.5615 1.68359 12.5615C2.33529 12.5615 2.96533 12.4567 3.57373 12.2471C4.18212 12.0374 4.74153 11.7321 5.25195 11.331C4.94661 11.3265 4.65266 11.2752 4.37011 11.1772C4.08756 11.0793 3.82893 10.9425 3.59423 10.7671C3.35953 10.5916 3.15445 10.3831 2.979 10.1416C2.80354 9.90006 2.66796 9.63346 2.57226 9.34179C2.6634 9.35546 2.75341 9.36686 2.84228 9.37597C2.93115 9.38509 3.02115 9.38964 3.1123 9.38964C3.36751 9.38964 3.61815 9.35547 3.86425 9.28711C3.52701 9.21875 3.21826 9.09798 2.93798 8.9248C2.65771 8.75162 2.41503 8.54085 2.20996 8.29248C2.00488 8.04411 1.84537 7.76383 1.73144 7.45166C1.61751 7.13948 1.56054 6.8125 1.56054 6.4707V6.43652C1.96158 6.66439 2.3968 6.78515 2.8662 6.79883C2.66568 6.66211 2.48681 6.50602 2.32959 6.33056C2.17236 6.15511 2.03906 5.96484 1.92968 5.75976C1.82031 5.55469 1.736 5.33822 1.67675 5.11035C1.61751 4.88249 1.58789 4.64779 1.58789 4.40625C1.58789 4.15104 1.61979 3.90153 1.68359 3.65772C1.74739 3.4139 1.84537 3.18262 1.97753 2.96387C2.34212 3.41504 2.74772 3.8195 3.19433 4.17725C3.64094 4.53499 4.11604 4.84147 4.61962 5.09668C5.1232 5.35189 5.65071 5.55355 6.20214 5.70166C6.75357 5.84977 7.31868 5.9375 7.89745 5.96484C7.87011 5.86003 7.85074 5.75179 7.83934 5.64014C7.82795 5.52848 7.82225 5.41797 7.82225 5.30859C7.82225 4.91211 7.89745 4.53955 8.04784 4.19092C8.19823 3.84228 8.40331 3.53809 8.66307 3.27832C8.92284 3.01855 9.22704 2.81348 9.57567 2.66309C9.92431 2.5127 10.2969 2.4375 10.6933 2.4375C11.0944 2.4375 11.4761 2.51611 11.8384 2.67334C12.2007 2.83057 12.5185 3.05501 12.792 3.34668C13.1155 3.28288 13.4289 3.19287 13.7319 3.07666C14.035 2.96045 14.3278 2.81803 14.6103 2.64941C14.5055 2.9821 14.3449 3.28516 14.1284 3.55859C13.9119 3.83203 13.6533 4.05762 13.3525 4.23535C13.9267 4.16699 14.4759 4.0166 15 3.78418Z" fill="white"/>
</svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none"
xmlns="http://www.w3.org/2000/svg">
<path d="M15 3.78418C14.8086 4.07129 14.5921 4.33902 14.3506 4.5874C14.109 4.83577 13.847 5.0625 13.5644 5.26757C13.569 5.33138 13.5724 5.39404 13.5747 5.45556C13.577 5.51709 13.5781 5.57975 13.5781 5.64355C13.5781 6.21777 13.5166 6.78515 13.3935 7.3457C13.2705 7.90624 13.0928 8.44856 12.8603 8.97265C12.5231 9.73372 12.1016 10.4139 11.5957 11.0132C11.0898 11.6125 10.5168 12.1195 9.87646 12.5342C9.23616 12.9489 8.53775 13.2656 7.78125 13.4844C7.02474 13.7031 6.23177 13.8125 5.40234 13.8125C4.61848 13.8125 3.854 13.7043 3.10888 13.4878C2.36377 13.2713 1.6608 12.9489 1 12.5205C1.22331 12.5478 1.45117 12.5615 1.68359 12.5615C2.33529 12.5615 2.96533 12.4567 3.57373 12.2471C4.18212 12.0374 4.74153 11.7321 5.25195 11.331C4.94661 11.3265 4.65266 11.2752 4.37011 11.1772C4.08756 11.0793 3.82893 10.9425 3.59423 10.7671C3.35953 10.5916 3.15445 10.3831 2.979 10.1416C2.80354 9.90006 2.66796 9.63346 2.57226 9.34179C2.6634 9.35546 2.75341 9.36686 2.84228 9.37597C2.93115 9.38509 3.02115 9.38964 3.1123 9.38964C3.36751 9.38964 3.61815 9.35547 3.86425 9.28711C3.52701 9.21875 3.21826 9.09798 2.93798 8.9248C2.65771 8.75162 2.41503 8.54085 2.20996 8.29248C2.00488 8.04411 1.84537 7.76383 1.73144 7.45166C1.61751 7.13948 1.56054 6.8125 1.56054 6.4707V6.43652C1.96158 6.66439 2.3968 6.78515 2.8662 6.79883C2.66568 6.66211 2.48681 6.50602 2.32959 6.33056C2.17236 6.15511 2.03906 5.96484 1.92968 5.75976C1.82031 5.55469 1.736 5.33822 1.67675 5.11035C1.61751 4.88249 1.58789 4.64779 1.58789 4.40625C1.58789 4.15104 1.61979 3.90153 1.68359 3.65772C1.74739 3.4139 1.84537 3.18262 1.97753 2.96387C2.34212 3.41504 2.74772 3.8195 3.19433 4.17725C3.64094 4.53499 4.11604 4.84147 4.61962 5.09668C5.1232 5.35189 5.65071 5.55355 6.20214 5.70166C6.75357 5.84977 7.31868 5.9375 7.89745 5.96484C7.87011 5.86003 7.85074 5.75179 7.83934 5.64014C7.82795 5.52848 7.82225 5.41797 7.82225 5.30859C7.82225 4.91211 7.89745 4.53955 8.04784 4.19092C8.19823 3.84228 8.40331 3.53809 8.66307 3.27832C8.92284 3.01855 9.22704 2.81348 9.57567 2.66309C9.92431 2.5127 10.2969 2.4375 10.6933 2.4375C11.0944 2.4375 11.4761 2.51611 11.8384 2.67334C12.2007 2.83057 12.5185 3.05501 12.792 3.34668C13.1155 3.28288 13.4289 3.19287 13.7319 3.07666C14.035 2.96045 14.3278 2.81803 14.6103 2.64941C14.5055 2.9821 14.3449 3.28516 14.1284 3.55859C13.9119 3.83203 13.6533 4.05762 13.3525 4.23535C13.9267 4.16699 14.4759 4.0166 15 3.78418Z" fill="#424242"/>
</svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none"
xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.59454 6.25211L8 1L6.40546 6.25211H1L5.37311 9.65247L3.7496 15L8 11.695L12.2504 15L10.6269 9.65247L15 6.25211H9.59454ZM2.34804 6.72168H6.72044L8 2.50706L8.00002 2.50708L6.72046 6.7217H2.34805L2.34804 6.72168ZM5.88539 9.4722L4.57848 13.7769L4.57851 13.7769L5.8854 9.47221L5.88539 9.4722ZM13.6519 6.7217L13.652 6.72168H9.27956L9.27958 6.7217H13.6519ZM4.90113 7.6229H7.26847L8.00002 5.21332L8.73156 7.6229H11.0989L9.18369 9.1121L9.91523 11.5217L8.00002 10.0325L6.0848 11.5217L6.81635 9.1121L4.90113 7.6229Z" fill="#C5C5C5"/>
</svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none"
xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.59454 6.25211L8 1L6.40546 6.25211H1L5.37311 9.65247L3.7496 15L8 11.695L12.2504 15L10.6269 9.65247L15 6.25211H9.59454ZM2.34804 6.72168H6.72044L8 2.50706L8.00002 2.50708L6.72046 6.7217H2.34805L2.34804 6.72168ZM5.88539 9.4722L4.57848 13.7769L4.57851 13.7769L5.8854 9.47221L5.88539 9.4722ZM13.6519 6.7217L13.652 6.72168H9.27956L9.27958 6.7217H13.6519ZM4.90113 7.6229H7.26847L8.00002 5.21332L8.73156 7.6229H11.0989L9.18369 9.1121L9.91523 11.5217L8.00002 10.0325L6.0848 11.5217L6.81635 9.1121L4.90113 7.6229Z" fill="white"/>
</svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none"
xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.59454 6.25211L8 1L6.40546 6.25211H1L5.37311 9.65247L3.7496 15L8 11.695L12.2504 15L10.6269 9.65247L15 6.25211H9.59454ZM2.34804 6.72168H6.72044L8 2.50706L8.00002 2.50708L6.72046 6.7217H2.34805L2.34804 6.72168ZM5.88539 9.4722L4.57848 13.7769L4.57851 13.7769L5.8854 9.47221L5.88539 9.4722ZM13.6519 6.7217L13.652 6.72168H9.27956L9.27958 6.7217H13.6519ZM4.90113 7.6229H7.26847L8.00002 5.21332L8.73156 7.6229H11.0989L9.18369 9.1121L9.91523 11.5217L8.00002 10.0325L6.0848 11.5217L6.81635 9.1121L4.90113 7.6229Z" fill="#424242"/>
</svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none"
xmlns="http://www.w3.org/2000/svg">
<path d="M14.5 2H1.5L1 2.5V11.5L1.5 12H4V14.5L4.854 14.854L7.707 12H14.5L15 11.5V2.5L14.5 2ZM14 11H7.5L7.146 11.146L5 13.293V11.5L4.5 11H2V3H14V11Z" fill="#C5C5C5"/>
</svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none"
xmlns="http://www.w3.org/2000/svg">
<path d="M14.5 2H1.5L1 2.5V11.5L1.5 12H4V14.5L4.854 14.854L7.707 12H14.5L15 11.5V2.5L14.5 2ZM14 11H7.5L7.146 11.146L5 13.293V11.5L4.5 11H2V3H14V11Z" fill="white"/>
</svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none"
xmlns="http://www.w3.org/2000/svg">
<path d="M14.5 2H1.5L1 2.5V11.5L1.5 12H4V14.5L4.854 14.854L7.707 12H14.5L15 11.5V2.5L14.5 2ZM14 11H7.5L7.146 11.146L5 13.293V11.5L4.5 11H2V3H14V11Z" fill="#424242"/>
</svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none"
xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M13 7.5C13 10.5376 10.5376 13 7.5 13C4.46243 13 2 10.5376 2 7.5C2 4.46243 4.46243 2 7.5 2C10.5376 2 13 4.46243 13 7.5ZM14 7.5C14 11.0899 11.0899 14 7.5 14C3.91015 14 1 11.0899 1 7.5C1 3.91015 3.91015 1 7.5 1C11.0899 1 14 3.91015 14 7.5ZM7 9V4H8V9H7ZM7 10V11H8V10H7Z" fill="#C5C5C5"/>
</svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none"
xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M13 7.5C13 10.5376 10.5376 13 7.5 13C4.46243 13 2 10.5376 2 7.5C2 4.46243 4.46243 2 7.5 2C10.5376 2 13 4.46243 13 7.5ZM14 7.5C14 11.0899 11.0899 14 7.5 14C3.91015 14 1 11.0899 1 7.5C1 3.91015 3.91015 1 7.5 1C11.0899 1 14 3.91015 14 7.5ZM7 9V4H8V9H7ZM7 10V11H8V10H7Z" fill="white"/>
</svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none"
xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M13 7.5C13 10.5376 10.5376 13 7.5 13C4.46243 13 2 10.5376 2 7.5C2 4.46243 4.46243 2 7.5 2C10.5376 2 13 4.46243 13 7.5ZM14 7.5C14 11.0899 11.0899 14 7.5 14C3.91015 14 1 11.0899 1 7.5C1 3.91015 3.91015 1 7.5 1C11.0899 1 14 3.91015 14 7.5ZM7 9V4H8V9H7ZM7 10V11H8V10H7Z" fill="#424242"/>
</svg>
<svg width="24" height="24" viewBox="0 0 24 24" fill="none"
xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0)">
<path fill-rule="evenodd" clip-rule="evenodd" d="M1.34375 2.125H21.6562L22.4375 2.90625V11.5048C21.9519 11.1401 21.4272 10.8346 20.875 10.593V3.6875H2.125V17.75H9.9375C9.9375 18.2593 9.9873 18.7698 10.0876 19.2741C10.3167 20.4256 10.8012 21.5058 11.5 22.4375H5.25V20.875H9.9375V19.3125H1.34375L0.5625 18.5312V2.90625L1.34375 2.125Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M18.1998 17.1526L20.3527 19.3056L21 18.6591L19.4935 17.1526L21 15.6465L20.3527 15L18.1998 17.1526ZM16.5065 18.7528L15 17.2464L15.6473 16.5998L17.7999 18.7528L15.6473 20.9062L15 20.2593L16.5065 18.7528Z" fill="white"/>
<circle cx="17.75" cy="17.75" r="5.625" stroke="white" stroke-width="1.25"/>
</g>
<defs>
<clipPath id="clip0">
<rect width="24" height="24" fill="white"/>
</clipPath>
</defs>
</svg>
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import 'vs/css!./remoteViewlet';
import * as nls from 'vs/nls';
import * as dom from 'vs/base/browser/dom';
import { URI } from 'vs/base/common/uri';
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { ViewContainerViewlet } from 'vs/workbench/browser/parts/views/viewsViewlet';
import { VIEWLET_ID, VIEW_CONTAINER } from 'vs/workbench/contrib/remote/common/remote.contribution';
import { ViewletPanel, IViewletPanelOptions } from 'vs/workbench/browser/parts/views/panelViewlet';
import { IAddedViewDescriptorRef } from 'vs/workbench/browser/parts/views/views';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IViewDescriptor, IViewsRegistry, Extensions } from 'vs/workbench/common/views';
import { Registry } from 'vs/platform/registry/common/platform';
import { ExtensionsRegistry, IExtensionPointUser } from 'vs/workbench/services/extensions/common/extensionsRegistry';
import { WorkbenchAsyncDataTree, TreeResourceNavigator2 } from 'vs/platform/list/browser/listService';
import { IListVirtualDelegate } from 'vs/base/browser/ui/list/list';
import { ITreeRenderer, ITreeNode, IAsyncDataSource } from 'vs/base/browser/ui/tree/tree';
import { Event } from 'vs/base/common/event';
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { ViewletRegistry, Extensions as ViewletExtensions, ViewletDescriptor } from 'vs/workbench/browser/viewlet';
interface HelpInformation {
extensionDescription: IExtensionDescription;
getStarted?: string;
documentation?: string;
feedback?: string;
issues?: string;
}
const remoteHelpExtPoint = ExtensionsRegistry.registerExtensionPoint<HelpInformation>({
extensionPoint: 'remoteHelp',
jsonSchema: {
description: nls.localize('RemoteHelpInformationExtPoint', 'Contributes help information for Remote'),
type: 'object',
properties: {
'getStarted': {
description: nls.localize('RemoteHelpInformationExtPoint.getStarted', "The url to your project's Getting Started page"),
type: 'string'
},
'documentation': {
description: nls.localize('RemoteHelpInformationExtPoint.documentation', "The url to your project's documentation page"),
type: 'string'
},
'feedback': {
description: nls.localize('RemoteHelpInformationExtPoint.feedback', "The url to your project's feedback reporter"),
type: 'string'
},
'issues': {
description: nls.localize('RemoteHelpInformationExtPoint.issues', "The url to your project's issues list"),
type: 'string'
}
}
}
});
interface IViewModel {
helpInformations: HelpInformation[];
}
class HelpTreeVirtualDelegate implements IListVirtualDelegate<IHelpItem> {
getHeight(element: IHelpItem): number {
return 22;
}
getTemplateId(element: IHelpItem): string {
return 'HelpItemTemplate';
}
}
interface IHelpItemTemplateData {
parent: HTMLElement;
icon: HTMLElement;
}
class HelpTreeRenderer implements ITreeRenderer<HelpModel | IHelpItem, IHelpItem, IHelpItemTemplateData> {
templateId: string = 'HelpItemTemplate';
renderTemplate(container: HTMLElement): IHelpItemTemplateData {
dom.addClass(container, 'remote-help-tree-node-item');
const icon = dom.append(container, dom.$('.remote-help-tree-node-item-icon'));
const data = <IHelpItemTemplateData>Object.create(null);
data.parent = container;
data.icon = icon;
return data;
}
renderElement(element: ITreeNode<IHelpItem, IHelpItem>, index: number, templateData: IHelpItemTemplateData, height: number | undefined): void {
const container = templateData.parent;
dom.append(container, templateData.icon);
dom.addClass(templateData.icon, element.element.key);
const labelContainer = dom.append(container, dom.$('.help-item-label'));
labelContainer.innerText = element.element.label;
}
disposeTemplate(templateData: IHelpItemTemplateData): void {
}
}
class HelpDataSource implements IAsyncDataSource<any, any> {
hasChildren(element: any) {
return element instanceof HelpModel;
}
getChildren(element: any) {
if (element instanceof HelpModel) {
return element.items;
}
return [];
}
}
interface IHelpItem {
key: string;
label: string;
handleClick(): Promise<void>;
}
class HelpItem implements IHelpItem {
constructor(
public key: string,
public label: string,
public values: { extensionDescription: IExtensionDescription; url: string }[],
private openerService: IOpenerService,
private quickInputService: IQuickInputService
) {
}
async handleClick() {
if (this.values.length > 1) {
let actions = this.values.map(value => {
return {
label: value.extensionDescription.displayName || value.extensionDescription.identifier.value,
description: value.url
};
});
const action = await this.quickInputService.pick(actions, { placeHolder: nls.localize('pickRemoteExtension', "Select url to open") });
if (action) {
await this.openerService.open(URI.parse(action.label));
}
} else {
await this.openerService.open(URI.parse(this.values[0].url));
}
}
}
class IssueReporterItem implements IHelpItem {
constructor(
public key: string,
public label: string,
public extensionDescriptions: IExtensionDescription[],
private quickInputService: IQuickInputService,
private commandService: ICommandService
) {
}
async handleClick() {
if (this.extensionDescriptions.length > 1) {
let actions = this.extensionDescriptions.map(extension => {
return {
label: extension.displayName || extension.identifier.value,
identifier: extension.identifier
};
});
const action = await this.quickInputService.pick(actions, { placeHolder: nls.localize('pickRemoteExtensionToReportIssue', "Select an extension to report issue") });
if (action) {
await this.commandService.executeCommand('workbench.action.openIssueReporter', [action.identifier.value]);
}
} else {
await this.commandService.executeCommand('workbench.action.openIssueReporter', [this.extensionDescriptions[0].identifier.value]);
}
}
}
class HelpModel {
items: IHelpItem[];
constructor(
viewModel: IViewModel,
openerService: IOpenerService,
quickInputService: IQuickInputService,
commandService: ICommandService
) {
let helpItems: IHelpItem[] = [];
const getStarted = viewModel.helpInformations.filter(info => info.getStarted);
if (getStarted.length) {
helpItems.push(new HelpItem(
'getStarted',
nls.localize('remote.help.getStarted', "Get Started"),
getStarted.map((info: HelpInformation) => ({
extensionDescription: info.extensionDescription,
url: info.getStarted!
})),
openerService,
quickInputService
));
}
const documentation = viewModel.helpInformations.filter(info => info.documentation);
if (documentation.length) {
helpItems.push(new HelpItem(
'documentation',
nls.localize('remote.help.documentation', "Read Documentation"),
documentation.map((info: HelpInformation) => ({
extensionDescription: info.extensionDescription,
url: info.documentation!
})),
openerService,
quickInputService
));
}
const feedback = viewModel.helpInformations.filter(info => info.feedback);
if (feedback.length) {
helpItems.push(new HelpItem(
'feedback',
nls.localize('remote.help.feedback', "Provide Feedback"),
feedback.map((info: HelpInformation) => ({
extensionDescription: info.extensionDescription,
url: info.feedback!
})),
openerService,
quickInputService
));
}
const issues = viewModel.helpInformations.filter(info => info.issues);
if (issues.length) {
helpItems.push(new HelpItem(
'issues',
nls.localize('remote.help.issues', "Review Issues"),
issues.map((info: HelpInformation) => ({
extensionDescription: info.extensionDescription,
url: info.issues!
})),
openerService,
quickInputService
));
}
if (helpItems.length) {
helpItems.push(new IssueReporterItem(
'issueReporter',
nls.localize('remote.help.report', "Report Issue"),
viewModel.helpInformations.map(info => info.extensionDescription),
quickInputService,
commandService
));
}
if (helpItems.length) {
this.items = helpItems;
}
}
}
class HelpPanel extends ViewletPanel {
static readonly ID = '~remote.helpPanel';
static readonly TITLE = nls.localize('remote.help', "Help and feedback");
private tree!: WorkbenchAsyncDataTree<any, any, any>;
constructor(
protected viewModel: IViewModel,
options: IViewletPanelOptions,
@IKeybindingService protected keybindingService: IKeybindingService,
@IContextMenuService protected contextMenuService: IContextMenuService,
@IContextKeyService protected contextKeyService: IContextKeyService,
@IConfigurationService protected configurationService: IConfigurationService,
@IInstantiationService protected readonly instantiationService: IInstantiationService,
@IOpenerService protected openerService: IOpenerService,
@IQuickInputService protected quickInputService: IQuickInputService,
@ICommandService protected commandService: ICommandService
) {
super(options, keybindingService, contextMenuService, configurationService, contextKeyService);
}
protected renderBody(container: HTMLElement): void {
dom.addClass(container, 'remote-help');
const treeContainer = document.createElement('div');
dom.addClass(treeContainer, 'remote-help-content');
container.appendChild(treeContainer);
this.tree = this.instantiationService.createInstance(WorkbenchAsyncDataTree,
treeContainer,
new HelpTreeVirtualDelegate(),
[new HelpTreeRenderer()],
new HelpDataSource(),
{
keyboardSupport: true,
}
);
const model = new HelpModel(this.viewModel, this.openerService, this.quickInputService, this.commandService);
this.tree.setInput(model);
const helpItemNavigator = this._register(new TreeResourceNavigator2(this.tree, { openOnFocus: false, openOnSelection: false }));
this._register(Event.debounce(helpItemNavigator.onDidOpenResource, (last, event) => event, 75, true)(e => {
e.element.handleClick();
}));
}
protected layoutBody(height: number, width: number): void {
this.tree.layout(height, width);
}
}
class HelpPanelDescriptor implements IViewDescriptor {
readonly id = HelpPanel.ID;
readonly name = HelpPanel.TITLE;
readonly ctorDescriptor: { ctor: any, arguments?: any[] };
readonly canToggleVisibility = true;
readonly hideByDefault = false;
readonly workspace = true;
constructor(viewModel: IViewModel) {
this.ctorDescriptor = { ctor: HelpPanel, arguments: [viewModel] };
}
}
export class RemoteViewlet extends ViewContainerViewlet implements IViewModel {
private helpPanelDescriptor = new HelpPanelDescriptor(this);
helpInformations: HelpInformation[] = [];
constructor(
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService,
@ITelemetryService telemetryService: ITelemetryService,
@IWorkspaceContextService contextService: IWorkspaceContextService,
@IStorageService storageService: IStorageService,
@IConfigurationService configurationService: IConfigurationService,
@IInstantiationService instantiationService: IInstantiationService,
@IThemeService themeService: IThemeService,
@IContextMenuService contextMenuService: IContextMenuService,
@IExtensionService extensionService: IExtensionService
) {
super(VIEWLET_ID, `${VIEWLET_ID}.state`, true, configurationService, layoutService, telemetryService, storageService, instantiationService, themeService, contextMenuService, extensionService, contextService);
remoteHelpExtPoint.setHandler((extensions) => {
let helpInformation: HelpInformation[] = [];
for (let extension of extensions) {
this._handleRemoteInfoExtensionPoint(extension, helpInformation);
}
this.helpInformations = helpInformation;
const viewsRegistry = Registry.as<IViewsRegistry>(Extensions.ViewsRegistry);
if (this.helpInformations.length) {
viewsRegistry.registerViews([this.helpPanelDescriptor], VIEW_CONTAINER);
} else {
viewsRegistry.deregisterViews([this.helpPanelDescriptor], VIEW_CONTAINER);
}
});
}
private _handleRemoteInfoExtensionPoint(extension: IExtensionPointUser<HelpInformation>, helpInformation: HelpInformation[]) {
if (!extension.value.documentation && !extension.value.feedback && !extension.value.getStarted && !extension.value.issues) {
return;
}
helpInformation.push({
extensionDescription: extension.description,
getStarted: extension.value.getStarted,
documentation: extension.value.documentation,
feedback: extension.value.feedback,
issues: extension.value.issues
});
}
onDidAddViews(added: IAddedViewDescriptorRef[]): ViewletPanel[] {
// too late, already added to the view model
return super.onDidAddViews(added);
}
getTitle(): string {
const title = nls.localize('remote.explorer', "Remote Explorer");
return title;
}
}
Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets).registerViewlet(new ViewletDescriptor(
RemoteViewlet,
VIEWLET_ID,
nls.localize('remote.explorer', "Remote Explorer"),
'remote',
4
));
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
.monaco-workbench .activitybar>.content .monaco-action-bar .action-label.remote {
-webkit-mask: url('remote-activity-bar.svg') no-repeat 50% 50%;
}
.remote-help-content .monaco-list .monaco-list-row .remote-help-tree-node-item {
display: flex;
height: 22px;
line-height: 22px;
flex: 1;
text-overflow: ellipsis;
overflow: hidden;
flex-wrap: nowrap;
}
.remote-help-content .monaco-list .monaco-list-row .remote-help-tree-node-item>.remote-help-tree-node-item-icon {
background-size: 16px;
background-position: left center;
background-repeat: no-repeat;
padding-right: 6px;
width: 16px;
height: 22px;
-webkit-font-smoothing: antialiased;
}
.remote-help-content .monaco-list .monaco-list-row .monaco-tl-twistie {
width: 0px !important;
}
.vs .monaco-list .monaco-list-row .remote-help-tree-node-item>.remote-help-tree-node-item-icon.getStarted {
background-image: url('help-getting-started-light.svg')
}
.vs .monaco-list .monaco-list-row .remote-help-tree-node-item>.remote-help-tree-node-item-icon.documentation {
background-image: url('help-documentation-light.svg')
}
.vs .monaco-list .monaco-list-row .remote-help-tree-node-item>.remote-help-tree-node-item-icon.feedback {
background-image: url('help-feedback-light.svg')
}
.vs .monaco-list .monaco-list-row .remote-help-tree-node-item>.remote-help-tree-node-item-icon.issues {
background-image: url('help-review-issues-light.svg')
}
.vs .monaco-list .monaco-list-row .remote-help-tree-node-item>.remote-help-tree-node-item-icon.issueReporter {
background-image: url('help-report-issue-light.svg')
}
.vs-dark .monaco-list .monaco-list-row .remote-help-tree-node-item>.remote-help-tree-node-item-icon.getStarted {
background-image: url('help-getting-started-dark.svg')
}
.vs-dark .monaco-list .monaco-list-row .remote-help-tree-node-item>.remote-help-tree-node-item-icon.documentation {
background-image: url('help-documentation-dark.svg')
}
.vs-dark .monaco-list .monaco-list-row .remote-help-tree-node-item>.remote-help-tree-node-item-icon.feedback {
background-image: url('help-feedback-dark.svg')
}
.vs-dark .monaco-list .monaco-list-row .remote-help-tree-node-item>.remote-help-tree-node-item-icon.issues {
background-image: url('help-review-issues-dark.svg')
}
.vs-dark .monaco-list .monaco-list-row .remote-help-tree-node-item>.remote-help-tree-node-item-icon.issueReporter {
background-image: url('help-report-issue-dark.svg')
}
.hc-black .monaco-list .monaco-list-row .remote-help-tree-node-item>.remote-help-tree-node-item-icon.getStarted {
background-image: url('help-getting-started-hc.svg')
}
.hc-black .monaco-list .monaco-list-row .remote-help-tree-node-item>.remote-help-tree-node-item-icon.documentation {
background-image: url('help-documentation-hc.svg')
}
.hc-black .monaco-list .monaco-list-row .remote-help-tree-node-item>.remote-help-tree-node-item-icon.feedback {
background-image: url('help-feedback-hc.svg')
}
.hc-black .monaco-list .monaco-list-row .remote-help-tree-node-item>.remote-help-tree-node-item-icon.issues {
background-image: url('help-review-issues-hc.svg')
}
.hc-black .monaco-list .monaco-list-row .remote-help-tree-node-item>.remote-help-tree-node-item-icon.issueReporter {
background-image: url('help-report-issue-hc.svg')
}
......@@ -17,6 +17,34 @@ import { IOutputChannelRegistry, Extensions as OutputExt, } from 'vs/workbench/c
import { localize } from 'vs/nls';
import { joinPath } from 'vs/base/common/resources';
import { Disposable } from 'vs/base/common/lifecycle';
import { ViewContainer, IViewContainersRegistry, Extensions as ViewContainerExtensions } from 'vs/workbench/common/views';
export const VIEWLET_ID = 'workbench.view.remote';
export const VIEW_CONTAINER: ViewContainer = Registry.as<IViewContainersRegistry>(ViewContainerExtensions.ViewContainersRegistry).registerViewContainer(
VIEWLET_ID,
true,
undefined,
{
getOrder: (group?: string) => {
if (!group) {
return;
}
let matches = /^targets@(\d+)$/.exec(group);
if (matches) {
return -1000;
}
matches = /^details@(\d+)$/.exec(group);
if (matches) {
return -500;
}
return;
}
}
);
export class LabelContribution implements IWorkbenchContribution {
constructor(
......
......@@ -194,6 +194,7 @@ import 'vs/workbench/contrib/tasks/browser/task.contribution';
// Remote
import 'vs/workbench/contrib/remote/common/remote.contribution';
import 'vs/workbench/contrib/remote/browser/remote';
// Emmet
import 'vs/workbench/contrib/emmet/browser/emmet.contribution';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册