-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: https://fsprojectextender.svn.codeplex.com/svn@47654 0e26…
…99bc-83d4-4a8f-98e7-55e24ab8c7a5
- Loading branch information
SND\svlasova_cp
authored and
SND\svlasova_cp
committed
Jun 22, 2010
1 parent
9eaea18
commit 6b7d017
Showing
95 changed files
with
8,231 additions
and
0 deletions.
There are no files selected for viewing
161 changes: 161 additions & 0 deletions
161
tags/r0.9.3.0/ProjectExtender/Commands/ProjectExtender.cs
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,161 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Microsoft.VisualStudio.Shell; | ||
using Microsoft.VisualStudio.Shell.Interop; | ||
using Microsoft.VisualStudio; | ||
using System.ComponentModel.Design; | ||
using System.Xml; | ||
using System.Runtime.InteropServices; | ||
using OleConstants = Microsoft.VisualStudio.OLE.Interop.Constants; | ||
using Microsoft.Build.BuildEngine; | ||
using Microsoft.VisualStudio.FSharp.ProjectSystem; | ||
|
||
namespace FSharp.ProjectExtender.Commands | ||
{ | ||
public class ProjectExtender : OleMenuCommand | ||
{ | ||
public ProjectExtender() | ||
: base(Execute, new CommandID(Constants.guidProjectExtenderCmdSet, (int)Constants.cmdidProjectExtender)) | ||
{ | ||
BeforeQueryStatus += new EventHandler(QueryStatus); | ||
} | ||
|
||
private const string enable_extender_text = "Enable F# project extender"; | ||
private const string disable_extender_text = "Disable F# project extender"; | ||
private const string disable_warning = "For projects with subdirectories it may or may not be possible to keep compilation order as defined in the extender.\n\n Press OK to proceed or Cancel to cancel"; | ||
|
||
/// <summary> | ||
/// Modifies caption on the project extender command | ||
/// </summary> | ||
/// <param name="sender"></param> | ||
/// <param name="e"></param> | ||
void QueryStatus(object sender, EventArgs e) | ||
{ | ||
if (GlobalServices.get_current_project() is IProjectManager) | ||
((OleMenuCommand)sender).Text = disable_extender_text; | ||
else | ||
((OleMenuCommand)sender).Text = enable_extender_text; | ||
} | ||
|
||
private static void Execute(object sender, EventArgs e) | ||
{ | ||
var project = GlobalServices.get_current_project(); | ||
if (project is IProjectManager) | ||
{ | ||
Guid guid = Guid.Empty; | ||
int result; | ||
ErrorHandler.ThrowOnFailure(GlobalServices.shell.ShowMessageBox(0, ref guid, | ||
null, | ||
disable_warning, | ||
null, | ||
0, | ||
OLEMSGBUTTON.OLEMSGBUTTON_OKCANCEL, | ||
OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_SECOND, | ||
OLEMSGICON.OLEMSGICON_WARNING, | ||
0, | ||
out result)); | ||
if (result == NativeMethods.IDOK) | ||
ModifyProject(project, disable_extender); | ||
} | ||
else | ||
ModifyProject(project, enable_extender); | ||
} | ||
|
||
/// <summary> | ||
/// Modifies the loaded project by changing the project's proj file | ||
/// </summary> | ||
/// <param name="vsProject">project to be modified</param> | ||
/// <param name="effector"></param> | ||
private static void ModifyProject(IVsProject vsProject, Func<string, string> effector) | ||
{ | ||
var project = GlobalServices.getFSharpProjectNode(vsProject); | ||
|
||
set_ProjectTypeGuids( | ||
project, | ||
effector( | ||
get_ProjectTypeGuids(project) | ||
)); | ||
|
||
// Set dirty flag to true to force project save | ||
project.SetProjectFileDirty(true); | ||
|
||
// Unload the project - also saves the modifications | ||
ErrorHandler.ThrowOnFailure(GlobalServices.solution.CloseSolutionElement((uint)__VSSLNCLOSEOPTIONS.SLNCLOSEOPT_UnloadProject, project, 0)); | ||
|
||
// Reload the project | ||
GlobalServices.dte.ExecuteCommand("Project.ReloadProject", ""); | ||
} | ||
|
||
private static string get_ProjectTypeGuids(ProjectNode project) | ||
{ | ||
#if VS2008 | ||
foreach (BuildPropertyGroup group in project.BuildProject.PropertyGroups) | ||
{ | ||
foreach (BuildProperty property in group) | ||
{ | ||
if (property.Name == "ProjectTypeGuids") | ||
{ | ||
group.RemoveProperty(property); | ||
return property.Value; | ||
} | ||
} | ||
} | ||
return null; | ||
#elif VS2010 | ||
var property = project.BuildProject.Properties.FirstOrDefault(prop => prop.Name == "ProjectTypeGuids"); | ||
if (property == null) | ||
return null; | ||
return property.EvaluatedValue; | ||
#endif | ||
} | ||
|
||
private static void set_ProjectTypeGuids(ProjectNode project, string value) | ||
{ | ||
#if VS2008 | ||
foreach (BuildPropertyGroup group in project.BuildProject.PropertyGroups) | ||
{ | ||
foreach (BuildProperty property in group) | ||
{ | ||
if (property.Name == "ProjectGuid") | ||
{ | ||
group.AddNewProperty("ProjectTypeGuids", value); | ||
return; | ||
} | ||
} | ||
} | ||
#elif VS2010 | ||
project.BuildProject.Xml.AddProperty("ProjectTypeGuids", value); | ||
#endif | ||
} | ||
|
||
/// <summary> | ||
/// Modifies the XML to enable the extender | ||
/// </summary> | ||
/// <param name="project"></param> | ||
private static string enable_extender(string old_types) | ||
{ | ||
if (old_types == null) | ||
return "{" + Constants.guidProjectExtenderFactoryString + "};{" + Constants.guidFSharpProjectString + "}"; | ||
|
||
// parse the existing guid list | ||
var types = new List<string>(old_types.Split(';')); | ||
|
||
// prepend the guid list with the extender project type | ||
types.Insert(0, '{' + Constants.guidProjectExtenderFactoryString + '}'); | ||
|
||
// format the guid list | ||
var typestring = ""; | ||
types.ForEach(type => typestring += ';' + type); | ||
|
||
return typestring.Substring(1); | ||
} | ||
|
||
private static string disable_extender(string old_types) | ||
{ | ||
return old_types.Replace('{' + Constants.guidProjectExtenderFactoryString + "};", ""); | ||
} | ||
|
||
} | ||
} |
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,35 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Microsoft.VisualStudio; | ||
using System.ComponentModel.Design; | ||
using Microsoft.VisualStudio.Shell.Interop; | ||
using Microsoft.VisualStudio.Shell; | ||
|
||
namespace FSharp.ProjectExtender.Commands | ||
{ | ||
public class Refresh : OleMenuCommand | ||
{ | ||
public Refresh() | ||
: base(Execute, new CommandID(Constants.guidProjectExtenderCmdSet, (int)Constants.cmdidProjectRefresh)) | ||
{ | ||
BeforeQueryStatus += new EventHandler(QueryStatus); | ||
} | ||
|
||
void QueryStatus(object sender, EventArgs e) | ||
{ | ||
Visible = GlobalServices.get_current_project() is IProjectManager; | ||
} | ||
|
||
private static void Execute(object sender, EventArgs e) | ||
{ | ||
var project = GlobalServices.get_current_project(); | ||
if (project != null) | ||
{ | ||
((IProjectManager)project).Refresh(); | ||
} | ||
} | ||
|
||
} | ||
} |
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,39 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Microsoft.VisualStudio.Shell; | ||
using System.ComponentModel.Design; | ||
using Microsoft.VisualStudio.Shell.Interop; | ||
using Microsoft.VisualStudio; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace FSharp.ProjectExtender.Commands | ||
{ | ||
public class ShowAll : OleMenuCommand | ||
{ | ||
|
||
public ShowAll() | ||
: base(Execute, new CommandID(Constants.guidProjectExtenderCmdSet, (int)Constants.cmdidProjectShowAll)) | ||
{ | ||
BeforeQueryStatus += new EventHandler(QueryStatus); | ||
} | ||
|
||
/// <summary> | ||
/// </summary> | ||
/// <param name="sender"></param> | ||
/// <param name="e"></param> | ||
void QueryStatus(object sender, EventArgs e) | ||
{ | ||
Visible = GlobalServices.get_current_project() is IProjectManager; | ||
} | ||
|
||
private static void Execute(object sender, EventArgs e) | ||
{ | ||
var project = GlobalServices.get_current_project(); | ||
if (project != null) | ||
((IProjectManager)project).FlipShowAll(); | ||
} | ||
|
||
} | ||
} |
107 changes: 107 additions & 0 deletions
107
tags/r0.9.3.0/ProjectExtender/CompileOrderDialog/EditDependenciesDialog.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
tags/r0.9.3.0/ProjectExtender/CompileOrderDialog/EditDependenciesDialog.cs
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,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Data; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Windows.Forms; | ||
|
||
namespace FSharp.ProjectExtender | ||
{ | ||
public partial class EditDependenciesDialog : Form | ||
{ | ||
public EditDependenciesDialog() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
} |
Oops, something went wrong.