Browse Source

Let IViewContent decide whether it should close together with the solution

pull/2/head
Daniel Grunwald 15 years ago
parent
commit
6ca892eb11
  1. 6
      src/AddIns/BackendBindings/Scripting/Test/Utils/MockViewContent.cs
  2. 4
      src/AddIns/BackendBindings/WixBinding/Test/Utils/MockViewContent.cs
  3. 5
      src/AddIns/BackendBindings/WixBinding/Test/Utils/MockWorkbench.cs
  4. 4
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockViewContent.cs
  5. 5
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockWorkbench.cs
  6. 4
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Test/Designer/MockViewContend.cs
  7. 8
      src/Main/Base/Project/Src/Gui/AbstractViewContent.cs
  8. 5
      src/Main/Base/Project/Src/Gui/IViewContent.cs
  9. 28
      src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.cs
  10. 6
      src/Main/Base/Project/Src/Util/FakeXmlViewContent.cs

6
src/AddIns/BackendBindings/Scripting/Test/Utils/MockViewContent.cs

@ -47,6 +47,12 @@ namespace ICSharpCode.Scripting.Tests.Utils
} }
} }
public bool CloseWithSolution {
get {
throw new NotImplementedException();
}
}
public ICollection<IViewContent> SecondaryViewContents { public ICollection<IViewContent> SecondaryViewContents {
get { return secondaryViewContents; } get { return secondaryViewContents; }
} }

4
src/AddIns/BackendBindings/WixBinding/Test/Utils/MockViewContent.cs

@ -141,6 +141,10 @@ namespace WixBinding.Tests.Utils
} }
} }
public bool CloseWithSolution {
get { throw new NotImplementedException(); }
}
public bool IsDirty { public bool IsDirty {
get { get {
throw new NotImplementedException(); throw new NotImplementedException();

5
src/AddIns/BackendBindings/WixBinding/Test/Utils/MockWorkbench.cs

@ -196,5 +196,10 @@ namespace WixBinding.Tests.Utils
throw new NotImplementedException(); throw new NotImplementedException();
} }
} }
public bool CloseAllSolutionViews()
{
throw new NotImplementedException();
}
} }
} }

4
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockViewContent.cs

@ -113,6 +113,10 @@ namespace XmlEditor.Tests.Utils
} }
} }
public bool CloseWithSolution {
get { throw new NotImplementedException(); }
}
public System.Collections.Generic.ICollection<IViewContent> SecondaryViewContents { public System.Collections.Generic.ICollection<IViewContent> SecondaryViewContents {
get { get {
throw new NotImplementedException(); throw new NotImplementedException();

5
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockWorkbench.cs

@ -201,5 +201,10 @@ namespace XmlEditor.Tests.Utils
throw new NotImplementedException(); throw new NotImplementedException();
} }
} }
public bool CloseAllSolutionViews()
{
throw new NotImplementedException();
}
} }
} }

4
src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Test/Designer/MockViewContend.cs

@ -54,6 +54,10 @@ namespace ICSharpCode.Reports.Addin.Test.Designer
} }
} }
public bool CloseWithSolution {
get { throw new NotImplementedException(); }
}
public ICollection<IViewContent> SecondaryViewContents { public ICollection<IViewContent> SecondaryViewContents {
get { return secondaryViewContents; } get { return secondaryViewContents; }
} }

8
src/Main/Base/Project/Src/Gui/AbstractViewContent.cs

@ -554,5 +554,13 @@ namespace ICSharpCode.SharpDevelop.Gui
public virtual bool IsViewOnly { public virtual bool IsViewOnly {
get { return Files.Count == 0; } get { return Files.Count == 0; }
} }
public virtual bool CloseWithSolution {
get {
var fileName = this.PrimaryFileName;
return fileName == null
|| Project.ProjectService.OpenSolution.FindProjectContainingFile(fileName) != null;
}
}
} }
} }

5
src/Main/Base/Project/Src/Gui/IViewContent.cs

@ -138,6 +138,11 @@ namespace ICSharpCode.SharpDevelop.Gui
/// </summary> /// </summary>
bool IsViewOnly { get; } bool IsViewOnly { get; }
/// <summary>
/// Gets whether this view content should be closed when the solution is closed.
/// </summary>
bool CloseWithSolution { get; }
#region Secondary view content support #region Secondary view content support
/// <summary> /// <summary>
/// Gets the collection that stores the secondary view contents. /// Gets the collection that stores the secondary view contents.

28
src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.cs

@ -436,34 +436,16 @@ namespace ICSharpCode.SharpDevelop.Gui
public bool CloseAllSolutionViews() public bool CloseAllSolutionViews()
{ {
bool isSolutionWindow;
bool result = true; bool result = true;
WorkbenchSingleton.AssertMainThread(); WorkbenchSingleton.AssertMainThread();
try try {
{
closeAll = true; closeAll = true;
foreach (IWorkbenchWindow window in this.WorkbenchWindowCollection.ToArray()) foreach (IWorkbenchWindow window in this.WorkbenchWindowCollection.ToArray()) {
{ if (window.ActiveViewContent != null && window.ActiveViewContent.CloseWithSolution)
isSolutionWindow = false; result &= window.CloseWindow(false);
foreach (IViewContent content in window.ViewContents)
{
foreach (OpenedFile file in content.Files)
{
if (ProjectService.OpenSolution.FindProjectContainingFile(file.FileName) != null)
{
isSolutionWindow = true;
break;
}
}
}
if (isSolutionWindow)
result = window.CloseWindow(false) && result;
} }
} } finally {
finally
{
closeAll = false; closeAll = false;
OnActiveWindowChanged(this, EventArgs.Empty); OnActiveWindowChanged(this, EventArgs.Empty);
} }

6
src/Main/Base/Project/Src/Util/FakeXmlViewContent.cs

@ -154,6 +154,12 @@ namespace ICSharpCode.SharpDevelop.Util
} }
} }
bool IViewContent.CloseWithSolution {
get {
throw new NotImplementedException();
}
}
System.Collections.Generic.ICollection<IViewContent> IViewContent.SecondaryViewContents { System.Collections.Generic.ICollection<IViewContent> IViewContent.SecondaryViewContents {
get { get {
throw new NotImplementedException(); throw new NotImplementedException();

Loading…
Cancel
Save