mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Merge from vscode e74405d11443c5361c31e2bc341866d146eee206 (#8740)
This commit is contained in:
@@ -1177,6 +1177,11 @@ export interface IEditorPartOptions extends IEditorPartConfiguration {
|
||||
iconTheme?: string;
|
||||
}
|
||||
|
||||
export interface IEditorPartOptionsChangeEvent {
|
||||
oldPartOptions: IEditorPartOptions;
|
||||
newPartOptions: IEditorPartOptions;
|
||||
}
|
||||
|
||||
export enum SideBySideEditor {
|
||||
MASTER = 1,
|
||||
DETAILS = 2
|
||||
|
||||
@@ -12,11 +12,12 @@ import { IViewlet } from 'vs/workbench/common/viewlet';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { ThemeIcon } from 'vs/platform/theme/common/themeService';
|
||||
import { values, keys } from 'vs/base/common/map';
|
||||
import { values, keys, getOrSet } from 'vs/base/common/map';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IKeybindings } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { IAction } from 'vs/base/common/actions';
|
||||
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
|
||||
import { flatten } from 'vs/base/common/arrays';
|
||||
|
||||
export const TEST_VIEW_CONTAINER_ID = 'workbench.view.extension.test';
|
||||
export const FocusedViewContext = new RawContextKey<string>('focusedView', '');
|
||||
@@ -31,16 +32,30 @@ export enum ViewContainerLocation {
|
||||
Panel
|
||||
}
|
||||
|
||||
export interface IViewContainerDescriptor {
|
||||
|
||||
readonly id: string;
|
||||
|
||||
readonly name: string;
|
||||
|
||||
readonly viewOrderDelegate?: ViewOrderDelegate;
|
||||
|
||||
readonly hideIfEmpty?: boolean;
|
||||
|
||||
readonly extensionId?: ExtensionIdentifier;
|
||||
|
||||
}
|
||||
|
||||
export interface IViewContainersRegistry {
|
||||
/**
|
||||
* An event that is triggerred when a view container is registered.
|
||||
*/
|
||||
readonly onDidRegister: Event<ViewContainer>;
|
||||
readonly onDidRegister: Event<{ viewContainer: ViewContainer, viewContainerLocation: ViewContainerLocation }>;
|
||||
|
||||
/**
|
||||
* An event that is triggerred when a view container is deregistered.
|
||||
*/
|
||||
readonly onDidDeregister: Event<ViewContainer>;
|
||||
readonly onDidDeregister: Event<{ viewContainer: ViewContainer, viewContainerLocation: ViewContainerLocation }>;
|
||||
|
||||
/**
|
||||
* All registered view containers
|
||||
@@ -48,14 +63,15 @@ export interface IViewContainersRegistry {
|
||||
readonly all: ViewContainer[];
|
||||
|
||||
/**
|
||||
* Registers a view container with given id
|
||||
* No op if a view container is already registered with the given id.
|
||||
* Registers a view container to given location.
|
||||
* No op if a view container is already registered.
|
||||
*
|
||||
* @param id of the view container.
|
||||
* @param viewContainerDescriptor descriptor of view container
|
||||
* @param location location of the view container
|
||||
*
|
||||
* @returns the registered ViewContainer.
|
||||
*/
|
||||
registerViewContainer(id: string, location: ViewContainerLocation, hideIfEmpty?: boolean, extensionId?: ExtensionIdentifier, viewOrderDelegate?: ViewOrderDelegate): ViewContainer;
|
||||
registerViewContainer(viewContainerDescriptor: IViewContainerDescriptor, location: ViewContainerLocation): ViewContainer;
|
||||
|
||||
/**
|
||||
* Deregisters the given view container
|
||||
@@ -69,6 +85,11 @@ export interface IViewContainersRegistry {
|
||||
* @returns the view container with given id.
|
||||
*/
|
||||
get(id: string): ViewContainer | undefined;
|
||||
|
||||
/**
|
||||
* Returns all view containers in the given location
|
||||
*/
|
||||
getViewContainers(location: ViewContainerLocation): ViewContainer[];
|
||||
}
|
||||
|
||||
interface ViewOrderDelegate {
|
||||
@@ -76,49 +97,68 @@ interface ViewOrderDelegate {
|
||||
}
|
||||
|
||||
export class ViewContainer {
|
||||
protected constructor(readonly id: string, readonly location: ViewContainerLocation, readonly hideIfEmpty: boolean, readonly extensionId?: ExtensionIdentifier, readonly orderDelegate?: ViewOrderDelegate) { }
|
||||
|
||||
protected constructor(private readonly descriptor: IViewContainerDescriptor) { }
|
||||
|
||||
readonly id: string = this.descriptor.id;
|
||||
readonly name: string = this.descriptor.name;
|
||||
readonly hideIfEmpty: boolean = !!this.descriptor.hideIfEmpty;
|
||||
readonly extensionId: ExtensionIdentifier | undefined = this.descriptor.extensionId;
|
||||
readonly orderDelegate: ViewOrderDelegate | undefined = this.descriptor.viewOrderDelegate;
|
||||
}
|
||||
|
||||
class ViewContainersRegistryImpl extends Disposable implements IViewContainersRegistry {
|
||||
|
||||
private readonly _onDidRegister = this._register(new Emitter<ViewContainer>());
|
||||
readonly onDidRegister: Event<ViewContainer> = this._onDidRegister.event;
|
||||
private readonly _onDidRegister = this._register(new Emitter<{ viewContainer: ViewContainer, viewContainerLocation: ViewContainerLocation }>());
|
||||
readonly onDidRegister: Event<{ viewContainer: ViewContainer, viewContainerLocation: ViewContainerLocation }> = this._onDidRegister.event;
|
||||
|
||||
private readonly _onDidDeregister = this._register(new Emitter<ViewContainer>());
|
||||
readonly onDidDeregister: Event<ViewContainer> = this._onDidDeregister.event;
|
||||
private readonly _onDidDeregister = this._register(new Emitter<{ viewContainer: ViewContainer, viewContainerLocation: ViewContainerLocation }>());
|
||||
readonly onDidDeregister: Event<{ viewContainer: ViewContainer, viewContainerLocation: ViewContainerLocation }> = this._onDidDeregister.event;
|
||||
|
||||
private viewContainers: Map<string, ViewContainer> = new Map<string, ViewContainer>();
|
||||
private viewContainers: Map<ViewContainerLocation, ViewContainer[]> = new Map<ViewContainerLocation, ViewContainer[]>();
|
||||
|
||||
get all(): ViewContainer[] {
|
||||
return values(this.viewContainers);
|
||||
return flatten(values(this.viewContainers));
|
||||
}
|
||||
|
||||
registerViewContainer(id: string, location: ViewContainerLocation, hideIfEmpty?: boolean, extensionId?: ExtensionIdentifier, viewOrderDelegate?: ViewOrderDelegate): ViewContainer {
|
||||
const existing = this.viewContainers.get(id);
|
||||
registerViewContainer(viewContainerDescriptor: IViewContainerDescriptor, viewContainerLocation: ViewContainerLocation): ViewContainer {
|
||||
const existing = this.get(viewContainerDescriptor.id);
|
||||
if (existing) {
|
||||
return existing;
|
||||
}
|
||||
|
||||
const viewContainer = new class extends ViewContainer {
|
||||
constructor() {
|
||||
super(id, location, !!hideIfEmpty, extensionId, viewOrderDelegate);
|
||||
super(viewContainerDescriptor);
|
||||
}
|
||||
};
|
||||
this.viewContainers.set(id, viewContainer);
|
||||
this._onDidRegister.fire(viewContainer);
|
||||
const viewContainers = getOrSet(this.viewContainers, viewContainerLocation, []);
|
||||
viewContainers.push(viewContainer);
|
||||
this._onDidRegister.fire({ viewContainer, viewContainerLocation });
|
||||
return viewContainer;
|
||||
}
|
||||
|
||||
deregisterViewContainer(viewContainer: ViewContainer): void {
|
||||
const existing = this.viewContainers.get(viewContainer.id);
|
||||
if (existing) {
|
||||
this.viewContainers.delete(viewContainer.id);
|
||||
this._onDidDeregister.fire(viewContainer);
|
||||
for (const viewContainerLocation of keys(this.viewContainers)) {
|
||||
const viewContainers = this.viewContainers.get(viewContainerLocation)!;
|
||||
const index = viewContainers?.indexOf(viewContainer);
|
||||
if (index !== -1) {
|
||||
viewContainers?.splice(index, 1);
|
||||
if (viewContainers.length === 0) {
|
||||
this.viewContainers.delete(viewContainerLocation);
|
||||
}
|
||||
this._onDidDeregister.fire({ viewContainer, viewContainerLocation });
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
get(id: string): ViewContainer | undefined {
|
||||
return this.viewContainers.get(id);
|
||||
return this.all.filter(viewContainer => viewContainer.id === id)[0];
|
||||
}
|
||||
|
||||
getViewContainers(location: ViewContainerLocation): ViewContainer[] {
|
||||
return [...(this.viewContainers.get(location) || [])];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user