提交 a8756e8d 编写于 作者: I isidor

introduce fileDialog context

上级 5ac625f8
...@@ -6,6 +6,11 @@ ...@@ -6,6 +6,11 @@
'use strict'; 'use strict';
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey'; import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
import { isMacintosh, isLinux, isWindows } from 'vs/base/common/platform';
export const InputFocusedContextKey = 'inputFocus'; export const InputFocusedContextKey = 'inputFocus';
export const InputFocusedContext = new RawContextKey<boolean>(InputFocusedContextKey, false); export const InputFocusedContext = new RawContextKey<boolean>(InputFocusedContextKey, false);
\ No newline at end of file export const FileDialogContext = new RawContextKey<string>('fileDialog', 'local');
export const IsMacContext = new RawContextKey<boolean>('isMac', isMacintosh);
export const IsLinuxContext = new RawContextKey<boolean>('isLinux', isLinux);
export const IsWindowsContext = new RawContextKey<boolean>('isWindows', isWindows);
...@@ -22,6 +22,8 @@ import { inQuickOpenContext, getQuickNavigateHandler } from 'vs/workbench/browse ...@@ -22,6 +22,8 @@ import { inQuickOpenContext, getQuickNavigateHandler } from 'vs/workbench/browse
import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { CommandsRegistry } from 'vs/platform/commands/common/commands'; import { CommandsRegistry } from 'vs/platform/commands/common/commands';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ADD_ROOT_FOLDER_COMMAND_ID } from 'vs/workbench/browser/actions/workspaceCommands';
import { FileDialogContext, IsMacContext } from 'vs/platform/workbench/common/contextkeys';
// Contribute Commands // Contribute Commands
registerCommands(); registerCommands();
...@@ -161,34 +163,35 @@ MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, { ...@@ -161,34 +163,35 @@ MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
order: 2 order: 2
}); });
if (!isMacintosh) { MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, { group: '2_open',
group: '2_open', command: {
command: { id: OpenFileAction.ID,
id: OpenFileAction.ID, title: nls.localize({ key: 'miOpenFile', comment: ['&& denotes a mnemonic'] }, "&&Open File...")
title: nls.localize({ key: 'miOpenFile', comment: ['&& denotes a mnemonic'] }, "&&Open File...") },
}, order: 1,
order: 1 when: ContextKeyExpr.and(IsMacContext.toNegated(), FileDialogContext.isEqualTo('local'))
}); });
MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, { MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
group: '2_open', group: '2_open',
command: { command: {
id: OpenFolderAction.ID, id: OpenFolderAction.ID,
title: nls.localize({ key: 'miOpenFolder', comment: ['&& denotes a mnemonic'] }, "Open &&Folder...") title: nls.localize({ key: 'miOpenFolder', comment: ['&& denotes a mnemonic'] }, "Open &&Folder...")
}, },
order: 2 order: 2,
}); when: ContextKeyExpr.and(IsMacContext.toNegated(), FileDialogContext.isEqualTo('local'))
} else { });
MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
group: '2_open', MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
command: { group: '2_open',
id: OpenFileFolderAction.ID, command: {
title: nls.localize({ key: 'miOpen', comment: ['&& denotes a mnemonic'] }, "&&Open...") id: OpenFileFolderAction.ID,
}, title: nls.localize({ key: 'miOpen', comment: ['&& denotes a mnemonic'] }, "&&Open...")
order: 1 },
}); order: 1,
} when: ContextKeyExpr.and(IsMacContext, FileDialogContext.isEqualTo('local'))
});
MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, { MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
group: '2_open', group: '2_open',
...@@ -196,7 +199,8 @@ MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, { ...@@ -196,7 +199,8 @@ MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
id: OpenWorkspaceAction.ID, id: OpenWorkspaceAction.ID,
title: nls.localize({ key: 'miOpenWorkspace', comment: ['&& denotes a mnemonic'] }, "Open Wor&&kspace...") title: nls.localize({ key: 'miOpenWorkspace', comment: ['&& denotes a mnemonic'] }, "Open Wor&&kspace...")
}, },
order: 3 order: 3,
when: FileDialogContext.isEqualTo('local')
}); });
MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, { MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
...@@ -220,10 +224,11 @@ MenuRegistry.appendMenuItem(MenuId.MenubarRecentMenu, { ...@@ -220,10 +224,11 @@ MenuRegistry.appendMenuItem(MenuId.MenubarRecentMenu, {
MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, { MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
group: '3_workspace', group: '3_workspace',
command: { command: {
id: AddRootFolderAction.ID, id: ADD_ROOT_FOLDER_COMMAND_ID,
title: nls.localize({ key: 'miAddFolderToWorkspace', comment: ['&& denotes a mnemonic'] }, "A&&dd Folder to Workspace...") title: nls.localize({ key: 'miAddFolderToWorkspace', comment: ['&& denotes a mnemonic'] }, "A&&dd Folder to Workspace...")
}, },
order: 1 order: 1,
when: FileDialogContext.isEqualTo('local')
}); });
MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, { MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
...@@ -232,17 +237,17 @@ MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, { ...@@ -232,17 +237,17 @@ MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
id: SaveWorkspaceAsAction.ID, id: SaveWorkspaceAsAction.ID,
title: nls.localize('miSaveWorkspaceAs', "Save Workspace As...") title: nls.localize('miSaveWorkspaceAs', "Save Workspace As...")
}, },
order: 2 order: 2,
when: FileDialogContext.isEqualTo('local')
}); });
if (!isMacintosh) { MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, { title: nls.localize({ key: 'miPreferences', comment: ['&& denotes a mnemonic'] }, "&&Preferences"),
title: nls.localize({ key: 'miPreferences', comment: ['&& denotes a mnemonic'] }, "&&Preferences"), submenu: MenuId.MenubarPreferencesMenu,
submenu: MenuId.MenubarPreferencesMenu, group: '5_autosave',
group: '5_autosave', order: 2,
order: 2 when: IsMacContext.toNegated()
}); });
}
MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, { MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
group: '6_close', group: '6_close',
...@@ -455,16 +460,15 @@ MenuRegistry.appendMenuItem(MenuId.MenubarHelpMenu, { ...@@ -455,16 +460,15 @@ MenuRegistry.appendMenuItem(MenuId.MenubarHelpMenu, {
}); });
// About // About
if (!isMacintosh) { MenuRegistry.appendMenuItem(MenuId.MenubarHelpMenu, {
MenuRegistry.appendMenuItem(MenuId.MenubarHelpMenu, { group: 'z_about',
group: 'z_about', command: {
command: { id: 'workbench.action.showAboutDialog',
id: 'workbench.action.showAboutDialog', title: nls.localize({ key: 'miAbout', comment: ['&& denotes a mnemonic'] }, "&&About")
title: nls.localize({ key: 'miAbout', comment: ['&& denotes a mnemonic'] }, "&&About") },
}, order: 1,
order: 1 when: IsMacContext.toNegated()
}); });
}
// Configuration: Workbench // Configuration: Workbench
const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration); const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
......
...@@ -93,7 +93,7 @@ import { IDecorationsService } from 'vs/workbench/services/decorations/browser/d ...@@ -93,7 +93,7 @@ import { IDecorationsService } from 'vs/workbench/services/decorations/browser/d
import { ActivityService } from 'vs/workbench/services/activity/browser/activityService'; import { ActivityService } from 'vs/workbench/services/activity/browser/activityService';
import URI from 'vs/base/common/uri'; import URI from 'vs/base/common/uri';
import { IListService, ListService } from 'vs/platform/list/browser/listService'; import { IListService, ListService } from 'vs/platform/list/browser/listService';
import { InputFocusedContext } from 'vs/platform/workbench/common/contextkeys'; import { InputFocusedContext, IsMacContext, IsLinuxContext, IsWindowsContext } from 'vs/platform/workbench/common/contextkeys';
import { IViewsService } from 'vs/workbench/common/views'; import { IViewsService } from 'vs/workbench/common/views';
import { ViewsService } from 'vs/workbench/browser/parts/views/views'; import { ViewsService } from 'vs/workbench/browser/parts/views/views';
import { INotificationService } from 'vs/platform/notification/common/notification'; import { INotificationService } from 'vs/platform/notification/common/notification';
...@@ -613,9 +613,9 @@ export class Workbench extends Disposable implements IPartService { ...@@ -613,9 +613,9 @@ export class Workbench extends Disposable implements IPartService {
private handleContextKeys(): void { private handleContextKeys(): void {
this.inZenMode = InEditorZenModeContext.bindTo(this.contextKeyService); this.inZenMode = InEditorZenModeContext.bindTo(this.contextKeyService);
(new RawContextKey<boolean>('isMac', isMacintosh)).bindTo(this.contextKeyService); IsMacContext.bindTo(this.contextKeyService);
(new RawContextKey<boolean>('isLinux', isLinux)).bindTo(this.contextKeyService); IsLinuxContext.bindTo(this.contextKeyService);
(new RawContextKey<boolean>('isWindows', isWindows)).bindTo(this.contextKeyService); IsWindowsContext.bindTo(this.contextKeyService);
const sidebarVisibleContextRaw = new RawContextKey<boolean>('sidebarVisible', false); const sidebarVisibleContextRaw = new RawContextKey<boolean>('sidebarVisible', false);
this.sideBarVisibleContext = sidebarVisibleContextRaw.bindTo(this.contextKeyService); this.sideBarVisibleContext = sidebarVisibleContextRaw.bindTo(this.contextKeyService);
......
...@@ -25,6 +25,7 @@ import { ResourceContextKey } from 'vs/workbench/common/resources'; ...@@ -25,6 +25,7 @@ import { ResourceContextKey } from 'vs/workbench/common/resources';
import { WorkbenchListDoubleSelection } from 'vs/platform/list/browser/listService'; import { WorkbenchListDoubleSelection } from 'vs/platform/list/browser/listService';
import URI from 'vs/base/common/uri'; import URI from 'vs/base/common/uri';
import { Schemas } from 'vs/base/common/network'; import { Schemas } from 'vs/base/common/network';
import { FileDialogContext } from 'vs/platform/workbench/common/contextkeys';
// Contribute Global Actions // Contribute Global Actions
const category = nls.localize('filesCategory', "File"); const category = nls.localize('filesCategory', "File");
...@@ -425,7 +426,7 @@ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, { ...@@ -425,7 +426,7 @@ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
id: ADD_ROOT_FOLDER_COMMAND_ID, id: ADD_ROOT_FOLDER_COMMAND_ID,
title: ADD_ROOT_FOLDER_LABEL title: ADD_ROOT_FOLDER_LABEL
}, },
when: ExplorerRootContext when: ContextKeyExpr.and(ExplorerRootContext, FileDialogContext.isEqualTo('local'))
}); });
MenuRegistry.appendMenuItem(MenuId.ExplorerContext, { MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
...@@ -505,7 +506,8 @@ MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, { ...@@ -505,7 +506,8 @@ MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
id: SAVE_FILE_AS_COMMAND_ID, id: SAVE_FILE_AS_COMMAND_ID,
title: nls.localize({ key: 'miSaveAs', comment: ['&& denotes a mnemonic'] }, "Save &&As...") title: nls.localize({ key: 'miSaveAs', comment: ['&& denotes a mnemonic'] }, "Save &&As...")
}, },
order: 2 order: 2,
when: FileDialogContext.isEqualTo('local')
}); });
MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, { MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册