debugViewModel.ts 3.9 KB
Newer Older
E
Erich Gamma 已提交
1 2 3 4
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
5

J
Johannes Rieken 已提交
6
import Event, { Emitter } from 'vs/base/common/event';
I
isidor 已提交
7
import * as debug from 'vs/workbench/parts/debug/common/debug';
E
Erich Gamma 已提交
8

9
export class ViewModel implements debug.IViewModel {
E
Erich Gamma 已提交
10

11
	private _focusedStackFrame: debug.IStackFrame;
I
isidor 已提交
12
	private _focusedProcess: debug.IProcess;
E
Erich Gamma 已提交
13
	private selectedExpression: debug.IExpression;
I
isidor 已提交
14
	private selectedFunctionBreakpoint: debug.IFunctionBreakpoint;
15
	private _onDidFocusProcess: Emitter<debug.IProcess | undefined>;
16 17 18
	private _onDidFocusStackFrame: Emitter<debug.IStackFrame>;
	private _onDidSelectExpression: Emitter<debug.IExpression>;
	private _onDidSelectFunctionBreakpoint: Emitter<debug.IFunctionBreakpoint>;
19
	private _onDidSelectConfigurationName: Emitter<string>;
20
	private multiProcessView: boolean;
21
	public changedWorkbenchViewState: boolean;
22

23
	constructor(private _selectedConfigurationName: string) {
24
		this._onDidFocusProcess = new Emitter<debug.IProcess | undefined>();
25 26 27
		this._onDidFocusStackFrame = new Emitter<debug.IStackFrame>();
		this._onDidSelectExpression = new Emitter<debug.IExpression>();
		this._onDidSelectFunctionBreakpoint = new Emitter<debug.IFunctionBreakpoint>();
28
		this._onDidSelectConfigurationName = new Emitter<string>();
29
		this.changedWorkbenchViewState = false;
I
isidor 已提交
30
		this.multiProcessView = false;
31
	}
E
Erich Gamma 已提交
32 33 34 35 36

	public getId(): string {
		return 'root';
	}

37
	public get focusedProcess(): debug.IProcess {
I
isidor 已提交
38
		return this._focusedProcess;
39 40
	}

41
	public get focusedThread(): debug.IThread {
42
		return this._focusedStackFrame ? this._focusedStackFrame.thread : (this._focusedProcess ? this._focusedProcess.getAllThreads().pop() : null);
43 44
	}

45
	public get focusedStackFrame(): debug.IStackFrame {
46
		return this._focusedStackFrame;
E
Erich Gamma 已提交
47 48
	}

49
	public setFocusedStackFrame(stackFrame: debug.IStackFrame, process: debug.IProcess): void {
I
isidor 已提交
50
		this._focusedStackFrame = stackFrame;
51 52 53 54
		if (process !== this._focusedProcess) {
			this._focusedProcess = process;
			this._onDidFocusProcess.fire(process);
		}
I
isidor 已提交
55
		this._onDidFocusStackFrame.fire(stackFrame);
56 57
	}

58 59 60 61
	public get onDidFocusProcess(): Event<debug.IProcess> {
		return this._onDidFocusProcess.event;
	}

62 63
	public get onDidFocusStackFrame(): Event<debug.IStackFrame> {
		return this._onDidFocusStackFrame.event;
E
Erich Gamma 已提交
64 65 66 67 68 69 70 71
	}

	public getSelectedExpression(): debug.IExpression {
		return this.selectedExpression;
	}

	public setSelectedExpression(expression: debug.IExpression) {
		this.selectedExpression = expression;
72 73 74 75 76
		this._onDidSelectExpression.fire(expression);
	}

	public get onDidSelectExpression(): Event<debug.IExpression> {
		return this._onDidSelectExpression.event;
E
Erich Gamma 已提交
77
	}
I
isidor 已提交
78 79 80 81 82 83 84

	public getSelectedFunctionBreakpoint(): debug.IFunctionBreakpoint {
		return this.selectedFunctionBreakpoint;
	}

	public setSelectedFunctionBreakpoint(functionBreakpoint: debug.IFunctionBreakpoint): void {
		this.selectedFunctionBreakpoint = functionBreakpoint;
85 86 87 88 89
		this._onDidSelectFunctionBreakpoint.fire(functionBreakpoint);
	}

	public get onDidSelectFunctionBreakpoint(): Event<debug.IFunctionBreakpoint> {
		return this._onDidSelectFunctionBreakpoint.event;
I
isidor 已提交
90
	}
91 92 93 94 95 96 97 98 99 100

	public get selectedConfigurationName(): string {
		return this._selectedConfigurationName;
	}

	public setSelectedConfigurationName(configurationName: string): void {
		this._selectedConfigurationName = configurationName;
		this._onDidSelectConfigurationName.fire(configurationName);
	}

101 102 103 104 105 106 107 108
	public isMultiProcessView(): boolean {
		return this.multiProcessView;
	}

	public setMultiProcessView(isMultiProcessView: boolean): void {
		this.multiProcessView = isMultiProcessView;
	}

109
	public get onDidSelectConfiguration(): Event<string> {
110 111
		return this._onDidSelectConfigurationName.event;
	}
E
Erich Gamma 已提交
112
}