提交 6793e088 编写于 作者: P Pine Wu

Remove awkward workaround for extension viewletid

上级 e2b7b520
......@@ -30,15 +30,6 @@ export class ActivitybarPart extends Part implements IActivityService {
private activityActionItems: { [actionId: string]: IActionItem; };
private compositeIdToActions: { [compositeId: string]: ActivityAction; };
// Serves two purposes:
// 1. Expose the viewletId that will be assigned to an extension viewlet,
// which wouldn't know its viewletId until construction time.
// 2. When workbench restores sidebar, if the last-opened viewlet is an extension viewlet,
// it'll set this value and defer restoration until all extensions are loaded.
private _extViewletIdToOpen: string;
public get extViewletIdToOpen() { return this._extViewletIdToOpen; };
public set extViewletIdToOpen(viewletId: string) { this._extViewletIdToOpen = viewletId; };
constructor(
id: string,
@IViewletService private viewletService: IViewletService,
......@@ -62,7 +53,7 @@ export class ActivitybarPart extends Part implements IActivityService {
// Deactivate viewlet action on close
this.toUnbind.push(this.viewletService.onDidViewletClose(viewlet => this.onCompositeClosed(viewlet)));
this.toUnbind.push(this.viewletService.onDidViewletRegister(() => this.onDidViewletRegister()));
this.toUnbind.push(this.viewletService.onDidViewletRegister(() => this.refreshViewletSwitcher()));
}
private onActiveCompositeChanged(composite: IComposite): void {
......@@ -77,10 +68,6 @@ export class ActivitybarPart extends Part implements IActivityService {
}
}
private onDidViewletRegister(): void {
this.refreshViewletSwitcher();
}
public showActivity(compositeId: string, badge: IBadge, clazz?: string): void {
const action = this.compositeIdToActions[compositeId];
if (action) {
......@@ -127,12 +114,6 @@ export class ActivitybarPart extends Part implements IActivityService {
private toAction(composite: ViewletDescriptor): ActivityAction {
const action = this.instantiationService.createInstance(ViewletActivityAction, composite.id + '.activity-bar-action', composite);
// Store the viewletId of the extension viewlet that is about to open.
// Later retrieved by TreeExplorerViewlet, which wouldn't know its id until
// its construction at runtime.
action.onOpenExtViewlet((viewletId) => {
this._extViewletIdToOpen = viewletId;
});
this.activityActionItems[action.id] = new ActivityActionItem(action, composite.name, this.getKeybindingLabel(composite.id));
this.compositeIdToActions[composite.id] = action;
......
......@@ -155,6 +155,10 @@ export class ViewletDescriptor extends CompositeDescriptor<Viewlet> {
constructor(moduleId: string, ctorName: string, id: string, name: string, cssClass?: string, order?: number, public isExtension: boolean = false) {
super(moduleId, ctorName, id, name, cssClass, order);
if (isExtension) {
// Pass viewletId to extension viewlet, which doesn't know its id until runtime.
this.appendStaticArguments([id]);
}
}
}
......
......@@ -232,15 +232,10 @@ export class Workbench implements IPartService {
viewletId = this.storageService.get(SidebarPart.activeViewletSettingsKey, StorageScope.WORKSPACE, viewletId); // help developers and restore last view
}
// If extension viewlet is the last active viewlet, defer its construction until all extensions are loaded
if (!viewletRegistry.getViewlet(viewletId)) {
this.activitybarPart.extViewletIdToOpen = viewletId;
} else {
if (!this.sideBarHidden && !!viewletId) {
const viewletTimerEvent = timer.start(timer.Topic.STARTUP, strings.format('Opening Viewlet: {0}', viewletId));
compositeAndEditorPromises.push(this.sidebarPart.openViewlet(viewletId, false).then(() => viewletTimerEvent.stop()));
}
}
// Load Panel
const panelRegistry = Registry.as<PanelRegistry>(PanelExtensions.Panels);
......
......@@ -14,36 +14,31 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { TreeExplorerView } from 'vs/workbench/parts/explorers/browser/views/treeExplorerView';
import { TreeExplorerViewletState } from 'vs/workbench/parts/explorers/browser/views/treeExplorerViewer';
import { IActivityService } from 'vs/workbench/services/activity/common/activityService';
import { toCustomViewletId } from 'vs/workbench/parts/explorers/common/treeExplorer';
export class TreeExplorerViewlet extends Viewlet {
private static _idCounter = 1;
private viewletContainer: Builder;
private view: IViewletView;
private viewletState: TreeExplorerViewletState;
private extViewletId: string;
private viewletId: string;
private treeNodeProviderId: string;
constructor(
viewletId: string,
@ITelemetryService telemetryService: ITelemetryService,
@IInstantiationService private instantiationService: IInstantiationService,
@IActivityService private activityService: IActivityService
) {
super(toCustomViewletId(TreeExplorerViewlet._idCounter.toString()), telemetryService);
super(viewletId, telemetryService);
this.viewletState = new TreeExplorerViewletState();
this.extViewletId = this.activityService.extViewletIdToOpen;
this.treeNodeProviderId = this.getTreeProviderName(this.extViewletId);
TreeExplorerViewlet._idCounter++;
this.viewletId = viewletId;
this.treeNodeProviderId = this.getTreeProviderName(viewletId);
}
public getId(): string {
return this.extViewletId;
return this.viewletId;
}
public create(parent: Builder): TPromise<void> {
......
......@@ -60,7 +60,6 @@ export const IActivityService = createDecorator<IActivityService>('activityServi
export interface IActivityService {
_serviceBrand: any;
extViewletIdToOpen: string;
/**
* Show activity in the activitybar for the given viewlet or panel.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册