Skip to content

Commit

Permalink
debug: process dropdown in actions widget
Browse files Browse the repository at this point in the history
  • Loading branch information
isidorn committed Nov 4, 2016
1 parent c4193ca commit befd068
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 6 deletions.
17 changes: 16 additions & 1 deletion src/vs/workbench/parts/debug/browser/debugActionItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { SelectActionItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IDebugService, IGlobalConfig } from 'vs/workbench/parts/debug/common/debug';

export class DebugSelectActionItem extends SelectActionItem {
export class SelectConfigurationActionItem extends SelectActionItem {

constructor(
action: IAction,
Expand Down Expand Up @@ -47,3 +47,18 @@ export class DebugSelectActionItem extends SelectActionItem {
}
}
}

export class FocusProcessActionItem extends SelectActionItem {
constructor(
action: IAction,
@IDebugService private debugService: IDebugService
) {
super(null, action, [], -1);

this.debugService.getModel().onDidChangeCallStack(() => {
const names = this.debugService.getModel().getProcesses().map(p => p.name);
const focusedProcess = this.debugService.getViewModel().focusedProcess;
this.setOptions(names, focusedProcess ? names.indexOf(focusedProcess.name) : 0);
});
}
}
14 changes: 14 additions & 0 deletions src/vs/workbench/parts/debug/browser/debugActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -909,3 +909,17 @@ export class RunAction extends AbstractDebugAction {
return super.isEnabled(state) && state === debug.State.Inactive;
}
}

export class FocusProcessAction extends AbstractDebugAction {
static ID = 'workbench.action.debug.focusProcess';
static LABEL = nls.localize('focusProcess', "Focus Process");

constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
super(id, label, null, debugService, keybindingService, 100);
}

public run(processName: string): TPromise<any> {
const process = this.debugService.getModel().getProcesses().filter(p => p.name === processName).pop();
return this.debugService.setFocusedStackFrameAndEvaluate(null, process);
}
}
21 changes: 19 additions & 2 deletions src/vs/workbench/parts/debug/browser/debugActionsWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ 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 { AbstractDebugAction, 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, FocusProcessAction } from 'vs/workbench/parts/debug/browser/debugActions';
import { FocusProcessActionItem } from 'vs/workbench/parts/debug/browser/debugActionItems';
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';
Expand All @@ -37,6 +38,7 @@ export class DebugActionsWidget implements IWorkbenchContribution {
private actions: AbstractDebugAction[];
private isVisible: boolean;
private isBuilt: boolean;
private focusProcessActionItem: FocusProcessActionItem;

constructor(
@IMessageService private messageService: IMessageService,
Expand All @@ -55,7 +57,14 @@ export class DebugActionsWidget implements IWorkbenchContribution {

this.toDispose = [];
this.actionBar = new ActionBar(actionBarContainter, {
orientation: ActionsOrientation.HORIZONTAL
orientation: ActionsOrientation.HORIZONTAL,
actionItemProvider: (action: IAction) => {
if (action.id === FocusProcessAction.ID) {
return this.focusProcessActionItem;
}

return null;
}
});

this.toDispose.push(this.actionBar);
Expand Down Expand Up @@ -169,6 +178,11 @@ export class DebugActionsWidget implements IWorkbenchContribution {
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));
const focusProcesAction = this.instantiationService.createInstance(FocusProcessAction, FocusProcessAction.ID, FocusProcessAction.LABEL);
this.actions.push(focusProcesAction);
this.focusProcessActionItem = this.instantiationService.createInstance(FocusProcessActionItem, focusProcesAction);

this.toDispose.push(this.focusProcessActionItem);
this.actions.forEach(a => {
this.toDispose.push(a);
});
Expand All @@ -194,6 +208,9 @@ export class DebugActionsWidget implements IWorkbenchContribution {
if (a.id === StopAction.ID) {
return !attached;
}
if (a.id === FocusProcessAction.ID) {
return this.debugService.getModel().getProcesses().length > 1;
}

return true;
}).sort((first, second) => first.weight - second.weight);
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/parts/debug/browser/debugViewlet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class DebugViewlet extends Viewlet {

public getActionItem(action: actions.IAction): actionbar.IActionItem {
if (action.id === debugactions.SelectConfigAction.ID) {
return this.instantiationService.createInstance(dbgactionitems.DebugSelectActionItem, action);
return this.instantiationService.createInstance(dbgactionitems.SelectConfigurationActionItem, action);
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,21 @@
position: absolute;
z-index: 200;
height: 32px;
padding-top: 3px;
left: 50%;
margin-left: -96px;
display: flex;
padding-left: 7px;
}

.monaco-workbench .debug-actions-widget .monaco-action-bar .action-item.select-container {
margin-right: 7px;
}

.monaco-workbench .debug-actions-widget .monaco-action-bar .action-item .select-box {
background-color: initial;
margin-top: 6px;
}

.monaco-workbench .debug-actions-widget .drag-area {
cursor: -webkit-grab;
height: 32px;
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/parts/debug/common/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ export interface IDebugService {
/**
* Sets the focused stack frame and evaluates all expresions against the newly focused stack frame,
*/
setFocusedStackFrameAndEvaluate(focusedStackFrame: IStackFrame): TPromise<void>;
setFocusedStackFrameAndEvaluate(focusedStackFrame: IStackFrame, process?: IProcess): TPromise<void>;

/**
* Adds new breakpoints to the model for the file specified with the uri. Notifies debug adapter of breakpoint changes.
Expand Down

0 comments on commit befd068

Please sign in to comment.