Skip to content

Commit

Permalink
#169: Now "paste" is shown in context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandoescolar committed Feb 20, 2023
1 parent cd14a2c commit 08f4851
Show file tree
Hide file tree
Showing 34 changed files with 123 additions and 122 deletions.
172 changes: 86 additions & 86 deletions src/SolutionExplorerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,135 +14,135 @@ export class SolutionExplorerCommands {
private readonly actionsRunner: ActionsRunner,
private readonly templateEngineCollection: TemplateEngineCollection,
private readonly eventAggregator: IEventAggregator) {

const { cps, both } = ContextValues;

this.commands['addExistingProject'] = [new cmds.AddExistingProjectCommand(provider),
this.commands['addExistingProject'] = [new cmds.AddExistingProjectCommand(provider),
both(ContextValues.solution)];
this.commands['addNewProject'] = [new cmds.AddNewProjectCommand(provider),

this.commands['addNewProject'] = [new cmds.AddNewProjectCommand(provider),
both(ContextValues.solution)];
this.commands['addPackage'] = [new cmds.AddPackageCommand(),

this.commands['addPackage'] = [new cmds.AddPackageCommand(),
cps(ContextValues.project, ContextValues.projectReferencedPackages)];
this.commands['updatePackageVersion'] = [new cmds.UpdatePackageVersionCommand(),

this.commands['updatePackageVersion'] = [new cmds.UpdatePackageVersionCommand(),
cps(ContextValues.projectReferencedPackage)];
this.commands['addProjectReference'] = [new cmds.AddProjectReferenceCommand(),

this.commands['addProjectReference'] = [new cmds.AddProjectReferenceCommand(),
cps(ContextValues.project, ContextValues.projectReferencedProjects)];
this.commands['addSolutionFile'] = [new cmds.AddExistingFileToSolutionFolderCommand(),

this.commands['addSolutionFile'] = [new cmds.AddExistingFileToSolutionFolderCommand(),
[ContextValues.solutionFolder]];
this.commands['build'] = [new cmds.BuildCommand(),

this.commands['build'] = [new cmds.BuildCommand(),
cps(ContextValues.solution, ContextValues.project)];
this.commands['clean'] = [new cmds.CleanCommand(),

this.commands['clean'] = [new cmds.CleanCommand(),
cps(ContextValues.solution, ContextValues.project)];
this.commands['collapseAll'] = [new cmds.CollapseAllCommand(provider),

this.commands['collapseAll'] = [new cmds.CollapseAllCommand(provider),
undefined];
this.commands['copy'] = [new cmds.CopyCommand(),

this.commands['copy'] = [new cmds.CopyCommand(),
[ContextValues.projectFolder, ContextValues.projectFile]];
this.commands['createFile'] = [new cmds.CreateFileCommand(templateEngineCollection),

this.commands['createFile'] = [new cmds.CreateFileCommand(templateEngineCollection),
[ContextValues.projectFile, ContextValues.projectFolder, ...both(ContextValues.project)]];
this.commands['createFolder'] = [new cmds.CreateFolderCommand(),

this.commands['createFolder'] = [new cmds.CreateFolderCommand(),
[ContextValues.projectFile, ContextValues.projectFolder, ...both(ContextValues.project)]];
this.commands['createNewSolution'] = [new cmds.CreateNewSolutionCommand(),

this.commands['createNewSolution'] = [new cmds.CreateNewSolutionCommand(),
[ContextValues.noSolution]];
this.commands['createSolutionFolder'] = [new cmds.CreateSolutionFolderCommand(),

this.commands['createSolutionFolder'] = [new cmds.CreateSolutionFolderCommand(),
[ContextValues.solutionFolder, ...both(ContextValues.solution)]];
this.commands['deleteFile'] = [new cmds.DeleteUnifiedCommand(),

this.commands['deleteFile'] = [new cmds.DeleteUnifiedCommand(),
[ContextValues.projectFile]];
this.commands['deleteFolder'] = [new cmds.DeleteUnifiedCommand(),

this.commands['deleteFolder'] = [new cmds.DeleteUnifiedCommand(),
[ContextValues.projectFolder]];
this.commands['deleteSolutionFile'] = [new cmds.DeleteUnifiedCommand(),

this.commands['deleteSolutionFile'] = [new cmds.DeleteUnifiedCommand(),
[ContextValues.solutionFile]];
this.commands['duplicate'] = [new cmds.DuplicateCommand(),

this.commands['duplicate'] = [new cmds.DuplicateCommand(),
[ContextValues.projectFile]];
this.commands['installTemplates'] = [new cmds.InstallWorkspaceTemplateFilesCommand(templateEngineCollection),

this.commands['installTemplates'] = [new cmds.InstallWorkspaceTemplateFilesCommand(templateEngineCollection),
both(ContextValues.solution)];
this.commands['moveFile'] = [new cmds.MoveCommand(provider),

this.commands['moveFile'] = [new cmds.MoveCommand(provider),
[ContextValues.projectFile]];
this.commands['moveFolder'] = [new cmds.MoveCommand(provider),

this.commands['moveFolder'] = [new cmds.MoveCommand(provider),
[ContextValues.projectFolder]];
this.commands['moveToSolutionFolder'] = [new cmds.MoveToSolutionFolderCommand(),

this.commands['moveToSolutionFolder'] = [new cmds.MoveToSolutionFolderCommand(),
[ContextValues.solutionFolder, ...both(ContextValues.project)]];
this.commands['openFile'] = [new cmds.OpenFileCommand(),

this.commands['openFile'] = [new cmds.OpenFileCommand(),
both(ContextValues.solution, ContextValues.project)];
this.commands['pack'] = [new cmds.PackCommand(),

this.commands['pack'] = [new cmds.PackCommand(),
cps(ContextValues.solution, ContextValues.project)];
this.commands['paste'] = [new cmds.PasteCommand(provider),
[ContextValues.projectFolder, ...both(ContextValues.project)]];
this.commands['publish'] = [new cmds.PublishCommand(),

this.commands['paste'] = [new cmds.PasteCommand(provider),
[ContextValues.projectFolder, ContextValues.projectFile, ...both(ContextValues.project)]];

this.commands['publish'] = [new cmds.PublishCommand(),
cps(ContextValues.solution, ContextValues.project)];
this.commands['refresh'] = [new cmds.RefreshCommand(provider),

this.commands['refresh'] = [new cmds.RefreshCommand(provider),
[ContextValues.projectFolder, ContextValues.solutionFolder, ...both(ContextValues.project)]];
this.commands['removePackage'] = [new cmds.DeleteUnifiedCommand(),

this.commands['removePackage'] = [new cmds.DeleteUnifiedCommand(),
cps(ContextValues.projectReferencedPackage)];
this.commands['removeProject'] = [new cmds.DeleteUnifiedCommand(),

this.commands['removeProject'] = [new cmds.DeleteUnifiedCommand(),
both(ContextValues.project)];
this.commands['removeProjectReference'] = [new cmds.DeleteUnifiedCommand(),

this.commands['removeProjectReference'] = [new cmds.DeleteUnifiedCommand(),
cps(ContextValues.projectReferencedProject)];
this.commands['removeSolutionFolder'] = [new cmds.DeleteUnifiedCommand(),

this.commands['removeSolutionFolder'] = [new cmds.DeleteUnifiedCommand(),
[ContextValues.solutionFolder]];
this.commands['renameFile'] = [new cmds.RenameCommand(),

this.commands['renameFile'] = [new cmds.RenameCommand(),
[ContextValues.projectFile]];
this.commands['renameFolder'] = [new cmds.RenameCommand(),

this.commands['renameFolder'] = [new cmds.RenameCommand(),
[ContextValues.projectFolder]];
this.commands['renameSolutionItem'] = [new cmds.RenameSolutionItemCommand(provider),

this.commands['renameSolutionItem'] = [new cmds.RenameSolutionItemCommand(provider),
[ContextValues.solutionFolder, ...both(ContextValues.solution, ContextValues.project)]];
this.commands['restore'] = [new cmds.RestoreCommand(),

this.commands['restore'] = [new cmds.RestoreCommand(),
cps(ContextValues.solution, ContextValues.project)];
this.commands['revealFileInOS'] = [new cmds.RevealInOSCommand(),

this.commands['revealFileInOS'] = [new cmds.RevealInOSCommand(),
[ContextValues.projectFile]];
this.commands['run'] = [new cmds.RunCommand(),

this.commands['run'] = [new cmds.RunCommand(),
cps(ContextValues.project)];
this.commands['showActiveFileInExplorer'] = [new cmds.SelectActiveDocumentCommand(provider),

this.commands['showActiveFileInExplorer'] = [new cmds.SelectActiveDocumentCommand(provider),
undefined];
this.commands['test'] = [new cmds.TestCommand(),

this.commands['test'] = [new cmds.TestCommand(),
cps(ContextValues.project)];
this.commands['updatePackagesVersion'] = [new cmds.UpdatePackagesVersionCommand(),

this.commands['updatePackagesVersion'] = [new cmds.UpdatePackagesVersionCommand(),
cps(ContextValues.project, ContextValues.projectReferencedPackages)];
this.commands['watchRun'] = [new cmds.WatchRunCommand(),

this.commands['watchRun'] = [new cmds.WatchRunCommand(),
cps(ContextValues.project)];
this.commands['openSolution'] = [new cmds.OpenSolutionCommand(eventAggregator),

this.commands['openSolution'] = [new cmds.OpenSolutionCommand(eventAggregator),
undefined];

this.commands['deleteMultiple'] = [new cmds.DeleteUnifiedCommand(),
[ContextValues.multipleSelection]];
}
Expand Down
7 changes: 4 additions & 3 deletions src/actions/Paste.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ export class Paste implements Action {
public async execute(context: ActionContext): Promise<void> {
const data = await clipboard.readText();
if (!data) { return; }

if (!(await fs.exists(data))) { return; }
if (!(await fs.exists(this.targetPath))) { return; }

const target = await fs.isDirectory(this.targetPath) ? this.targetPath : path.dirname(this.targetPath);
const isDirectory = await fs.isDirectory(data);
if (isDirectory) {
this.copyDirectory(data, this.targetPath);
this.copyDirectory(data, target);
} else {
this.copyFile(data, this.targetPath);
this.copyFile(data, target);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/AddExistingProjectCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class AddExistingProjectCommand extends SingleItemActionsCommand {
super('Add existing project');
}

public shouldRun(item: TreeItem): boolean {
public shouldRun(item: TreeItem): boolean {
return !item || (item && !!item.path && (item.contextValue === ContextValues.solution || item.contextValue === ContextValues.solution + '-cps'));
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/AddNewProjectCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class AddNewProjectCommand extends SingleItemActionsCommand {
super('Add new project');
}

public shouldRun(item: TreeItem): boolean {
public shouldRun(item: TreeItem): boolean {
return !item || (item && !!item.path && (item.contextValue === ContextValues.solution || item.contextValue === ContextValues.solution + '-cps'));
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/AddPackageCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class AddPackageCommand extends SingleItemActionsCommand {
super('Add package');
}

public shouldRun(item: TreeItem): boolean {
public shouldRun(item: TreeItem): boolean {
return item && !!item.project && item.project.type === 'cps';
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/AddProjectReferenceCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class AddProjectReferenceCommand extends SingleItemActionsCommand {
super('Add project reference');
}

public shouldRun(item: TreeItem): boolean {
public shouldRun(item: TreeItem): boolean {
return item && !!item.project && item.project.type === 'cps';
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/BuildCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class BuildCommand extends SingleItemActionsCommand {
super('Build');
}

public shouldRun(item: TreeItem): boolean {
public shouldRun(item: TreeItem): boolean {
return item && (item.contextValue === ContextValues.project + '-cps' || item.contextValue === ContextValues.solution + '-cps');
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/CleanCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class CleanCommand extends SingleItemActionsCommand {
super('Clean');
}

public shouldRun(item: TreeItem): boolean {
public shouldRun(item: TreeItem): boolean {
return item && (item.contextValue === ContextValues.project + '-cps' || item.contextValue === ContextValues.solution + '-cps');
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/CollapseAllCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class CollapseAllCommand extends SingleItemActionsCommand {
super('Collapse All');
}

public shouldRun(item: TreeItem): boolean {
public shouldRun(item: TreeItem): boolean {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/CopyCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class CopyCommand extends SingleItemActionsCommand {
super('Copy');
}

public shouldRun(item: TreeItem): boolean {
public shouldRun(item: TreeItem): boolean {
return !!item && !!item.path;
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/CreateFileCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class CreateFileCommand extends SingleItemActionsCommand {
super('Create file');
}

public shouldRun(item: TreeItem): boolean {
public shouldRun(item: TreeItem): boolean {
return item && !!item.project;
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/CreateFolderCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class CreateFolderCommand extends SingleItemActionsCommand {
super('Create folder');
}

public shouldRun(item: TreeItem): boolean {
public shouldRun(item: TreeItem): boolean {
return !!item.project;
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/CreateNewSolutionCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class CreateNewSolutionCommand extends SingleItemActionsCommand {
super('Create solution');
}

public shouldRun(item: TreeItem): boolean {
public shouldRun(item: TreeItem): boolean {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/CreateSolutionFolderCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class CreateSolutionFolderCommand extends SingleItemActionsCommand {
super('Create solution folder');
}

public shouldRun(item: TreeItem): boolean {
public shouldRun(item: TreeItem): boolean {
return !!item && !!item.solution;
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/DuplicateCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class DuplicateCommand extends SingleItemActionsCommand {
super('Duplicate');
}

public shouldRun(item: TreeItem): boolean {
public shouldRun(item: TreeItem): boolean {
return item && !!item.path && item.contextValue.startsWith(ContextValues.projectFile);
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/InstallWorkspaceTemplateFilesCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class InstallWorkspaceTemplateFilesCommand extends SingleItemActionsComma
super('Install Workspace Template Files');
}

public shouldRun(item: TreeItem): boolean {
public shouldRun(item: TreeItem): boolean {
return item && !!item.workspaceRoot;
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/MoveCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class MoveCommand extends SingleItemActionsCommand {
super('Move');
}

public shouldRun(item: TreeItem): boolean {
public shouldRun(item: TreeItem): boolean {
return !!item && !!item.project && !!item.path && ( item.contextValue.startsWith(ContextValues.projectFile) || item.contextValue.startsWith(ContextValues.projectFolder) );
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/MoveToSolutionFolderCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class MoveToSolutionFolderCommand extends SingleItemActionsCommand {
super('Move to solution folder');
}

public shouldRun(item: TreeItem): boolean {
public shouldRun(item: TreeItem): boolean {
return !!item && !!item.solution && !!item.projectInSolution;
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/OpenFileCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class OpenFileCommand extends SingleItemActionsCommand {
super('Open file');
}

public shouldRun(item: TreeItem): boolean {
public shouldRun(item: TreeItem): boolean {
return !!item && !!item.path;
}

Expand Down
Loading

0 comments on commit 08f4851

Please sign in to comment.