Skip to content

Commit

Permalink
#43645 Prepare for activity groups contribution
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Apr 16, 2018
1 parent 6c22305 commit 20acc5e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 28 deletions.
17 changes: 10 additions & 7 deletions src/vs/workbench/api/browser/viewsExtensionPoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ namespace schema {
};
}

function getViewLocation(value: string): ViewLocation {
switch (value) {
case 'explorer': return ViewLocation.Explorer;
case 'debug': return ViewLocation.Debug;
default: return ViewLocation.get(`workbench.view.extension.${value}`) || ViewLocation.Explorer;
}
}

ExtensionsRegistry.registerExtensionPoint<{ [loc: string]: schema.IUserFriendlyViewDescriptor[] }>('views', [], schema.viewsContribution)
.setHandler((extensions) => {
for (let extension of extensions) {
Expand All @@ -93,12 +101,7 @@ ExtensionsRegistry.registerExtensionPoint<{ [loc: string]: schema.IUserFriendlyV
return;
}

const location = ViewLocation.getContributedViewLocation(entry.key);
if (!location) {
collector.warn(localize('locationId.invalid', "`{0}` is not a valid view location", entry.key));
return;
}

const location = getViewLocation(entry.key);
const registeredViews = ViewsRegistry.getViews(location);
const viewIds = [];
const viewDescriptors = coalesce(entry.value.map(item => {
Expand Down Expand Up @@ -129,4 +132,4 @@ ExtensionsRegistry.registerExtensionPoint<{ [loc: string]: schema.IUserFriendlyV
ViewsRegistry.registerViews(viewDescriptors);
});
}
});
});
2 changes: 1 addition & 1 deletion src/vs/workbench/browser/parts/views/viewsViewlet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ export class ViewsViewlet extends PanelViewlet implements IViewsViewlet {
return false;
}

if (ViewLocation.getContributedViewLocation(this.location.id)) {
if (ViewLocation.get(this.location.id)) {
let visibleViewsCount = 0;
if (this.areExtensionsReady) {
visibleViewsCount = this.getViewDescriptorsFromRegistry().reduce((visibleViewsCount, v) => visibleViewsCount + (this.canBeVisible(v) ? 1 : 0), 0);
Expand Down
29 changes: 14 additions & 15 deletions src/vs/workbench/common/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,23 @@ import { ThemeIcon } from 'vs/platform/theme/common/themeService';

export class ViewLocation {

static readonly Explorer = new ViewLocation('workbench.view.explorer');
static readonly Debug = new ViewLocation('workbench.view.debug');
static readonly Extensions = new ViewLocation('workbench.view.extensions');

constructor(private _id: string) {
private static locations: Map<string, ViewLocation> = new Map<string, ViewLocation>();
static register(id: string): ViewLocation {
const viewLocation = new ViewLocation(id);
ViewLocation.locations.set(id, viewLocation);
return viewLocation;
}

get id(): string {
return this._id;
static get(value: string): ViewLocation {
return ViewLocation.locations.get(value);
}

static getContributedViewLocation(value: string): ViewLocation {
switch (value) {
case 'explorer': return ViewLocation.Explorer;
case 'debug': return ViewLocation.Debug;
}
return void 0;
}
static readonly Explorer: ViewLocation = ViewLocation.register('workbench.view.explorer');
static readonly Debug: ViewLocation = ViewLocation.register('workbench.view.debug');
static readonly Extensions: ViewLocation = ViewLocation.register('workbench.view.extensions');

private constructor(private _id: string) { }
get id(): string { return this._id; }

}

export interface IViewDescriptor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,7 @@ export class ViewPickerHandler extends QuickOpenHandler {

// Views
viewlets.forEach((viewlet, index) => {
const viewLocation: ViewLocation = viewlet.id === EXPLORER_VIEWLET_ID ? ViewLocation.Explorer
: viewlet.id === DEBUG_VIEWLET_ID ? ViewLocation.Debug
: viewlet.id === EXTENSIONS_VIEWLET_ID ? ViewLocation.Extensions
: null;

const viewLocation: ViewLocation = ViewLocation.get(viewlet.id);
if (viewLocation) {
const viewEntriesForViewlet: ViewEntry[] = getViewEntriesForViewlet(viewlet, viewLocation);
viewEntries.push(...viewEntriesForViewlet);
Expand Down

0 comments on commit 20acc5e

Please sign in to comment.