From 811c298f6689fa2d6f5f8efbcb1b72916fb9ec8b Mon Sep 17 00:00:00 2001 From: Sven Efftinge Date: Wed, 4 Sep 2019 09:17:06 +0000 Subject: [PATCH] [navigator] Added command and toolbar menu item to disable auto sync Signed-off-by: Sven Efftinge --- .../src/browser/shell/tab-bar-toolbar.tsx | 4 +-- .../src/browser/navigator-contribution.ts | 32 +++++++++++++++++-- .../src/browser/navigator-preferences.ts | 6 ++-- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/packages/core/src/browser/shell/tab-bar-toolbar.tsx b/packages/core/src/browser/shell/tab-bar-toolbar.tsx index 384f2424e2cc9..5e9215df1f146 100644 --- a/packages/core/src/browser/shell/tab-bar-toolbar.tsx +++ b/packages/core/src/browser/shell/tab-bar-toolbar.tsx @@ -124,7 +124,7 @@ export class TabBarToolbar extends ReactWidget { } } const command = this.commands.getCommand(item.command); - const iconClass = item.icon || (command && command.iconClass); + const iconClass = (typeof item.icon === 'function' && item.icon()) || item.icon || (command && command.iconClass); if (iconClass) { classNames.push(iconClass); } @@ -266,7 +266,7 @@ export interface TabBarToolbarItem { /** * Optional icon for the item. */ - readonly icon?: string; + readonly icon?: string | (() => string); /** * https://code.visualstudio.com/docs/getstarted/keybindings#_when-clause-contexts diff --git a/packages/navigator/src/browser/navigator-contribution.ts b/packages/navigator/src/browser/navigator-contribution.ts index 610e1598a6f14..66e32bf83006d 100644 --- a/packages/navigator/src/browser/navigator-contribution.ts +++ b/packages/navigator/src/browser/navigator-contribution.ts @@ -18,7 +18,7 @@ import { injectable, inject, postConstruct } from 'inversify'; import { AbstractViewContribution } from '@theia/core/lib/browser/shell/view-contribution'; import { Navigatable, SelectableTreeNode, Widget, KeybindingRegistry, CommonCommands, - OpenerService, FrontendApplicationContribution, FrontendApplication, CompositeTreeNode + OpenerService, FrontendApplicationContribution, FrontendApplication, CompositeTreeNode, PreferenceScope } from '@theia/core/lib/browser'; import { FileDownloadCommands } from '@theia/filesystem/lib/browser/download/file-download-command-contribution'; import { CommandRegistry, MenuModelRegistry, MenuPath, isOSX, Command, DisposableCollection, Mutable } from '@theia/core/lib/common'; @@ -34,6 +34,7 @@ import { TabBarToolbarContribution, TabBarToolbarRegistry, TabBarToolbarItem } f import { FileSystemCommands } from '@theia/filesystem/lib/browser/filesystem-frontend-contribution'; import { NavigatorDiff, NavigatorDiffCommands } from './navigator-diff'; import { UriSelection } from '@theia/core/lib/common/selection'; +import { PreferenceService } from '@theia/core/lib/browser'; export namespace FileNavigatorCommands { export const REVEAL_IN_NAVIGATOR: Command = { @@ -44,6 +45,11 @@ export namespace FileNavigatorCommands { id: 'navigator.toggle.hidden.files', label: 'Toggle Hidden Files' }; + export const TOGGLE_AUTO_REVEAL: Command = { + id: 'navigator.toggle.autoReveal', + category: 'File', + label: 'Auto Reveal' + }; export const REFRESH_NAVIGATOR: Command = { id: 'navigator.refresh', category: 'File', @@ -67,7 +73,8 @@ export namespace FileNavigatorCommands { */ export namespace NavigatorMoreToolbarGroups { export const NEW_OPEN = '1_navigator_new_open'; - export const WORKSPACE = '2_navigator_workspace'; + export const TOOLS = '2_navigator_tools'; + export const WORKSPACE = '3_navigator_workspace'; } export const NAVIGATOR_CONTEXT_MENU: MenuPath = ['navigator-context-menu']; @@ -119,6 +126,9 @@ export class FileNavigatorContribution extends AbstractViewContribution true, isVisible: () => true }); + registry.registerCommand(FileNavigatorCommands.TOGGLE_AUTO_REVEAL, { + execute: () => { + const autoReveal = !this.fileNavigatorPreferences['explorer.autoReveal']; + this.preferenceService.set('explorer.autoReveal', autoReveal, PreferenceScope.User); + if (autoReveal) { + this.selectWidgetFileNode(this.shell.currentWidget); + } + }, + isToggled: () => this.fileNavigatorPreferences['explorer.autoReveal'] + }); registry.registerCommand(FileNavigatorCommands.COLLAPSE_ALL, { execute: widget => this.withWidget(widget, () => this.collapseFileNavigatorTree()), isEnabled: widget => this.withWidget(widget, () => this.workspaceService.opened), @@ -367,6 +387,12 @@ export class FileNavigatorContribution extends AbstractViewContribution