[mapguide-commits] r7925 - in trunk/Tools/Maestro: Maestro.Base Maestro.Base/UI Maestro.Shared.UI

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Sun Nov 24 07:55:50 PST 2013


Author: jng
Date: 2013-11-24 07:55:48 -0800 (Sun, 24 Nov 2013)
New Revision: 7925

Modified:
   trunk/Tools/Maestro/Maestro.Base/UI/SiteExplorer.cs
   trunk/Tools/Maestro/Maestro.Base/Workbench.cs
   trunk/Tools/Maestro/Maestro.Shared.UI/WorkbenchBase.cs
Log:
#2326: Add support so that when an active editor tab has changed, the Site Explorer will auto-focus on the resource that the new active editor tab is editing.

Modified: trunk/Tools/Maestro/Maestro.Base/UI/SiteExplorer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/UI/SiteExplorer.cs	2013-11-24 15:52:37 UTC (rev 7924)
+++ trunk/Tools/Maestro/Maestro.Base/UI/SiteExplorer.cs	2013-11-24 15:55:48 UTC (rev 7925)
@@ -64,8 +64,24 @@
             var clip = ServiceRegistry.GetService<ClipboardService>();
             _model = new RepositoryTreeModel(_connManager, trvResources, omgr, clip);
             trvResources.Model = _model;
+
+            Workbench wb = Workbench.Instance;
+            wb.ActiveDocumentChanged += OnActiveDocumentChanged;
         }
 
+        void OnActiveDocumentChanged(object sender, EventArgs e)
+        {
+            Workbench wb = Workbench.Instance;
+            var ed = wb.ActiveEditor;
+            if (ed != null)
+            {
+                if (ed.Resource != null && ed.EditorService != null)
+                {
+                    FocusOnNode(ed.Resource.CurrentConnection.DisplayName, ed.EditorService.ResourceID);
+                }
+            }
+        }
+
         void OnIdle(object sender, EventArgs e)
         {
             foreach (var item in tsSiteExplorer.Items)
@@ -338,6 +354,19 @@
             }
         }
 
+        public void FocusOnNode(string connectionName, string resourceId)
+        {
+            var path = _model.GetPathFromResourceId(connectionName, resourceId);
+            if (path != null)
+            {
+                var node = trvResources.FindNode(path, true);
+                if (node != null)
+                {
+                    trvResources.ScrollTo(node);
+                }
+            }
+        }
+
         public void FlagNode(string connectionName, string resourceId, NodeFlagAction action)
         {
             var path = _model.GetPathFromResourceId(connectionName, resourceId);

Modified: trunk/Tools/Maestro/Maestro.Base/Workbench.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Workbench.cs	2013-11-24 15:52:37 UTC (rev 7924)
+++ trunk/Tools/Maestro/Maestro.Base/Workbench.cs	2013-11-24 15:55:48 UTC (rev 7925)
@@ -94,8 +94,16 @@
             get { return this.ActiveDocumentView as IEditorViewContent; }
         }
 
+        /// <summary>
+        /// Raised when the active document has changed
+        /// </summary>
+        public event EventHandler ActiveDocumentChanged;
+
         protected override void OnViewActivated(object sender, IViewContent content)
         {
+            var h = this.ActiveDocumentChanged;
+            if (h != null)
+                h(this, EventArgs.Empty);
         }
 
         public Workbench(IWorkbenchInitializer init) : base(init) { }

Modified: trunk/Tools/Maestro/Maestro.Shared.UI/WorkbenchBase.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Shared.UI/WorkbenchBase.cs	2013-11-24 15:52:37 UTC (rev 7924)
+++ trunk/Tools/Maestro/Maestro.Shared.UI/WorkbenchBase.cs	2013-11-24 15:55:48 UTC (rev 7925)
@@ -58,6 +58,7 @@
             this.WindowState = init.StartMaximized ? FormWindowState.Maximized : FormWindowState.Normal;
 
             contentPanel = new DockPanel();
+            contentPanel.ActiveDocumentChanged += OnActiveDocumentChanged;
             contentPanel.DocumentStyle = DocumentStyle.DockingWindow;
             contentPanel.ShowDocumentIcon = true;
             contentPanel.Dock = DockStyle.Fill;
@@ -97,6 +98,17 @@
             Application.Idle += OnApplicationIdle;
         }
 
+        void OnActiveDocumentChanged(object sender, EventArgs e)
+        {
+            var doc = contentPanel.ActiveDocument as DockContent;
+            if (doc != null)
+            {
+                var vc = doc.Tag as IViewContent;
+                if (vc != null)
+                    OnViewActivated(this, vc);
+            }
+        }
+
         const string BASE_TOOLSTRIP = "Base"; //NOXLATE
 
         protected virtual void OnViewActivated(object sender, IViewContent content) { }



More information about the mapguide-commits mailing list