From 6b1d0f34c7269f9b123c1b7269e40295152936c5 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Fri, 23 Oct 2020 21:57:34 -0400 Subject: [PATCH] implement 'Open Containing Folder' for Solution Explorer panel --- .../Panels/SolutionExplorer/Commands.uexml | 10 ++++ .../SolutionExplorer/Languages/English.uexml | 2 + .../Panels/SolutionExplorerPanel.cs | 49 +++++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/Content/UniversalEditor.Content.PlatformIndependent/Panels/SolutionExplorer/Commands.uexml b/Content/UniversalEditor.Content.PlatformIndependent/Panels/SolutionExplorer/Commands.uexml index de290934..7a6f8bbf 100644 --- a/Content/UniversalEditor.Content.PlatformIndependent/Panels/SolutionExplorer/Commands.uexml +++ b/Content/UniversalEditor.Content.PlatformIndependent/Panels/SolutionExplorer/Commands.uexml @@ -1,6 +1,8 @@  + + @@ -32,6 +34,8 @@ + + @@ -73,6 +77,8 @@ + + @@ -88,6 +94,8 @@ + + @@ -115,6 +123,8 @@ + + diff --git a/Content/UniversalEditor.Content.PlatformIndependent/Panels/SolutionExplorer/Languages/English.uexml b/Content/UniversalEditor.Content.PlatformIndependent/Panels/SolutionExplorer/Languages/English.uexml index 22593505..35791a4f 100644 --- a/Content/UniversalEditor.Content.PlatformIndependent/Panels/SolutionExplorer/Languages/English.uexml +++ b/Content/UniversalEditor.Content.PlatformIndependent/Panels/SolutionExplorer/Languages/English.uexml @@ -2,6 +2,8 @@ + + diff --git a/Libraries/UniversalEditor.UserInterface/Panels/SolutionExplorerPanel.cs b/Libraries/UniversalEditor.UserInterface/Panels/SolutionExplorerPanel.cs index eeb68014..fa04d468 100644 --- a/Libraries/UniversalEditor.UserInterface/Panels/SolutionExplorerPanel.cs +++ b/Libraries/UniversalEditor.UserInterface/Panels/SolutionExplorerPanel.cs @@ -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("project"); + ProjectFile file = tvSolutionExplorer.SelectedRows[0].GetExtraData("file"); + ProjectFolder folder = tvSolutionExplorer.SelectedRows[0].GetExtraData("folder"); + + TreeModelRow prow = tvSolutionExplorer.SelectedRows[0].ParentRow; + while (project == null && prow != null) + { + project = prow.GetExtraData("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);