提交 e8d5a793 编写于 作者: I isidor

output: introduce onActiveOutputChannel

fixes #3892
上级 d292e6b0
...@@ -724,7 +724,7 @@ export class SelectActionItem extends BaseActionItem { ...@@ -724,7 +724,7 @@ export class SelectActionItem extends BaseActionItem {
private select: HTMLSelectElement; private select: HTMLSelectElement;
private options: string[]; private options: string[];
private selected: number; private selected: number;
private toDispose: lifecycle.IDisposable[]; protected toDispose: lifecycle.IDisposable[];
constructor(ctx: any, action: IAction, options: string[], selected: number) { constructor(ctx: any, action: IAction, options: string[], selected: number) {
super(ctx, action); super(ctx, action);
......
...@@ -8,7 +8,6 @@ import {TPromise} from 'vs/base/common/winjs.base'; ...@@ -8,7 +8,6 @@ import {TPromise} from 'vs/base/common/winjs.base';
import nls = require('vs/nls'); import nls = require('vs/nls');
import {Registry} from 'vs/platform/platform'; import {Registry} from 'vs/platform/platform';
import arrays = require('vs/base/common/arrays'); import arrays = require('vs/base/common/arrays');
import {IDisposable} from 'vs/base/common/lifecycle';
import {IAction, Action} from 'vs/base/common/actions'; import {IAction, Action} from 'vs/base/common/actions';
import {EditorAction} from 'vs/editor/common/editorAction'; import {EditorAction} from 'vs/editor/common/editorAction';
import {Behaviour} from 'vs/editor/common/editorActionEnablement'; import {Behaviour} from 'vs/editor/common/editorActionEnablement';
...@@ -108,15 +107,14 @@ export class SwitchOutputAction extends Action { ...@@ -108,15 +107,14 @@ export class SwitchOutputAction extends Action {
export class SwitchOutputActionItem extends SelectActionItem { export class SwitchOutputActionItem extends SelectActionItem {
private input: OutputEditorInput; private input: OutputEditorInput;
private outputListenerDispose: IDisposable;
constructor( constructor(
action: IAction, action: IAction,
@IOutputService private outputService: IOutputService @IOutputService private outputService: IOutputService
) { ) {
super(null, action, SwitchOutputActionItem.getChannels(outputService), Math.max(0, SwitchOutputActionItem.getChannels(outputService).indexOf(outputService.getActiveChannel()))); super(null, action, SwitchOutputActionItem.getChannels(outputService), Math.max(0, SwitchOutputActionItem.getChannels(outputService).indexOf(outputService.getActiveChannel())));
this.toDispose.push(this.outputService.onOutputChannel(this.onOutputChannel, this));
this.outputListenerDispose = this.outputService.onOutputChannel(this.onOutputChannel, this); this.toDispose.push(this.outputService.onActiveOutputChannel(this.onOutputChannel, this));
} }
private onOutputChannel(): void { private onOutputChannel(): void {
...@@ -135,12 +133,6 @@ export class SwitchOutputActionItem extends SelectActionItem { ...@@ -135,12 +133,6 @@ export class SwitchOutputActionItem extends SelectActionItem {
public dispose(): void { public dispose(): void {
super.dispose(); super.dispose();
if (this.outputListenerDispose) {
this.outputListenerDispose.dispose();
delete this.outputListenerDispose;
}
delete this.input; delete this.input;
} }
} }
...@@ -99,6 +99,11 @@ export interface IOutputService { ...@@ -99,6 +99,11 @@ export interface IOutputService {
* Allows to register on a new Output channel getting filled with output * Allows to register on a new Output channel getting filled with output
*/ */
onOutputChannel: Event<string>; onOutputChannel: Event<string>;
/**
* Allows to register on active output channel change
*/
onActiveOutputChannel: Event<string>;
} }
export interface IOutputChannelRegistry { export interface IOutputChannelRegistry {
......
...@@ -30,6 +30,7 @@ export class OutputService implements IOutputService { ...@@ -30,6 +30,7 @@ export class OutputService implements IOutputService {
private _onOutput: Emitter<IOutputEvent>; private _onOutput: Emitter<IOutputEvent>;
private _onOutputChannel: Emitter<string>; private _onOutputChannel: Emitter<string>;
private _onActiveOutputChannel: Emitter<string>;
constructor( constructor(
@IStorageService private storageService: IStorageService, @IStorageService private storageService: IStorageService,
...@@ -40,6 +41,7 @@ export class OutputService implements IOutputService { ...@@ -40,6 +41,7 @@ export class OutputService implements IOutputService {
) { ) {
this._onOutput = new Emitter<IOutputEvent>(); this._onOutput = new Emitter<IOutputEvent>();
this._onOutputChannel = new Emitter<string>(); this._onOutputChannel = new Emitter<string>();
this._onActiveOutputChannel = new Emitter<string>();
this.receivedOutput = Object.create(null); this.receivedOutput = Object.create(null);
...@@ -55,6 +57,10 @@ export class OutputService implements IOutputService { ...@@ -55,6 +57,10 @@ export class OutputService implements IOutputService {
return this._onOutputChannel.event; return this._onOutputChannel.event;
} }
public get onActiveOutputChannel(): Event<string> {
return this._onActiveOutputChannel.event;
}
public append(channel: string, output: string): void { public append(channel: string, output: string): void {
// Initialize // Initialize
...@@ -114,6 +120,7 @@ export class OutputService implements IOutputService { ...@@ -114,6 +120,7 @@ export class OutputService implements IOutputService {
public showOutput(channel: string, preserveFocus?: boolean): TPromise<IEditor> { public showOutput(channel: string, preserveFocus?: boolean): TPromise<IEditor> {
this.activeChannel = channel; this.activeChannel = channel;
this.storageService.store(OUTPUT_ACTIVE_CHANNEL_KEY, this.activeChannel, StorageScope.WORKSPACE); this.storageService.store(OUTPUT_ACTIVE_CHANNEL_KEY, this.activeChannel, StorageScope.WORKSPACE);
this._onActiveOutputChannel.fire(channel); // emit event that we a new channel is active
return this.panelService.openPanel(OUTPUT_PANEL_ID, !preserveFocus).then((outputPanel: OutputPanel) => { return this.panelService.openPanel(OUTPUT_PANEL_ID, !preserveFocus).then((outputPanel: OutputPanel) => {
return outputPanel && outputPanel.setInput(OutputEditorInput.getInstance(this.instantiationService, channel), EditorOptions.create({ preserveFocus: preserveFocus })). return outputPanel && outputPanel.setInput(OutputEditorInput.getInstance(this.instantiationService, channel), EditorOptions.create({ preserveFocus: preserveFocus })).
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册