提交 daa71ca0 编写于 作者: B Benjamin Pasero

💄

上级 c082cc53
......@@ -12,7 +12,7 @@ import errors = require('vs/base/common/errors');
import { TPromise } from 'vs/base/common/winjs.base';
import { Builder, $ } from 'vs/base/browser/builder';
import { DelayedDragHandler } from 'vs/base/browser/dnd';
import { Action } from 'vs/base/common/actions';
import { Action, IAction } from 'vs/base/common/actions';
import { BaseActionItem, Separator } from 'vs/base/browser/ui/actionbar/actionbar';
import { IActivityBarService, ProgressBadge, TextBadge, NumberBadge, IconBadge, IBadge } from 'vs/workbench/services/activity/common/activityBarService';
import Event, { Emitter } from 'vs/base/common/event';
......@@ -22,6 +22,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { ViewletDescriptor } from 'vs/workbench/browser/viewlet';
import { dispose } from 'vs/base/common/lifecycle';
import { Keybinding } from 'vs/base/common/keybinding';
import { IViewletService, } from 'vs/workbench/services/viewlet/browser/viewlet';
import { IPartService, Parts } from 'vs/workbench/services/part/common/partService';
......@@ -120,7 +121,6 @@ export class ActivityActionItem extends BaseActionItem {
action: ActivityAction,
private viewlet: ViewletDescriptor,
@IContextMenuService private contextMenuService: IContextMenuService,
@IViewletService private viewletService: IViewletService,
@IActivityBarService private activityBarService: IActivityBarService,
@IKeybindingService private keybindingService: IKeybindingService,
@IInstantiationService instantiationService: IInstantiationService
......@@ -131,8 +131,6 @@ export class ActivityActionItem extends BaseActionItem {
this.name = viewlet.name;
this._keybinding = this.getKeybindingLabel(viewlet.id);
action.onDidChangeBadge(this.handleBadgeChangeEvenet, this, this._callOnDispose);
if (!ActivityActionItem.manageExtensionAction) {
ActivityActionItem.manageExtensionAction = instantiationService.createInstance(ManageExtensionAction);
}
......@@ -140,6 +138,8 @@ export class ActivityActionItem extends BaseActionItem {
if (!ActivityActionItem.toggleViewletPinnedAction) {
ActivityActionItem.toggleViewletPinnedAction = instantiationService.createInstance(ToggleViewletPinnedAction, void 0);
}
action.onDidChangeBadge(this.handleBadgeChangeEvenet, this, this._callOnDispose);
}
private getKeybindingLabel(id: string): string {
......@@ -422,6 +422,7 @@ export class ViewletOverflowActivityActionItem extends BaseActionItem {
private getBadge: (viewlet: ViewletDescriptor) => IBadge,
@IInstantiationService private instantiationService: IInstantiationService,
@IViewletService private viewletService: IViewletService,
@IKeybindingService private keybindingService: IKeybindingService,
@IContextMenuService private contextMenuService: IContextMenuService,
) {
super(null, action);
......@@ -451,10 +452,20 @@ export class ViewletOverflowActivityActionItem extends BaseActionItem {
this.contextMenuService.showContextMenu({
getAnchor: () => this.builder.getHTMLElement(),
getActions: () => TPromise.as(this.actions),
getKeyBinding: (action) => this.getKeybinding(action),
onHide: () => dispose(this.actions)
});
}
private getKeybinding(action: IAction): Keybinding {
const opts = this.keybindingService.lookupKeybindings(action.id);
if (opts.length > 0) {
return opts[0]; // only take the first one
}
return null;
}
private getActions(): OpenViewletAction[] {
const activeViewlet = this.viewletService.getActiveViewlet();
......@@ -503,11 +514,15 @@ class ManageExtensionAction extends Action {
class OpenViewletAction extends Action {
constructor(
public viewlet: ViewletDescriptor,
private _viewlet: ViewletDescriptor,
@IPartService private partService: IPartService,
@IViewletService private viewletService: IViewletService
) {
super(viewlet.id, viewlet.name);
super(_viewlet.id, _viewlet.name);
}
public get viewlet(): ViewletDescriptor {
return this._viewlet;
}
public run(): TPromise<any> {
......
......@@ -21,7 +21,6 @@ import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { IActivityBarService, IBadge } from 'vs/workbench/services/activity/common/activityBarService';
import { IPartService } from 'vs/workbench/services/part/common/partService';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IExtensionService } from 'vs/platform/extensions/common/extensions';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { Scope as MementoScope } from 'vs/workbench/common/memento';
......@@ -48,8 +47,8 @@ export class ActivitybarPart extends Part implements IActivityBarService {
private viewletOverflowAction: ViewletOverflowActivityAction;
private viewletOverflowActionItem: ViewletOverflowActivityActionItem;
private activityActionItems: { [actionId: string]: IActionItem; };
private viewletIdToActions: { [viewletId: string]: ActivityAction; };
private viewletIdToActionItems: { [viewletId: string]: IActionItem; };
private viewletIdToActivity: { [viewletId: string]: IViewletActivity; };
private memento: any;
......@@ -60,7 +59,6 @@ export class ActivitybarPart extends Part implements IActivityBarService {
id: string,
@IViewletService private viewletService: IViewletService,
@IExtensionService private extensionService: IExtensionService,
@IKeybindingService private keybindingService: IKeybindingService,
@IStorageService private storageService: IStorageService,
@IContextMenuService private contextMenuService: IContextMenuService,
@IInstantiationService private instantiationService: IInstantiationService,
......@@ -68,7 +66,7 @@ export class ActivitybarPart extends Part implements IActivityBarService {
) {
super(id);
this.activityActionItems = Object.create(null);
this.viewletIdToActionItems = Object.create(null);
this.viewletIdToActions = Object.create(null);
this.viewletIdToActivity = Object.create(null);
......@@ -168,7 +166,7 @@ export class ActivitybarPart extends Part implements IActivityBarService {
private createViewletSwitcher(div: Builder): void {
this.viewletSwitcherBar = new ActionBar(div, {
actionItemProvider: (action: Action) => action instanceof ViewletOverflowActivityAction ? this.viewletOverflowActionItem : this.activityActionItems[action.id],
actionItemProvider: (action: Action) => action instanceof ViewletOverflowActivityAction ? this.viewletOverflowActionItem : this.viewletIdToActionItems[action.id],
orientation: ActionsOrientation.VERTICAL,
ariaLabel: nls.localize('activityBarAriaLabel', "Active View Switcher"),
animated: false
......@@ -182,7 +180,7 @@ export class ActivitybarPart extends Part implements IActivityBarService {
// Always show the active viewlet even if it is marked to be hidden
const activeViewlet = this.viewletService.getActiveViewlet();
if (activeViewlet && !viewletsToShow.some(v => v.id === activeViewlet.getId())) {
if (activeViewlet && !viewletsToShow.some(viewlet => viewlet.id === activeViewlet.getId())) {
this.activeUnpinnedViewlet = this.viewletService.getViewlet(activeViewlet.getId());
viewletsToShow.push(this.activeUnpinnedViewlet);
} else {
......@@ -201,7 +199,7 @@ export class ActivitybarPart extends Part implements IActivityBarService {
}
const visibleViewlets = Object.keys(this.viewletIdToActions);
const visibleViewletsChange = !arrays.equals(viewletsToShow.map(v => v.id), visibleViewlets);
const visibleViewletsChange = !arrays.equals(viewletsToShow.map(viewlet => viewlet.id), visibleViewlets);
// Pull out overflow action if there is a viewlet change so that we can add it to the end later
if (this.viewletOverflowAction && visibleViewletsChange) {
......@@ -292,16 +290,16 @@ export class ActivitybarPart extends Part implements IActivityBarService {
action.dispose();
delete this.viewletIdToActions[viewletId];
const actionItem = this.activityActionItems[action.id];
const actionItem = this.viewletIdToActionItems[action.id];
actionItem.dispose();
delete this.activityActionItems[action.id];
delete this.viewletIdToActionItems[action.id];
}
}
private toAction(viewlet: ViewletDescriptor): ActivityAction {
const action = this.instantiationService.createInstance(ViewletActivityAction, viewlet);
this.activityActionItems[action.id] = this.instantiationService.createInstance(ActivityActionItem, action, viewlet);
this.viewletIdToActionItems[action.id] = this.instantiationService.createInstance(ActivityActionItem, action, viewlet);
this.viewletIdToActions[viewlet.id] = action;
return action;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册