viewlet.ts 1.8 KB
Newer Older
B
Benjamin Pasero 已提交
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
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
'use strict';

import { TPromise } from 'vs/base/common/winjs.base';
import { IViewlet } from 'vs/workbench/common/viewlet';
import { createDecorator, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
import Event from 'vs/base/common/event';
import { ViewletDescriptor } from 'vs/workbench/browser/viewlet';

export const IViewletService = createDecorator<IViewletService>('viewletService');

export interface IViewletService {
	_serviceBrand: ServiceIdentifier<any>;

	onDidViewletOpen: Event<IViewlet>;
	onDidViewletClose: Event<IViewlet>;
	onDidViewletToggle: Event<void>;

	/**
	 * Opens a viewlet with the given identifier and pass keyboard focus to it if specified.
	 */
	openViewlet(id: string, focus?: boolean): TPromise<IViewlet>;

27 28 29 30 31
	/**
	 * Allows to wait until all viewlets are ready, including contributed ones.
	 */
	onReady(): TPromise<void>;

B
Benjamin Pasero 已提交
32 33 34
	/**
	 * Toggles a viewlet with the given identifier.
	 */
B
Benjamin Pasero 已提交
35
	toggleViewlet(id: string): void;
B
Benjamin Pasero 已提交
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58

	/**
	 * Returns the current active viewlet or null if none.
	 */
	getActiveViewlet(): IViewlet;

	/**
	 * Returns all registered viewlets
	 */
	getAllViewlets(): ViewletDescriptor[];

	/**
	 * Returns all viewlets that should be displayed, ordered by:
	 * - Stock Viewlets: order attribute
	 * - External Viewlets: enabling sequence
	 */
	getAllViewletsToDisplay(): ViewletDescriptor[];

	/**
	 * Checks if an extension is enabled
	 */
	isViewletEnabled(id: string): boolean;
}