提交 a8756e8d 编写于 作者: I isidor

introduce fileDialog context

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