forked from irinazheltisheva/vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpanel.ts
More file actions
86 lines (71 loc) · 2.79 KB
/
Copy pathpanel.ts
File metadata and controls
86 lines (71 loc) · 2.79 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Registry } from 'vs/platform/registry/common/platform';
import { IPanel } from 'vs/workbench/common/panel';
import { CompositeDescriptor, CompositeRegistry } from 'vs/workbench/browser/composite';
import { IConstructorSignature0, BrandedService } from 'vs/platform/instantiation/common/instantiation';
import { assertIsDefined } from 'vs/base/common/types';
import { PaneComposite } from 'vs/workbench/browser/panecomposite';
export abstract class Panel extends PaneComposite implements IPanel { }
/**
* A panel descriptor is a leightweight descriptor of a panel in the workbench.
*/
export class PanelDescriptor extends CompositeDescriptor<Panel> {
static create<Services extends BrandedService[]>(ctor: { new(...services: Services): Panel }, id: string, name: string, cssClass?: string, order?: number, requestedIndex?: number, _commandId?: string): PanelDescriptor {
return new PanelDescriptor(ctor as IConstructorSignature0<Panel>, id, name, cssClass, order, requestedIndex, _commandId);
}
private constructor(ctor: IConstructorSignature0<Panel>, id: string, name: string, cssClass?: string, order?: number, requestedIndex?: number, _commandId?: string) {
super(ctor, id, name, cssClass, order, requestedIndex, _commandId);
}
}
export class PanelRegistry extends CompositeRegistry<Panel> {
private defaultPanelId: string | undefined;
/**
* Registers a panel to the platform.
*/
registerPanel(descriptor: PanelDescriptor): void {
super.registerComposite(descriptor);
}
/**
* Deregisters a panel to the platform.
*/
deregisterPanel(id: string): void {
super.deregisterComposite(id);
}
/**
* Returns a panel by id.
*/
getPanel(id: string): PanelDescriptor | undefined {
return this.getComposite(id);
}
/**
* Returns an array of registered panels known to the platform.
*/
getPanels(): PanelDescriptor[] {
return this.getComposites();
}
/**
* Sets the id of the panel that should open on startup by default.
*/
setDefaultPanelId(id: string): void {
this.defaultPanelId = id;
}
/**
* Gets the id of the panel that should open on startup by default.
*/
getDefaultPanelId(): string {
return assertIsDefined(this.defaultPanelId);
}
/**
* Find out if a panel exists with the provided ID.
*/
hasPanel(id: string): boolean {
return this.getPanels().some(panel => panel.id === id);
}
}
export const Extensions = {
Panels: 'workbench.contributions.panels'
};
Registry.add(Extensions.Panels, new PanelRegistry());