Skip to content

Commit

Permalink
Use QuickInput (#29096)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrmarti committed Aug 8, 2018
1 parent 3f5a4bc commit 8600035
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ import { INotificationService, Severity } from 'vs/platform/notification/common/
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { mnemonicButtonLabel } from 'vs/base/common/labels';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IQuickOpenService, IPickOpenEntry } from 'vs/platform/quickOpen/common/quickOpen';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IEditorGroupsService } from 'vs/workbench/services/group/common/editorGroupsService';
import { ExtensionsInput } from 'vs/workbench/parts/extensions/common/extensionsInput';
import product from 'vs/platform/node/product';
import { ContextSubMenu } from 'vs/base/browser/contextmenu';
import { IQuickPickItem, IQuickInputService } from 'vs/platform/quickinput/common/quickInput';

const promptDownloadManually = (extension: IGalleryExtension, message: string, instantiationService: IInstantiationService, notificationService: INotificationService, openerService: IOpenerService) => {
const downloadUrl = `${product.extensionsGallery.serviceUrl}/publishers/${extension.publisher}/vsextensions/${extension.name}/${extension.version}/vspackage`;
Expand Down Expand Up @@ -2694,7 +2694,7 @@ export class ReinstallAction extends Action {
constructor(
id: string = ReinstallAction.ID, label: string = ReinstallAction.LABEL,
@IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService,
@IQuickOpenService private quickOpenService: IQuickOpenService,
@IQuickInputService private quickInputService: IQuickInputService,
@INotificationService private notificationService: INotificationService,
@IWindowService private windowService: IWindowService
) {
Expand All @@ -2706,21 +2706,22 @@ export class ReinstallAction extends Action {
}

run(): TPromise<any> {
return this.quickOpenService.pick(this.getEntries(), { placeHolder: localize('selectExtension', "Select Extension to Reinstall") });
return this.quickInputService.pick(this.getEntries(), { placeHolder: localize('selectExtension', "Select Extension to Reinstall") })
.then(pick => pick && this.reinstallExtension(pick.extension));
}

private getEntries(): TPromise<IPickOpenEntry[]> {
private getEntries() {
return this.extensionsWorkbenchService.queryLocal()
.then(local => {
const entries: IPickOpenEntry[] = local
const entries = local
.filter(extension => extension.type === LocalExtensionType.User)
.map(extension => {
return <IPickOpenEntry>{
return {
id: extension.id,
label: extension.displayName,
description: extension.id,
run: () => this.reinstallExtension(extension),
};
extension,
} as (IQuickPickItem & { extension: IExtension });
});
return entries;
});
Expand Down
18 changes: 9 additions & 9 deletions src/vs/workbench/parts/logs/electron-browser/logsActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import * as paths from 'vs/base/common/paths';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IWindowsService, IWindowService } from 'vs/platform/windows/common/windows';
import { TPromise } from 'vs/base/common/winjs.base';
import { IQuickOpenService, IPickOpenEntry } from 'vs/platform/quickOpen/common/quickOpen';
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 * as Constants from 'vs/workbench/parts/logs/common/logConstants';
import { ICommandService } from 'vs/platform/commands/common/commands';
import URI from 'vs/base/common/uri';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IQuickPickItem, IQuickInputService } from 'vs/platform/quickinput/common/quickInput';

export class OpenLogsFolderAction extends Action {

Expand All @@ -40,22 +40,22 @@ export class ShowLogsAction extends Action {
static LABEL = nls.localize('showLogs', "Show Logs...");

constructor(id: string, label: string,
@IQuickOpenService private quickOpenService: IQuickOpenService,
@IQuickInputService private quickInputService: IQuickInputService,
@IOutputService private outputService: IOutputService,
@IWorkspaceContextService private contextService: IWorkspaceContextService
) {
super(id, label);
}

run(): TPromise<void> {
const entries: IPickOpenEntry[] = [
const entries: IQuickPickItem[] = [
{ id: Constants.rendererLogChannelId, label: this.contextService.getWorkspace().name ? nls.localize('rendererProcess', "Window ({0})", this.contextService.getWorkspace().name) : nls.localize('emptyWindow', "Window") },
{ id: Constants.extHostLogChannelId, label: nls.localize('extensionHost', "Extension Host") },
{ id: Constants.sharedLogChannelId, label: nls.localize('sharedProcess', "Shared") },
{ id: Constants.mainLogChannelId, label: nls.localize('mainProcess', "Main") }
];

return this.quickOpenService.pick(entries, { placeHolder: nls.localize('selectProcess', "Select Log for Process") })
return this.quickInputService.pick(entries, { placeHolder: nls.localize('selectProcess', "Select Log for Process") })
.then(entry => {
if (entry) {
return this.outputService.showChannel(entry.id);
Expand All @@ -71,7 +71,7 @@ export class OpenLogFileAction extends Action {
static LABEL = nls.localize('openLogFile', "Open Log File...");

constructor(id: string, label: string,
@IQuickOpenService private quickOpenService: IQuickOpenService,
@IQuickInputService private quickInputService: IQuickInputService,
@IEnvironmentService private environmentService: IEnvironmentService,
@ICommandService private commandService: ICommandService,
@IWindowService private windowService: IWindowService,
Expand All @@ -81,15 +81,15 @@ export class OpenLogFileAction extends Action {
}

run(): TPromise<void> {
const entries: IPickOpenEntry[] = [
const entries: IQuickPickItem[] = [
{ id: URI.file(paths.join(this.environmentService.logsPath, `renderer${this.windowService.getCurrentWindowId()}.log`)).fsPath, label: this.contextService.getWorkspace().name ? nls.localize('rendererProcess', "Window ({0})", this.contextService.getWorkspace().name) : nls.localize('emptyWindow', "Window") },
{ id: URI.file(paths.join(this.environmentService.logsPath, `exthost${this.windowService.getCurrentWindowId()}.log`)).fsPath, label: nls.localize('extensionHost', "Extension Host") },
{ id: URI.file(paths.join(this.environmentService.logsPath, `sharedprocess.log`)).fsPath, label: nls.localize('sharedProcess', "Shared") },
{ id: URI.file(paths.join(this.environmentService.logsPath, `main.log`)).fsPath, label: nls.localize('mainProcess', "Main") },
{ id: URI.file(paths.join(this.environmentService.logsPath, `telemetry.log`)).fsPath, label: nls.localize('telemetry', "Telemetry") }
];

return this.quickOpenService.pick(entries, { placeHolder: nls.localize('selectProcess', "Select Log for Process") })
return this.quickInputService.pick(entries, { placeHolder: nls.localize('selectProcess', "Select Log for Process") })
.then(entry => {
if (entry) {
return this.commandService.executeCommand(COMMAND_OPEN_LOG_VIEWER, URI.file(entry.id));
Expand All @@ -105,7 +105,7 @@ export class SetLogLevelAction extends Action {
static LABEL = nls.localize('setLogLevel', "Set Log Level...");

constructor(id: string, label: string,
@IQuickOpenService private quickOpenService: IQuickOpenService,
@IQuickInputService private quickInputService: IQuickInputService,
@ILogService private logService: ILogService
) {
super(id, label);
Expand All @@ -123,7 +123,7 @@ export class SetLogLevelAction extends Action {
{ label: nls.localize('off', "Off"), level: LogLevel.Off, description: this.getDescription(LogLevel.Off, current) },
];

return this.quickOpenService.pick(entries, { placeHolder: nls.localize('selectLogLevel', "Select log level"), autoFocus: { autoFocusIndex: this.logService.getLevel() } }).then(entry => {
return this.quickInputService.pick(entries, { placeHolder: nls.localize('selectLogLevel', "Select log level"), activeItem: entries[this.logService.getLevel()] }).then(entry => {
if (entry) {
this.logService.setLevel(entry.level);
}
Expand Down
17 changes: 10 additions & 7 deletions src/vs/workbench/parts/preferences/browser/preferencesActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import URI from 'vs/base/common/uri';
import { Action } from 'vs/base/common/actions';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { IModeService } from 'vs/editor/common/services/modeService';
import { IQuickOpenService, IPickOpenEntry, IFilePickOpenEntry } from 'vs/platform/quickOpen/common/quickOpen';
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
import { IWorkspaceContextService, WorkbenchState, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { PICK_WORKSPACE_FOLDER_COMMAND_ID } from 'vs/workbench/browser/actions/workspaceCommands';
import { IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput';
import { getIconClasses } from 'vs/workbench/browser/labels';
import { IModelService } from 'vs/editor/common/services/modelService';

export class OpenRawDefaultSettingsAction extends Action {

Expand Down Expand Up @@ -225,16 +227,17 @@ export class ConfigureLanguageBasedSettingsAction extends Action {
constructor(
id: string,
label: string,
@IModelService private modelService: IModelService,
@IModeService private modeService: IModeService,
@IQuickOpenService private quickOpenService: IQuickOpenService,
@IQuickInputService private quickInputService: IQuickInputService,
@IPreferencesService private preferencesService: IPreferencesService
) {
super(id, label);
}

public run(): TPromise<any> {
const languages = this.modeService.getRegisteredLanguageNames();
const picks: IPickOpenEntry[] = languages.sort().map((lang, index) => {
const picks: IQuickPickItem[] = languages.sort().map((lang, index) => {
let description: string = nls.localize('languageDescriptionConfigured', "({0})", this.modeService.getModeIdForLanguageName(lang.toLowerCase()));
// construct a fake resource to be able to show nice icons if any
let fakeResource: URI;
Expand All @@ -247,14 +250,14 @@ export class ConfigureLanguageBasedSettingsAction extends Action {
fakeResource = URI.file(filenames[0]);
}
}
return <IFilePickOpenEntry>{
return {
label: lang,
resource: fakeResource,
iconClasses: getIconClasses(this.modelService, this.modeService, fakeResource),
description
};
} as IQuickPickItem;
});

return this.quickOpenService.pick(picks, { placeHolder: nls.localize('pickLanguage', "Select Language") })
return this.quickInputService.pick(picks, { placeHolder: nls.localize('pickLanguage', "Select Language") })
.then(pick => {
if (pick) {
return this.modeService.getOrCreateModeByLanguageName(pick.label)
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/parts/tasks/common/taskTemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import * as nls from 'vs/nls';

import { IPickOpenEntry } from 'vs/platform/quickOpen/common/quickOpen';
import { IQuickPickItem } from 'vs/platform/quickinput/common/quickInput';

export interface TaskEntry extends IPickOpenEntry {
export interface TaskEntry extends IQuickPickItem {
sort?: string;
autoDetect: boolean;
content: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ import { QuickOpenActionContributor } from '../browser/quickOpen';

import { Themable, STATUS_BAR_FOREGROUND, STATUS_BAR_NO_FOLDER_FOREGROUND } from 'vs/workbench/common/theme';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';

let tasksCategory = nls.localize('tasksCategory', "Tasks");

Expand Down Expand Up @@ -475,6 +476,7 @@ class TaskService implements ITaskService {
@IModelService private modelService: IModelService,
@IExtensionService private extensionService: IExtensionService,
@IQuickOpenService private quickOpenService: IQuickOpenService,
@IQuickInputService private quickInputService: IQuickInputService,
@IConfigurationResolverService private configurationResolverService: IConfigurationResolverService,
@ITerminalService private terminalService: ITerminalService,
@IStorageService private storageService: IStorageService,
Expand Down Expand Up @@ -2205,7 +2207,7 @@ class TaskService implements ITaskService {
if (stat) {
return stat.resource;
}
return this.quickOpenService.pick(getTaskTemplates(), { placeHolder: nls.localize('TaskService.template', 'Select a Task Template') }).then((selection) => {
return this.quickInputService.pick(getTaskTemplates(), { placeHolder: nls.localize('TaskService.template', 'Select a Task Template') }).then((selection) => {
if (!selection) {
return undefined;
}
Expand Down

0 comments on commit 8600035

Please sign in to comment.