Skip to content

Commit

Permalink
#43645 Out of the box test view container
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Apr 25, 2018
1 parent 6dfd02e commit 7973d15
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
10 changes: 10 additions & 0 deletions src/vs/workbench/api/browser/media/test.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 14 additions & 4 deletions src/vs/workbench/api/browser/viewsContainersExtensionPoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const viewsContainerSchema: IJSONSchema = {
type: 'string'
},
icon: {
description: localize('vscode.extension.contributes.views.containers.icon', 'Path to the container icon'),
description: localize('vscode.extension.contributes.views.containers.icon', "Path to the container icon. Icons are 24x24 centered on a 50x40 square and have a fill color of 'rgb(215, 218, 224)' or '#d7dae0'. It is recommended that icons be in SVG, though any image file type is accepted."),
type: 'string'
}
}
Expand All @@ -70,14 +70,24 @@ export const viewsContainersContribution: IJSONSchema = {

export const viewsContainersExtensionPoint: IExtensionPoint<{ [loc: string]: IUserFriendlyViewsContainerDescriptor[] }> = ExtensionsRegistry.registerExtensionPoint<{ [loc: string]: IUserFriendlyViewsContainerDescriptor[] }>('viewsContainers', [], viewsContainersContribution);

const CUSTOM_VIEW_CONTAINER_ORDER = 5;
const TEST_VIEW_CONTAINER_ORDER = 6;

class ViewsContainersExtensionHandler implements IWorkbenchContribution {

constructor() {
this.registerTestViewContainer();
this.handleAndRegisterCustomViewContainers();
}

private registerTestViewContainer(): void {
const id = 'test';
const title = localize('test', "Test");
const cssClass = `extensionViewlet-${id}`;
const icon = require.toUrl('./media/test.svg');

this.registerCustomViewlet({ id, title, icon }, TEST_VIEW_CONTAINER_ORDER, cssClass);
}

private handleAndRegisterCustomViewContainers() {
viewsContainersExtensionPoint.setHandler((extensions) => {
for (let extension of extensions) {
Expand Down Expand Up @@ -132,7 +142,7 @@ class ViewsContainersExtensionHandler implements IWorkbenchContribution {
containers.forEach((descriptor, index) => {
const cssClass = `extensionViewlet-${descriptor.id}`;
const icon = join(extension.extensionFolderPath, descriptor.icon);
this.registerCustomViewlet({ id: descriptor.id, title: descriptor.title, icon }, CUSTOM_VIEW_CONTAINER_ORDER + index + 1, cssClass);
this.registerCustomViewlet({ id: descriptor.id, title: descriptor.title, icon }, TEST_VIEW_CONTAINER_ORDER + index + 1, cssClass);
});
}

Expand Down Expand Up @@ -186,7 +196,7 @@ class ViewsContainersExtensionHandler implements IWorkbenchContribution {

// Generate CSS to show the icon in the activity bar
const iconClass = `.monaco-workbench > .activitybar .monaco-action-bar .action-label.${cssClass}`;
createCSSRule(iconClass, `-webkit-mask: url('${descriptor.icon}') no-repeat 50% 50%;`);
createCSSRule(iconClass, `-webkit-mask: url('${descriptor.icon}') no-repeat 50% 50%`);
}
}

Expand Down

0 comments on commit 7973d15

Please sign in to comment.