diff options
author | Therzok <teromario@yahoo.com> | 2013-07-30 19:31:46 +0400 |
---|---|---|
committer | Therzok <teromario@yahoo.com> | 2013-07-30 19:31:46 +0400 |
commit | 97238ed93a3d22a4f4fc65592e4a9c14489d52c5 (patch) | |
tree | 83ca6bdec9f8a342f68be3a7c4ec3fa37f506b2a /main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Navigation | |
parent | 70fb324516aea44cee10f8cdbeb79a2fc9032877 (diff) |
[IDE] Fixed issues with closed documents list.
Changed to a Stack.
Implemented support for AssemblyBrowser.
Purposefully ignoring Disassembly view.
API changes to NavigationPoint.
Refactored AssemblyBrowser filling.
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Navigation')
5 files changed, 30 insertions, 113 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Navigation/ClosedDocumentNavigationPoint.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Navigation/ClosedDocumentNavigationPoint.cs deleted file mode 100644 index 071514ca29..0000000000 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Navigation/ClosedDocumentNavigationPoint.cs +++ /dev/null @@ -1,95 +0,0 @@ -//
-// ClosedDocumentNavigationPoint.cs
-//
-// Author:
-// Therzok <therzok@gmail.com>
-//
-// Copyright (c) 2013 Xamarin Inc. (http://xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using MonoDevelop.Core;
-using MonoDevelop.Ide.Gui;
-
-namespace MonoDevelop.Ide.Navigation
-{
- public class ClosedDocumentNavigationPoint : NavigationPoint
- {
- FilePath fileName;
- int position;
-
- public ClosedDocumentNavigationPoint (FilePath fileName, int position)
- {
- this.fileName = fileName;
- this.position = position;
- }
-
- public override void Dispose ()
- {
- if (fileName != null) {
- fileName = null;
- }
- base.Dispose ();
- }
-
- FilePath FileName {
- get { return fileName; }
- }
-
- public override void Show ()
- {
- DoShow ();
- Dispose ();
- }
-
- protected virtual Document DoShow ()
- {
- Document doc = IdeApp.Workbench.OpenDocument (fileName, true);
- IdeApp.Workbench.ReorderTab (IdeApp.Workbench.Documents.IndexOf (doc), position);
- return doc;
- }
-
- public override string DisplayName {
- get {
- return System.IO.Path.GetFileName ((string) fileName);
- }
- }
-
- public override bool Equals (object o)
- {
- ClosedDocumentNavigationPoint dp = o as ClosedDocumentNavigationPoint;
- return dp != null && ((FileName != FilePath.Null && FileName == dp.FileName));
- }
-
- public override int GetHashCode ()
- {
- return (FileName != FilePath.Null ? FileName.GetHashCode () : 0);
- }
-
- internal bool HandleRenameEvent (string oldName, string newName)
- {
- if (oldName == fileName) {
- fileName = newName;
- return true;
- }
- return false;
- }
- }
-}
-
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Navigation/DocumentNavigationPoint.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Navigation/DocumentNavigationPoint.cs index 5235e1a460..ac20d06a30 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Navigation/DocumentNavigationPoint.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Navigation/DocumentNavigationPoint.cs @@ -79,15 +79,19 @@ namespace MonoDevelop.Ide.Navigation { DoShow (); } + + public override Document ShowDocument () + { + return DoShow (); + } protected virtual Document DoShow () { if (doc != null) { doc.Select (); return doc; - } else { - return IdeApp.Workbench.OpenDocument (fileName, true); } + return IdeApp.Workbench.OpenDocument (fileName, true); } public override string DisplayName { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Navigation/NavigationHistoryItem.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Navigation/NavigationHistoryItem.cs index a9f855ec6b..72665babf7 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Navigation/NavigationHistoryItem.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Navigation/NavigationHistoryItem.cs @@ -59,7 +59,7 @@ namespace MonoDevelop.Ide.Navigation if (!NavigationHistoryService.IsCurrent (this)) NavigationHistoryService.MoveTo (this); } - NavigationPoint.Show (); + NavigationPoint.ShowDocument (); } public string DisplayName { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Navigation/NavigationHistoryService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Navigation/NavigationHistoryService.cs index 9dbdeaa0c0..283494e865 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Navigation/NavigationHistoryService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Navigation/NavigationHistoryService.cs @@ -40,8 +40,8 @@ namespace MonoDevelop.Ide.Navigation public static class NavigationHistoryService { static HistoryList history = new HistoryList (); - static HistoryList closedHistory = new HistoryList (); - + static Stack<Tuple<NavigationPoint, int>> closedHistory = new Stack<Tuple<NavigationPoint, int>> (); + //used to prevent re-logging the current point during a switch static bool switching; @@ -61,12 +61,12 @@ namespace MonoDevelop.Ide.Navigation OnHistoryChanged (); }; - IdeApp.Workbench.DocumentClosed += delegate(object sender, DocumentEventArgs e) { - ClosedDocumentNavigationPoint point = new ClosedDocumentNavigationPoint ( - e.Document.FileName, IdeApp.Workbench.Documents.IndexOf (IdeApp.Workbench.ActiveDocument) - ); - NavigationHistoryItem item = new NavigationHistoryItem (point); - closedHistory.AddPoint (item); + IdeApp.Workbench.DocumentClosing += delegate(object sender, DocumentEventArgs e) { + NavigationPoint point = GetNavPointForDoc (e.Document); + if (point == null) + return; + + closedHistory.Push (new Tuple<NavigationPoint, int> (point, IdeApp.Workbench.Documents.IndexOf (e.Document))); OnClosedHistoryChanged (); }; @@ -216,12 +216,14 @@ namespace MonoDevelop.Ide.Navigation #region Closed Document List public static bool HasClosedDocuments { - get { return closedHistory.Current != null; } + get { return closedHistory.Count != 0; } } public static void OpenLastClosedDocument () { - if (closedHistory.Current != null) { - closedHistory.Current.Show (); + if (HasClosedDocuments) { + var tuple = closedHistory.Pop (); + var doc = tuple.Item1.ShowDocument (); + IdeApp.Workbench.ReorderTab (IdeApp.Workbench.Documents.IndexOf (doc), tuple.Item2); } } @@ -346,7 +348,7 @@ namespace MonoDevelop.Ide.Navigation historyChanged &= (dp != null && dp.HandleRenameEvent (args.OldName, args.NewName)); } foreach (NavigationHistoryItem point in history) { - ClosedDocumentNavigationPoint cdp = point.NavigationPoint as ClosedDocumentNavigationPoint; + DocumentNavigationPoint cdp = point.NavigationPoint as DocumentNavigationPoint; closedHistoryChanged &= (cdp != null && cdp.HandleRenameEvent (args.OldName, args.NewName)); } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Navigation/NavigationPoint.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Navigation/NavigationPoint.cs index e3e2a8b202..b19f53fefc 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Navigation/NavigationPoint.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Navigation/NavigationPoint.cs @@ -26,8 +26,7 @@ // THE SOFTWARE. using System; -using System.Collections.Generic; -using MonoDevelop.Ide.Gui.Content; +using MonoDevelop.Ide.Gui; namespace MonoDevelop.Ide.Navigation { @@ -35,8 +34,15 @@ namespace MonoDevelop.Ide.Navigation { public abstract string DisplayName { get; } //public abstract string Tooltip { get; } - + + [Obsolete ("Will be removed. Please use ShowDocument.")] public abstract void Show (); + + public virtual Document ShowDocument () + { + Show (); + return null; + } // used for fuzzy matching to decide whether to replace an existing nav point // e.g if user just moves around a little, we don't want to add too many points |