Skip to content

Commit

Permalink
Improve the 'file has changed' dialog
Browse files Browse the repository at this point in the history
- 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 <kaiyue.pan@ericsson.com>
  • Loading branch information
Kaiyue Pan authored and vince-fugnitto committed Jan 16, 2020
1 parent 39f5927 commit 135af5d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/filesystem/src/browser/filesystem-frontend-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand All @@ -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<boolean> {
bind(FileShouldOverwrite).toDynamicValue(context => async (file: FileStat, stat: FileStat): Promise<boolean> => {
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 => {
Expand Down

0 comments on commit 135af5d

Please sign in to comment.