Browse Source

NAnt pad now supports build files that are not part of a project.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.1@2343 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 19 years ago
parent
commit
7b039c6368
  1. 8
      src/AddIns/Misc/NAntAddIn/Project/NAnt.addin
  2. 1
      src/AddIns/Misc/NAntAddIn/Project/NAntAddIn.csproj
  3. 39
      src/AddIns/Misc/NAntAddIn/Project/Src/Commands/RunSelectedNAntCleanTargetCommand.cs
  4. 2
      src/AddIns/Misc/NAntAddIn/Project/Src/Gui/NAntBuildFileTreeNode.cs
  5. 49
      src/AddIns/Misc/NAntAddIn/Project/Src/Gui/NAntPadContent.cs
  6. 2
      src/AddIns/Misc/NAntAddIn/Project/Src/Gui/NAntPadTreeView.cs

8
src/AddIns/Misc/NAntAddIn/Project/NAnt.addin

@ -29,7 +29,6 @@ @@ -29,7 +29,6 @@
type="Menu">
<ComplexCondition action="Disable">
<And>
<Condition name="SolutionOpen"/>
<Not>
<Condition name="IsNAntRunning"/>
</Not>
@ -50,7 +49,6 @@ @@ -50,7 +49,6 @@
</ComplexCondition>
<ComplexCondition action="Disable">
<And>
<Condition name="SolutionOpen"/>
<Condition name="IsNAntRunning"/>
</And>
<MenuItem id = "StopNAnt"
@ -94,7 +92,6 @@ @@ -94,7 +92,6 @@
<Path name = "/SharpDevelop/Pads/NAntPad/Toolbar">
<ComplexCondition action="Disable">
<And>
<Condition name="SolutionOpen"/>
<Not>
<Condition name="IsNAntRunning"/>
</Not>
@ -104,15 +101,12 @@ @@ -104,15 +101,12 @@
tooltip = "${res:ICSharpCode.NAntAddIn.NAntPadContent.RunCommandBarButtonText}"
class = "ICSharpCode.NAntAddIn.Commands.RunSelectedNAntTargetCommand"/>
</ComplexCondition>
<Condition name = "SolutionOpen" action="Disable">
<ToolbarItem id = "Refresh"
icon = "Icons.16x16.BrowserRefresh"
tooltip = "${res:ICSharpCode.NAntAddIn.NAntPadContent.RefreshCommandBarButtonText}"
class = "ICSharpCode.NAntAddIn.Commands.RefreshNAntPadCommand"/>
</Condition>
<ComplexCondition action="Disable">
<And>
<Condition name="SolutionOpen"/>
<Condition name="IsNAntRunning"/>
</And>
<ToolbarItem id = "Stop"
@ -133,7 +127,7 @@ @@ -133,7 +127,7 @@
icon = "NAntAddIn.Icons.16x16.RunNAntClean"
label = "${res:ICSharpCode.NAntAddIn.RunCleanTargetMenuLabel}"
description = "Runs the clean target on the build file."
class = "ICSharpCode.NAntAddIn.Commands.RunNAntCleanTargetCommand"/>
class = "ICSharpCode.NAntAddIn.Commands.RunSelectedNAntCleanTargetCommand"/>
</Condition>
<Condition name="Ownerstate" ownerstate="BuildFileSelected">
<MenuItem id = "StopNAnt"

1
src/AddIns/Misc/NAntAddIn/Project/NAntAddIn.csproj

@ -41,6 +41,7 @@ @@ -41,6 +41,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Src\AddInOptions.cs" />
<Compile Include="Src\Commands\RunSelectedNAntCleanTargetCommand.cs" />
<Compile Include="Src\Gui\NAntAddInOptionPanel.cs" />
<Compile Include="Src\Commands\RunNAntCommand.cs" />
<Compile Include="Src\NAntAddInException.cs" />

39
src/AddIns/Misc/NAntAddIn/Project/Src/Commands/RunSelectedNAntCleanTargetCommand.cs

@ -0,0 +1,39 @@ @@ -0,0 +1,39 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.Core;
using ICSharpCode.NAntAddIn.Gui;
namespace ICSharpCode.NAntAddIn.Commands
{
/// <summary>
/// Runs the NAnt clean target for the file selected in the NAnt Pad view.
/// </summary>
public class RunSelectedNAntCleanTargetCommand : AbstractRunNAntCommand
{
/// <summary>
/// Runs the <see cref="RunSelectedNAntCleanTargetCommand"/>.
/// </summary>
public override void Run()
{
try {
NAntBuildFile buildFile = NAntPadContent.Instance.SelectedBuildFile;
if (buildFile != null) {
RunPreBuildSteps();
RunBuild(buildFile.FileName,
buildFile.Directory,
IsActiveConfigurationDebug,
"clean",
GetPadTextBoxArguments());
}
} catch (Exception ex) {
MessageService.ShowMessage(ex.Message);
}
}
}
}

2
src/AddIns/Misc/NAntAddIn/Project/Src/Gui/NAntBuildFileTreeNode.cs

@ -71,8 +71,10 @@ namespace ICSharpCode.NAntAddIn.Gui @@ -71,8 +71,10 @@ namespace ICSharpCode.NAntAddIn.Gui
{
StringBuilder nodeText = new StringBuilder();
if (projectName.Length > 0) {
nodeText.Append(projectName);
nodeText.Append(Path.DirectorySeparatorChar);
}
nodeText.Append(buildFile.FileName);
if (buildFile.DefaultTarget != null) {

49
src/AddIns/Misc/NAntAddIn/Project/Src/Gui/NAntPadContent.cs

@ -56,6 +56,8 @@ namespace ICSharpCode.NAntAddIn.Gui @@ -56,6 +56,8 @@ namespace ICSharpCode.NAntAddIn.Gui
ProjectService.SolutionClosed += SolutionClosed;
ProjectService.ProjectItemRemoved += ProjectItemRemoved;
ProjectService.ProjectItemAdded += ProjectItemAdded;
WorkbenchSingleton.Workbench.ViewOpened += WorkbenchViewOpened;
WorkbenchSingleton.Workbench.ViewClosed += WorkbenchViewClosed;
FileService.FileRenamed += FileRenamed;
FileService.FileRemoved += FileRemoved;
FileUtility.FileSaved += FileSaved;
@ -66,8 +68,7 @@ namespace ICSharpCode.NAntAddIn.Gui @@ -66,8 +68,7 @@ namespace ICSharpCode.NAntAddIn.Gui
// Due to lazy loading we have missed the solution loaded event
// so add it now.
AddSolutionToPad(ProjectService.OpenSolution);
Refresh();
}
/// <summary>
@ -97,6 +98,11 @@ namespace ICSharpCode.NAntAddIn.Gui @@ -97,6 +98,11 @@ namespace ICSharpCode.NAntAddIn.Gui
if (solution != null) {
treeView.AddSolution(solution);
}
foreach (IViewContent view in WorkbenchSingleton.Workbench.ViewContentCollection) {
if (IsStandaloneNAntBuildFile(view.FileName)) {
treeView.AddBuildFile(String.Empty, view.FileName);
}
}
}
/// <summary>
@ -152,6 +158,8 @@ namespace ICSharpCode.NAntAddIn.Gui @@ -152,6 +158,8 @@ namespace ICSharpCode.NAntAddIn.Gui
ProjectService.SolutionClosed -= SolutionClosed;
ProjectService.ProjectItemRemoved -= ProjectItemRemoved;
ProjectService.ProjectItemAdded -= ProjectItemAdded;
WorkbenchSingleton.Workbench.ViewOpened -= WorkbenchViewOpened;
WorkbenchSingleton.Workbench.ViewClosed -= WorkbenchViewClosed;
FileService.FileRenamed -= FileRenamed;
FileService.FileRemoved -= FileRemoved;
FileUtility.FileSaved -= FileSaved;
@ -170,7 +178,6 @@ namespace ICSharpCode.NAntAddIn.Gui @@ -170,7 +178,6 @@ namespace ICSharpCode.NAntAddIn.Gui
{
LoggingService.Debug("SolutionClosed.");
treeView.Clear();
UpdateToolbar();
}
void SolutionLoaded(object sender, SolutionEventArgs e)
@ -183,7 +190,6 @@ namespace ICSharpCode.NAntAddIn.Gui @@ -183,7 +190,6 @@ namespace ICSharpCode.NAntAddIn.Gui
{
if (solution != null) {
treeView.AddSolution(solution);
UpdateToolbar();
}
}
@ -236,6 +242,41 @@ namespace ICSharpCode.NAntAddIn.Gui @@ -236,6 +242,41 @@ namespace ICSharpCode.NAntAddIn.Gui
}
}
void WorkbenchViewOpened(object sender, ViewContentEventArgs e)
{
if (IsStandaloneNAntBuildFile(e.Content.FileName)) {
treeView.UpdateBuildFile(e.Content.FileName);
}
}
void WorkbenchViewClosed(object sender, ViewContentEventArgs e)
{
if (IsStandaloneNAntBuildFile(e.Content.FileName)) {
treeView.RemoveBuildFile(e.Content.FileName);
}
}
bool IsStandaloneNAntBuildFile(string fileName)
{
if (fileName != null) {
return NAntBuildFile.IsBuildFile(fileName) && !IsInProject(fileName);
}
return false;
}
bool IsInProject(string fileName)
{
Solution solution = ProjectService.OpenSolution;
if (solution != null) {
foreach (IProject project in solution.Projects) {
if (project.IsFileInProject(fileName)) {
return true;
}
}
}
return false;
}
void FileSaved(object sender, FileNameEventArgs e)
{
LoggingService.Debug("FileSaved.");

2
src/AddIns/Misc/NAntAddIn/Project/Src/Gui/NAntPadTreeView.cs

@ -153,6 +153,8 @@ namespace ICSharpCode.NAntAddIn.Gui @@ -153,6 +153,8 @@ namespace ICSharpCode.NAntAddIn.Gui
if (node != null) {
NAntBuildFile buildFile = new NAntBuildFile(fileName);
node.BuildFile = buildFile;
} else {
AddBuildFile(String.Empty, fileName);
}
}

Loading…
Cancel
Save