-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#289 Adding a context option to Open in Solution Explorer
- Loading branch information
fernandoescolar
committed
Dec 11, 2023
1 parent
3220e90
commit 4c59f38
Showing
9 changed files
with
74 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { IEventAggregator } from "@events"; | ||
import { Action, OpenSolution } from "@actions"; | ||
import { SingleItemActionsFromDefaultExplorerCommand } from "./SingleItemActionsFromDefaultExplorerCommand"; | ||
|
||
|
||
export class OpenSolutionFromDefaultExplorerCommand extends SingleItemActionsFromDefaultExplorerCommand { | ||
constructor(private readonly eventAggregator: IEventAggregator) { | ||
super('Open Solution'); | ||
} | ||
|
||
public shouldRun(item: string): boolean { | ||
return item.toLocaleLowerCase().endsWith('.sln'); | ||
} | ||
|
||
public async getActions(item: string): Promise<Action[]> { | ||
return [new OpenSolution(item, this.eventAggregator)]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
import { TreeItem } from "@tree"; | ||
import { Action } from "@actions"; | ||
import { ActionsCommand } from "./ActionsCommand"; | ||
import { ActionCommandContext, ActionsCommand } from "./ActionsCommand"; | ||
|
||
export abstract class SingleItemActionsCommand extends ActionsCommand { | ||
constructor(title: string) { | ||
super(title); | ||
} | ||
|
||
public async getActionsBase(clickedItem: TreeItem | undefined, selectedItems: readonly TreeItem[] | undefined): Promise<Action[]> { | ||
const item = clickedItem ?? (selectedItems?.length === 1 ? selectedItems[0] : undefined); | ||
public async getActionsBase(ctx: ActionCommandContext): Promise<Action[]> { | ||
const item = ctx.clickedItem ?? (ctx.selectedItems?.length === 1 ? ctx.selectedItems[0] : undefined); | ||
return this.shouldRun(item) ? this.getActions(item) : []; | ||
} | ||
|
||
public abstract shouldRun(item: TreeItem | undefined): boolean; | ||
|
||
public abstract getActions(item: TreeItem | undefined): Promise<Action[]>; | ||
} | ||
|
||
|
22 changes: 22 additions & 0 deletions
22
src/commands/SingleItemActionsFromDefaultExplorerCommand.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Action } from "@actions"; | ||
import { ActionCommandContext, ActionsCommand } from "./ActionsCommand"; | ||
|
||
|
||
|
||
export abstract class SingleItemActionsFromDefaultExplorerCommand extends ActionsCommand { | ||
constructor(title: string) { | ||
super(title); | ||
} | ||
|
||
public async getActionsBase(ctx: ActionCommandContext): Promise<Action[]> { | ||
if (!!ctx && !!ctx.args && !!ctx.args.path) { | ||
return this.shouldRun(ctx.args.path) ? this.getActions(ctx.args.path) : []; | ||
} | ||
|
||
return []; | ||
} | ||
|
||
public abstract shouldRun(item: string): boolean; | ||
|
||
public abstract getActions(item: string): Promise<Action[]>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters