Move log actions to output actions

This commit is contained in:
Sandeep Somavarapu 2018-09-07 14:36:09 +02:00
parent de17948191
commit 0f84693cb8
5 changed files with 75 additions and 85 deletions

View file

@ -16,8 +16,7 @@ import { URI } from 'vs/base/common/uri';
import * as Constants from 'vs/workbench/parts/logs/common/logConstants';
import { IWorkbenchActionRegistry, Extensions as WorkbenchActionExtensions } from 'vs/workbench/common/actions';
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
import { ShowLogsAction, OpenLogsFolderAction, SetLogLevelAction, OpenLogFileAction } from 'vs/workbench/parts/logs/electron-browser/logsActions';
import { OpenLogsFolderAction, SetLogLevelAction } from 'vs/workbench/parts/logs/electron-browser/logsActions';
class LogOutputChannels extends Disposable implements IWorkbenchContribution {
@ -35,8 +34,6 @@ class LogOutputChannels extends Disposable implements IWorkbenchContribution {
const devCategory = nls.localize('developer', "Developer");
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(OpenLogsFolderAction, OpenLogsFolderAction.ID, OpenLogsFolderAction.LABEL), 'Developer: Open Log Folder', devCategory);
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(SetLogLevelAction, SetLogLevelAction.ID, SetLogLevelAction.LABEL), 'Developer: Set Log Level', devCategory);
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ShowLogsAction, ShowLogsAction.ID, ShowLogsAction.LABEL), 'Developer: Show Logs...', devCategory);
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(OpenLogFileAction, OpenLogFileAction.ID, OpenLogFileAction.LABEL), 'Developer: Open Log File...', devCategory);
}
}

View file

@ -10,10 +10,7 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
import { IWindowsService } from 'vs/platform/windows/common/windows';
import { TPromise } from 'vs/base/common/winjs.base';
import { ILogService, LogLevel, DEFAULT_LOG_LEVEL } from 'vs/platform/log/common/log';
import { IOutputService, COMMAND_OPEN_LOG_VIEWER } from 'vs/workbench/parts/output/common/output';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { URI } from 'vs/base/common/uri';
import { IQuickPickItem, IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
export class OpenLogsFolderAction extends Action {
@ -32,61 +29,6 @@ export class OpenLogsFolderAction extends Action {
}
}
export class ShowLogsAction extends Action {
static ID = 'workbench.action.showLogs';
static LABEL = nls.localize('showLogs', "Show Logs...");
constructor(id: string, label: string,
@IQuickInputService private quickInputService: IQuickInputService,
@IOutputService private outputService: IOutputService
) {
super(id, label);
}
run(): TPromise<void> {
const entries: IQuickPickItem[] = this.outputService.getChannelDescriptors().filter(c => c.file && c.log)
.map(({ label, id }) => (<IQuickPickItem>{ id, label }));
return this.quickInputService.pick(entries, { placeHolder: nls.localize('selectlog', "Select Log") })
.then(entry => {
if (entry) {
return this.outputService.showChannel(entry.id);
}
return null;
});
}
}
export class OpenLogFileAction extends Action {
static ID = 'workbench.action.openLogFile';
static LABEL = nls.localize('openLogFile', "Open Log File...");
constructor(id: string, label: string,
@IQuickInputService private quickInputService: IQuickInputService,
@IEnvironmentService private environmentService: IEnvironmentService,
@ICommandService private commandService: ICommandService,
@IOutputService private outputService: IOutputService
) {
super(id, label);
}
run(): TPromise<void> {
const entries: IQuickPickItem[] = this.outputService.getChannelDescriptors().filter(c => c.file && c.log)
.map(({ label, file }) => (<IQuickPickItem>{ id: file.toString(), label }));
entries.push({ id: URI.file(paths.join(this.environmentService.logsPath, `telemetry.log`)).toString(), label: nls.localize('telemetry', "Telemetry") });
return this.quickInputService.pick(entries, { placeHolder: nls.localize('selectlogFile', "Select Log file") })
.then(entry => {
if (entry) {
return this.commandService.executeCommand(COMMAND_OPEN_LOG_VIEWER, URI.parse(entry.id));
}
return null;
});
}
}
export class SetLogLevelAction extends Action {
static ID = 'workbench.action.setLogLevel';

View file

@ -8,7 +8,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
import * as nls from 'vs/nls';
import * as aria from 'vs/base/browser/ui/aria/aria';
import { IAction, Action } from 'vs/base/common/actions';
import { IOutputService, OUTPUT_PANEL_ID, IOutputChannelRegistry, Extensions as OutputExt, IOutputChannelDescriptor, COMMAND_OPEN_LOG_VIEWER } from 'vs/workbench/parts/output/common/output';
import { IOutputService, OUTPUT_PANEL_ID, IOutputChannelRegistry, Extensions as OutputExt, IOutputChannelDescriptor } from 'vs/workbench/parts/output/common/output';
import { SelectActionItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { IPartService } from 'vs/workbench/services/part/common/partService';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
@ -19,7 +19,10 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { Registry } from 'vs/platform/registry/common/platform';
import { groupBy } from 'vs/base/common/arrays';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { LogViewerInput } from 'vs/workbench/parts/output/browser/logViewer';
export class ToggleOutputAction extends TogglePanelAction {
@ -170,8 +173,9 @@ export class OpenLogOutputFile extends Action {
private disposables: IDisposable[] = [];
constructor(
@ICommandService private commandService: ICommandService,
@IOutputService private outputService: IOutputService
@IOutputService private outputService: IOutputService,
@IEditorService private editorService: IEditorService,
@IInstantiationService private instantiationService: IInstantiationService
) {
super(OpenLogOutputFile.ID, OpenLogOutputFile.LABEL, 'output-action open-log-file');
this.outputService.onActiveOutputChannel(this.update, this, this.disposables);
@ -184,7 +188,7 @@ export class OpenLogOutputFile extends Action {
}
public run(): TPromise<any> {
return this.enabled ? this.commandService.executeCommand(COMMAND_OPEN_LOG_VIEWER, this.getOutputChannelDescriptor()) : TPromise.as(null);
return this.enabled ? this.editorService.openEditor(this.instantiationService.createInstance(LogViewerInput, this.getOutputChannelDescriptor())).then(() => null) : TPromise.as(null);
}
private getOutputChannelDescriptor(): IOutputChannelDescriptor {
@ -192,3 +196,61 @@ export class OpenLogOutputFile extends Action {
return channel ? this.outputService.getChannelDescriptors().filter(c => c.id === channel.id)[0] : null;
}
}
export class ShowLogsOutputChannelAction extends Action {
static ID = 'workbench.action.showLogs';
static LABEL = nls.localize('showLogs', "Show Logs...");
constructor(id: string, label: string,
@IQuickInputService private quickInputService: IQuickInputService,
@IOutputService private outputService: IOutputService
) {
super(id, label);
}
run(): TPromise<void> {
const entries: IQuickPickItem[] = this.outputService.getChannelDescriptors().filter(c => c.file && c.log)
.map(({ id, label }) => (<IQuickPickItem>{ id, label }));
return this.quickInputService.pick(entries, { placeHolder: nls.localize('selectlog', "Select Log") })
.then(entry => {
if (entry) {
return this.outputService.showChannel(entry.id);
}
return null;
});
}
}
interface IOutputChannelQuickPickItem extends IQuickPickItem {
channel: IOutputChannelDescriptor;
}
export class OpenOutputLogFileAction extends Action {
static ID = 'workbench.action.openLogFile';
static LABEL = nls.localize('openLogFile', "Open Log File...");
constructor(id: string, label: string,
@IQuickInputService private quickInputService: IQuickInputService,
@IOutputService private outputService: IOutputService,
@IEditorService private editorService: IEditorService,
@IInstantiationService private instantiationService: IInstantiationService
) {
super(id, label);
}
run(): TPromise<void> {
const entries: IOutputChannelQuickPickItem[] = this.outputService.getChannelDescriptors().filter(c => c.file && c.log)
.map(channel => (<IOutputChannelQuickPickItem>{ id: channel.id, label: channel.label, channel }));
return this.quickInputService.pick(entries, { placeHolder: nls.localize('selectlogFile', "Select Log file") })
.then(entry => {
if (entry) {
return this.editorService.openEditor(this.instantiationService.createInstance(LogViewerInput, entry.channel)).then(() => null);
}
return null;
});
}
}

View file

@ -46,11 +46,6 @@ export const LOG_MODE_ID = 'log';
*/
export const OUTPUT_PANEL_ID = 'workbench.panel.output';
/**
* Open log viewer command id
*/
export const COMMAND_OPEN_LOG_VIEWER = 'workbench.action.openLogViewer';
export const Extensions = {
OutputChannels: 'workbench.contributions.outputChannels'
};

View file

@ -12,8 +12,8 @@ import { KeybindingsRegistry, IKeybindings } from 'vs/platform/keybinding/common
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions';
import { OutputService, LogContentProvider } from 'vs/workbench/parts/output/electron-browser/outputServices';
import { ToggleOutputAction, ClearOutputAction, OpenLogOutputFile } from 'vs/workbench/parts/output/browser/outputActions';
import { OUTPUT_MODE_ID, OUTPUT_MIME, OUTPUT_PANEL_ID, IOutputService, CONTEXT_IN_OUTPUT, LOG_SCHEME, COMMAND_OPEN_LOG_VIEWER, LOG_MODE_ID, LOG_MIME, CONTEXT_ACTIVE_LOG_OUTPUT, IOutputChannelDescriptor } from 'vs/workbench/parts/output/common/output';
import { ToggleOutputAction, ClearOutputAction, OpenLogOutputFile, ShowLogsOutputChannelAction, OpenOutputLogFileAction } from 'vs/workbench/parts/output/browser/outputActions';
import { OUTPUT_MODE_ID, OUTPUT_MIME, OUTPUT_PANEL_ID, IOutputService, CONTEXT_IN_OUTPUT, LOG_SCHEME, LOG_MODE_ID, LOG_MIME, CONTEXT_ACTIVE_LOG_OUTPUT } from 'vs/workbench/parts/output/common/output';
import { PanelRegistry, Extensions, PanelDescriptor } from 'vs/workbench/browser/panel';
import { CommandsRegistry, ICommandHandler } from 'vs/platform/commands/common/commands';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
@ -23,9 +23,8 @@ import { LogViewer, LogViewerInput } from 'vs/workbench/parts/output/browser/log
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions, IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ITextModelService } from 'vs/editor/common/services/resolverService';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
// Register Service
registerSingleton(IOutputService, OutputService);
@ -90,6 +89,9 @@ actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ToggleOutputActi
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ClearOutputAction, ClearOutputAction.ID, ClearOutputAction.LABEL),
'View: Clear Output', nls.localize('viewCategory', "View"));
const devCategory = nls.localize('developer', "Developer");
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ShowLogsOutputChannelAction, ShowLogsOutputChannelAction.ID, ShowLogsOutputChannelAction.LABEL), 'Developer: Show Logs...', devCategory);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(OpenOutputLogFileAction, OpenOutputLogFileAction.ID, OpenOutputLogFileAction.LABEL), 'Developer: Open Log File...', devCategory);
interface IActionDescriptor {
id: string;
@ -179,14 +181,6 @@ registerAction({
}
});
CommandsRegistry.registerCommand(COMMAND_OPEN_LOG_VIEWER, function (accessor: ServicesAccessor, outputChannelDescriptor: IOutputChannelDescriptor) {
if (outputChannelDescriptor && outputChannelDescriptor.file) {
const editorService = accessor.get(IEditorService);
return editorService.openEditor(accessor.get(IInstantiationService).createInstance(LogViewerInput, outputChannelDescriptor));
}
return null;
});
MenuRegistry.appendMenuItem(MenuId.MenubarViewMenu, {
group: '4_panels',
command: {