Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ViewPane.actionRunner #90831

Merged
merged 1 commit into from
Feb 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions src/vs/workbench/browser/parts/views/viewPaneContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { SIDE_BAR_DRAG_AND_DROP_BACKGROUND, SIDE_BAR_SECTION_HEADER_FOREGROUND,
import { append, $, trackFocus, toggleClass, EventType, isAncestor, Dimension, addDisposableListener, removeClass, addClass } from 'vs/base/browser/dom';
import { IDisposable, combinedDisposable, dispose, toDisposable, Disposable, DisposableStore } from 'vs/base/common/lifecycle';
import { firstIndex } from 'vs/base/common/arrays';
import { IAction, IActionRunner, ActionRunner } from 'vs/base/common/actions';
import { IAction } from 'vs/base/common/actions';
import { IActionViewItem, ActionsOrientation, Separator } from 'vs/base/browser/ui/actionbar/actionbar';
import { Registry } from 'vs/platform/registry/common/platform';
import { prepareActions } from 'vs/workbench/browser/actions';
Expand Down Expand Up @@ -51,7 +51,6 @@ export interface IPaneColors extends IColorMapping {
}

export interface IViewPaneOptions extends IPaneOptions {
actionRunner?: IActionRunner;
id: string;
title: string;
showActionsAlways?: boolean;
Expand Down Expand Up @@ -169,7 +168,6 @@ export abstract class ViewPane extends Pane implements IView {

private readonly menuActions: ViewMenuActions;

protected actionRunner?: IActionRunner;
private toolbar?: ToolBar;
private readonly showActionsAlways: boolean = false;
private headerContainer?: HTMLElement;
Expand All @@ -196,7 +194,6 @@ export abstract class ViewPane extends Pane implements IView {

this.id = options.id;
this.title = options.title;
this.actionRunner = options.actionRunner;
this.showActionsAlways = !!options.showActionsAlways;
this.focusedViewContextKey = FocusedViewContext.bindTo(contextKeyService);

Expand Down Expand Up @@ -262,7 +259,6 @@ export abstract class ViewPane extends Pane implements IView {
actionViewItemProvider: action => this.getActionViewItem(action),
ariaLabel: nls.localize('viewToolbarAriaLabel', "{0} actions", this.title),
getKeyBinding: action => this.keybindingService.lookupKeybinding(action.id),
actionRunner: this.actionRunner
});

this._register(this.toolbar);
Expand Down Expand Up @@ -453,8 +449,6 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {
private didLayout = false;
private dimension: Dimension | undefined;

protected actionRunner: IActionRunner | undefined;

private readonly visibleViewsCountFromCache: number | undefined;
private readonly visibleViewsStorageId: string;
protected readonly viewsModel: PersistentContributableViewsModel;
Expand Down Expand Up @@ -800,7 +794,6 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {
{
id: viewDescriptor.id,
title: viewDescriptor.name,
actionRunner: this.getActionRunner(),
expanded: !collapsed,
minimumBodySize: this.viewDescriptorService.getViewContainerLocation(this.viewContainer) === ViewContainerLocation.Panel ? 0 : 120
});
Expand Down Expand Up @@ -831,14 +824,6 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {
return panes;
}

getActionRunner(): IActionRunner {
if (!this.actionRunner) {
this.actionRunner = new ActionRunner();
}

return this.actionRunner;
}

private onDidRemoveViewDescriptors(removed: IViewDescriptorRef[]): void {
removed = removed.sort((a, b) => b.index - a.index);
const panesToRemove: ViewPane[] = [];
Expand Down
11 changes: 0 additions & 11 deletions src/vs/workbench/contrib/files/browser/media/explorerviewlet.css
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,6 @@
border-radius: 0; /* goes better when ellipsis shows up on narrow sidebar */
}

.explorer-viewlet .explorer-empty-view {
padding: 0 20px 0 20px;
}

.explorer-viewlet .explorer-empty-view .monaco-button {
max-width: 260px;
margin-left: auto;
margin-right: auto;
display: block;
}

.explorer-viewlet .explorer-item.nonexistent-root {
opacity: 0.5;
}
Expand Down
7 changes: 3 additions & 4 deletions src/vs/workbench/contrib/files/browser/views/emptyView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { isWeb } from 'vs/base/common/platform';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IViewDescriptorService } from 'vs/workbench/common/views';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { ActionRunner } from 'vs/base/common/actions';

export class EmptyView extends ViewPane {

Expand Down Expand Up @@ -71,14 +72,12 @@ export class EmptyView extends ViewPane {
this.button = new Button(messageContainer);
attachButtonStyler(this.button, this.themeService);

const actionRunner = new ActionRunner();
this._register(this.button.onDidClick(() => {
if (!this.actionRunner) {
return;
}
const action = this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE
? this.instantiationService.createInstance(AddRootFolderAction, AddRootFolderAction.ID, AddRootFolderAction.LABEL)
: this.instantiationService.createInstance(OpenFolderAction, OpenFolderAction.ID, OpenFolderAction.LABEL);
this.actionRunner.run(action).then(() => {
actionRunner.run(action).then(() => {
action.dispose();
}, err => {
action.dispose();
Expand Down
5 changes: 3 additions & 2 deletions src/vs/workbench/contrib/search/browser/searchView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as aria from 'vs/base/browser/ui/aria/aria';
import { MessageType } from 'vs/base/browser/ui/inputbox/inputBox';
import { IIdentityProvider } from 'vs/base/browser/ui/list/list';
import { ITreeContextMenuEvent, ITreeElement } from 'vs/base/browser/ui/tree/tree';
import { IAction } from 'vs/base/common/actions';
import { IAction, ActionRunner } from 'vs/base/common/actions';
import { Delayer } from 'vs/base/common/async';
import * as errors from 'vs/base/common/errors';
import { Event } from 'vs/base/common/event';
Expand Down Expand Up @@ -1584,14 +1584,15 @@ export class SearchView extends ViewPane {
const openFolderLink = dom.append(textEl,
$('a.pointer.prominent', { tabindex: 0 }, nls.localize('openFolder', "Open Folder")));

const actionRunner = new ActionRunner();
this.messageDisposables.push(dom.addDisposableListener(openFolderLink, dom.EventType.CLICK, (e: MouseEvent) => {
dom.EventHelper.stop(e, false);

const action = env.isMacintosh ?
this.instantiationService.createInstance(OpenFileFolderAction, OpenFileFolderAction.ID, OpenFileFolderAction.LABEL) :
this.instantiationService.createInstance(OpenFolderAction, OpenFolderAction.ID, OpenFolderAction.LABEL);

this.actionRunner!.run(action).then(() => {
actionRunner.run(action).then(() => {
action.dispose();
}, err => {
action.dispose();
Expand Down