提交 712147af 编写于 作者: I isidor

debugActionsWidget: use action weights

上级 dd2e58b4
......@@ -34,7 +34,8 @@ export class AbstractDebugAction extends Action {
constructor(
id: string, label: string, cssClass: string,
@IDebugService protected debugService: IDebugService,
@IKeybindingService protected keybindingService: IKeybindingService
@IKeybindingService protected keybindingService: IKeybindingService,
public weight?: number
) {
super(id, label, cssClass, false);
this.debugService = debugService;
......@@ -134,7 +135,7 @@ export class RestartAction extends AbstractDebugAction {
static RECONNECT_LABEL = nls.localize('reconnectDebug', "Reconnect");
constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
super(id, label, 'debug-action restart', debugService, keybindingService);
super(id, label, 'debug-action restart', debugService, keybindingService, 70);
this.setLabel(this.debugService.getViewModel().focusedProcess);
this.toDispose.push(this.debugService.getViewModel().onDidFocusStackFrame(() => this.setLabel(this.debugService.getViewModel().focusedProcess)));
}
......@@ -158,7 +159,7 @@ export class StepOverAction extends AbstractDebugAction {
static LABEL = nls.localize('stepOverDebug', "Step Over");
constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
super(id, label, 'debug-action step-over', debugService, keybindingService);
super(id, label, 'debug-action step-over', debugService, keybindingService, 20);
}
public run(thread: debug.IThread): TPromise<any> {
......@@ -179,7 +180,7 @@ export class StepIntoAction extends AbstractDebugAction {
static LABEL = nls.localize('stepIntoDebug', "Step Into");
constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
super(id, label, 'debug-action step-into', debugService, keybindingService);
super(id, label, 'debug-action step-into', debugService, keybindingService, 30);
}
public run(thread: debug.IThread): TPromise<any> {
......@@ -200,7 +201,7 @@ export class StepOutAction extends AbstractDebugAction {
static LABEL = nls.localize('stepOutDebug', "Step Out");
constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
super(id, label, 'debug-action step-out', debugService, keybindingService);
super(id, label, 'debug-action step-out', debugService, keybindingService, 40);
}
public run(thread: debug.IThread): TPromise<any> {
......@@ -221,7 +222,7 @@ export class StepBackAction extends AbstractDebugAction {
static LABEL = nls.localize('stepBackDebug', "Step Back");
constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
super(id, label, 'debug-action step-back', debugService, keybindingService);
super(id, label, 'debug-action step-back', debugService, keybindingService, 50);
}
public run(thread: debug.IThread): TPromise<any> {
......@@ -244,7 +245,7 @@ export class StopAction extends AbstractDebugAction {
static LABEL = nls.localize('stopDebug', "Stop");
constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
super(id, label, 'debug-action stop', debugService, keybindingService);
super(id, label, 'debug-action stop', debugService, keybindingService, 80);
}
public run(): TPromise<any> {
......@@ -262,7 +263,7 @@ export class DisconnectAction extends AbstractDebugAction {
static LABEL = nls.localize('disconnectDebug', "Disconnect");
constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
super(id, label, 'debug-action disconnect', debugService, keybindingService);
super(id, label, 'debug-action disconnect', debugService, keybindingService, 80);
}
public run(): TPromise<any> {
......@@ -280,7 +281,7 @@ export class ContinueAction extends AbstractDebugAction {
static LABEL = nls.localize('continueDebug', "Continue");
constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
super(id, label, 'debug-action continue', debugService, keybindingService);
super(id, label, 'debug-action continue', debugService, keybindingService, 10);
}
public run(thread: debug.IThread): TPromise<any> {
......@@ -301,7 +302,7 @@ export class PauseAction extends AbstractDebugAction {
static LABEL = nls.localize('pauseDebug', "Pause");
constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
super(id, label, 'debug-action pause', debugService, keybindingService);
super(id, label, 'debug-action pause', debugService, keybindingService, 10);
}
public run(thread: debug.IThread): TPromise<any> {
......
......@@ -16,7 +16,7 @@ import { ActionBar, ActionsOrientation } from 'vs/base/browser/ui/actionbar/acti
import { IPartService } from 'vs/workbench/services/part/common/partService';
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
import * as debug from 'vs/workbench/parts/debug/common/debug';
import { PauseAction, ContinueAction, StepBackAction, StopAction, DisconnectAction, StepOverAction, StepIntoAction, StepOutAction, RestartAction } from 'vs/workbench/parts/debug/browser/debugActions';
import { AbstractDebugAction, PauseAction, ContinueAction, StepBackAction, StopAction, DisconnectAction, StepOverAction, StepIntoAction, StepOutAction, RestartAction } from 'vs/workbench/parts/debug/browser/debugActions';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { IMessageService } from 'vs/platform/message/common/message';
......@@ -34,12 +34,7 @@ export class DebugActionsWidget implements IWorkbenchContribution {
private dragArea: builder.Builder;
private toDispose: lifecycle.IDisposable[];
private actionBar: ActionBar;
private actions: IAction[];
private pauseAction: PauseAction;
private continueAction: ContinueAction;
private stepBackAction: StepBackAction;
private stopAction: StopAction;
private disconnectAction: DisconnectAction;
private actions: AbstractDebugAction[];
private isVisible: boolean;
private isBuilt: boolean;
......@@ -139,7 +134,7 @@ export class DebugActionsWidget implements IWorkbenchContribution {
}
this.actionBar.clear();
this.actionBar.push(this.getActions(this.instantiationService, this.debugService.state), { icon: true, label: false });
this.actionBar.push(this.getActions(), { icon: true, label: false });
this.show();
}
......@@ -162,43 +157,46 @@ export class DebugActionsWidget implements IWorkbenchContribution {
this.$el.hide();
}
private getActions(instantiationService: IInstantiationService, state: debug.State): IAction[] {
private getActions(): IAction[] {
if (!this.actions) {
this.continueAction = instantiationService.createInstance(ContinueAction, ContinueAction.ID, ContinueAction.LABEL);
this.pauseAction = instantiationService.createInstance(PauseAction, PauseAction.ID, PauseAction.LABEL);
this.stopAction = instantiationService.createInstance(StopAction, StopAction.ID, StopAction.LABEL);
this.disconnectAction = instantiationService.createInstance(DisconnectAction, DisconnectAction.ID, DisconnectAction.LABEL);
this.actions = [
this.continueAction,
instantiationService.createInstance(StepOverAction, StepOverAction.ID, StepOverAction.LABEL),
instantiationService.createInstance(StepIntoAction, StepIntoAction.ID, StepIntoAction.LABEL),
instantiationService.createInstance(StepOutAction, StepOutAction.ID, StepOutAction.LABEL),
instantiationService.createInstance(RestartAction, RestartAction.ID, RestartAction.LABEL),
this.stopAction
];
this.actions = [];
this.actions.push(this.instantiationService.createInstance(ContinueAction, ContinueAction.ID, ContinueAction.LABEL));
this.actions.push(this.instantiationService.createInstance(PauseAction, PauseAction.ID, PauseAction.LABEL));
this.actions.push(this.instantiationService.createInstance(StopAction, StopAction.ID, StopAction.LABEL));
this.actions.push(this.instantiationService.createInstance(DisconnectAction, DisconnectAction.ID, DisconnectAction.LABEL));
this.actions.push(this.instantiationService.createInstance(StepOverAction, StepOverAction.ID, StepOverAction.LABEL));
this.actions.push(this.instantiationService.createInstance(StepIntoAction, StepIntoAction.ID, StepIntoAction.LABEL));
this.actions.push(this.instantiationService.createInstance(StepOutAction, StepOutAction.ID, StepOutAction.LABEL));
this.actions.push(this.instantiationService.createInstance(RestartAction, RestartAction.ID, RestartAction.LABEL));
this.actions.push(this.instantiationService.createInstance(StepBackAction, StepBackAction.ID, StepBackAction.LABEL));
this.actions.forEach(a => {
this.toDispose.push(a);
});
this.toDispose.push(this.pauseAction);
this.toDispose.push(this.disconnectAction);
}
this.actions[0] = state === debug.State.Running ? this.pauseAction : this.continueAction;
const state = this.debugService.state;
const process = this.debugService.getViewModel().focusedProcess;
this.actions[5] = (process && !strings.equalsIgnoreCase(process.session.configuration.type, 'extensionHost') && process.session.requestType === debug.SessionRequestType.ATTACH) ? this.disconnectAction : this.stopAction;
const attached = process && !strings.equalsIgnoreCase(process.session.configuration.type, 'extensionHost') && process.session.requestType === debug.SessionRequestType.ATTACH;
if (process && process.session.configuration.capabilities.supportsStepBack) {
if (!this.stepBackAction) {
this.stepBackAction = instantiationService.createInstance(StepBackAction, StepBackAction.ID, StepBackAction.LABEL);
this.toDispose.push(this.stepBackAction);
return this.actions.filter(a => {
if (a.id === ContinueAction.ID) {
return state !== debug.State.Running;
}
if (a.id === PauseAction.ID) {
return state === debug.State.Running;
}
if (a.id === StepBackAction.ID) {
return process && process.session.configuration.capabilities.supportsStepBack;
}
if (a.id === DisconnectAction.ID) {
return attached;
}
if (a.id === StopAction.ID) {
return !attached;
}
// Return a copy of this.actions containing stepBackAction
return [...this.actions.slice(0, 4), this.stepBackAction, ...this.actions.slice(4)];
} else {
return this.actions;
}
return true;
}).sort((first, second) => first.weight - second.weight);
}
public dispose(): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册