Skip to content

Commit

Permalink
enable panel contribution
Browse files Browse the repository at this point in the history
  • Loading branch information
sbatten committed Mar 24, 2020
1 parent cdd0132 commit 7a5b90c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
23 changes: 16 additions & 7 deletions src/vs/workbench/api/browser/viewsExtensionPoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ export const viewsContainersContribution: IJSONSchema = {
description: localize('views.container.activitybar', "Contribute views containers to Activity Bar"),
type: 'array',
items: viewsContainerSchema
},
'panel': {
description: localize('views.container.panel', "Contribute views containers to Panel"),
type: 'array',
items: viewsContainerSchema
}
}
};
Expand Down Expand Up @@ -214,15 +219,19 @@ class ViewsExtensionHandler implements IWorkbenchContribution {

private addCustomViewContainers(extensionPoints: readonly IExtensionPointUser<ViewContainerExtensionPointType>[], existingViewContainers: ViewContainer[]): void {
const viewContainersRegistry = Registry.as<IViewContainersRegistry>(ViewContainerExtensions.ViewContainersRegistry);
let order = TEST_VIEW_CONTAINER_ORDER + viewContainersRegistry.all.filter(v => !!v.extensionId).length + 1;
let activityBarOrder = TEST_VIEW_CONTAINER_ORDER + viewContainersRegistry.all.filter(v => !!v.extensionId && viewContainersRegistry.getViewContainerLocation(v) === ViewContainerLocation.Sidebar).length + 1;
let panelOrder = 5 + viewContainersRegistry.all.filter(v => !!v.extensionId && viewContainersRegistry.getViewContainerLocation(v) === ViewContainerLocation.Panel).length + 1;
for (let { value, collector, description } of extensionPoints) {
forEach(value, entry => {
if (!this.isValidViewsContainer(entry.value, collector)) {
return;
}
switch (entry.key) {
case 'activitybar':
order = this.registerCustomViewContainers(entry.value, description, order, existingViewContainers);
activityBarOrder = this.registerCustomViewContainers(entry.value, description, activityBarOrder, existingViewContainers, ViewContainerLocation.Sidebar);
break;
case 'panel':
panelOrder = this.registerCustomViewContainers(entry.value, description, panelOrder, existingViewContainers, ViewContainerLocation.Panel);
break;
}
});
Expand All @@ -248,7 +257,7 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
const title = localize('test', "Test");
const icon = URI.parse(require.toUrl('./media/test.svg'));

this.registerCustomViewContainer(TEST_VIEW_CONTAINER_ID, title, icon, TEST_VIEW_CONTAINER_ORDER, undefined);
this.registerCustomViewContainer(TEST_VIEW_CONTAINER_ID, title, icon, TEST_VIEW_CONTAINER_ORDER, undefined, ViewContainerLocation.Sidebar);
}

private isValidViewsContainer(viewsContainersDescriptors: IUserFriendlyViewsContainerDescriptor[], collector: ExtensionMessageCollector): boolean {
Expand Down Expand Up @@ -279,11 +288,11 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
return true;
}

private registerCustomViewContainers(containers: IUserFriendlyViewsContainerDescriptor[], extension: IExtensionDescription, order: number, existingViewContainers: ViewContainer[]): number {
private registerCustomViewContainers(containers: IUserFriendlyViewsContainerDescriptor[], extension: IExtensionDescription, order: number, existingViewContainers: ViewContainer[], location: ViewContainerLocation): number {
containers.forEach(descriptor => {
const icon = resources.joinPath(extension.extensionLocation, descriptor.icon);
const id = `workbench.view.extension.${descriptor.id}`;
const viewContainer = this.registerCustomViewContainer(id, descriptor.title, icon, order++, extension.identifier);
const viewContainer = this.registerCustomViewContainer(id, descriptor.title, icon, order++, extension.identifier, location);

// Move those views that belongs to this container
if (existingViewContainers.length) {
Expand All @@ -301,7 +310,7 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
return order;
}

private registerCustomViewContainer(id: string, title: string, icon: URI, order: number, extensionId: ExtensionIdentifier | undefined): ViewContainer {
private registerCustomViewContainer(id: string, title: string, icon: URI, order: number, extensionId: ExtensionIdentifier | undefined, location: ViewContainerLocation): ViewContainer {
let viewContainer = this.viewContainersRegistry.get(id);

if (!viewContainer) {
Expand All @@ -316,7 +325,7 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
hideIfEmpty: true,
order,
icon,
}, ViewContainerLocation.Sidebar);
}, location);

// Register Action to Open Viewlet
class OpenCustomViewletAction extends ShowViewletAction {
Expand Down
3 changes: 2 additions & 1 deletion src/vs/workbench/contrib/debug/browser/debug.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const viewContainer = Registry.as<IViewContainersRegistry>(ViewExtensions.ViewCo
name: nls.localize('run', "Run"),
ctorDescriptor: new SyncDescriptor(DebugViewPaneContainer),
icon: 'codicon-debug-alt-2',
order: 3
order: 2
}, ViewContainerLocation.Sidebar);

const openViewletKb: IKeybindings = {
Expand All @@ -96,6 +96,7 @@ const VIEW_CONTAINER: ViewContainer = Registry.as<IViewContainersRegistry>(ViewE
id: OpenDebugPanelAction.ID,
keybindings: openPanelKb
},
order: 3,
hideIfEmpty: true
}, ViewContainerLocation.Panel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const VIEW_CONTAINER: ViewContainer = Registry.as<IViewContainersRegistry>(ViewC
id: Constants.MARKERS_CONTAINER_ID,
name: Messages.MARKERS_PANEL_TITLE_PROBLEMS,
hideIfEmpty: true,
order: 0,
ctorDescriptor: new SyncDescriptor(ViewPaneContainer, [Constants.MARKERS_CONTAINER_ID, Constants.MARKERS_VIEW_STORAGE_ID, { mergeViewWithContainerWhenSingleView: true, donotShowContainerTitleWhenMergedWithContainer: true }]),
focusCommand: {
id: ToggleMarkersPanelAction.ID, keybindings: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const toggleOutputActionKeybindings = {
const VIEW_CONTAINER: ViewContainer = Registry.as<IViewContainersRegistry>(ViewContainerExtensions.ViewContainersRegistry).registerViewContainer({
id: OUTPUT_VIEW_ID,
name: nls.localize('output', "Output"),
order: 1,
ctorDescriptor: new SyncDescriptor(ViewPaneContainer, [OUTPUT_VIEW_ID, OUTPUT_VIEW_ID, { mergeViewWithContainerWhenSingleView: true, donotShowContainerTitleWhenMergedWithContainer: true }]),
focusCommand: { id: toggleOutputAcitonId, keybindings: toggleOutputActionKeybindings }
}, ViewContainerLocation.Panel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,8 @@ const VIEW_CONTAINER = Registry.as<IViewContainersRegistry>(ViewContainerExtensi
name: nls.localize('terminal', "Terminal"),
ctorDescriptor: new SyncDescriptor(ViewPaneContainer, [TERMINAL_VIEW_ID, TERMINAL_VIEW_ID, { mergeViewWithContainerWhenSingleView: true, donotShowContainerTitleWhenMergedWithContainer: true }]),
focusCommand: { id: TERMINAL_COMMAND_ID.FOCUS },
hideIfEmpty: true
hideIfEmpty: true,
order: 3
}, ViewContainerLocation.Panel);
Registry.as<panel.PanelRegistry>(panel.Extensions.Panels).setDefaultPanelId(TERMINAL_VIEW_ID);

Expand Down

0 comments on commit 7a5b90c

Please sign in to comment.