提交 eb405494 编写于 作者: I isidor

rename command

上级 919b7df8
......@@ -9,7 +9,7 @@ import { Registry } from 'vs/platform/registry/common/platform';
import { Action, IAction } from 'vs/base/common/actions';
import { ActionItem, BaseActionItem, Separator } from 'vs/base/browser/ui/actionbar/actionbar';
import { Scope, IActionBarRegistry, Extensions as ActionBarExtensions, ActionBarContributor } from 'vs/workbench/browser/actions';
import { GlobalNewUntitledFileAction, SaveFileAsAction, ShowOpenedFileInNewWindow, CopyPathAction, GlobalCopyPathAction, RevealInOSAction, GlobalRevealInOSAction, pasteIntoFocusedFilesExplorerViewItem, FocusOpenEditorsView, FocusFilesExplorer, GlobalCompareResourcesAction, GlobalNewFileAction, GlobalNewFolderAction, RevertFileAction, SaveFilesAction, SaveAllAction, SaveFileAction, MoveFileToTrashAction, TriggerRenameFileAction, PasteFileAction, CopyFileAction, ShowActiveFileInExplorer, CollapseExplorerView, RefreshExplorerView, CompareWithSavedAction, CompareWithClipboardAction, NEW_FILE_COMMAND_ID, NEW_FILE_LABEL, NEW_FOLDER_COMMAND_ID, NEW_FOLDER_LABEL } from 'vs/workbench/parts/files/electron-browser/fileActions';
import { GlobalNewUntitledFileAction, SaveFileAsAction, ShowOpenedFileInNewWindow, CopyPathAction, GlobalCopyPathAction, RevealInOSAction, GlobalRevealInOSAction, pasteIntoFocusedFilesExplorerViewItem, FocusOpenEditorsView, FocusFilesExplorer, GlobalCompareResourcesAction, GlobalNewFileAction, GlobalNewFolderAction, RevertFileAction, SaveFilesAction, SaveAllAction, SaveFileAction, MoveFileToTrashAction, PasteFileAction, CopyFileAction, ShowActiveFileInExplorer, CollapseExplorerView, RefreshExplorerView, CompareWithSavedAction, CompareWithClipboardAction, NEW_FILE_COMMAND_ID, NEW_FILE_LABEL, NEW_FOLDER_COMMAND_ID, NEW_FOLDER_LABEL, TRIGGER_RENAME_COMMAND_ID, TRIGGER_RENAME_LABEL } from 'vs/workbench/parts/files/electron-browser/fileActions';
import { revertLocalChangesCommand, acceptLocalChangesCommand, CONFLICT_RESOLUTION_CONTEXT } from 'vs/workbench/parts/files/electron-browser/saveErrorHandler';
import { SyncActionDescriptor, MenuId, MenuRegistry } from 'vs/platform/actions/common/actions';
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions';
......@@ -66,7 +66,6 @@ class FilesViewerActionContributor extends ActionBarContributor {
// Rename File/Folder
if (!stat.isRoot) {
actions.push(new Separator(null, 150));
actions.push(this.instantiationService.createInstance(TriggerRenameFileAction, tree, <FileStat>stat));
// Delete File/Folder
actions.push(this.instantiationService.createInstance(MoveFileToTrashAction, tree, <FileStat>stat));
}
......@@ -444,3 +443,13 @@ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
},
when: ContextKeyExpr.and(ExplorerFolderContext)
});
MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
group: '5_modify',
order: 10,
command: {
id: TRIGGER_RENAME_COMMAND_ID,
title: TRIGGER_RENAME_LABEL
},
when: ExplorerRootContext.toNegated()
});
......@@ -68,6 +68,9 @@ export const NEW_FILE_LABEL = nls.localize('newFile', "New File");
export const NEW_FOLDER_COMMAND_ID = 'workbench.command.files.newFolder';
export const NEW_FOLDER_LABEL = nls.localize('newFolder', "New Folder");
export const TRIGGER_RENAME_COMMAND_ID = 'workbench.command.files.rename';
export const TRIGGER_RENAME_LABEL = nls.localize('rename', "Rename");
export class BaseErrorReportingAction extends Action {
constructor(
......@@ -149,7 +152,7 @@ export class BaseFileAction extends BaseErrorReportingAction {
}
}
export class TriggerRenameFileAction extends BaseFileAction {
class TriggerRenameFileAction extends BaseFileAction {
public static readonly ID = 'renameFile';
......@@ -164,7 +167,7 @@ export class TriggerRenameFileAction extends BaseFileAction {
@ITextFileService textFileService: ITextFileService,
@IInstantiationService instantiationService: IInstantiationService
) {
super(TriggerRenameFileAction.ID, nls.localize('rename', "Rename"), fileService, messageService, textFileService);
super(TriggerRenameFileAction.ID, TRIGGER_RENAME_LABEL, fileService, messageService, textFileService);
this.tree = tree;
this.element = element;
......@@ -1785,3 +1788,14 @@ CommandsRegistry.registerCommand({
return newFolderAction.run(explorerContext);
}
});
CommandsRegistry.registerCommand({
id: TRIGGER_RENAME_COMMAND_ID,
handler: (accessor, resource: URI, explorerContext: IExplorerContext) => {
const instantationService = accessor.get(IInstantiationService);
const listService = accessor.get(IListService);
const renameAction = instantationService.createInstance(TriggerRenameFileAction, listService.lastFocusedList, explorerContext.stat);
return renameAction.run(explorerContext);
}
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册