提交 dd7601fd 编写于 作者: I isidor

explorerResourceIsReadonly -> explorerResourceReadonly

also add negative context key for simplicity
上级 a543a0a1
......@@ -50,12 +50,13 @@ const openEditorsVisibleId = 'openEditorsVisible';
const openEditorsFocusId = 'openEditorsFocus';
const explorerViewletFocusId = 'explorerViewletFocus';
const explorerResourceIsFolderId = 'explorerResourceIsFolder';
const explorerResourceIsReadonly = 'explorerResourceIsReadonly';
const explorerResourceReadonly = 'explorerResourceReadonly';
const explorerResourceIsRootId = 'explorerResourceIsRoot';
export const ExplorerViewletVisibleContext = new RawContextKey<boolean>(explorerViewletVisibleId, true);
export const ExplorerFolderContext = new RawContextKey<boolean>(explorerResourceIsFolderId, false);
export const ExplorerResourceIsReadonlyContext = new RawContextKey<boolean>(explorerResourceIsReadonly, false);
export const ExplorerResourceReadonlyContext = new RawContextKey<boolean>(explorerResourceReadonly, false);
export const ExplorerResourceNotReadonlyContext = ExplorerResourceReadonlyContext.toNegated();
export const ExplorerRootContext = new RawContextKey<boolean>(explorerResourceIsRootId, false);
export const FilesExplorerFocusedContext = new RawContextKey<boolean>(filesExplorerFocusId, true);
export const OpenEditorsVisibleContext = new RawContextKey<boolean>(openEditorsVisibleId, false);
......
......@@ -16,7 +16,7 @@ import { CommandsRegistry, ICommandHandler } from 'vs/platform/commands/common/c
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { isWindows, isMacintosh } from 'vs/base/common/platform';
import { FilesExplorerFocusCondition, ExplorerRootContext, ExplorerFolderContext, ExplorerResourceIsReadonlyContext } from 'vs/workbench/parts/files/common/files';
import { FilesExplorerFocusCondition, ExplorerRootContext, ExplorerFolderContext, ExplorerResourceNotReadonlyContext } from 'vs/workbench/parts/files/common/files';
import { ADD_ROOT_FOLDER_COMMAND_ID, ADD_ROOT_FOLDER_LABEL } from 'vs/workbench/browser/actions/workspaceCommands';
import { CLOSE_SAVED_EDITORS_COMMAND_ID, CLOSE_EDITORS_IN_GROUP_COMMAND_ID, CLOSE_EDITOR_COMMAND_ID, CLOSE_OTHER_EDITORS_IN_GROUP_COMMAND_ID } from 'vs/workbench/browser/parts/editor/editorCommands';
import { OPEN_FOLDER_SETTINGS_COMMAND, OPEN_FOLDER_SETTINGS_LABEL } from 'vs/workbench/parts/preferences/browser/preferencesActions';
......@@ -51,7 +51,7 @@ const RENAME_ID = 'renameFile';
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: RENAME_ID,
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(explorerCommandsWeightBonus),
when: ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerRootContext.toNegated(), ExplorerResourceIsReadonlyContext.toNegated()),
when: ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerRootContext.toNegated(), ExplorerResourceNotReadonlyContext),
primary: KeyCode.F2,
mac: {
primary: KeyCode.Enter
......@@ -63,7 +63,7 @@ const MOVE_FILE_TO_TRASH_ID = 'moveFileToTrash';
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: MOVE_FILE_TO_TRASH_ID,
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(explorerCommandsWeightBonus),
when: ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerRootContext.toNegated(), ExplorerResourceIsReadonlyContext.toNegated()),
when: ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerRootContext.toNegated(), ExplorerResourceNotReadonlyContext),
primary: KeyCode.Delete,
mac: {
primary: KeyMod.CtrlCmd | KeyCode.Backspace
......@@ -75,7 +75,7 @@ const DELETE_FILE_ID = 'deleteFile';
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: DELETE_FILE_ID,
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(explorerCommandsWeightBonus),
when: ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerRootContext.toNegated(), ExplorerResourceIsReadonlyContext.toNegated()),
when: ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerRootContext.toNegated(), ExplorerResourceNotReadonlyContext),
primary: KeyMod.Shift | KeyCode.Delete,
mac: {
primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.Backspace
......@@ -97,7 +97,7 @@ const PASTE_FILE_ID = 'filesExplorer.paste';
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: PASTE_FILE_ID,
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(explorerCommandsWeightBonus),
when: ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerResourceIsReadonlyContext.toNegated()),
when: ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerResourceNotReadonlyContext),
primary: KeyMod.CtrlCmd | KeyCode.KEY_V,
handler: pasteFileHandler
});
......@@ -330,7 +330,7 @@ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
command: {
id: NEW_FILE_COMMAND_ID,
title: NEW_FILE_LABEL,
precondition: ExplorerResourceIsReadonlyContext.toNegated()
precondition: ExplorerResourceNotReadonlyContext
},
when: ExplorerFolderContext
});
......@@ -341,7 +341,7 @@ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
command: {
id: NEW_FOLDER_COMMAND_ID,
title: NEW_FOLDER_LABEL,
precondition: ExplorerResourceIsReadonlyContext.toNegated()
precondition: ExplorerResourceNotReadonlyContext
},
when: ExplorerFolderContext
});
......@@ -445,7 +445,7 @@ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
command: {
id: RENAME_ID,
title: TRIGGER_RENAME_LABEL,
precondition: ExplorerResourceIsReadonlyContext.toNegated()
precondition: ExplorerResourceNotReadonlyContext
},
when: ExplorerRootContext.toNegated()
});
......@@ -456,12 +456,12 @@ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
command: {
id: MOVE_FILE_TO_TRASH_ID,
title: MOVE_FILE_TO_TRASH_LABEL,
precondition: ExplorerResourceIsReadonlyContext.toNegated()
precondition: ExplorerResourceNotReadonlyContext
},
alt: {
id: DELETE_FILE_ID,
title: nls.localize('deleteFile', "Delete Permanently"),
precondition: ExplorerResourceIsReadonlyContext.toNegated()
precondition: ExplorerResourceNotReadonlyContext
},
when: ExplorerRootContext.toNegated()
});
......
......@@ -14,7 +14,7 @@ import * as resources from 'vs/base/common/resources';
import * as glob from 'vs/base/common/glob';
import { Action, IAction } from 'vs/base/common/actions';
import { memoize } from 'vs/base/common/decorators';
import { IFilesConfiguration, ExplorerFolderContext, FilesExplorerFocusedContext, ExplorerFocusedContext, SortOrderConfiguration, SortOrder, IExplorerView, ExplorerRootContext, ExplorerResourceIsReadonlyContext } from 'vs/workbench/parts/files/common/files';
import { IFilesConfiguration, ExplorerFolderContext, FilesExplorerFocusedContext, ExplorerFocusedContext, SortOrderConfiguration, SortOrder, IExplorerView, ExplorerRootContext, ExplorerResourceReadonlyContext } from 'vs/workbench/parts/files/common/files';
import { FileOperation, FileOperationEvent, IResolveFileOptions, FileChangeType, FileChangesEvent, IFileService, FILES_EXCLUDE_CONFIG } from 'vs/platform/files/common/files';
import { RefreshViewExplorerAction, NewFolderAction, NewFileAction } from 'vs/workbench/parts/files/electron-browser/fileActions';
import { FileDragAndDrop, FileFilter, FileSorter, FileController, FileRenderer, FileDataSource, FileViewletState, FileAccessibilityProvider } from 'vs/workbench/parts/files/electron-browser/views/explorerViewer';
......@@ -105,7 +105,7 @@ export class ExplorerView extends TreeViewsViewletPanel implements IExplorerView
this.resourceContext = instantiationService.createInstance(ResourceContextKey);
this.folderContext = ExplorerFolderContext.bindTo(contextKeyService);
this.readonlyContext = ExplorerResourceIsReadonlyContext.bindTo(contextKeyService);
this.readonlyContext = ExplorerResourceReadonlyContext.bindTo(contextKeyService);
this.rootContext = ExplorerRootContext.bindTo(contextKeyService);
this.fileEventsFilter = instantiationService.createInstance(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册