Skip to content

Commit 481923c

Browse files
authored
migrate search to use new setting (microsoft#89190)
* migrate search to use new setting * rename * add getViewLocation api to vds for search * remove unreferenced location option
1 parent aac1e3d commit 481923c

33 files changed

Lines changed: 259 additions & 325 deletions

src/vs/workbench/browser/parts/views/customView.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView
1313
import { IMenuService, MenuId, MenuItemAction } from 'vs/platform/actions/common/actions';
1414
import { ContextAwareMenuEntryActionViewItem, createAndFillInContextMenuActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
1515
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
16-
import { ITreeView, ITreeItem, TreeItemCollapsibleState, ITreeViewDataProvider, TreeViewItemHandleArg, ITreeViewDescriptor, IViewsRegistry, ViewContainer, ITreeItemLabel, Extensions } from 'vs/workbench/common/views';
16+
import { ITreeView, ITreeItem, TreeItemCollapsibleState, ITreeViewDataProvider, TreeViewItemHandleArg, ITreeViewDescriptor, IViewsRegistry, ViewContainer, ITreeItemLabel, Extensions, IViewDescriptorService } from 'vs/workbench/common/views';
1717
import { IViewletViewOptions } from 'vs/workbench/browser/parts/views/viewsViewlet';
1818
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
1919
import { INotificationService } from 'vs/platform/notification/common/notification';
@@ -54,9 +54,10 @@ export class CustomTreeViewPane extends ViewPane {
5454
@IContextMenuService contextMenuService: IContextMenuService,
5555
@IConfigurationService configurationService: IConfigurationService,
5656
@IContextKeyService contextKeyService: IContextKeyService,
57+
@IViewDescriptorService viewDescriptorService: IViewDescriptorService,
5758
@IInstantiationService instantiationService: IInstantiationService,
5859
) {
59-
super({ ...(options as IViewPaneOptions), ariaHeaderLabel: options.title, titleMenuId: MenuId.ViewTitle }, keybindingService, contextMenuService, configurationService, contextKeyService, instantiationService);
60+
super({ ...(options as IViewPaneOptions), ariaHeaderLabel: options.title, titleMenuId: MenuId.ViewTitle }, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService);
6061
const { treeView } = (<ITreeViewDescriptor>Registry.as<IViewsRegistry>(Extensions.ViewsRegistry).getView(options.id));
6162
this.treeView = treeView;
6263
this._register(this.treeView.onDidChangeActions(() => this.updateActions(), this));

src/vs/workbench/browser/parts/views/viewPaneContainer.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as nls from 'vs/nls';
88
import { Event, Emitter } from 'vs/base/common/event';
99
import { ColorIdentifier } from 'vs/platform/theme/common/colorRegistry';
1010
import { attachStyler, IColorMapping } from 'vs/platform/theme/common/styler';
11-
import { SIDE_BAR_DRAG_AND_DROP_BACKGROUND, SIDE_BAR_SECTION_HEADER_FOREGROUND, SIDE_BAR_SECTION_HEADER_BACKGROUND, SIDE_BAR_SECTION_HEADER_BORDER } from 'vs/workbench/common/theme';
11+
import { SIDE_BAR_DRAG_AND_DROP_BACKGROUND, SIDE_BAR_SECTION_HEADER_FOREGROUND, SIDE_BAR_SECTION_HEADER_BACKGROUND, SIDE_BAR_SECTION_HEADER_BORDER, PANEL_BACKGROUND, SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme';
1212
import { append, $, trackFocus, toggleClass, EventType, isAncestor, Dimension, addDisposableListener } from 'vs/base/browser/dom';
1313
import { IDisposable, combinedDisposable, dispose, toDisposable } from 'vs/base/common/lifecycle';
1414
import { firstIndex } from 'vs/base/common/arrays';
@@ -25,7 +25,7 @@ import { PaneView, IPaneViewOptions, IPaneOptions, Pane, DefaultPaneDndControlle
2525
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
2626
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
2727
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
28-
import { Extensions as ViewContainerExtensions, IView, FocusedViewContext, IViewContainersRegistry, IViewDescriptor, ViewContainer, IViewDescriptorService } from 'vs/workbench/common/views';
28+
import { Extensions as ViewContainerExtensions, IView, FocusedViewContext, IViewContainersRegistry, IViewDescriptor, ViewContainer, IViewDescriptorService, ViewContainerLocation, IViewPaneContainer } from 'vs/workbench/common/views';
2929
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
3030
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
3131
import { assertIsDefined } from 'vs/base/common/types';
@@ -34,7 +34,6 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
3434
import { IViewletViewOptions } from 'vs/workbench/browser/parts/views/viewsViewlet';
3535
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
3636
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
37-
import { IViewPaneContainer } from 'vs/workbench/common/viewPaneContainer';
3837
import { Component } from 'vs/workbench/common/component';
3938
import { MenuId, MenuItemAction } from 'vs/platform/actions/common/actions';
4039
import { ContextAwareMenuEntryActionViewItem } from 'vs/platform/actions/browser/menuEntryActionViewItem';
@@ -92,6 +91,7 @@ export abstract class ViewPane extends Pane implements IView {
9291
@IContextMenuService protected contextMenuService: IContextMenuService,
9392
@IConfigurationService protected readonly configurationService: IConfigurationService,
9493
@IContextKeyService contextKeyService: IContextKeyService,
94+
@IViewDescriptorService private viewDescriptorService: IViewDescriptorService,
9595
@IInstantiationService protected instantiationService: IInstantiationService,
9696
) {
9797
super(options);
@@ -189,6 +189,14 @@ export abstract class ViewPane extends Pane implements IView {
189189
this._onDidChangeTitleArea.fire();
190190
}
191191

192+
protected getProgressLocation(): string {
193+
return this.viewDescriptorService.getViewContainer(this.id)!.id;
194+
}
195+
196+
protected getBackgroundColor(): string {
197+
return this.viewDescriptorService.getViewLocation(this.id) === ViewContainerLocation.Panel ? PANEL_BACKGROUND : SIDE_BAR_BACKGROUND;
198+
}
199+
192200
focus(): void {
193201
if (this.element) {
194202
this.element.focus();
@@ -602,13 +610,14 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {
602610

603611
protected onDidAddViews(added: IAddedViewDescriptorRef[]): ViewPane[] {
604612
const panesToAdd: { pane: ViewPane, size: number, index: number }[] = [];
613+
605614
for (const { viewDescriptor, collapsed, index, size } of added) {
606615
const pane = this.createView(viewDescriptor,
607616
{
608617
id: viewDescriptor.id,
609618
title: viewDescriptor.name,
610619
actionRunner: this.getActionRunner(),
611-
expanded: !collapsed
620+
expanded: !collapsed,
612621
});
613622

614623
pane.render();

src/vs/workbench/browser/parts/views/views.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
2323
import { IPaneComposite } from 'vs/workbench/common/panecomposite';
2424
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
2525
import type { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
26+
import { PaneComposite } from 'vs/workbench/browser/panecomposite';
2627

2728
export interface IViewState {
2829
visibleGlobal: boolean | undefined;
@@ -565,6 +566,27 @@ export class ViewsService extends Disposable implements IViewsService {
565566
return undefined;
566567
}
567568

569+
getActiveViewWithId(id: string): IView | null {
570+
const viewContainer = this.viewDescriptorService.getViewContainer(id);
571+
if (viewContainer) {
572+
const location = this.viewContainersRegistry.getViewContainerLocation(viewContainer);
573+
574+
if (location === ViewContainerLocation.Sidebar) {
575+
const activeViewlet = this.viewletService.getActiveViewlet();
576+
if (activeViewlet?.getId() === viewContainer.id) {
577+
return activeViewlet.getViewPaneContainer().getView(id) ?? null;
578+
}
579+
} else if (location === ViewContainerLocation.Panel) {
580+
const activePanel = this.panelService.getActivePanel();
581+
if (activePanel?.getId() === viewContainer.id && activePanel instanceof PaneComposite) {
582+
return activePanel.getViewPaneContainer().getView(id) ?? null;
583+
}
584+
}
585+
}
586+
587+
return null;
588+
}
589+
568590
async openView(id: string, focus: boolean): Promise<IView | null> {
569591
const viewContainer = this.viewDescriptorService.getViewContainer(id);
570592
if (viewContainer) {

src/vs/workbench/common/panecomposite.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { IView } from 'vs/workbench/common/views';
6+
import { IView, IViewPaneContainer } from 'vs/workbench/common/views';
77
import { IComposite } from 'vs/workbench/common/composite';
8-
import { IViewPaneContainer } from 'vs/workbench/common/viewPaneContainer';
98

109
export interface IPaneComposite extends IComposite {
1110
openView(id: string, focus?: boolean): IView;

src/vs/workbench/common/viewPaneContainer.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/vs/workbench/common/views.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ import { ThemeIcon } from 'vs/platform/theme/common/themeService';
1515
import { values, keys, getOrSet } from 'vs/base/common/map';
1616
import { Registry } from 'vs/platform/registry/common/platform';
1717
import { IKeybindings } from 'vs/platform/keybinding/common/keybindingsRegistry';
18-
import { IAction } from 'vs/base/common/actions';
18+
import { IAction, IActionViewItem } from 'vs/base/common/actions';
1919
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
2020
import { flatten } from 'vs/base/common/arrays';
21-
import { IViewPaneContainer } from 'vs/workbench/common/viewPaneContainer';
2221
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
2322

2423
export const TEST_VIEW_CONTAINER_ID = 'workbench.view.extension.test';
@@ -357,6 +356,8 @@ export const IViewsService = createDecorator<IViewsService>('viewsService');
357356
export interface IViewsService {
358357
_serviceBrand: undefined;
359358

359+
getActiveViewWithId(id: string): IView | null;
360+
360361
openView(id: string, focus?: boolean): Promise<IView | null>;
361362
}
362363

@@ -375,6 +376,8 @@ export interface IViewDescriptorService {
375376

376377
getViewContainer(viewId: string): ViewContainer | null;
377378

379+
getViewLocation(viewId: string): ViewContainerLocation | null;
380+
378381
getDefaultContainer(viewId: string): ViewContainer | null;
379382
}
380383

@@ -505,3 +508,15 @@ export interface IEditableData {
505508
startingValue?: string | null;
506509
onFinish: (value: string, success: boolean) => void;
507510
}
511+
512+
export interface IViewPaneContainer {
513+
setVisible(visible: boolean): void;
514+
isVisible(): boolean;
515+
focus(): void;
516+
getActions(): IAction[];
517+
getSecondaryActions(): IAction[];
518+
getActionViewItem(action: IAction): IActionViewItem | undefined;
519+
getView(viewId: string): IView | undefined;
520+
saveState(): void;
521+
}
522+

src/vs/workbench/contrib/bulkEdit/browser/bulkEditPane.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { CancellationToken } from 'vs/base/common/cancellation';
3636
import { ITextEditorOptions } from 'vs/platform/editor/common/editor';
3737
import type { IAsyncDataTreeViewState } from 'vs/base/browser/ui/tree/asyncDataTree';
3838
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
39+
import { IViewDescriptorService } from 'vs/workbench/common/views';
3940

4041
const enum State {
4142
Data = 'data',
@@ -76,13 +77,14 @@ export class BulkEditPane extends ViewPane {
7677
@IContextMenuService private readonly _contextMenuService: IContextMenuService,
7778
@IContextKeyService private readonly _contextKeyService: IContextKeyService,
7879
@IStorageService private readonly _storageService: IStorageService,
80+
@IViewDescriptorService viewDescriptorService: IViewDescriptorService,
7981
@IKeybindingService keybindingService: IKeybindingService,
8082
@IContextMenuService contextMenuService: IContextMenuService,
8183
@IConfigurationService configurationService: IConfigurationService,
8284
) {
8385
super(
8486
{ ...options, titleMenuId: MenuId.BulkEditTitle },
85-
keybindingService, contextMenuService, configurationService, _contextKeyService, _instaService
87+
keybindingService, contextMenuService, configurationService, _contextKeyService, viewDescriptorService, _instaService
8688
);
8789

8890
this.element.classList.add('bulk-edit-panel', 'show-file-icons');

src/vs/workbench/contrib/debug/browser/breakpointsView.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { ILabelService } from 'vs/platform/label/common/label';
3333
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
3434
import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme';
3535
import { Gesture } from 'vs/base/browser/touch';
36+
import { IViewDescriptorService } from 'vs/workbench/common/views';
3637

3738
const $ = dom.$;
3839

@@ -66,9 +67,10 @@ export class BreakpointsView extends ViewPane {
6667
@IEditorService private readonly editorService: IEditorService,
6768
@IContextViewService private readonly contextViewService: IContextViewService,
6869
@IConfigurationService configurationService: IConfigurationService,
70+
@IViewDescriptorService viewDescriptorService: IViewDescriptorService,
6971
@IContextKeyService contextKeyService: IContextKeyService,
7072
) {
71-
super({ ...(options as IViewPaneOptions), ariaHeaderLabel: nls.localize('breakpointsSection', "Breakpoints Section") }, keybindingService, contextMenuService, configurationService, contextKeyService, instantiationService);
73+
super({ ...(options as IViewPaneOptions), ariaHeaderLabel: nls.localize('breakpointsSection', "Breakpoints Section") }, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService);
7274

7375
this.minimumBodySize = this.maximumBodySize = getExpandedBodySize(this.debugService.getModel());
7476
this._register(this.debugService.getModel().onDidChangeBreakpoints(() => this.onBreakpointsChange()));

src/vs/workbench/contrib/debug/browser/callStackView.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { STOP_ID, STOP_LABEL, DISCONNECT_ID, DISCONNECT_LABEL, RESTART_SESSION_I
3535
import { ICommandService } from 'vs/platform/commands/common/commands';
3636
import { CollapseAction } from 'vs/workbench/browser/viewlet';
3737
import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme';
38+
import { IViewDescriptorService } from 'vs/workbench/common/views';
3839

3940
const $ = dom.$;
4041

@@ -92,12 +93,13 @@ export class CallStackView extends ViewPane {
9293
@IDebugService private readonly debugService: IDebugService,
9394
@IKeybindingService keybindingService: IKeybindingService,
9495
@IInstantiationService instantiationService: IInstantiationService,
96+
@IViewDescriptorService viewDescriptorService: IViewDescriptorService,
9597
@IEditorService private readonly editorService: IEditorService,
9698
@IConfigurationService configurationService: IConfigurationService,
9799
@IMenuService menuService: IMenuService,
98100
@IContextKeyService readonly contextKeyService: IContextKeyService,
99101
) {
100-
super({ ...(options as IViewPaneOptions), ariaHeaderLabel: nls.localize('callstackSection', "Call Stack Section") }, keybindingService, contextMenuService, configurationService, contextKeyService, instantiationService);
102+
super({ ...(options as IViewPaneOptions), ariaHeaderLabel: nls.localize('callstackSection', "Call Stack Section") }, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService);
101103
this.callStackItemType = CONTEXT_CALLSTACK_ITEM_TYPE.bindTo(contextKeyService);
102104

103105
this.contributedContextMenu = menuService.createMenu(MenuId.DebugCallStackContext, contextKeyService);

src/vs/workbench/contrib/debug/browser/loadedScriptsView.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { ILabelService } from 'vs/platform/label/common/label';
3737
import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme';
3838
import type { ICompressedTreeNode } from 'vs/base/browser/ui/tree/compressedObjectTreeModel';
3939
import type { ICompressibleTreeRenderer } from 'vs/base/browser/ui/tree/objectTree';
40+
import { IViewDescriptorService } from 'vs/workbench/common/views';
4041

4142
const NEW_STYLE_COMPRESS = true;
4243

@@ -415,6 +416,7 @@ export class LoadedScriptsView extends ViewPane {
415416
@IContextMenuService contextMenuService: IContextMenuService,
416417
@IKeybindingService keybindingService: IKeybindingService,
417418
@IInstantiationService instantiationService: IInstantiationService,
419+
@IViewDescriptorService viewDescriptorService: IViewDescriptorService,
418420
@IConfigurationService configurationService: IConfigurationService,
419421
@IEditorService private readonly editorService: IEditorService,
420422
@IContextKeyService readonly contextKeyService: IContextKeyService,
@@ -423,7 +425,7 @@ export class LoadedScriptsView extends ViewPane {
423425
@IDebugService private readonly debugService: IDebugService,
424426
@ILabelService private readonly labelService: ILabelService
425427
) {
426-
super({ ...(options as IViewPaneOptions), ariaHeaderLabel: nls.localize('loadedScriptsSection', "Loaded Scripts Section") }, keybindingService, contextMenuService, configurationService, contextKeyService, instantiationService);
428+
super({ ...(options as IViewPaneOptions), ariaHeaderLabel: nls.localize('loadedScriptsSection', "Loaded Scripts Section") }, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService);
427429
this.loadedScriptsItemType = CONTEXT_LOADED_SCRIPTS_ITEM_TYPE.bindTo(contextKeyService);
428430
}
429431

0 commit comments

Comments
 (0)