Skip to content

Commit 8317c45

Browse files
committed
output: introduce channel.id
1 parent f0d88b6 commit 8317c45

7 files changed

Lines changed: 29 additions & 22 deletions

File tree

src/vs/workbench/parts/extensions/common/extensions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,5 @@ export interface IExtensionTipsService {
8484
getRecommendations(): TPromise<IExtension[]>;
8585
}
8686

87-
export const ExtensionsLabel = nls.localize('extensions', "Extensions");
87+
export const ExtensionsLabel = nls.localize('extensions', "Extensions");
88+
export const ExtensionsChannelId = 'extensions';

src/vs/workbench/parts/extensions/electron-browser/extensions.contribution.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Registry } from 'vs/platform/platform';
88
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
99
import { IStatusbarRegistry, Extensions as StatusbarExtensions, StatusbarItemDescriptor, StatusbarAlignment } from 'vs/workbench/browser/parts/statusbar/statusbar';
1010
import { ExtensionsStatusbarItem } from 'vs/workbench/parts/extensions/electron-browser/extensionsWidgets';
11-
import { IGalleryService, ExtensionsLabel } from 'vs/workbench/parts/extensions/common/extensions';
11+
import { IGalleryService, ExtensionsLabel, ExtensionsChannelId } from 'vs/workbench/parts/extensions/common/extensions';
1212
import { GalleryService } from 'vs/workbench/parts/extensions/common/vsoGalleryService';
1313
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
1414
import { ExtensionsWorkbenchExtension } from 'vs/workbench/parts/extensions/electron-browser/extensionsWorkbenchExtension';
@@ -23,4 +23,4 @@ Registry.as<IStatusbarRegistry>(StatusbarExtensions.Statusbar)
2323
.registerStatusbarItem(new StatusbarItemDescriptor(ExtensionsStatusbarItem, StatusbarAlignment.LEFT,10000));
2424

2525
Registry.as<IOutputChannelRegistry>(OutputExtensions.OutputChannels)
26-
.registerChannel(ExtensionsLabel);
26+
.registerChannel(ExtensionsChannelId, ExtensionsLabel);

src/vs/workbench/parts/git/browser/gitWorkbenchContributions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ export function registerContributions(): void {
452452

453453
// Register Output Channel
454454
var outputChannelRegistry = <output.IOutputChannelRegistry>platform.Registry.as(output.Extensions.OutputChannels);
455-
outputChannelRegistry.registerChannel('Git');
455+
outputChannelRegistry.registerChannel('git', nls.localize('git', "Git"));
456456

457457
// Register Git Output
458458
(<ext.IWorkbenchContributionsRegistry>platform.Registry.as(ext.Extensions.Workbench)).registerWorkbenchContribution(

src/vs/workbench/parts/output/browser/outputActions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export class SwitchOutputActionItem extends SelectActionItem {
123123
}
124124

125125
private static getChannels(outputService: IOutputService): string[] {
126-
const contributedChannels = (<IOutputChannelRegistry>Registry.as(Extensions.OutputChannels)).getChannels();
126+
const contributedChannels = (<IOutputChannelRegistry>Registry.as(Extensions.OutputChannels)).getChannels().map(channelData => channelData.id);
127127
const usedChannels = outputService.getChannels();
128128

129129
return arrays.distinct(contributedChannels.concat(usedChannels)).sort(); // sort by name

src/vs/workbench/parts/output/common/output.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,35 +108,40 @@ export interface IOutputService {
108108
onActiveOutputChannel: Event<string>;
109109
}
110110

111+
export interface IOutputChannel {
112+
113+
114+
}
115+
111116
export interface IOutputChannelRegistry {
112117

113118
/**
114119
* Make an output channel known to the output world.
115120
*/
116-
registerChannel(name: string): void;
121+
registerChannel(id: string, name: string): void;
117122

118123
/**
119124
* Returns the list of channels known to the output world.
120125
*/
121-
getChannels(): string[];
126+
getChannels(): { id: string, displayName: string}[];
122127
}
123128

124129
class OutputChannelRegistry implements IOutputChannelRegistry {
125-
private channels: string[];
130+
private channels: { id: string, displayName: string }[];
126131

127132
constructor() {
128133
this.channels = [];
129134
}
130135

131-
public registerChannel(name: string): void {
132-
if (this.channels.indexOf(name) === -1) {
133-
this.channels.push(name);
136+
public registerChannel(id: string, displayName: string): void {
137+
if (this.channels.every(channel => channel.id !== id)) {
138+
this.channels.push({ id, displayName });
134139
}
135140
}
136141

137-
public getChannels(): string[] {
138-
return this.channels.slice(0);
142+
public getChannels(): { id: string, displayName: string}[] {
143+
return this.channels;
139144
}
140145
}
141146

142-
Registry.add(Extensions.OutputChannels, new OutputChannelRegistry());
147+
Registry.add(Extensions.OutputChannels, new OutputChannelRegistry());

src/vs/workbench/parts/output/common/outputServices.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class OutputService implements IOutputService {
2525

2626
private receivedOutput: { [channel: string]: string; };
2727

28-
private activeChannel: string;
28+
private activeChannelId: string;
2929

3030
private _onOutput: Emitter<IOutputEvent>;
3131
private _onOutputChannel: Emitter<string>;
@@ -45,7 +45,7 @@ export class OutputService implements IOutputService {
4545
this.receivedOutput = Object.create(null);
4646

4747
const channels = (<IOutputChannelRegistry>Registry.as(Extensions.OutputChannels)).getChannels();
48-
this.activeChannel = this.storageService.get(OUTPUT_ACTIVE_CHANNEL_KEY, StorageScope.WORKSPACE, channels && channels.length > 0 ? channels[0] : null);
48+
this.activeChannelId = this.storageService.get(OUTPUT_ACTIVE_CHANNEL_KEY, StorageScope.WORKSPACE, channels && channels.length > 0 ? channels[0].id : null);
4949
}
5050

5151
public get onOutput(): Event<IOutputEvent> {
@@ -89,7 +89,7 @@ export class OutputService implements IOutputService {
8989
}
9090

9191
public getActiveChannel(): string {
92-
return this.activeChannel;
92+
return this.activeChannelId;
9393
}
9494

9595
public clearOutput(channel: string): void {
@@ -100,12 +100,12 @@ export class OutputService implements IOutputService {
100100

101101
public showOutput(channel: string, preserveFocus?: boolean): TPromise<IEditor> {
102102
const panel = this.panelService.getActivePanel();
103-
if (this.activeChannel === channel && panel && panel.getId() === OUTPUT_PANEL_ID) {
103+
if (this.activeChannelId === channel && panel && panel.getId() === OUTPUT_PANEL_ID) {
104104
return TPromise.as(<OutputPanel>panel);
105105
}
106106

107-
this.activeChannel = channel;
108-
this.storageService.store(OUTPUT_ACTIVE_CHANNEL_KEY, this.activeChannel, StorageScope.WORKSPACE);
107+
this.activeChannelId = channel;
108+
this.storageService.store(OUTPUT_ACTIVE_CHANNEL_KEY, this.activeChannelId, StorageScope.WORKSPACE);
109109
this._onActiveOutputChannel.fire(channel); // emit event that a new channel is active
110110

111111
return this.panelService.openPanel(OUTPUT_PANEL_ID, !preserveFocus).then((outputPanel: OutputPanel) => {

src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,8 @@ interface TaskServiceEventData {
452452
class TaskService extends EventEmitter implements ITaskService {
453453
public serviceId = ITaskService;
454454
public static SERVICE_ID: string = 'taskService';
455-
public static OutputChannel:string = 'Tasks';
455+
public static OutputChannel:string = 'tasks';
456+
public static OutputChannelLabel:string = nls.localize('tasks', "Tasks");
456457

457458
private modeService: IModeService;
458459
private configurationService: IConfigurationService;
@@ -831,7 +832,7 @@ if (Env.enableTasks) {
831832

832833
// Output channel
833834
let outputChannelRegistry = <IOutputChannelRegistry>Registry.as(OutputExt.OutputChannels);
834-
outputChannelRegistry.registerChannel(TaskService.OutputChannel);
835+
outputChannelRegistry.registerChannel(TaskService.OutputChannel, TaskService.OutputChannelLabel);
835836

836837
(<IWorkbenchContributionsRegistry>Registry.as(WorkbenchExtensions.Workbench)).registerWorkbenchContribution(TaskServiceParticipant);
837838

0 commit comments

Comments
 (0)