From 3800561d0f82745e4dde7d6b8ed2bb84f77ec681 Mon Sep 17 00:00:00 2001 From: Kaiyue Pan Date: Mon, 13 Jan 2020 11:33:14 -0500 Subject: [PATCH] Improve the 'file has changed' dialog - Use LabelProvider.getName(uri) to get a systemwide human readable representation of a simple file name. - Use LabelProvider.getLongName(uri) to get a systemwide human readable representation of a full path. Signed-off-by: Kaiyue Pan --- .../src/browser/filesystem-frontend-module.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/filesystem/src/browser/filesystem-frontend-module.ts b/packages/filesystem/src/browser/filesystem-frontend-module.ts index 3da73512178fa..351c873b4e599 100644 --- a/packages/filesystem/src/browser/filesystem-frontend-module.ts +++ b/packages/filesystem/src/browser/filesystem-frontend-module.ts @@ -18,7 +18,7 @@ import '../../src/browser/style/index.css'; import { ContainerModule, interfaces } from 'inversify'; import { ResourceResolver, CommandContribution } from '@theia/core/lib/common'; -import { WebSocketConnectionProvider, FrontendApplicationContribution, ConfirmDialog, LabelProviderContribution } from '@theia/core/lib/browser'; +import { WebSocketConnectionProvider, FrontendApplicationContribution, ConfirmDialog, LabelProviderContribution, LabelProvider } from '@theia/core/lib/browser'; import { FileSystem, fileSystemPath, FileShouldOverwrite, FileStat } from '../common'; import { fileSystemWatcherPath, FileSystemWatcherServer, @@ -31,6 +31,7 @@ import { FileSystemFrontendContribution } from './filesystem-frontend-contributi import { FileSystemProxyFactory } from './filesystem-proxy-factory'; import { FileUploadService } from './file-upload-service'; import { FileTreeLabelProvider } from './file-tree/file-tree-label-provider'; +import URI from '@theia/core/lib/common/uri'; export default new ContainerModule(bind => { bindFileSystemPreferences(bind); @@ -40,15 +41,16 @@ export default new ContainerModule(bind => { ); bind(FileSystemWatcherServer).to(ReconnectingFileSystemWatcherServer); bind(FileSystemWatcher).toSelf().inSingletonScope(); - bind(FileShouldOverwrite).toFunction(async function (file: FileStat, stat: FileStat): Promise { + bind(FileShouldOverwrite).toDynamicValue(context => async (file: FileStat, stat: FileStat): Promise => { + const labelProvider = context.container.get(LabelProvider); const dialog = new ConfirmDialog({ - title: `The file '${file.uri}' has been changed on the file system.`, - msg: 'Do you want to overwrite the changes made on the file system?', + title: `The file '${labelProvider.getName(new URI(file.uri))}' has been changed on the file system.`, + msg: `Do you want to overwrite the changes made to '${labelProvider.getLongName(new URI(file.uri))}' on the file system?`, ok: 'Yes', cancel: 'No' }); return !!await dialog.open(); - }); + }).inSingletonScope(); bind(FileSystemProxyFactory).toSelf(); bind(FileSystem).toDynamicValue(ctx => {