提交 747c1018 编写于 作者: S Sandeep Somavarapu

Fix #50730

上级 41729b45
......@@ -17,7 +17,6 @@ import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions, IWo
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { Registry } from 'vs/platform/registry/common/platform';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ProgressLocation } from 'vs/workbench/services/progress/common/progress';
import { VIEWLET_ID as EXPLORER } from 'vs/workbench/parts/files/common/files';
import { VIEWLET_ID as SCM } from 'vs/workbench/parts/scm/common/scm';
import { VIEWLET_ID as DEBUG } from 'vs/workbench/parts/debug/common/debug';
......@@ -133,7 +132,7 @@ class ViewsContainersExtensionHandler implements IWorkbenchContribution {
when: ContextKeyExpr.deserialize(item.when),
canToggleVisibility: true,
collapsed: this.showCollapsed(container),
treeViewer: this.instantiationService.createInstance(CustomTreeViewer, item.id, this.getProgressLocation(container))
treeViewer: this.instantiationService.createInstance(CustomTreeViewer, item.id, container)
};
viewIds.push(viewDescriptor.id);
......@@ -145,18 +144,6 @@ class ViewsContainersExtensionHandler implements IWorkbenchContribution {
});
}
private getProgressLocation(container: ViewContainer): ProgressLocation {
switch (container.id) {
case EXPLORER:
return ProgressLocation.Explorer;
case SCM:
return ProgressLocation.Scm;
case DEBUG:
return null /* No debug progress location yet */;
}
return null;
}
private isValidViewDescriptors(viewDescriptors: IUserFriendlyViewDescriptor[], collector: ExtensionMessageCollector): boolean {
if (!Array.isArray(viewDescriptors)) {
collector.error(localize('requirearray', "views must be an array"));
......
......@@ -14,11 +14,11 @@ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView
import { IMenuService, MenuId, MenuItemAction } from 'vs/platform/actions/common/actions';
import { ContextAwareMenuItemActionItem, fillInActionBarActions, fillInContextMenuActions } from 'vs/platform/actions/browser/menuItemActionItem';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IViewsService, ITreeViewer, ITreeItem, TreeItemCollapsibleState, ITreeViewDataProvider, TreeViewItemHandleArg, ICustomViewDescriptor, ViewsRegistry } from 'vs/workbench/common/views';
import { IViewsService, ITreeViewer, ITreeItem, TreeItemCollapsibleState, ITreeViewDataProvider, TreeViewItemHandleArg, ICustomViewDescriptor, ViewsRegistry, ViewContainer } from 'vs/workbench/common/views';
import { IViewletViewOptions, FileIconThemableWorkbenchTree } from 'vs/workbench/browser/parts/views/viewsViewlet';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IProgressService2, ProgressLocation } from 'vs/workbench/services/progress/common/progress';
import { IProgressService2 } from 'vs/workbench/services/progress/common/progress';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { ICommandService } from 'vs/platform/commands/common/commands';
......@@ -194,7 +194,7 @@ export class CustomTreeViewer extends Disposable implements ITreeViewer {
constructor(
private id: string,
private progressLocation: ProgressLocation,
private container: ViewContainer,
@IExtensionService private extensionService: IExtensionService,
@IWorkbenchThemeService private themeService: IWorkbenchThemeService,
@IInstantiationService private instantiationService: IInstantiationService,
......@@ -292,7 +292,7 @@ export class CustomTreeViewer extends Disposable implements ITreeViewer {
this.treeContainer = DOM.$('.tree-explorer-viewlet-tree-view');
const actionItemProvider = (action: IAction) => action instanceof MenuItemAction ? this.instantiationService.createInstance(ContextAwareMenuItemActionItem, action) : undefined;
const menus = this.instantiationService.createInstance(TreeMenus, this.id);
const dataSource = this.instantiationService.createInstance(TreeDataSource, this, this.progressLocation);
const dataSource = this.instantiationService.createInstance(TreeDataSource, this, this.container);
const renderer = this.instantiationService.createInstance(TreeRenderer, this.id, menus, actionItemProvider);
const controller = this.instantiationService.createInstance(TreeController, this.id, menus);
this.tree = this.instantiationService.createInstance(FileIconThemableWorkbenchTree, this.treeContainer, { dataSource, renderer, controller }, {});
......@@ -395,7 +395,7 @@ class TreeDataSource implements IDataSource {
constructor(
private treeView: ITreeViewer,
private location: ProgressLocation,
private container: ViewContainer,
@IProgressService2 private progressService: IProgressService2
) {
}
......@@ -410,7 +410,7 @@ class TreeDataSource implements IDataSource {
public getChildren(tree: ITree, node: ITreeItem): TPromise<any[]> {
if (this.treeView.dataProvider) {
return this.location ? this.progressService.withProgress({ location: this.location }, () => this.treeView.dataProvider.getChildren(node)) : this.treeView.dataProvider.getChildren(node);
return this.progressService.withProgress({ location: this.container }, () => this.treeView.dataProvider.getChildren(node));
}
return TPromise.as([]);
}
......
......@@ -243,7 +243,7 @@ export interface ITreeViewer extends IDisposable {
export interface ICustomViewDescriptor extends IViewDescriptor {
treeViewer: ITreeViewer;
readonly treeViewer: ITreeViewer;
}
......
......@@ -20,6 +20,7 @@ import { ProgressBadge, IActivityService } from 'vs/workbench/services/activity/
import { INotificationService, Severity, INotificationHandle, INotificationActions } from 'vs/platform/notification/common/notification';
import { Action } from 'vs/base/common/actions';
import { once } from 'vs/base/common/event';
import { ViewContainer } from 'vs/workbench/common/views';
class WindowProgressItem implements IStatusbarItem {
......@@ -91,6 +92,15 @@ export class ProgressService2 implements IProgressService2 {
withProgress<P extends Thenable<R>, R=any>(options: IProgressOptions, task: (progress: IProgress<IProgressStep>) => P, onDidCancel?: () => void): P {
const { location } = options;
if (location instanceof ViewContainer) {
const viewlet = this._viewletService.getViewlet(location.id);
if (viewlet) {
return this._withViewletProgress(location.id, task);
}
console.warn(`Bad progress location: ${location.id}`);
return undefined;
}
switch (location) {
case ProgressLocation.Notification:
return this._withNotificationProgress(options, task, onDidCancel);
......
......@@ -6,6 +6,7 @@
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IProgress } from 'vs/platform/progress/common/progress';
import { ViewContainer } from 'vs/workbench/common/views';
export enum ProgressLocation {
Explorer = 1,
......@@ -16,7 +17,7 @@ export enum ProgressLocation {
}
export interface IProgressOptions {
location: ProgressLocation;
location: ProgressLocation | ViewContainer;
title?: string;
source?: string;
total?: number;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册