activityBarService.ts 2.1 KB
Newer Older
E
Erich Gamma 已提交
1 2 3 4 5 6
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
'use strict';

J
Johannes Rieken 已提交
7
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
E
Erich Gamma 已提交
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 39 40 41 42 43 44 45 46 47 48

export interface IBadge {
	getDescription(): string;
}

export class BaseBadge implements IBadge {
	public descriptorFn: (args: any) => string;

	constructor(descriptorFn: (args: any) => string) {
		this.descriptorFn = descriptorFn;
	}

	/* protected */ public getDescription(): string {
		return this.descriptorFn(null);
	}
}

export class NumberBadge extends BaseBadge {
	public number: number;

	constructor(number: number, descriptorFn: (args: any) => string) {
		super(descriptorFn);

		this.number = number;
	}

	/* protected */ public getDescription(): string {
		return this.descriptorFn(this.number);
	}
}

export class TextBadge extends BaseBadge {
	public text: string;

	constructor(text: string, descriptorFn: (args: any) => string) {
		super(descriptorFn);

		this.text = text;
	}
}

I
isidor 已提交
49 50 51 52 53 54 55
export class IconBadge extends BaseBadge {

	constructor(descriptorFn: (args: any) => string) {
		super(descriptorFn);
	}
}

E
Erich Gamma 已提交
56 57 58
export class ProgressBadge extends BaseBadge {
}

59
export const IActivityBarService = createDecorator<IActivityBarService>('activityBarService');
E
Erich Gamma 已提交
60

61
export interface IActivityBarService {
62
	_serviceBrand: any;
E
Erich Gamma 已提交
63 64

	/**
65
	 * Show activity in the activitybar for the given viewlet.
E
Erich Gamma 已提交
66
	 */
67
	showActivity(viewletId: string, badge: IBadge, clazz?: string): void;
E
Erich Gamma 已提交
68 69

	/**
70
	 * Clears activity shown in the activitybar for the given viewlet.
E
Erich Gamma 已提交
71
	 */
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
	clearActivity(viewletId: string): void;

	/**
	 * Unpins a viewlet from the activitybar.
	 */
	unpin(viewletId: string): void;

	/**
	 * Pin a viewlet inside the activity bar.
	 */
	pin(viewletId: string): void;

	/**
	 * Find out if a viewlet is pinned in the activity bar.
	 */
	isPinned(viewletId: string): boolean;
E
Erich Gamma 已提交
88
}