debugViewRegistry.ts 1.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

import { IActionRunner } from 'vs/base/common/actions';
import { IViewletView } from 'vs/workbench/browser/viewlet';
import { ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';

// Debug view registration

export interface IDebugViewConstructorSignature {
	new (actionRunner: IActionRunner, viewletSetings: any, ...services: { serviceId: ServiceIdentifier<any>; }[]): IViewletView;
}

export interface IDebugViewRegistry {
	registerDebugView(view: IDebugViewConstructorSignature, order: number): void;
	getDebugViews(): IDebugViewConstructorSignature[];
}

class DebugViewRegistryImpl implements IDebugViewRegistry {
	private debugViews: { view: IDebugViewConstructorSignature, order: number }[];

	constructor() {
		this.debugViews = [];
	}

	public registerDebugView(view: IDebugViewConstructorSignature, order: number): void {
		this.debugViews.push({ view, order });
	}

	public getDebugViews(): IDebugViewConstructorSignature[] {
		return this.debugViews.sort((first, second) => first.order - second.order)
			.map(viewWithOrder => viewWithOrder.view);
	}
}

export var DebugViewRegistry = <IDebugViewRegistry>new DebugViewRegistryImpl();