提交 8317c45b 编写于 作者: I isidor

output: introduce channel.id

上级 f0d88b60
......@@ -84,4 +84,5 @@ export interface IExtensionTipsService {
getRecommendations(): TPromise<IExtension[]>;
}
export const ExtensionsLabel = nls.localize('extensions', "Extensions");
\ No newline at end of file
export const ExtensionsLabel = nls.localize('extensions', "Extensions");
export const ExtensionsChannelId = 'extensions';
\ No newline at end of file
......@@ -8,7 +8,7 @@ import { Registry } from 'vs/platform/platform';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IStatusbarRegistry, Extensions as StatusbarExtensions, StatusbarItemDescriptor, StatusbarAlignment } from 'vs/workbench/browser/parts/statusbar/statusbar';
import { ExtensionsStatusbarItem } from 'vs/workbench/parts/extensions/electron-browser/extensionsWidgets';
import { IGalleryService, ExtensionsLabel } from 'vs/workbench/parts/extensions/common/extensions';
import { IGalleryService, ExtensionsLabel, ExtensionsChannelId } from 'vs/workbench/parts/extensions/common/extensions';
import { GalleryService } from 'vs/workbench/parts/extensions/common/vsoGalleryService';
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
import { ExtensionsWorkbenchExtension } from 'vs/workbench/parts/extensions/electron-browser/extensionsWorkbenchExtension';
......@@ -23,4 +23,4 @@ Registry.as<IStatusbarRegistry>(StatusbarExtensions.Statusbar)
.registerStatusbarItem(new StatusbarItemDescriptor(ExtensionsStatusbarItem, StatusbarAlignment.LEFT,10000));
Registry.as<IOutputChannelRegistry>(OutputExtensions.OutputChannels)
.registerChannel(ExtensionsLabel);
\ No newline at end of file
.registerChannel(ExtensionsChannelId, ExtensionsLabel);
\ No newline at end of file
......@@ -452,7 +452,7 @@ export function registerContributions(): void {
// Register Output Channel
var outputChannelRegistry = <output.IOutputChannelRegistry>platform.Registry.as(output.Extensions.OutputChannels);
outputChannelRegistry.registerChannel('Git');
outputChannelRegistry.registerChannel('git', nls.localize('git', "Git"));
// Register Git Output
(<ext.IWorkbenchContributionsRegistry>platform.Registry.as(ext.Extensions.Workbench)).registerWorkbenchContribution(
......
......@@ -123,7 +123,7 @@ export class SwitchOutputActionItem extends SelectActionItem {
}
private static getChannels(outputService: IOutputService): string[] {
const contributedChannels = (<IOutputChannelRegistry>Registry.as(Extensions.OutputChannels)).getChannels();
const contributedChannels = (<IOutputChannelRegistry>Registry.as(Extensions.OutputChannels)).getChannels().map(channelData => channelData.id);
const usedChannels = outputService.getChannels();
return arrays.distinct(contributedChannels.concat(usedChannels)).sort(); // sort by name
......
......@@ -108,35 +108,40 @@ export interface IOutputService {
onActiveOutputChannel: Event<string>;
}
export interface IOutputChannel {
}
export interface IOutputChannelRegistry {
/**
* Make an output channel known to the output world.
*/
registerChannel(name: string): void;
registerChannel(id: string, name: string): void;
/**
* Returns the list of channels known to the output world.
*/
getChannels(): string[];
getChannels(): { id: string, displayName: string}[];
}
class OutputChannelRegistry implements IOutputChannelRegistry {
private channels: string[];
private channels: { id: string, displayName: string }[];
constructor() {
this.channels = [];
}
public registerChannel(name: string): void {
if (this.channels.indexOf(name) === -1) {
this.channels.push(name);
public registerChannel(id: string, displayName: string): void {
if (this.channels.every(channel => channel.id !== id)) {
this.channels.push({ id, displayName });
}
}
public getChannels(): string[] {
return this.channels.slice(0);
public getChannels(): { id: string, displayName: string}[] {
return this.channels;
}
}
Registry.add(Extensions.OutputChannels, new OutputChannelRegistry());
\ No newline at end of file
Registry.add(Extensions.OutputChannels, new OutputChannelRegistry());
......@@ -25,7 +25,7 @@ export class OutputService implements IOutputService {
private receivedOutput: { [channel: string]: string; };
private activeChannel: string;
private activeChannelId: string;
private _onOutput: Emitter<IOutputEvent>;
private _onOutputChannel: Emitter<string>;
......@@ -45,7 +45,7 @@ export class OutputService implements IOutputService {
this.receivedOutput = Object.create(null);
const channels = (<IOutputChannelRegistry>Registry.as(Extensions.OutputChannels)).getChannels();
this.activeChannel = this.storageService.get(OUTPUT_ACTIVE_CHANNEL_KEY, StorageScope.WORKSPACE, channels && channels.length > 0 ? channels[0] : null);
this.activeChannelId = this.storageService.get(OUTPUT_ACTIVE_CHANNEL_KEY, StorageScope.WORKSPACE, channels && channels.length > 0 ? channels[0].id : null);
}
public get onOutput(): Event<IOutputEvent> {
......@@ -89,7 +89,7 @@ export class OutputService implements IOutputService {
}
public getActiveChannel(): string {
return this.activeChannel;
return this.activeChannelId;
}
public clearOutput(channel: string): void {
......@@ -100,12 +100,12 @@ export class OutputService implements IOutputService {
public showOutput(channel: string, preserveFocus?: boolean): TPromise<IEditor> {
const panel = this.panelService.getActivePanel();
if (this.activeChannel === channel && panel && panel.getId() === OUTPUT_PANEL_ID) {
if (this.activeChannelId === channel && panel && panel.getId() === OUTPUT_PANEL_ID) {
return TPromise.as(<OutputPanel>panel);
}
this.activeChannel = channel;
this.storageService.store(OUTPUT_ACTIVE_CHANNEL_KEY, this.activeChannel, StorageScope.WORKSPACE);
this.activeChannelId = channel;
this.storageService.store(OUTPUT_ACTIVE_CHANNEL_KEY, this.activeChannelId, StorageScope.WORKSPACE);
this._onActiveOutputChannel.fire(channel); // emit event that a new channel is active
return this.panelService.openPanel(OUTPUT_PANEL_ID, !preserveFocus).then((outputPanel: OutputPanel) => {
......
......@@ -452,7 +452,8 @@ interface TaskServiceEventData {
class TaskService extends EventEmitter implements ITaskService {
public serviceId = ITaskService;
public static SERVICE_ID: string = 'taskService';
public static OutputChannel:string = 'Tasks';
public static OutputChannel:string = 'tasks';
public static OutputChannelLabel:string = nls.localize('tasks', "Tasks");
private modeService: IModeService;
private configurationService: IConfigurationService;
......@@ -831,7 +832,7 @@ if (Env.enableTasks) {
// Output channel
let outputChannelRegistry = <IOutputChannelRegistry>Registry.as(OutputExt.OutputChannels);
outputChannelRegistry.registerChannel(TaskService.OutputChannel);
outputChannelRegistry.registerChannel(TaskService.OutputChannel, TaskService.OutputChannelLabel);
(<IWorkbenchContributionsRegistry>Registry.as(WorkbenchExtensions.Workbench)).registerWorkbenchContribution(TaskServiceParticipant);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册