From 4b87a5739e432e9c3fcbafbb7f314d96243df36e Mon Sep 17 00:00:00 2001 From: kpge Date: Wed, 14 Aug 2019 09:25:46 +0800 Subject: [PATCH] add force refresh button in navigator Signed-off-by: kpge --- .../src/browser/navigator-contribution.ts | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/packages/navigator/src/browser/navigator-contribution.ts b/packages/navigator/src/browser/navigator-contribution.ts index 8c18fcaa7321a..d4dcc631dc6d7 100644 --- a/packages/navigator/src/browser/navigator-contribution.ts +++ b/packages/navigator/src/browser/navigator-contribution.ts @@ -44,6 +44,12 @@ export namespace FileNavigatorCommands { id: 'navigator.toggle.hidden.files', label: 'Toggle Hidden Files' }; + export const REFRESH_NAVIGATOR: Command = { + id: 'navigator.refresh', + category: 'File', + label: 'Refresh in Explorer', + iconClass: 'refresh' + }; export const COLLAPSE_ALL: Command = { id: 'navigator.collapse.all', category: 'File', @@ -161,6 +167,11 @@ export class FileNavigatorContribution extends AbstractViewContribution this.withWidget(widget, () => this.workspaceService.opened), isVisible: widget => this.withWidget(widget, () => this.workspaceService.opened) }); + registry.registerCommand(FileNavigatorCommands.REFRESH_NAVIGATOR, { + execute: widget => this.withWidget(widget, () => this.refreshWorkspace()), + isEnabled: widget => this.withWidget(widget, () => this.workspaceService.opened), + isVisible: widget => this.withWidget(widget, () => this.workspaceService.opened) + }); registry.registerCommand(FileNavigatorCommands.ADD_ROOT_FOLDER, { execute: (...args) => registry.executeCommand(WorkspaceCommands.ADD_FOLDER.id, ...args), isEnabled: (...args) => registry.isEnabled(WorkspaceCommands.ADD_FOLDER.id, ...args), @@ -317,11 +328,17 @@ export class FileNavigatorContribution extends AbstractViewContribution { + toolbarRegistry.registerItem({ + id: FileNavigatorCommands.REFRESH_NAVIGATOR.id, + command: FileNavigatorCommands.REFRESH_NAVIGATOR.id, + tooltip: 'Refresh Explorer', + priority: 0, + }); toolbarRegistry.registerItem({ id: FileNavigatorCommands.COLLAPSE_ALL.id, command: FileNavigatorCommands.COLLAPSE_ALL.id, tooltip: 'Collapse All', - priority: 0, + priority: 1, }); } @@ -373,6 +390,14 @@ export class FileNavigatorContribution extends AbstractViewContribution { + const { model } = await this.widget; + await model.refresh(); + } + private readonly toDisposeAddRemoveFolderActions = new DisposableCollection(); private updateAddRemoveFolderActions(registry: MenuModelRegistry): void { this.toDisposeAddRemoveFolderActions.dispose();