implement 'Open Containing Folder' for Solution Explorer panel

This commit is contained in:
Michael Becker 2020-10-23 21:57:34 -04:00
parent a1ec00983b
commit 6b1d0f34c7
No known key found for this signature in database
GPG Key ID: 506F54899E2BFED7
3 changed files with 61 additions and 0 deletions

View File

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<ApplicationFramework>
<Commands>
<Command ID="SolutionExplorer_ContextMenu_OpenContainingFolder" />
<Command ID="SolutionExplorer_ContextMenu_Project_BuildProject" />
<Command ID="SolutionExplorer_ContextMenu_Project_RebuildProject" />
<Command ID="SolutionExplorer_ContextMenu_Project_CleanProject" />
@ -32,6 +34,8 @@
<Separator />
<CommandReference CommandID="SolutionExplorer_ContextMenu_Project_Add" />
<Separator />
<CommandReference CommandID="SolutionExplorer_ContextMenu_OpenContainingFolder" />
<Separator />
<CommandReference CommandID="EditCut" />
<CommandReference CommandID="EditCopy" />
<CommandReference CommandID="EditPaste" />
@ -73,6 +77,8 @@
<Separator />
<CommandReference CommandID="SolutionExplorer_ContextMenu_Solution_Add" />
<Separator />
<CommandReference CommandID="SolutionExplorer_ContextMenu_OpenContainingFolder" />
<Separator />
<CommandReference CommandID="EditCut" />
<CommandReference CommandID="EditCopy" />
<CommandReference CommandID="EditPaste" />
@ -88,6 +94,8 @@
<Items>
<CommandReference CommandID="SolutionExplorer_ContextMenu_File_Open" />
<Separator />
<CommandReference CommandID="SolutionExplorer_ContextMenu_OpenContainingFolder" />
<Separator />
<CommandReference CommandID="EditCut" />
<CommandReference CommandID="EditCopy" />
<CommandReference CommandID="EditPaste" />
@ -115,6 +123,8 @@
<Items>
<CommandReference CommandID="SolutionExplorer_ContextMenu_Folder_Add" />
<Separator />
<CommandReference CommandID="SolutionExplorer_ContextMenu_OpenContainingFolder" />
<Separator />
<CommandReference CommandID="EditCut" />
<CommandReference CommandID="EditCopy" />
<CommandReference CommandID="EditPaste" />

View File

@ -2,6 +2,8 @@
<Languages>
<Language ID="English">
<Commands>
<Command ID="SolutionExplorer_ContextMenu_OpenContainingFolder" Title="Open Containing _Folder" />
<Command ID="SolutionExplorer_ContextMenu_Project_BuildProject" Title="B_uild Project" />
<Command ID="SolutionExplorer_ContextMenu_Project_RebuildProject" Title="R_ebuild Project" />
<Command ID="SolutionExplorer_ContextMenu_Project_CleanProject" Title="C_lean Project" />

View File

@ -188,6 +188,55 @@ namespace UniversalEditor.UserInterface.Panels
this.Controls.Add(tvSolutionExplorer, new BoxLayout.Constraints(true, true));
Application.AttachCommandEventHandler("SolutionExplorer_ContextMenu_OpenContainingFolder", delegate(object sender, EventArgs e)
{
if (tvSolutionExplorer.SelectedRows.Count != 1) return;
ProjectObjectModel project = tvSolutionExplorer.SelectedRows[0].GetExtraData<ProjectObjectModel>("project");
ProjectFile file = tvSolutionExplorer.SelectedRows[0].GetExtraData<ProjectFile>("file");
ProjectFolder folder = tvSolutionExplorer.SelectedRows[0].GetExtraData<ProjectFolder>("folder");
TreeModelRow prow = tvSolutionExplorer.SelectedRows[0].ParentRow;
while (project == null && prow != null)
{
project = prow.GetExtraData<ProjectObjectModel>("project");
prow = prow.ParentRow;
}
if (project != null)
{
if (project.BasePath != null)
{
string fullpath = System.IO.Path.Combine(project.BasePath, tvSolutionExplorer.SelectedRows[0].RowColumns[0].Value.ToString());
if (file == null && folder == null)
{
fullpath = fullpath + ".ueproj";
}
// not sure if this should be made into a UWT convenience function or not...
try
{
if (Environment.OSVersion.Platform == PlatformID.Unix)
{
Application.Launch("nautilus", String.Format("-s \"{0}\"", fullpath));
}
else if (Environment.OSVersion.Platform == PlatformID.Win32Windows)
{
Application.Launch("explorer", String.Format("/select \"{0}\"", fullpath));
}
else
{
Application.Launch(System.IO.Path.GetDirectoryName(fullpath));
}
}
catch (Exception ex)
{
// not using nautilus, just launch the folder
Application.Launch(System.IO.Path.GetDirectoryName(fullpath));
}
}
}
});
Application.AttachCommandEventHandler("SolutionExplorer_ContextMenu_Project_Add_ExistingFiles", mnuContextProjectAddExistingFiles_Click);
Application.AttachCommandEventHandler("SolutionExplorer_ContextMenu_Project_Add_NewFolder", mnuContextProjectAddNewFolder_Click);
Application.AttachCommandEventHandler("SolutionExplorer_ContextMenu_Solution_Add_ExistingFiles", mnuContextSolutionAddExistingProject_Click);