Skip to content

Commit

Permalink
add force refresh button in navigator
Browse files Browse the repository at this point in the history
Signed-off-by: kpge <gekangping@126.com>
  • Loading branch information
kpge committed Aug 14, 2019
1 parent 11badc8 commit 4b87a57
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion packages/navigator/src/browser/navigator-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -161,6 +167,11 @@ export class FileNavigatorContribution extends AbstractViewContribution<FileNavi
isEnabled: widget => 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),
Expand Down Expand Up @@ -317,11 +328,17 @@ export class FileNavigatorContribution extends AbstractViewContribution<FileNavi
}

async registerToolbarItems(toolbarRegistry: TabBarToolbarRegistry): Promise<void> {
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,
});
}

Expand Down Expand Up @@ -373,6 +390,14 @@ export class FileNavigatorContribution extends AbstractViewContribution<FileNavi
}
}

/**
* force refresh workspace in navigator
*/
async refreshWorkspace(): Promise<void> {
const { model } = await this.widget;
await model.refresh();
}

private readonly toDisposeAddRemoveFolderActions = new DisposableCollection();
private updateAddRemoveFolderActions(registry: MenuModelRegistry): void {
this.toDisposeAddRemoveFolderActions.dispose();
Expand Down

0 comments on commit 4b87a57

Please sign in to comment.