partService.ts 2.9 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 8
import { TPromise } from 'vs/base/common/winjs.base';
import { createDecorator, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
9
import Event from 'vs/base/common/event';
E
Erich Gamma 已提交
10 11 12 13

export enum Parts {
	ACTIVITYBAR_PART,
	SIDEBAR_PART,
I
isidor 已提交
14
	PANEL_PART,
E
Erich Gamma 已提交
15
	EDITOR_PART,
16 17
	STATUSBAR_PART,
	TITLEBAR_PART
E
Erich Gamma 已提交
18 19 20 21 22 23 24
}

export enum Position {
	LEFT,
	RIGHT
}

25 26 27 28 29
export interface ILayoutOptions {
	forceStyleRecompute?: boolean;
	toggleMaximizedPanel?: boolean;
}

B
Benjamin Pasero 已提交
30
export const IPartService = createDecorator<IPartService>('partService');
E
Erich Gamma 已提交
31 32

export interface IPartService {
J
Johannes Rieken 已提交
33
	_serviceBrand: ServiceIdentifier<any>;
E
Erich Gamma 已提交
34

35 36 37 38 39
	/**
	 * Emits when the visibility of the title bar changes.
	 */
	onTitleBarVisibilityChange: Event<void>;

E
Erich Gamma 已提交
40 41 42
	/**
	 * Asks the part service to layout all parts.
	 */
43
	layout(options?: ILayoutOptions): void;
E
Erich Gamma 已提交
44 45 46 47 48 49 50 51 52 53 54 55

	/**
	 * Asks the part service to if all parts have been created.
	 */
	isCreated(): boolean;

	/**
	 * Promise is complete when all parts have been created.
	 */
	joinCreation(): TPromise<boolean>;

	/**
P
Pascal Borreli 已提交
56
	 * Returns whether the given part has the keyboard focus or not.
E
Erich Gamma 已提交
57 58 59
	 */
	hasFocus(part: Parts): boolean;

60 61 62 63 64
	/**
	 * Returns the parts HTML element, if there is one.
	 */
	getContainer(part: Parts): HTMLElement;

E
Erich Gamma 已提交
65 66 67 68 69
	/**
	 * Returns iff the part is visible.
	 */
	isVisible(part: Parts): boolean;

S
Sanders Lauture 已提交
70 71 72 73 74
	/**
	 * Set activity bar hidden or not
	 */
	setActivityBarHidden(hidden: boolean): void;

75 76 77 78 79
	/**
	 * Number of pixels (adjusted for zooming) that the title bar (if visible) pushes down the workbench contents.
	 */
	getTitleBarOffset(): number;

E
Erich Gamma 已提交
80 81 82 83 84
	/**
	 * Set sidebar hidden or not
	 */
	setSideBarHidden(hidden: boolean): void;

I
isidor 已提交
85 86 87
	/**
	 * Set panel part hidden or not
	 */
I
isidor 已提交
88
	setPanelHidden(hidden: boolean): void;
I
isidor 已提交
89

I
isidor 已提交
90 91 92 93 94 95
	/**
	 * Maximizes the panel height if the panel is not already maximized.
	 * Shrinks the panel to the default starting size if the panel is maximized.
	 */
	toggleMaximizedPanel(): void;

E
Erich Gamma 已提交
96 97 98 99 100 101 102 103 104 105 106 107 108 109
	/**
	 * Gets the current side bar position. Note that the sidebar can be hidden too.
	 */
	getSideBarPosition(): Position;

	/**
	 * Adds a class to the workbench part.
	 */
	addClass(clazz: string): void;

	/**
	 * Removes a class from the workbench part.
	 */
	removeClass(clazz: string): void;
110 111 112 113 114

	/**
	 * Returns the identifier of the element that contains the workbench.
	 */
	getWorkbenchElementId(): string;
115 116 117 118 119

	/**
	 * Enables to restore the contents of the sidebar after a restart.
	 */
	setRestoreSidebar(): void;
I
isidor 已提交
120 121 122 123 124

	/**
	 * Toggles the workbench in and out of zen mode - parts get hidden and window goes fullscreen.
	 */
	toggleZenMode(): void;
E
Erich Gamma 已提交
125
}