major improvements to project system including 'virtual' in-memory file system for projects and multiple project types (natures)
This commit is contained in:
parent
4887657ad6
commit
a1ec00983b
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE UniversalEditor SYSTEM "U:\Doctypes\UniversalEditor.dtd">
|
||||
<UniversalEditor Version="3.0">
|
||||
<ProjectTypes>
|
||||
<ProjectType ID="{69878862-DA7D-4DC6-B0A1-50D8FAB4242F}">
|
||||
<Information>
|
||||
<Title>PlayStation(R) Mobile Project</Title>
|
||||
<ProjectFileExtension>.psproj</ProjectFileExtension>
|
||||
</Information>
|
||||
<Tasks>
|
||||
<!--
|
||||
ActionTypes are defined in libraries.
|
||||
{EE505E05-F125-4718-BA0A-879C72B5125A} corresponds to the built-in task action type ExecutableAction
|
||||
When Tasks are executed, each Action in Actions gets executed.
|
||||
When Actions are executed, the TaskType gets the inner XML of the task and processes it to extract parameters.
|
||||
Certain tags are expanded by the preprocessor, like StringBuilder which is common to all TaskTypes.
|
||||
-->
|
||||
<!-- Build Project -->
|
||||
<Task ID="{3EFB95BA-D2E8-46D0-9939-814DA4F5AB22}">
|
||||
<Actions>
|
||||
</Actions>
|
||||
</Task>
|
||||
</Tasks>
|
||||
</ProjectType>
|
||||
</ProjectTypes>
|
||||
</UniversalEditor>
|
||||
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE UniversalEditor SYSTEM "U:\Doctypes\UniversalEditor.dtd">
|
||||
<UniversalEditor Version="3.0">
|
||||
<ProjectTypes>
|
||||
<ProjectType ID="{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}">
|
||||
<Information>
|
||||
<Title>C# Project</Title>
|
||||
</Information>
|
||||
<Tasks>
|
||||
<!--
|
||||
ActionTypes are defined in libraries.
|
||||
{EE505E05-F125-4718-BA0A-879C72B5125A} corresponds to the built-in task action type ExecutableAction
|
||||
When Tasks are executed, each Action in Actions gets executed.
|
||||
When Actions are executed, the TaskType gets the inner XML of the task and processes it to extract parameters.
|
||||
Certain tags are expanded by the preprocessor, like StringBuilder which is common to all TaskTypes.
|
||||
-->
|
||||
<!-- Build Project -->
|
||||
<Task ID="{3EFB95BA-D2E8-46D0-9939-814DA4F5AB22}">
|
||||
<Actions>
|
||||
</Actions>
|
||||
</Task>
|
||||
</Tasks>
|
||||
</ProjectType>
|
||||
</ProjectTypes>
|
||||
</UniversalEditor>
|
||||
@ -1,7 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<UniversalEditor Version="2.0">
|
||||
<ProjectTemplates>
|
||||
<ProjectTemplate ID="{BF876842-64CA-4832-A562-DBA6970C691A}" TypeID="{33C51321-C18B-409C-A7D0-BEF65BFEFC9A}">
|
||||
<ProjectTemplate ID="{BF876842-64CA-4832-A562-DBA6970C691A}" TypeID="{69878862-DA7D-4DC6-B0A1-50D8FAB4242F}">
|
||||
<ProjectTypes>
|
||||
<!-- These are also called 'natures' in Eclipse -->
|
||||
<!-- SCE.PSM.projecttype -->
|
||||
<ProjectType ID="{69878862-DA7D-4DC6-B0A1-50D8FAB4242F}" />
|
||||
<!-- Microsoft.CSharp.projecttype -->
|
||||
<ProjectType ID="{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}" />
|
||||
</ProjectTypes>
|
||||
<Information>
|
||||
<Title>Basic PlayStation(R) Mobile Project</Title>
|
||||
<ProjectNamePrefix>PsmApp</ProjectNamePrefix>
|
||||
|
||||
@ -313,6 +313,8 @@
|
||||
<Content Include="Templates\Project\SCE\PSM\content\AppMain.cs" />
|
||||
<Content Include="Templates\Project\SCE\PSM\content\shaders\Simple.vcg" />
|
||||
<Content Include="Templates\Project\SCE\PSM\content\shaders\Simple.fcg" />
|
||||
<Content Include="ProjectTypes\{69878862-DA7D-4DC6-B0A1-50D8FAB4242F}.uexml" />
|
||||
<Content Include="ProjectTypes\{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}.uexml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Configuration\Application.upl" />
|
||||
|
||||
@ -24,7 +24,7 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
using MBS.Framework.Logic;
|
||||
|
||||
using UniversalEditor.Accessors;
|
||||
using UniversalEditor.DataFormats.Markup.XML;
|
||||
using UniversalEditor.DataFormats.PropertyList.XML;
|
||||
using UniversalEditor.ObjectModels.Markup;
|
||||
@ -336,6 +336,10 @@ namespace UniversalEditor.DataFormats.UEPackage
|
||||
{
|
||||
MarkupTagElement tagTitle = (tagInformation.Elements["Title"] as MarkupTagElement);
|
||||
if (tagTitle != null) projtype.Title = tagTitle.Value;
|
||||
|
||||
MarkupTagElement tagProjectFileExtension = (tagInformation.Elements["ProjectFileExtension"] as MarkupTagElement);
|
||||
if (tagProjectFileExtension != null) projtype.ProjectFileExtension = tagProjectFileExtension.Value;
|
||||
|
||||
MarkupTagElement tagIconPath = (tagInformation.Elements["IconPath"] as MarkupTagElement);
|
||||
if (tagIconPath != null)
|
||||
{
|
||||
@ -702,7 +706,11 @@ namespace UniversalEditor.DataFormats.UEPackage
|
||||
{
|
||||
try
|
||||
{
|
||||
template.ProjectType = Common.Reflection.GetProjectTypeByTypeID(new Guid(attTypeID.Value));
|
||||
ProjectType projectType = Common.Reflection.GetProjectTypeByTypeID(new Guid(attTypeID.Value));
|
||||
if (projectType != null)
|
||||
{
|
||||
template.ProjectTypes.Add(projectType);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
@ -780,16 +788,36 @@ namespace UniversalEditor.DataFormats.UEPackage
|
||||
MarkupTagElement tagFileSystem = (tagTemplate.Elements["FileSystem"] as MarkupTagElement);
|
||||
if (tagFileSystem != null)
|
||||
{
|
||||
MarkupTagElement tagFiles = (tagFileSystem.Elements["Files"] as MarkupTagElement);
|
||||
if (tagFiles != null)
|
||||
MarkupAttribute attCopyFrom = tagFileSystem.Attributes["CopyFrom"];
|
||||
if (attCopyFrom != null)
|
||||
{
|
||||
foreach (MarkupElement elFile in tagFiles.Elements)
|
||||
string dir = System.IO.Path.GetDirectoryName(Accessor.GetFileName());
|
||||
string copyFrom = System.IO.Path.Combine(new string[] { dir, attCopyFrom.Value });
|
||||
if (System.IO.Directory.Exists(copyFrom))
|
||||
{
|
||||
MarkupTagElement tagFile = (elFile as MarkupTagElement);
|
||||
if (tagFile == null) continue;
|
||||
if (tagFile.FullName != "File") continue;
|
||||
string[] files = System.IO.Directory.GetFiles(copyFrom, "*", System.IO.SearchOption.AllDirectories);
|
||||
for (int i = 0; i < files.Length; i++)
|
||||
{
|
||||
ProjectFile pf = new ProjectFile();
|
||||
pf.SourceFileAccessor = new MemoryAccessor(System.IO.File.ReadAllBytes(files[i]), System.IO.Path.GetFileName(files[i]));
|
||||
pf.DestinationFileName = files[i].Substring(copyFrom.Length + 1);
|
||||
template.FileSystem.Files.Add(pf);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MarkupTagElement tagFiles = (tagFileSystem.Elements["Files"] as MarkupTagElement);
|
||||
if (tagFiles != null)
|
||||
{
|
||||
foreach (MarkupElement elFile in tagFiles.Elements)
|
||||
{
|
||||
MarkupTagElement tagFile = (elFile as MarkupTagElement);
|
||||
if (tagFile == null) continue;
|
||||
if (tagFile.FullName != "File") continue;
|
||||
|
||||
LoadProjectFile(tagFile, template.FileSystem.Files);
|
||||
LoadProjectFile(tagFile, template.FileSystem.Files);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,6 +108,8 @@ namespace UniversalEditor.ObjectModels.Project
|
||||
/// </summary>
|
||||
public string SourceFileName { get { return mvarSourceFileName; } set { mvarSourceFileName = value; } }
|
||||
|
||||
public Accessor SourceFileAccessor { get; set; } = null;
|
||||
|
||||
private string mvarDestinationFileName = String.Empty;
|
||||
/// <summary>
|
||||
/// The name of the project file in the project itself, which can be different from the file name of the file on disk.
|
||||
@ -127,7 +129,8 @@ namespace UniversalEditor.ObjectModels.Project
|
||||
{
|
||||
ProjectFile clone = new ProjectFile();
|
||||
clone.DestinationFileName = (mvarDestinationFileName.Clone() as string);
|
||||
clone.SourceFileName = (mvarSourceFileName.Clone() as string);
|
||||
clone.SourceFileName = (mvarSourceFileName?.Clone() as string);
|
||||
clone.SourceFileAccessor = SourceFileAccessor?.Clone() as Accessor;
|
||||
clone.Configuration = (mvarConfiguration.Clone() as PropertyListObjectModel);
|
||||
return clone;
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ namespace UniversalEditor.ObjectModels.Project
|
||||
Configuration.Clear();
|
||||
FileSystem.Clear();
|
||||
ID = Guid.Empty;
|
||||
ProjectType = null;
|
||||
ProjectTypes.Clear();
|
||||
References.Clear();
|
||||
RelativeFileName = String.Empty;
|
||||
Title = String.Empty;
|
||||
@ -64,7 +64,10 @@ namespace UniversalEditor.ObjectModels.Project
|
||||
Configuration.CopyTo(clone.Configuration);
|
||||
FileSystem.CopyTo(clone.FileSystem);
|
||||
clone.ID = ID;
|
||||
clone.ProjectType = ProjectType;
|
||||
for (int i = 0; i < ProjectTypes.Count; i++)
|
||||
{
|
||||
clone.ProjectTypes.Add(ProjectTypes[i]);
|
||||
}
|
||||
foreach (Reference _ref in References)
|
||||
{
|
||||
clone.References.Add(_ref);
|
||||
@ -73,6 +76,8 @@ namespace UniversalEditor.ObjectModels.Project
|
||||
clone.Title = (Title.Clone() as string);
|
||||
}
|
||||
|
||||
public string BasePath { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the globally-unique identifier (GUID) for this <see cref="ProjectObjectModel" />.
|
||||
/// </summary>
|
||||
@ -99,10 +104,12 @@ namespace UniversalEditor.ObjectModels.Project
|
||||
/// <value>The file system containing the <see cref="ProjectFile" />s and <see cref="ProjectFolder" />s referenced by this <see cref="ProjectObjectModel" />.</value>
|
||||
public ProjectFileSystem FileSystem { get; } = new ProjectFileSystem();
|
||||
/// <summary>
|
||||
/// Gets or sets a <see cref="ProjectType" /> containing common settings and build actions shared between multiple projects of the same <see cref="ProjectType" />.
|
||||
/// Gets a collection of <see cref="ProjectType" />s containing common settings and build actions shared between multiple projects of the
|
||||
/// same <see cref="ProjectType" />.
|
||||
/// </summary>
|
||||
/// <value>The <see cref="ProjectType" /> containing common settings and build actions shared between multiple projects of the same <see cref="ProjectType" />.</value>
|
||||
public ProjectType ProjectType { get; set; } = null;
|
||||
/// <value>A collection of <see cref="ProjectType" />s containing common settings and build actions shared between multiple projects of the
|
||||
/// same <see cref="ProjectType" />.</value>
|
||||
public ProjectType.ProjectTypeCollection ProjectTypes { get; } = new ProjectType.ProjectTypeCollection();
|
||||
/// <summary>
|
||||
/// Gets or sets the relative path to the <see cref="ProjectObjectModel" />.
|
||||
/// </summary>
|
||||
|
||||
@ -59,6 +59,8 @@ namespace UniversalEditor.ObjectModels.Solution
|
||||
Configuration.CopyTo(solution.Configuration);
|
||||
}
|
||||
|
||||
public string BasePath { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection of <see cref="ProjectObjectModel" /> instances representing the projects contained within this solution.
|
||||
/// </summary>
|
||||
|
||||
@ -57,6 +57,8 @@ namespace UniversalEditor
|
||||
|
||||
private ProjectTypeVariable.ProjectTypeVariableCollection mvarVariables = new ProjectTypeVariable.ProjectTypeVariableCollection();
|
||||
public ProjectTypeVariable.ProjectTypeVariableCollection Variables { get { return mvarVariables; } }
|
||||
|
||||
public string ProjectFileExtension { get; set; } = null;
|
||||
}
|
||||
/// <summary>
|
||||
/// A shortcut placed in the "Add New Item" menu when the project is selected. When
|
||||
|
||||
@ -229,8 +229,7 @@ namespace UniversalEditor
|
||||
/// </summary>
|
||||
public string[] Path { get { return mvarPath; } set { mvarPath = value; } }
|
||||
|
||||
private ProjectType mvarProjectType = null;
|
||||
public ProjectType ProjectType { get { return mvarProjectType; } set { mvarProjectType = value; } }
|
||||
public ProjectType.ProjectTypeCollection ProjectTypes { get; } = new ProjectType.ProjectTypeCollection();
|
||||
|
||||
private string mvarProjectNamePrefix = String.Empty;
|
||||
public string ProjectNamePrefix { get { return mvarProjectNamePrefix; } set { mvarProjectNamePrefix = value; } }
|
||||
@ -248,10 +247,12 @@ namespace UniversalEditor
|
||||
public ProjectObjectModel Create()
|
||||
{
|
||||
ProjectObjectModel p = new ProjectObjectModel();
|
||||
p.ProjectType = mvarProjectType;
|
||||
for (int i = 0; i < ProjectTypes.Count; i++)
|
||||
{
|
||||
p.ProjectTypes.Add(ProjectTypes[i]);
|
||||
}
|
||||
mvarFileSystem.CopyTo(p.FileSystem);
|
||||
mvarConfiguration.CopyTo(p.Configuration);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
@ -276,61 +276,72 @@ namespace UniversalEditor.UserInterface.Dialogs
|
||||
case NewDialogMode.Project:
|
||||
{
|
||||
ProjectTemplate template = tvTemplate.SelectedRows[0].GetExtraData<ProjectTemplate>("dt");
|
||||
if (template.ProjectType != null)
|
||||
if (template.ProjectTypes.Count > 0)
|
||||
{
|
||||
if (template.ProjectType.Variables.Count > 0)
|
||||
{
|
||||
CustomOption.CustomOptionCollection coll = new CustomOption.CustomOptionCollection();
|
||||
foreach (ProjectTypeVariable ptv in template.ProjectType.Variables)
|
||||
{
|
||||
switch (ptv.Type)
|
||||
{
|
||||
case ProjectTypeVariableType.Text:
|
||||
{
|
||||
CustomOptionText co = new CustomOptionText(ptv.Name, ptv.Title);
|
||||
coll.Add(co);
|
||||
break;
|
||||
}
|
||||
case ProjectTypeVariableType.Choice:
|
||||
{
|
||||
List<CustomOptionFieldChoice> choices = new List<CustomOptionFieldChoice>();
|
||||
foreach (KeyValuePair<string, object> kvp in ptv.ValidValues)
|
||||
{
|
||||
choices.Add(new CustomOptionFieldChoice(kvp.Key, kvp.Value, kvp.Value == ptv.DefaultValue));
|
||||
}
|
||||
CustomSettingsProvider csp = new CustomSettingsProvider();
|
||||
|
||||
CustomOptionChoice co = new CustomOptionChoice(ptv.Name, ptv.Title, true, choices.ToArray());
|
||||
coll.Add(co);
|
||||
break;
|
||||
}
|
||||
case ProjectTypeVariableType.FileOpen:
|
||||
for (int i = 0; i < template.ProjectTypes.Count; i++)
|
||||
{
|
||||
SettingsGroup sg = new SettingsGroup(template.ProjectTypes[i].Title);
|
||||
if (template.ProjectTypes[i].Variables.Count > 0)
|
||||
{
|
||||
foreach (ProjectTypeVariable ptv in template.ProjectTypes[i].Variables)
|
||||
{
|
||||
switch (ptv.Type)
|
||||
{
|
||||
CustomOptionFile co = new CustomOptionFile(ptv.Name, ptv.Title);
|
||||
co.DialogMode = CustomOptionFileDialogMode.Open;
|
||||
coll.Add(co);
|
||||
break;
|
||||
}
|
||||
case ProjectTypeVariableType.FileSave:
|
||||
{
|
||||
CustomOptionFile co = new CustomOptionFile(ptv.Name, ptv.Title);
|
||||
co.DialogMode = CustomOptionFileDialogMode.Save;
|
||||
coll.Add(co);
|
||||
break;
|
||||
case ProjectTypeVariableType.Text:
|
||||
{
|
||||
sg.Settings.Add(new TextSetting(ptv.Name, ptv.Title));
|
||||
break;
|
||||
}
|
||||
case ProjectTypeVariableType.Choice:
|
||||
{
|
||||
List<ChoiceSetting.ChoiceSettingValue> choices = new List<ChoiceSetting.ChoiceSettingValue>();
|
||||
foreach (KeyValuePair<string, object> kvp in ptv.ValidValues)
|
||||
{
|
||||
choices.Add(new ChoiceSetting.ChoiceSettingValue(kvp.Key, kvp.Key, kvp.Value));
|
||||
}
|
||||
sg.Settings.Add(new ChoiceSetting(ptv.Name, ptv.Title, null, choices.ToArray()));
|
||||
break;
|
||||
}
|
||||
case ProjectTypeVariableType.FileOpen:
|
||||
{
|
||||
FileSetting co = new FileSetting(ptv.Name, ptv.Title);
|
||||
co.Mode = FileDialogMode.Open;
|
||||
sg.Settings.Add(co);
|
||||
break;
|
||||
}
|
||||
case ProjectTypeVariableType.FileSave:
|
||||
{
|
||||
FileSetting co = new FileSetting(ptv.Name, ptv.Title);
|
||||
co.Mode = FileDialogMode.Save;
|
||||
sg.Settings.Add(co);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!Engine.CurrentEngine.ShowCustomOptionDialog(ref coll, template.ProjectType.Title + " properties"))
|
||||
// template.ProjectType.Variables[co.PropertyName].Value = co.GetValue().ToString();
|
||||
// TODO: Figure out how to assign variable values to the newly
|
||||
// created project from the template
|
||||
if (sg.Settings.Count > 0)
|
||||
{
|
||||
// only add the SettingsGroup if there are settings to be displayed
|
||||
csp.SettingsGroups.Add(sg);
|
||||
}
|
||||
}
|
||||
|
||||
SettingsDialog dlg = new SettingsDialog();
|
||||
dlg.SettingsProviders.Clear();
|
||||
dlg.SettingsProviders.Add(csp);
|
||||
|
||||
if (csp.SettingsGroups.Count > 0)
|
||||
{
|
||||
if (dlg.ShowDialog() != DialogResult.OK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (CustomOption co in coll)
|
||||
{
|
||||
// template.ProjectType.Variables[co.PropertyName].Value = co.GetValue().ToString();
|
||||
// TODO: Figure out how to assign variable values to the newly
|
||||
// created project from the template
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@ -201,8 +201,8 @@ namespace UniversalEditor.UserInterface
|
||||
|
||||
AddPanel("Document Explorer", DockingItemPlacement.Bottom, pnlDocumentExplorer);
|
||||
|
||||
DockingContainer dcExplorerProperties = AddPanelContainer(DockingItemPlacement.Right, null);
|
||||
AddPanel("Solution Explorer", DockingItemPlacement.Top, pnlSolutionExplorer, dcExplorerProperties);
|
||||
DockingContainer dcExplorerProperties = null; // AddPanelContainer(DockingItemPlacement.Right, null);
|
||||
AddPanel("Solution Explorer", DockingItemPlacement.Left, pnlSolutionExplorer, dcExplorerProperties);
|
||||
AddPanel("Properties", DockingItemPlacement.Bottom, pnlPropertyList, dcExplorerProperties);
|
||||
|
||||
AddPanel("Error List", DockingItemPlacement.Bottom, pnlErrorList);
|
||||
@ -403,6 +403,12 @@ namespace UniversalEditor.UserInterface
|
||||
ProjectObjectModel project = pjt.Create();
|
||||
project.ID = Guid.NewGuid();
|
||||
project.Title = dlg.ProjectTitle;
|
||||
|
||||
// go through and update all referenced variables
|
||||
foreach (ProjectFile pf in project.FileSystem.Files)
|
||||
{
|
||||
pf.DestinationFileName = pf.DestinationFileName.Replace("$(Project.Title)", project.Title);
|
||||
}
|
||||
solution.Projects.Add(project);
|
||||
|
||||
CurrentSolution = solution;
|
||||
@ -1139,16 +1145,18 @@ namespace UniversalEditor.UserInterface
|
||||
|
||||
if (dlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_CurrentSolutionDocument = new Document(CurrentSolution, df, new FileAccessor(dlg.SelectedFileNames[dlg.SelectedFileNames.Count - 1], true, true));
|
||||
_CurrentSolutionDocument.Accessor.Open();
|
||||
_CurrentSolutionDocument.Save();
|
||||
_CurrentSolutionDocument.Accessor.Close();
|
||||
SaveProjectAs(dlg.SelectedFileName, df);
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveProjectAs(string FileName, DataFormat df)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
_CurrentSolutionDocument = new Document(CurrentSolution, df, new FileAccessor(FileName, true, true));
|
||||
_CurrentSolutionDocument.Accessor.Open();
|
||||
_CurrentSolutionDocument.Save();
|
||||
_CurrentSolutionDocument.Accessor.Close();
|
||||
|
||||
CurrentSolution.BasePath = System.IO.Path.GetDirectoryName(FileName);
|
||||
}
|
||||
|
||||
public void SaveAll()
|
||||
|
||||
@ -237,22 +237,28 @@ namespace UniversalEditor.UserInterface.Panels
|
||||
// TODO: implement what happens when we activate a row in the solution explorer list
|
||||
|
||||
// typically:
|
||||
// - if it is a ProjectFile we want to open the respective file in a new document tab
|
||||
// - if it is a ProjectFolder we just want to expand/collapse tree (default action)
|
||||
// - if it is a ProjectFile we want to open the respective file in a new document tab - DONE
|
||||
// - if it is a ProjectFolder we just want to expand/collapse tree (default action) - DONE
|
||||
// - if it is a special folder named "Properties", or the project item itself, it should display the special project properties dialog
|
||||
// - if it is a special folder named "Properties/Resources", the resource editor shall be shown
|
||||
|
||||
// these last two conditions can be simplified by simply having the Properties folder open the project file in an editor, and implementing
|
||||
// an editor for ProjectObjectModel which is essentially the "project properties" window (a la VS)
|
||||
ProjectObjectModel project = e.Row.GetExtraData<ProjectObjectModel>("project");
|
||||
ProjectFile file = e.Row.GetExtraData<ProjectFile>("file");
|
||||
ProjectFolder folder = e.Row.GetExtraData<ProjectFolder>("folder");
|
||||
if (project != null)
|
||||
{
|
||||
MessageDialog.ShowDialog(String.Format("Opening project properties for {0}", e.Row.RowColumns[0].Value), "Info", MessageDialogButtons.OK);
|
||||
Accessors.MemoryAccessor ma = new Accessors.MemoryAccessor(new byte[0], String.Format("{0} Properties", project.Title));
|
||||
Document d = new Document(project, null, ma);
|
||||
d.Title = String.Format("{0} Properties", project.Title);
|
||||
HostApplication.CurrentWindow.OpenFile(d);
|
||||
}
|
||||
else if (file != null)
|
||||
{
|
||||
if (String.IsNullOrEmpty(file.SourceFileName))
|
||||
if (file.SourceFileAccessor != null)
|
||||
{
|
||||
MessageDialog.ShowDialog("TODO: Implement OpenDocument() call so we can open embedded files (i.e. that do not actually exist as 'files')", "NOT IMPLEMENTED", MessageDialogButtons.OK, MessageDialogIcon.Error);
|
||||
Engine.CurrentEngine.LastWindow.OpenFile(new Document(file.SourceFileAccessor));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -29,6 +29,7 @@ using UniversalEditor.ObjectModels.Project;
|
||||
using UniversalEditor.ObjectModels.PropertyList;
|
||||
using UniversalEditor.ObjectModels.Solution;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.DataFormats.Project.Microsoft.VisualStudio
|
||||
{
|
||||
@ -183,7 +184,7 @@ namespace UniversalEditor.DataFormats.Project.Microsoft.VisualStudio
|
||||
|
||||
MarkupTagElement tagProjectGUID = new MarkupTagElement();
|
||||
tagProjectGUID.FullName = "ProjectGuid";
|
||||
tagProjectGUID.Value = proj.ID.ToString("D");
|
||||
tagProjectGUID.Value = proj.ID.ToString("B").ToUpper();
|
||||
tagPropertyGroup.Elements.Add(tagProjectGUID);
|
||||
|
||||
MarkupTagElement tagOutputType = new MarkupTagElement();
|
||||
@ -198,7 +199,17 @@ namespace UniversalEditor.DataFormats.Project.Microsoft.VisualStudio
|
||||
|
||||
MarkupTagElement tagProjectTypeGUIDs = new MarkupTagElement();
|
||||
tagProjectTypeGUIDs.FullName = "ProjectTypeGuids";
|
||||
tagProjectTypeGUIDs.Value = proj.ProjectType.ID.ToString("B");
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < proj.ProjectTypes.Count; i++)
|
||||
{
|
||||
sb.Append(proj.ProjectTypes[i].ID.ToString("B").ToUpper());
|
||||
if (i < proj.ProjectTypes.Count - 1)
|
||||
{
|
||||
sb.Append(";");
|
||||
}
|
||||
}
|
||||
tagProjectTypeGUIDs.Value = sb.ToString();
|
||||
tagPropertyGroup.Elements.Add(tagProjectTypeGUIDs);
|
||||
|
||||
MarkupTagElement tagAssemblyName = new MarkupTagElement();
|
||||
|
||||
@ -30,6 +30,7 @@ using UniversalEditor.ObjectModels.Solution;
|
||||
using UniversalEditor.ObjectModels.Project;
|
||||
using UniversalEditor.DataFormats.Project.Microsoft.VisualStudio;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UniversalEditor.DataFormats.Solution.Microsoft.VisualStudio
|
||||
{
|
||||
@ -108,6 +109,8 @@ namespace UniversalEditor.DataFormats.Solution.Microsoft.VisualStudio
|
||||
string projectTitle = paramz[0].Trim();
|
||||
string projectRelativeFileName = paramz[1].Trim();
|
||||
string projectFileName = solutionPath + System.IO.Path.DirectorySeparatorChar.ToString() + projectRelativeFileName;
|
||||
string projectDirectory = System.IO.Path.GetDirectoryName(projectFileName);
|
||||
|
||||
Guid projectID = new Guid(paramz[2].Trim());
|
||||
|
||||
if (projectTypeID == KnownProjectTypeIDs.SolutionFolder)
|
||||
@ -122,6 +125,7 @@ namespace UniversalEditor.DataFormats.Solution.Microsoft.VisualStudio
|
||||
{
|
||||
if (UniversalEditor.Common.Reflection.GetAvailableObjectModel<ProjectObjectModel>(projectFileName, out ProjectObjectModel project))
|
||||
{
|
||||
project.BasePath = projectDirectory;
|
||||
project.Title = projectTitle;
|
||||
sol.Projects.Add(project);
|
||||
lastProject = project;
|
||||
@ -173,7 +177,7 @@ namespace UniversalEditor.DataFormats.Solution.Microsoft.VisualStudio
|
||||
foreach (ProjectObjectModel project in sol.Projects)
|
||||
{
|
||||
string projdir = soldir + "/" + project.Title;
|
||||
project.RelativeFileName = project.Title + "\\" + project.Title + ".ueproj";
|
||||
project.RelativeFileName = project.Title + "\\" + project.Title + GetFileExtensionForProjectType(project.ProjectTypes);
|
||||
|
||||
/*
|
||||
if (project is SolutionFolder)
|
||||
@ -184,8 +188,13 @@ namespace UniversalEditor.DataFormats.Solution.Microsoft.VisualStudio
|
||||
else
|
||||
{
|
||||
*/
|
||||
|
||||
Guid projectTypeGuid = Guid.Empty;
|
||||
if (project.ProjectType != null) projectTypeGuid = project.ProjectType.ID;
|
||||
if (project.ProjectTypes.Count > 0)
|
||||
{
|
||||
projectTypeGuid = project.ProjectTypes[0].ID;
|
||||
}
|
||||
|
||||
writer.WriteLine("Project(\"" + projectTypeGuid.ToString("B").ToUpper() + "\") = \"" + project.Title + "\", \"" + project.RelativeFileName + "\", \"" + project.ID.ToString("B").ToUpper() + "\"");
|
||||
writer.WriteLine("EndProject");
|
||||
/*
|
||||
@ -197,7 +206,25 @@ namespace UniversalEditor.DataFormats.Solution.Microsoft.VisualStudio
|
||||
System.IO.Directory.CreateDirectory(projdir);
|
||||
}
|
||||
|
||||
foreach (ProjectFile pf in project.FileSystem.Files)
|
||||
{
|
||||
pf.SourceFileAccessor.Open();
|
||||
pf.SourceFileAccessor.Seek(0, SeekOrigin.Begin);
|
||||
byte[] data = pf.SourceFileAccessor.Reader.ReadToEnd();
|
||||
pf.SourceFileAccessor.Close();
|
||||
|
||||
string filename = System.IO.Path.Combine(new string[] { projdir, pf.DestinationFileName });
|
||||
string filedir = System.IO.Path.GetDirectoryName(filename);
|
||||
if (!System.IO.Directory.Exists(filedir))
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(filedir);
|
||||
}
|
||||
|
||||
System.IO.File.WriteAllBytes(System.IO.Path.Combine(new string[] { projdir, pf.DestinationFileName }), data);
|
||||
}
|
||||
|
||||
Document.Save(project, new VisualStudioProjectDataFormat(), new FileAccessor(projdir + "/" + project.Title + ".ueproj", true, true), true);
|
||||
project.BasePath = projdir;
|
||||
}
|
||||
|
||||
writer.WriteLine("Global");
|
||||
@ -226,5 +253,18 @@ namespace UniversalEditor.DataFormats.Solution.Microsoft.VisualStudio
|
||||
writer.WriteLine("\tEndGlobalSection");
|
||||
writer.WriteLine("EndGlobal");
|
||||
}
|
||||
|
||||
private string GetFileExtensionForProjectType(ProjectType.ProjectTypeCollection projectTypes)
|
||||
{
|
||||
ProjectType projectType = null;
|
||||
if (projectTypes.Count > 0)
|
||||
projectType = projectTypes[0];
|
||||
|
||||
if (projectType?.ProjectFileExtension != null)
|
||||
{
|
||||
return projectType.ProjectFileExtension;
|
||||
}
|
||||
return ".ueproj";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user