Permalink
Browse files

Let IViewContent decide whether it should close together with the sol…

…ution
  • Loading branch information...
dgrunwald committed Oct 21, 2010
1 parent 4e54652 commit 6ca892eb11af2d7a5d9623c286589f426b406b55
@@ -47,6 +47,12 @@ public MockViewContent()
}
}
+ public bool CloseWithSolution {
+ get {
+ throw new NotImplementedException();
+ }
+ }
+
public ICollection<IViewContent> SecondaryViewContents {
get { return secondaryViewContents; }
}
@@ -141,6 +141,10 @@ public void SwitchToThisWithoutSaveLoad(OpenedFile file, IViewContent oldView)
}
}
+ public bool CloseWithSolution {
+ get { throw new NotImplementedException(); }
+ }
+
public bool IsDirty {
get {
throw new NotImplementedException();
@@ -196,5 +196,10 @@ protected virtual void OnViewClosed(ViewContentEventArgs e)
throw new NotImplementedException();
}
}
+
+ public bool CloseAllSolutionViews()
+ {
+ throw new NotImplementedException();
+ }
}
}
@@ -113,6 +113,10 @@ protected virtual void OnIsDirtyChanged(EventArgs e)
}
}
+ public bool CloseWithSolution {
+ get { throw new NotImplementedException(); }
+ }
+
public System.Collections.Generic.ICollection<IViewContent> SecondaryViewContents {
get {
throw new NotImplementedException();
@@ -201,5 +201,10 @@ public void SetMemento(ICSharpCode.Core.Properties memento)
throw new NotImplementedException();
}
}
+
+ public bool CloseAllSolutionViews()
+ {
+ throw new NotImplementedException();
+ }
}
}
@@ -54,6 +54,10 @@ public object Control
}
}
+ public bool CloseWithSolution {
+ get { throw new NotImplementedException(); }
+ }
+
public ICollection<IViewContent> SecondaryViewContents {
get { return secondaryViewContents; }
}
@@ -554,5 +554,13 @@ public virtual INavigationPoint BuildNavPoint()
public virtual bool IsViewOnly {
get { return Files.Count == 0; }
}
+
+ public virtual bool CloseWithSolution {
+ get {
+ var fileName = this.PrimaryFileName;
+ return fileName == null
+ || Project.ProjectService.OpenSolution.FindProjectContainingFile(fileName) != null;
+ }
+ }
}
}
@@ -138,6 +138,11 @@ public interface IViewContent : IDisposable, ICanBeDirty, IServiceProvider
/// </summary>
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
/// <summary>
/// Gets the collection that stores the secondary view contents.
@@ -436,34 +436,16 @@ public void CloseAllViews()
public bool CloseAllSolutionViews()
{
- bool isSolutionWindow;
bool result = true;
WorkbenchSingleton.AssertMainThread();
- try
- {
+ try {
closeAll = true;
- foreach (IWorkbenchWindow window in this.WorkbenchWindowCollection.ToArray())
- {
- isSolutionWindow = 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;
+ foreach (IWorkbenchWindow window in this.WorkbenchWindowCollection.ToArray()) {
+ if (window.ActiveViewContent != null && window.ActiveViewContent.CloseWithSolution)
+ result &= window.CloseWindow(false);
}
- }
- finally
- {
+ } finally {
closeAll = false;
OnActiveWindowChanged(this, EventArgs.Empty);
}
@@ -154,6 +154,12 @@ void IViewContent.Load(OpenedFile file, Stream stream)
}
}
+ bool IViewContent.CloseWithSolution {
+ get {
+ throw new NotImplementedException();
+ }
+ }
+
System.Collections.Generic.ICollection<IViewContent> IViewContent.SecondaryViewContents {
get {
throw new NotImplementedException();

0 comments on commit 6ca892e

Please sign in to comment.