[mapguide-commits] r7195 - in trunk/Tools/Maestro: Install Maestro Maestro.AddIn.Scripting/Commands Maestro.AddIn.Scripting/Lang/Python Maestro.AddIn.Scripting/Services Maestro.AddIn.Scripting/UI Maestro.Base/Services Maestro.Base/UI Maestro.Editors Maestro.Editors/Common Maestro.Editors/Common/Expression Maestro.Editors/FeatureSource/Providers/Wms Maestro.Editors/MapDefinition Maestro.Shared.UI ProviderTemplate Thirdparty/SharpDevelop/ICSharpCode.TextEditor Thirdparty/SharpDevelop/ICSharpCode.TextEditor/Src Thirdparty/SharpDevelop/ICSharpCode.TextEditor/Src/Document/TextBufferStrategy Thirdparty/SharpDevelop/ICSharpCode.TextEditor/Src/Gui

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Nov 6 08:18:46 PST 2012


Author: jng
Date: 2012-11-06 08:18:45 -0800 (Tue, 06 Nov 2012)
New Revision: 7195

Added:
   trunk/Tools/Maestro/Maestro.Editors/Common/AutoCompletion.cs
   trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/Src/PlatformUtil.cs
Modified:
   trunk/Tools/Maestro/Install/Maestro.nsi
   trunk/Tools/Maestro/Maestro.AddIn.Scripting/Commands/StartupCommand.cs
   trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsole.cs
   trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsoleHost.cs
   trunk/Tools/Maestro/Maestro.AddIn.Scripting/Services/ScriptingClasses.cs
   trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.cs
   trunk/Tools/Maestro/Maestro.Base/Services/ResourcePreviewerFactory.cs
   trunk/Tools/Maestro/Maestro.Base/UI/MapPreviewDialog.Designer.cs
   trunk/Tools/Maestro/Maestro.Base/UI/ResourcePropertiesDialog.Designer.cs
   trunk/Tools/Maestro/Maestro.Editors/Common/Expression/FdoExpressionCompletionDataProvider.cs
   trunk/Tools/Maestro/Maestro.Editors/Common/ExpressionEditor.cs
   trunk/Tools/Maestro/Maestro.Editors/Common/ITextEditor.cs
   trunk/Tools/Maestro/Maestro.Editors/Common/TextEditor.cs
   trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Wms/WmsAdvancedConfigurationDialog.cs
   trunk/Tools/Maestro/Maestro.Editors/Maestro.Editors.csproj
   trunk/Tools/Maestro/Maestro.Editors/MapDefinition/LiveMapDefinitionEditorCtrl.Designer.cs
   trunk/Tools/Maestro/Maestro.Shared.UI/Maestro.Shared.UI.csproj
   trunk/Tools/Maestro/Maestro/Maestro.csproj
   trunk/Tools/Maestro/Maestro/Maestro.sh
   trunk/Tools/Maestro/ProviderTemplate/ProviderTemplate.csproj
   trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/ICSharpCode.TextEditor.csproj
   trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/Src/Document/TextBufferStrategy/GapTextBufferStrategy.cs
   trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/Src/Gui/TextEditorControl.cs
Log:
Maestro beta release preparation changes:
 - Mono workarounds and fixes:
   - Workarounds for ICSharpCode.TextEditor
   - Remove illegal SplitContainer casts from designer code
   - Export MONO_THREADS_PER_CPU in Maestro.sh
 - Remove LocalNative provider dll from installer listing (as users will now be expected to roll their own via ProviderTemplate.exe)
 - Move the IronPython globals setup to the first Write() call in PythonConsole
 - Abstract out the ITextEditor into a default implementation and a mono-friendly one. The correct implementation is selected by the TextEditorFactory utility class
 - Fix NRE when populating matching FDO conditions in auto-complete for the Expression Editor

Modified: trunk/Tools/Maestro/Install/Maestro.nsi
===================================================================
--- trunk/Tools/Maestro/Install/Maestro.nsi	2012-11-06 10:00:45 UTC (rev 7194)
+++ trunk/Tools/Maestro/Install/Maestro.nsi	2012-11-06 16:18:45 UTC (rev 7195)
@@ -209,7 +209,6 @@
     File "${INST_OUTPUT_MAESTRO}\IronPython.Modules.dll"
     File "${INST_OUTPUT_MAESTRO}\Maestro.Base.dll"
     File "${INST_OUTPUT_MAESTRO}\Maestro.Editors.dll"
-    File "${INST_OUTPUT_MAESTRO}\Maestro.LiveMapEditor.exe"
     File "${INST_OUTPUT_MAESTRO}\Maestro.Login.dll"
     File "${INST_OUTPUT_MAESTRO}\Maestro.MapViewer.dll"
     File "${INST_OUTPUT_MAESTRO}\Maestro.Packaging.dll"
@@ -221,7 +220,6 @@
     File "${INST_OUTPUT_MAESTRO}\OSGeo.MapGuide.ExtendedObjectModels.dll"
     File "${INST_OUTPUT_MAESTRO}\OSGeo.MapGuide.MaestroAPI.dll"
     File "${INST_OUTPUT_MAESTRO}\OSGeo.MapGuide.MaestroAPI.Http.dll"
-    File "${INST_OUTPUT_MAESTRO}\OSGeo.MapGuide.MaestroAPI.Native32-2.2.0.dll"
     File "${INST_OUTPUT_MAESTRO}\OSGeo.MapGuide.ObjectModels.LayerDefinition-1.1.0.dll"
     File "${INST_OUTPUT_MAESTRO}\OSGeo.MapGuide.ObjectModels.LayerDefinition-1.2.0.dll"
     File "${INST_OUTPUT_MAESTRO}\OSGeo.MapGuide.ObjectModels.LayerDefinition-1.3.0.dll"
@@ -254,7 +252,6 @@
     File "${INST_OUTPUT_MAESTRO}\Maestro.Shared.UI.pdb"
     File "${INST_OUTPUT_MAESTRO}\OSGeo.MapGuide.MaestroAPI.pdb"
     File "${INST_OUTPUT_MAESTRO}\OSGeo.MapGuide.MaestroAPI.Http.pdb"
-    File "${INST_OUTPUT_MAESTRO}\OSGeo.MapGuide.MaestroAPI.Native32-2.2.0.pdb"
     File "${INST_OUTPUT_MAESTRO}\OSGeo.MapGuide.ObjectModels.LayerDefinition-1.1.0.pdb"
     File "${INST_OUTPUT_MAESTRO}\OSGeo.MapGuide.ObjectModels.LayerDefinition-1.2.0.pdb"
     File "${INST_OUTPUT_MAESTRO}\OSGeo.MapGuide.ObjectModels.LayerDefinition-1.3.0.pdb"
@@ -277,6 +274,7 @@
     File "${INST_OUTPUT_MAESTRO}\LocalConfigure.exe"
     File "${INST_OUTPUT_MAESTRO}\MgCooker.exe"
     File "${INST_OUTPUT_MAESTRO}\MgCookerCmd.exe"
+    File "${INST_OUTPUT_MAESTRO}\Maestro.LiveMapEditor.exe"
     File "${INST_OUTPUT_MAESTRO}\MaestroFsPreview.exe"
     File "${INST_OUTPUT_MAESTRO}\RtMapInspector.exe"
 

Modified: trunk/Tools/Maestro/Maestro/Maestro.csproj
===================================================================
--- trunk/Tools/Maestro/Maestro/Maestro.csproj	2012-11-06 10:00:45 UTC (rev 7194)
+++ trunk/Tools/Maestro/Maestro/Maestro.csproj	2012-11-06 16:18:45 UTC (rev 7195)
@@ -147,6 +147,7 @@
     <EmbeddedResource Include="Strings.resx">
       <Generator>ResXFileCodeGenerator</Generator>
       <LastGenOutput>Strings.Designer.cs</LastGenOutput>
+      <SubType>Designer</SubType>
     </EmbeddedResource>
     <None Include="..\OSGeo.MapGuide.MaestroAPI\Schemas\ApplicationDefinition-1.0.0.xsd">
       <Link>Schemas\ApplicationDefinition-1.0.0.xsd</Link>

Modified: trunk/Tools/Maestro/Maestro/Maestro.sh
===================================================================
--- trunk/Tools/Maestro/Maestro/Maestro.sh	2012-11-06 10:00:45 UTC (rev 7194)
+++ trunk/Tools/Maestro/Maestro/Maestro.sh	2012-11-06 16:18:45 UTC (rev 7195)
@@ -1,2 +1,3 @@
 #!/bin/sh
+export MONO_THREADS_PER_CPU=2000
 mono Maestro.exe

Modified: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Commands/StartupCommand.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Commands/StartupCommand.cs	2012-11-06 10:00:45 UTC (rev 7194)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Commands/StartupCommand.cs	2012-11-06 16:18:45 UTC (rev 7195)
@@ -22,10 +22,20 @@
 
             Workbench.WorkbenchInitialized += (sender, e) =>
             {
+                var wb = Workbench.Instance;
+                wb.FormClosed += OnWorkbenchClosed;
                 var mgr = ServiceRegistry.GetService<ViewContentManager>();
                 if (Props.Get(ScriptingConfigProperties.ShowIronPythonConsole, ScriptingConfigProperties.DefaultShowIronPythonConsole))
-                    mgr.OpenContent<IronPythonRepl>(ViewRegion.Bottom);
+                    _repl = mgr.OpenContent<IronPythonRepl>(ViewRegion.Bottom);
             };
         }
+
+        private IronPythonRepl _repl;
+
+        void OnWorkbenchClosed(object sender, System.Windows.Forms.FormClosedEventArgs e)
+        {
+            if (_repl != null)
+                _repl.Shutdown();
+        }
     }
 }

Modified: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsole.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsole.cs	2012-11-06 10:00:45 UTC (rev 7194)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsole.cs	2012-11-06 16:18:45 UTC (rev 7195)
@@ -30,6 +30,7 @@
 // 
 #endregion
 using ICSharpCode.TextEditor.Document;
+using Maestro.AddIn.Scripting.Services;
 using Maestro.Editors.Common;
 using Microsoft.Scripting.Hosting.Shell;
 using System;
@@ -151,6 +152,8 @@
             return null;
         }
 
+        private bool bHostAppInitialized = false;
+
         /// <summary>
         /// Writes text to the console.
         /// </summary>
@@ -171,6 +174,13 @@
                 promptLength = text.Length;
                 textEditor.MakeCurrentContentReadOnly();
             }
+
+            //HACK: This seems to be the safest point which to inject our Host Application
+            if (!bHostAppInitialized && this.commandLine.ScriptScope != null)
+            {
+                this.commandLine.ScriptScope.SetVariable(ScriptGlobals.HostApp, new HostApplication());
+                bHostAppInitialized = true;
+            }
         }
 
         /// <summary>
@@ -273,6 +283,9 @@
         /// </summary>
         bool ProcessDialogKeyPress(Keys keyData)
         {
+            if (textEditor.ProcessKeyPress(keyData))
+                return true;
+
             if (textEditor.IsCompletionWindowDisplayed)
             {
                 return false;

Modified: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsoleHost.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsoleHost.cs	2012-11-06 10:00:45 UTC (rev 7194)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsoleHost.cs	2012-11-06 16:18:45 UTC (rev 7195)
@@ -124,7 +124,6 @@
         {
             var pc = HostingHelpers.GetLanguageContext(Engine) as PythonContext;
             pc.SetModuleState(typeof(ScriptEngine), Engine);
-            ScriptHostSetup.SetupGlobalScope(Engine, pc);
             base.ExecuteInternal();
         }
 

Modified: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Services/ScriptingClasses.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Services/ScriptingClasses.cs	2012-11-06 10:00:45 UTC (rev 7194)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Services/ScriptingClasses.cs	2012-11-06 16:18:45 UTC (rev 7195)
@@ -34,22 +34,11 @@
 using Maestro.AddIn.Scripting.UI;
 using Maestro.Editors.Generic;
 using Maestro.Base.Editor;
+using Microsoft.Scripting.Hosting.Providers;
 
 namespace Maestro.AddIn.Scripting.Services
 {
     /// <summary>
-    /// Helper class to inject the HostApplication object into the engine's global scope
-    /// </summary>
-    public static class ScriptHostSetup
-    {
-        internal static void SetupGlobalScope(ScriptEngine engine, LanguageContext context)
-        {
-            var global = context.GetScope(null);
-            context.ScopeSetVariable(global, ScriptGlobals.HostApp, new HostApplication());
-        }
-    }
-
-    /// <summary>
     /// Python built-ins injected into the Maestro IronPython REPL
     /// </summary>
     public static class ScriptGlobals

Modified: trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.cs	2012-11-06 10:00:45 UTC (rev 7194)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.cs	2012-11-06 16:18:45 UTC (rev 7195)
@@ -9,16 +9,17 @@
 using Maestro.Shared.UI;
 using ICSharpCode.TextEditor.Document;
 using System.IO;
+using Maestro.Editors.Common;
 using Microsoft.Scripting.Hosting.Shell;
 
 namespace Maestro.AddIn.Scripting.UI
 {
     using Lang.Python;
-    using Maestro.Editors.Common;
+    using ICSharpCode.Core;
 
     internal partial class IronPythonRepl : SingletonViewContent
     {
-        private TextEditor textEditor;
+        private ITextEditor textEditor;
         private PythonConsoleHost host;
 
         public IronPythonRepl()
@@ -37,14 +38,38 @@
             this.Title = this.Description = Strings.Title_IronPython_Console;
             this.Disposed += OnDisposed;
 
-            textEditor = new TextEditor(textEditorControl);
-            host = new PythonConsoleHost(textEditor);
-            host.Run();	
+            textEditor = TextEditorFactory.CreateEditor(textEditorControl);
+
+            if (PropertyService.Get(ScriptingConfigProperties.ShowIronPythonConsole, ScriptingConfigProperties.DefaultShowIronPythonConsole))
+            {
+                Console.WriteLine("Run python host");
+                host = new PythonConsoleHost(textEditor);
+                host.Run();
+            }
         }
 
+        public void Shutdown()
+        {
+            if (host != null)
+            {
+                Console.WriteLine("Terminate python host");
+                host.Terminate(0);
+            }
+        }
+
+        protected override void OnLoad(EventArgs e)
+        {
+            textEditor.SetParent(this.ParentForm);
+            base.OnLoad(e);
+        }
+
         void OnDisposed(object sender, EventArgs e)
         {
-            host.Dispose();
+            if (host != null)
+            {
+                Console.WriteLine("Dispose python host");
+                host.Dispose();
+            }
         }
 
         public override ViewRegion DefaultRegion
@@ -64,14 +89,20 @@
         private void btnClear_Click(object sender, EventArgs e)
         {
             textEditorControl.Text = string.Empty;
-            var con = host.Console;
-            var cmdline = con.CommandLine;
-            NewPrompt(con);
-            textEditorControl.Refresh();
+            if (host != null)
+            {
+                var con = host.Console;
+                var cmdline = con.CommandLine;
+                NewPrompt(con);
+                textEditorControl.Refresh();
+            }
         }
 
         private void btnLoadFile_Click(object sender, EventArgs e)
         {
+            if (host == null)
+                return;
+
             using (var picker = DialogFactory.OpenFile())
             {
                 picker.Filter = "*.py|*.py"; //NOXLATE
@@ -80,7 +111,7 @@
                     var con = host.Console;
                     var cmdline = con.CommandLine;
                     con.WriteLine();
-                    cmdline.ScriptScope.Engine.ExecuteFile(picker.FileName);
+                    cmdline.ScriptScope.Engine.ExecuteFile(picker.FileName, cmdline.ScriptScope);
                     NewPrompt(con);
                 }
             }

Modified: trunk/Tools/Maestro/Maestro.Base/Services/ResourcePreviewerFactory.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Services/ResourcePreviewerFactory.cs	2012-11-06 10:00:45 UTC (rev 7194)
+++ trunk/Tools/Maestro/Maestro.Base/Services/ResourcePreviewerFactory.cs	2012-11-06 16:18:45 UTC (rev 7195)
@@ -119,11 +119,12 @@
             IServerConnection conn = res.CurrentConnection;
             if (this.UseLocal && IsLocalPreviewableType(res) && SupportsMappingService(conn))
             {
-                BusyWaitDialog.Run(Strings.PrgPreparingResourcePreview, () => { 
+                BusyWaitDelegate worker = () =>
+                {
                     IMappingService mapSvc = (IMappingService)conn.GetService((int)ServiceType.Mapping);
                     IMapDefinition previewMdf = null;
                     switch (res.ResourceType)
-                    { 
+                    {
                         case ResourceTypes.LayerDefinition:
                             {
                                 ILayerDefinition ldf = (ILayerDefinition)res;
@@ -150,7 +151,9 @@
                         return mapSvc.CreateMap(previewMdf);
                     else
                         return null;
-                }, (obj) => {
+                };
+                Action<object> onComplete = (obj) =>
+                {
                     if (obj != null)
                     {
                         var rtMap = (RuntimeMap)obj;
@@ -162,7 +165,8 @@
                     {
                         _inner.Preview(res, edSvc, locale);
                     }
-                });
+                };
+                BusyWaitDialog.Run(Strings.PrgPreparingResourcePreview, worker, onComplete);
             }
             else
             {
@@ -212,7 +216,7 @@
             //and it is a nice way to test symbol parameters wrt to rendering
 
             IServerConnection conn = res.CurrentConnection;
-            BusyWaitDialog.Run(Strings.PrgPreparingResourcePreview, () => {
+            BusyWaitDelegate worker = () => {
                 string mapguideRootUrl = (string)conn.GetCustomProperty("BaseUrl"); //NOXLATE
                 //Save the current resource to another session copy
                 string resId = "Session:" + edSvc.SessionID + "//" + res.ResourceType.ToString() + "Preview" + Guid.NewGuid() + "." + res.ResourceType.ToString(); //NOXLATE
@@ -264,7 +268,8 @@
                     var url = new ResourcePreviewEngine(mapguideRootUrl, edSvc).GeneratePreviewUrl(previewCopy, locale);
                     return new UrlPreviewResult() { Url = url };
                 }
-            }, (result) => {
+            };
+            Action<object> onComplete = (result) => {
                 var urlResult = result as UrlPreviewResult;
                 var imgResult = result as ImagePreviewResult;
                 if (urlResult != null)
@@ -277,7 +282,8 @@
                 {
                     new SymbolPreviewDialog(imgResult.ImagePreview).Show(null);
                 }
-            });
+            };
+            BusyWaitDialog.Run(Strings.PrgPreparingResourcePreview, worker, onComplete);
         }
 
         /// <summary>

Modified: trunk/Tools/Maestro/Maestro.Base/UI/MapPreviewDialog.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/UI/MapPreviewDialog.Designer.cs	2012-11-06 10:00:45 UTC (rev 7194)
+++ trunk/Tools/Maestro/Maestro.Base/UI/MapPreviewDialog.Designer.cs	2012-11-06 16:18:45 UTC (rev 7195)
@@ -54,11 +54,9 @@
             this.txtMinX = new System.Windows.Forms.TextBox();
             this.label1 = new System.Windows.Forms.Label();
             this.statusStrip1.SuspendLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
             this.splitContainer1.Panel1.SuspendLayout();
             this.splitContainer1.Panel2.SuspendLayout();
             this.splitContainer1.SuspendLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
             this.splitContainer2.Panel1.SuspendLayout();
             this.splitContainer2.Panel2.SuspendLayout();
             this.splitContainer2.SuspendLayout();
@@ -89,7 +87,6 @@
             this.mapViewer.SelectionColor = System.Drawing.Color.Blue;
             this.mapViewer.Size = new System.Drawing.Size(381, 515);
             this.mapViewer.TabIndex = 0;
-            this.mapViewer.Text = "mapViewer1";
             this.mapViewer.TooltipDelayInterval = 1000;
             this.mapViewer.ZoomInFactor = 0.5D;
             this.mapViewer.ZoomOutFactor = 2D;
@@ -353,11 +350,9 @@
             this.statusStrip1.PerformLayout();
             this.splitContainer1.Panel1.ResumeLayout(false);
             this.splitContainer1.Panel2.ResumeLayout(false);
-            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
             this.splitContainer1.ResumeLayout(false);
             this.splitContainer2.Panel1.ResumeLayout(false);
             this.splitContainer2.Panel2.ResumeLayout(false);
-            ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
             this.splitContainer2.ResumeLayout(false);
             this.panel1.ResumeLayout(false);
             this.grpOtherTools.ResumeLayout(false);

Modified: trunk/Tools/Maestro/Maestro.Base/UI/ResourcePropertiesDialog.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/UI/ResourcePropertiesDialog.Designer.cs	2012-11-06 10:00:45 UTC (rev 7194)
+++ trunk/Tools/Maestro/Maestro.Base/UI/ResourcePropertiesDialog.Designer.cs	2012-11-06 16:18:45 UTC (rev 7195)
@@ -123,7 +123,6 @@
             this.CustomTab.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
             this.ReferenceTab.SuspendLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
             this.splitContainer1.Panel1.SuspendLayout();
             this.splitContainer1.Panel2.SuspendLayout();
             this.splitContainer1.SuspendLayout();
@@ -750,7 +749,6 @@
             this.ReferenceTab.ResumeLayout(false);
             this.splitContainer1.Panel1.ResumeLayout(false);
             this.splitContainer1.Panel2.ResumeLayout(false);
-            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
             this.splitContainer1.ResumeLayout(false);
             this.OutReferences.ResumeLayout(false);
             this.ctxReferences.ResumeLayout(false);

Added: trunk/Tools/Maestro/Maestro.Editors/Common/AutoCompletion.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Common/AutoCompletion.cs	                        (rev 0)
+++ trunk/Tools/Maestro/Maestro.Editors/Common/AutoCompletion.cs	2012-11-06 16:18:45 UTC (rev 7195)
@@ -0,0 +1,314 @@
+#region Disclaimer / License
+// Copyright (C) 2012, Jackie Ng
+// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
+// 
+// Original code from SharpDevelop 3.2.1 licensed under the same terms (LGPL 2.1)
+// Copyright 2002-2010 by
+//
+//  AlphaSierraPapa, Christoph Wille
+//  Vordernberger Strasse 27/8
+//  A-8700 Leoben
+//  Austria
+//
+//  email: office at alphasierrapapa.com
+//  court of jurisdiction: Landesgericht Leoben
+//
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// 
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+// 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+// 
+#endregion
+using ICSharpCode.TextEditor;
+using ICSharpCode.TextEditor.Gui.CompletionWindow;
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+
+namespace Maestro.Editors.Common
+{ 
+    internal class AutoCompletionListBoxItem
+    {
+        private string _myText;
+        private int _myImageIndex;
+        // properties 
+        public string Text
+        {
+            get { return _myText; }
+            set { _myText = value; }
+        }
+        public int ImageIndex
+        {
+            get { return _myImageIndex; }
+            set { _myImageIndex = value; }
+        }
+        //constructor
+        public AutoCompletionListBoxItem(string text, int index)
+        {
+            _myText = text;
+            _myImageIndex = index;
+        }
+        public AutoCompletionListBoxItem(string text) : this(text, -1) { }
+        public AutoCompletionListBoxItem() : this(string.Empty) { }
+
+        private object _tag;
+
+        public object Tag
+        {
+            get { return _tag; }
+            set { _tag = value; }
+        }
+
+        public override string ToString()
+        {
+            return _myText;
+        }
+    }
+
+    // AutoCompletionListBox class 
+    //
+    // Based on GListBox
+    //
+    // http://www.codeproject.com/KB/combobox/glistbox.aspx
+
+    internal class AutoCompletionListBox : ListBox
+    {
+        public ImageList ImageList
+        {
+            get;
+            private set;
+        }
+
+        public AutoCompletionListBox()
+        {
+            // Set owner draw mode
+            this.DrawMode = DrawMode.OwnerDrawFixed;
+            this.IsShown = false;
+            this.Font = new System.Drawing.Font(FontFamily.GenericMonospace, 10.0f); 
+            this.DoubleClick += new EventHandler(OnAutoCompleteDoubleClick);
+            this.SelectedIndexChanged += new EventHandler(OnAutoCompleteSelectedIndexChanged);
+            this.KeyPress += OnKeyPress;
+        }
+
+        void OnKeyPress(object sender, KeyPressEventArgs e)
+        {
+            
+        }
+
+        internal void HandleEnterKey()
+        {
+            if (!this.IsShown)
+                return;
+            PutAutoCompleteSuggestion();
+            this.HideBox();
+        }
+
+        internal void AdvanceInsertionOffset()
+        {
+            _context.InsertionOffset++;
+        }
+
+        private void PutAutoCompleteSuggestion()
+        {
+            if (this.SelectedItem != null)
+            {
+                var data = ((AutoCompletionListBoxItem)this.SelectedItem).Tag as ICompletionData;
+                if (data != null)
+                {
+                    _context.CompletionProvider.InsertAction(data,
+                                                             _context.Editor.ActiveTextAreaControl.TextArea,
+                                                             _context.InsertionOffset + 1,
+                                                             _context.FirstChar);
+                }
+            }
+        }
+
+        void OnAutoCompleteSelectedIndexChanged(object sender, EventArgs e)
+        {
+            _context.Editor.Focus();
+            if (this.Visible && this.SelectedIndex >= 0 && this.Items.Count > 0)
+            {
+                var data = ((AutoCompletionListBoxItem)this.SelectedItem).Tag as ICompletionData;
+                if (data != null)
+                {
+                    string tt = data.Description;
+                    if (!string.IsNullOrEmpty(tt))
+                    {
+                        Point pt = _context.GetCaretPoint();
+                        pt.X += this.Width + 10;
+                        pt.Y += 65;
+
+                        _context.AutoCompleteTooltip.Show(tt, this, pt.X, pt.Y);
+                    }
+                }
+            }
+        }
+
+        void OnAutoCompleteDoubleClick(object sender, EventArgs e)
+        {
+            PutAutoCompleteSuggestion();
+            HideBox();
+        }
+
+        public bool IsShown
+        {
+            get;
+            private set;
+        }
+
+        internal void MoveAutoCompleteSelectionDown()
+        {
+            if (this.SelectedIndex < 0)
+            {
+                this.SelectedIndex = 0;
+            }
+            else
+            {
+                int idx = this.SelectedIndex;
+                if ((idx + 1) <= this.Items.Count - 1)
+                {
+                    this.SelectedIndex = idx + 1;
+                }
+            }
+        }
+
+        internal void MoveAutoCompleteSelectionUp()
+        {
+            if (this.SelectedIndex < 0)
+            {
+                this.SelectedIndex = 0;
+            }
+            else
+            {
+                int idx = this.SelectedIndex;
+                if ((idx - 1) >= 0)
+                {
+                    this.SelectedIndex = idx - 1;
+                }
+            }
+        }
+
+        protected override void OnDrawItem(System.Windows.Forms.DrawItemEventArgs e)
+        {
+            e.DrawBackground();
+            e.DrawFocusRectangle();
+            AutoCompletionListBoxItem item;
+            Rectangle bounds = e.Bounds;
+            Size imageSize = this.ImageList.ImageSize;
+            try
+            {
+                item = (AutoCompletionListBoxItem)Items[e.Index];
+                if (item.ImageIndex != -1)
+                {
+                    this.ImageList.Draw(e.Graphics, bounds.Left, bounds.Top, item.ImageIndex);
+                    e.Graphics.DrawString(item.Text, e.Font, new SolidBrush(e.ForeColor),
+                        bounds.Left + imageSize.Width, bounds.Top);
+                }
+                else
+                {
+                    e.Graphics.DrawString(item.Text, e.Font, new SolidBrush(e.ForeColor),
+                        bounds.Left, bounds.Top);
+                }
+            }
+            catch
+            {
+                if (e.Index != -1)
+                {
+                    e.Graphics.DrawString(Items[e.Index].ToString(), e.Font,
+                        new SolidBrush(e.ForeColor), bounds.Left, bounds.Top);
+                }
+                else
+                {
+                    e.Graphics.DrawString(Text, e.Font, new SolidBrush(e.ForeColor),
+                        bounds.Left, bounds.Top);
+                }
+            }
+            base.OnDrawItem(e);
+        }
+
+        internal ICompletionDataProvider CurrentProvider
+        {
+            get
+            {
+                if (_context != null)
+                    return _context.CompletionProvider;
+                return null;
+            }
+        }
+
+        internal void SetCompletionItems(Form parent, AutoCompleteContext context, string fileName)
+        {
+            SetCompletionItems(parent, context, fileName, true, true);
+        }
+
+        internal class AutoCompleteContext
+        {
+            public ICompletionDataProvider CompletionProvider;
+            public TextEditorControl Editor;
+            public Func<Point> GetCaretPoint;
+            public ToolTip AutoCompleteTooltip;
+            public char FirstChar;
+            public int InsertionOffset;
+        }
+
+        private AutoCompleteContext _context;
+        
+        private void SetCompletionItems(Form parent, AutoCompleteContext context, string fileName, bool p1, bool p2)
+        {
+            _context = context;
+            ICompletionData[] completionData = _context.CompletionProvider.GenerateCompletionData(fileName, _context.Editor.ActiveTextAreaControl.TextArea, _context.FirstChar);
+            if (completionData == null || completionData.Length == 0)
+            {
+                _context = null;
+                HideBox();
+            }
+            else
+            {
+                this.ImageList = _context.CompletionProvider.ImageList;
+
+                int width = 0;
+                this.Items.Clear();
+                foreach (ICompletionData it in completionData)
+                {
+                    AutoCompletionListBoxItem litem = new AutoCompletionListBoxItem();
+                    litem.Text = it.Text;
+                    litem.ImageIndex = it.ImageIndex;
+                    litem.Tag = it;
+
+                    this.Items.Add(litem);
+                    int length = TextRenderer.MeasureText(it.Text, this.Font).Width + 30; //For icon size
+                    if (length > width)
+                        width = length;
+                }
+                this.Width = width + 30;
+                this.BringToFront();
+                this.Show();
+                this.IsShown = true;
+                Point pt = _context.GetCaretPoint();
+                this.Location = pt;
+            }
+        }
+
+        internal void HideBox()
+        {
+            System.Diagnostics.Debug.WriteLine("Contextual buffer cleared");
+            this.Hide();
+            if (_context != null)
+                _context.AutoCompleteTooltip.Hide(this);
+            this.IsShown = false;
+        }
+    }
+}

Modified: trunk/Tools/Maestro/Maestro.Editors/Common/Expression/FdoExpressionCompletionDataProvider.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Common/Expression/FdoExpressionCompletionDataProvider.cs	2012-11-06 10:00:45 UTC (rev 7194)
+++ trunk/Tools/Maestro/Maestro.Editors/Common/Expression/FdoExpressionCompletionDataProvider.cs	2012-11-06 16:18:45 UTC (rev 7195)
@@ -177,11 +177,17 @@
                     }
                     foreach (var member in GetMatchingFdoConditions(name))
                     {
-                        items.Add(new FdoCompletionData(name, member.Name, member.Description, member.AppendText, member.AppendText.Length - 1, 2));
+                        if (string.IsNullOrEmpty(member.AppendText))
+                            items.Add(new FdoCompletionData(name, member.Name, member.Description, 2));
+                        else
+                            items.Add(new FdoCompletionData(name, member.Name, member.Description, member.AppendText, member.AppendText.Length - 1, 2));
                     }
                     foreach (var member in GetMatchingFdoOperators(name))
                     {
-                        items.Add(new FdoCompletionData(name, member.Name, member.Description, member.AppendText, 0, 2));
+                        if (string.IsNullOrEmpty(member.AppendText))
+                            items.Add(new FdoCompletionData(name, member.Name, member.Description, 2));
+                        else
+                            items.Add(new FdoCompletionData(name, member.Name, member.Description, member.AppendText, 0, 2));
                     }
                     items.Sort((a, b) => { return a.Text.CompareTo(b.Text); });
                 }

Modified: trunk/Tools/Maestro/Maestro.Editors/Common/ExpressionEditor.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Common/ExpressionEditor.cs	2012-11-06 10:00:45 UTC (rev 7194)
+++ trunk/Tools/Maestro/Maestro.Editors/Common/ExpressionEditor.cs	2012-11-06 16:18:45 UTC (rev 7195)
@@ -35,44 +35,6 @@
 
 namespace Maestro.Editors.Common
 {
-    /*
-     * Intellisense overview:
-     * 
-     * The intellisense of this expression editor consists of the following parts:
-     *  - An ImageListBox which is filled with auto-complete suggestions
-     *  - A System.Windows.Forms.ToolTip which is shown when an auto-complete choice is highlighted (but not selected)
-     * 
-     * In order to invoke intellisense, we listen for the KeyUp and KeyDown events
-     * on the textbox to determine what actions to take. Some actions include:
-     * 
-     * Key Up:
-     *  - Comma: Show auto-complete with all suggestions
-     *  - Quotes (Single or Double): Insert an extra quote of that type
-     *  - Up/Down: Move the auto-complete selection up/down one item if the auto-complete box is visible.
-     *  - Backspace: Invoke auto-complete with suggestions if there is a context buffer, otherwise hide auto-complete.
-     *  - Alt + Right: Invoke auto-complete with all suggestions
-     *  - Alphanumeric (no modifiers): Invoke auto-complete with suggestions
-     * 
-     * Key Down:
-     *  - Escape: Hide auto-complete
-     *  - Enter: Hide auto-complete
-     * 
-     * As part of the loading process, a full list of auto-complete items (functions/properties) is constructed (sorted by name)
-     * Everytime intellisense is invoked, this list is queried for possible suggestions.
-     * 
-     * In order to determine what items to suggest, the editor builds a context buffer from the current position of the caret
-     * in the textbox. The context buffer algorithm is as follows:
-     * 
-     *  1 - Start from caret position
-     *  2 - Can we move back one char?
-     *    2.1 - Get this char.
-     *    2.2 - If alpha numeric, goto 2.
-     *  3 - Get the string that represents the uninterrupted alphanumeric string sequence that ends at the caret position
-     *  4 - Get the list of completable items that starts with this alphanumeric string
-     *  5 - Add these items to the auto-complete box.
-     *  6 - Show the auto-complete box
-     */
-
     /// <summary>
     /// An expression editor dialog
     /// </summary>
@@ -83,7 +45,7 @@
         private string m_featureSource = null;
         private FdoProviderCapabilities _caps;
         private ITextEditor _editor;
-
+        
         /// <summary>
         /// Initializes a new instance of the <see cref="ExpressionEditor"/> class.
         /// </summary>
@@ -91,17 +53,16 @@
         {
             InitializeComponent();
             ExpressionText.SetHighlighting("FDO");
-            _editor = new TextEditor(ExpressionText);
+            _editor = TextEditorFactory.CreateEditor(ExpressionText);
             _editor.KeyPress += OnEditorKeyPress;
+            _editor.DialogKeyPress += OnEditorDialogKeyPress;
+            _contextualBuffer = new StringBuilder();
         }
 
-        bool OnEditorKeyPress(char ch)
+        protected override void OnLoad(EventArgs e)
         {
-            if (Char.IsLetter(ch))
-            {
-                ShowAutoComplete(ch);
-            }
-            return false;
+            _editor.SetParent(ExpressionText);
+            base.OnLoad(e);
         }
 
         /// <summary>
@@ -245,29 +206,55 @@
             this.Close();
         }
 
-        private CodeCompletionWindow completionWindow;
+        bool OnEditorDialogKeyPress(Keys keyData)
+        {
+            if (_editor.ProcessKeyPress(keyData))
+                return true;
 
-        private void ShowAutoComplete(char ch)
+            if (keyData == Keys.Back)
+                StripKey();
+
+            return false;
+        }
+
+        bool OnEditorKeyPress(char ch)
         {
-            var provider = new FdoExpressionCompletionDataProvider(_cls, _caps);
-            completionWindow = CodeCompletionWindow.ShowCompletionWindow(ExpressionText.ParentForm, ExpressionText, String.Empty, provider, ch);
-            if (completionWindow != null)
+            if (Char.IsLetter(ch))
             {
-                completionWindow.Width = 250;
-                completionWindow.Closed += CompletionWindowClosed;
+                ShowAutoComplete(ch);
             }
+            return false;
         }
 
-        void CompletionWindowClosed(object source, EventArgs e)
+        private StringBuilder _contextualBuffer;
+
+        private void StripKey()
         {
-            if (completionWindow != null)
+            if (_contextualBuffer.Length == 0)
             {
-                completionWindow.Closed -= CompletionWindowClosed;
-                completionWindow.Dispose();
-                completionWindow = null;
+                //this.HideBox();
             }
+            else
+            {
+                _contextualBuffer.Remove(_contextualBuffer.Length - 1, 1);
+                System.Diagnostics.Debug.WriteLine("Contextual buffer: " + _contextualBuffer);
+                //if (_contextualBuffer.Length == 0)
+                    //this.HideBox();
+            }
         }
 
+        internal void AppendKey(Keys keyData)
+        {
+            _contextualBuffer.Append(Convert.ToChar((int)keyData));
+            System.Diagnostics.Debug.WriteLine("Contextual buffer: " + _contextualBuffer);
+        }
+
+        private void ShowAutoComplete(char ch)
+        {
+            var provider = new FdoExpressionCompletionDataProvider(_cls, _caps);
+            _editor.ShowCompletionWindow(provider, ch);
+        }
+
         private void ColumnName_Click(object sender, EventArgs e)
         {
 

Modified: trunk/Tools/Maestro/Maestro.Editors/Common/ITextEditor.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Common/ITextEditor.cs	2012-11-06 10:00:45 UTC (rev 7194)
+++ trunk/Tools/Maestro/Maestro.Editors/Common/ITextEditor.cs	2012-11-06 16:18:45 UTC (rev 7195)
@@ -126,6 +126,13 @@
         void ShowCompletionWindow(ICompletionDataProvider completionDataProvider);
 
         /// <summary>
+        /// Shows the code completion window
+        /// </summary>
+        /// <param name="completionDataProvider"></param>
+        /// <param name="enteredChar">The character just entered</param>
+        void ShowCompletionWindow(ICompletionDataProvider completionDataProvider, char enteredChar);
+
+        /// <summary>
         /// Indicates whether the completion window is currently being displayed.
         /// </summary>
         bool IsCompletionWindowDisplayed { get; }
@@ -134,5 +141,17 @@
         /// Makes the current text content read only. Text can be entered at the end.
         /// </summary>
         void MakeCurrentContentReadOnly();
+
+        /// <summary>
+        /// Perform custom key press handling
+        /// </summary>
+        /// <param name="keyData"></param>
+        bool ProcessKeyPress(System.Windows.Forms.Keys keyData);
+
+        /// <summary>
+        /// Sets the parent control for this editor
+        /// </summary>
+        /// <param name="frm"></param>
+        void SetParent(System.Windows.Forms.Control ctrl); 
     }
 }

Modified: trunk/Tools/Maestro/Maestro.Editors/Common/TextEditor.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Common/TextEditor.cs	2012-11-06 10:00:45 UTC (rev 7194)
+++ trunk/Tools/Maestro/Maestro.Editors/Common/TextEditor.cs	2012-11-06 16:18:45 UTC (rev 7195)
@@ -32,27 +32,27 @@
 using ICSharpCode.TextEditor;
 using ICSharpCode.TextEditor.Document;
 using ICSharpCode.TextEditor.Gui.CompletionWindow;
+using OSGeo.MapGuide.MaestroAPI;
 using System;
 using System.Collections.Generic;
 using System.Drawing;
 using System.Linq;
 using System.Text;
+using System.Windows.Forms;
 
 namespace Maestro.Editors.Common
 {
-    public class TextEditor : ITextEditor
+    public abstract class TextEditorBase : ITextEditor
     {
         delegate string GetLineInvoker(int index);
         delegate void WriteInvoker(string text, Color color, Color fore);
 
-        TextEditorControl textEditorControl;
-        TextArea textArea;
-        Color customLineColour = Color.LightGray;
-        TextMarker readOnlyMarker;
+        protected TextEditorControl textEditorControl;
+        protected TextArea textArea;
+        protected Color customLineColour = Color.LightGray;
+        protected TextMarker readOnlyMarker;
 
-        CodeCompletionWindow completionWindow;
-
-        public TextEditor(TextEditorControl textEditorControl)
+        protected TextEditorBase(TextEditorControl textEditorControl)
         {
             this.textEditorControl = textEditorControl;
             this.textArea = textEditorControl.ActiveTextAreaControl.TextArea;
@@ -65,7 +65,7 @@
             set { SetIndentStyle(value); }
         }
 
-        public event KeyEventHandler KeyPress
+        public event ICSharpCode.TextEditor.KeyEventHandler KeyPress
         {
             add { textArea.KeyEventHandler += value; }
             remove { textArea.KeyEventHandler -= value; }
@@ -201,19 +201,16 @@
             doc.UndoStack.ClearAll();
         }
 
-        public void ShowCompletionWindow(ICompletionDataProvider completionDataProvider)
+        public virtual void ShowCompletionWindow(ICompletionDataProvider completionDataProvider)
         {
-            completionWindow = CodeCompletionWindow.ShowCompletionWindow(textEditorControl.ParentForm, textEditorControl, String.Empty, completionDataProvider, ' ');
-            if (completionWindow != null)
-            {
-                completionWindow.Width = 250;
-                completionWindow.Closed += CompletionWindowClosed;
-            }
+            ShowCompletionWindow(completionDataProvider, ' ');
         }
 
-        public bool IsCompletionWindowDisplayed
+        public abstract void ShowCompletionWindow(ICompletionDataProvider completionDataProvider, char firstChar);
+
+        public abstract bool IsCompletionWindowDisplayed
         {
-            get { return completionWindow != null; }
+            get;
         }
 
         /// <summary>
@@ -237,6 +234,153 @@
             }
         }
 
+        public virtual bool ProcessKeyPress(Keys keyData)
+        {
+            return false;
+        }
+
+        public virtual void SetParent(Control frm) { } 
+    }
+
+    public static class TextEditorFactory
+    {
+        public static ITextEditor CreateEditor(TextEditorControl textEditor)
+        {
+            if (Platform.IsRunningOnMono)
+                return new MonoCompatibleTextEditor(textEditor);
+            else
+                return new DefaultTextEditor(textEditor);
+        }
+    }
+
+    /// <summary>
+    /// A text editor controller using Mono-friendly auto-completion
+    /// </summary>
+    internal class MonoCompatibleTextEditor : TextEditorBase
+    {
+        private AutoCompletionListBox _autoBox;
+        private ToolTip _autoCompleteTooltip;
+
+        internal MonoCompatibleTextEditor(TextEditorControl textEditor)
+            : base(textEditor)
+        {
+            _autoBox = new AutoCompletionListBox();
+            _autoCompleteTooltip = new ToolTip();
+        }
+
+        private Control _parent;
+
+        public override void SetParent(Control ctrl)
+        {
+            _parent = ctrl;
+            _parent.Controls.Add(_autoBox);
+        }
+
+        public override bool IsCompletionWindowDisplayed
+        {
+            get { return _autoBox.IsShown; }
+        }
+
+        public override void ShowCompletionWindow(ICompletionDataProvider completionDataProvider, char firstChar)
+        {
+            //Not ready for beta 5. Remove after release of beta 5.
+            return;
+
+            var context = new AutoCompletionListBox.AutoCompleteContext()
+            {
+                AutoCompleteTooltip = _autoCompleteTooltip,
+                CompletionProvider = completionDataProvider,
+                Editor = textEditorControl,
+                FirstChar = firstChar,
+                GetCaretPoint = GetCaretPoint,
+                InsertionOffset = textEditorControl.ActiveTextAreaControl.Caret.Offset
+            };
+            _autoBox.SetCompletionItems(textEditorControl.ParentForm, context, string.Empty);
+        }
+
+        private Point GetCaretPoint()
+        {
+            var pt = textArea.Caret.ScreenPosition;
+            var cpt = textEditorControl.PointToScreen(pt);
+            int dx = 15; //Shift a bit 
+            int dy = 0;
+
+            //Adjust the postion to accomodate as much space for the auto-complete box as much as possible
+            if (_parent != null)
+            {
+                if (_autoBox.Height > _parent.Height)
+                    dy = -pt.Y;
+            }
+
+            pt.Offset(dx, dy);
+            return pt;
+        }
+
+        static bool IsAlphanumeric(Keys key)
+        {
+            return (key >= Keys.D0 && key <= Keys.Z);
+        }
+
+        public override bool ProcessKeyPress(Keys keyData)
+        {
+            bool bProcessed = false;
+            if (IsCompletionWindowDisplayed)
+            {
+                if (IsAlphanumeric(keyData))
+                {
+                    _autoBox.AdvanceInsertionOffset();
+                    return false;
+                }
+
+                switch (keyData)
+                {
+                    case Keys.Up:
+                        _autoBox.MoveAutoCompleteSelectionUp();
+                        bProcessed = true;
+                        break;
+                    case Keys.Down:
+                        _autoBox.MoveAutoCompleteSelectionDown();
+                        bProcessed = true;
+                        break;
+                    case Keys.Enter:
+                        _autoBox.HandleEnterKey();
+                        bProcessed = true;
+                        break;
+                    case Keys.Escape:
+                        _autoBox.HideBox();
+                        break;
+                }
+            }
+            return bProcessed;
+        }
+    }
+
+    /// <summary>
+    /// Default text editor, using the ICSharpCode.TextEditor auto-completion facilities
+    /// </summary>
+    internal class DefaultTextEditor : TextEditorBase
+    {
+        CodeCompletionWindow completionWindow;
+
+        internal DefaultTextEditor(TextEditorControl textEditor)
+            : base(textEditor)
+        { }
+
+        public override bool IsCompletionWindowDisplayed
+        {
+            get { return completionWindow != null; }
+        }
+
+        public override void ShowCompletionWindow(ICompletionDataProvider completionDataProvider, char ch)
+        {
+            completionWindow = CodeCompletionWindow.ShowCompletionWindow(textEditorControl.ParentForm, textEditorControl, String.Empty, completionDataProvider, ch);
+            if (completionWindow != null)
+            {
+                completionWindow.Width = 250;
+                completionWindow.Closed += CompletionWindowClosed;
+            }
+        }
+
         void CompletionWindowClosed(object source, EventArgs e)
         {
             if (completionWindow != null)

Modified: trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Wms/WmsAdvancedConfigurationDialog.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Wms/WmsAdvancedConfigurationDialog.cs	2012-11-06 10:00:45 UTC (rev 7194)
+++ trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Wms/WmsAdvancedConfigurationDialog.cs	2012-11-06 16:18:45 UTC (rev 7195)
@@ -278,7 +278,7 @@
                         var sc = new FdoSpatialContextListSpatialContext()
                         {
                             Name = "EPSG:4326", //NOXLATE
-                            Description = "Maestro-generated spatialc context", //NOXLATE
+                            Description = "Maestro-generated spatial context", //NOXLATE
                             CoordinateSystemName = "EPSG:4326", //NOXLATE
                             CoordinateSystemWkt = "GEOGCS[\"LL84\",DATUM[\"WGS84\",SPHEROID[\"WGS84\",6378137.000,298.25722293]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.01745329251994]]", //NOXLATE
                             Extent = new FdoSpatialContextListSpatialContextExtent()

Modified: trunk/Tools/Maestro/Maestro.Editors/Maestro.Editors.csproj
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Maestro.Editors.csproj	2012-11-06 10:00:45 UTC (rev 7194)
+++ trunk/Tools/Maestro/Maestro.Editors/Maestro.Editors.csproj	2012-11-06 16:18:45 UTC (rev 7195)
@@ -72,6 +72,9 @@
     <Compile Include="..\Properties\SignedAssemblyInfo2.cs">
       <Link>SignedAssemblyInfo2.cs</Link>
     </Compile>
+    <Compile Include="Common\AutoCompletion.cs">
+      <SubType>Component</SubType>
+    </Compile>
     <Compile Include="Common\ColorComboBox.cs">
       <SubType>Component</SubType>
     </Compile>

Modified: trunk/Tools/Maestro/Maestro.Editors/MapDefinition/LiveMapDefinitionEditorCtrl.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/MapDefinition/LiveMapDefinitionEditorCtrl.Designer.cs	2012-11-06 10:00:45 UTC (rev 7194)
+++ trunk/Tools/Maestro/Maestro.Editors/MapDefinition/LiveMapDefinitionEditorCtrl.Designer.cs	2012-11-06 16:18:45 UTC (rev 7195)
@@ -52,18 +52,15 @@
             this.lblSelected = new System.Windows.Forms.ToolStripStatusLabel();
             this.lblScale = new System.Windows.Forms.ToolStripStatusLabel();
             this.mapStatusTracker = new Maestro.MapViewer.MapStatusTracker();
-            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
             this.splitContainer1.Panel1.SuspendLayout();
             this.splitContainer1.Panel2.SuspendLayout();
             this.splitContainer1.SuspendLayout();
             this.tabLayersAndGroups.SuspendLayout();
             this.TAB_LEGEND.SuspendLayout();
             this.TAB_DRAW_ORDER.SuspendLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).BeginInit();
             this.splitContainer3.Panel1.SuspendLayout();
             this.splitContainer3.Panel2.SuspendLayout();
             this.splitContainer3.SuspendLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
             this.splitContainer2.Panel1.SuspendLayout();
             this.splitContainer2.Panel2.SuspendLayout();
             this.splitContainer2.SuspendLayout();
@@ -275,18 +272,15 @@
             resources.ApplyResources(this, "$this");
             this.splitContainer1.Panel1.ResumeLayout(false);
             this.splitContainer1.Panel2.ResumeLayout(false);
-            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
             this.splitContainer1.ResumeLayout(false);
             this.tabLayersAndGroups.ResumeLayout(false);
             this.TAB_LEGEND.ResumeLayout(false);
             this.TAB_DRAW_ORDER.ResumeLayout(false);
             this.splitContainer3.Panel1.ResumeLayout(false);
             this.splitContainer3.Panel2.ResumeLayout(false);
-            ((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).EndInit();
             this.splitContainer3.ResumeLayout(false);
             this.splitContainer2.Panel1.ResumeLayout(false);
             this.splitContainer2.Panel2.ResumeLayout(false);
-            ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
             this.splitContainer2.ResumeLayout(false);
             this.tabRepo.ResumeLayout(false);
             this.TAB_REPO.ResumeLayout(false);

Modified: trunk/Tools/Maestro/Maestro.Shared.UI/Maestro.Shared.UI.csproj
===================================================================
--- trunk/Tools/Maestro/Maestro.Shared.UI/Maestro.Shared.UI.csproj	2012-11-06 10:00:45 UTC (rev 7194)
+++ trunk/Tools/Maestro/Maestro.Shared.UI/Maestro.Shared.UI.csproj	2012-11-06 16:18:45 UTC (rev 7195)
@@ -203,14 +203,14 @@
     </BootstrapperPackage>
   </ItemGroup>
   <ItemGroup>
+    <None Include="Resources\cross.png" />
+  </ItemGroup>
+  <ItemGroup>
     <ProjectReference Include="..\Thirdparty\WinFormsUI\WinFormsUI.csproj">
-      <Project>{C75532C4-765B-418E-B09B-46D36B2ABDB1}</Project>
+      <Project>{c75532c4-765b-418e-b09b-46d36b2abdb1}</Project>
       <Name>WinFormsUI</Name>
     </ProjectReference>
   </ItemGroup>
-  <ItemGroup>
-    <None Include="Resources\cross.png" />
-  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.

Modified: trunk/Tools/Maestro/ProviderTemplate/ProviderTemplate.csproj
===================================================================
--- trunk/Tools/Maestro/ProviderTemplate/ProviderTemplate.csproj	2012-11-06 10:00:45 UTC (rev 7194)
+++ trunk/Tools/Maestro/ProviderTemplate/ProviderTemplate.csproj	2012-11-06 16:18:45 UTC (rev 7195)
@@ -9,7 +9,7 @@
     <AppDesignerFolder>Properties</AppDesignerFolder>
     <RootNamespace>ProviderTemplate</RootNamespace>
     <AssemblyName>ProviderTemplate</AssemblyName>
-    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/ICSharpCode.TextEditor.csproj
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/ICSharpCode.TextEditor.csproj	2012-11-06 10:00:45 UTC (rev 7194)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/ICSharpCode.TextEditor.csproj	2012-11-06 16:18:45 UTC (rev 7195)
@@ -100,6 +100,7 @@
     <Compile Include="Src\Document\TextBufferStrategy\GapTextBufferStrategy.cs" />
     <Compile Include="Src\Document\TextBufferStrategy\ITextBufferStrategy.cs" />
     <Compile Include="Src\Document\TextBufferStrategy\StringTextBufferStrategy.cs" />
+    <Compile Include="Src\PlatformUtil.cs" />
     <Compile Include="Src\Util\AugmentableRedBlackTree.cs" />
     <Compile Include="Src\Util\CheckedList.cs" />
     <Compile Include="Src\Util\LoggingService.cs" />

Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/Src/Document/TextBufferStrategy/GapTextBufferStrategy.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/Src/Document/TextBufferStrategy/GapTextBufferStrategy.cs	2012-11-06 10:00:45 UTC (rev 7194)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/Src/Document/TextBufferStrategy/GapTextBufferStrategy.cs	2012-11-06 16:18:45 UTC (rev 7195)
@@ -17,7 +17,7 @@
 		
 		void CheckThread()
 		{
-			if (System.Threading.Thread.CurrentThread.ManagedThreadId != creatorThread)
+            if (!PlatformUtil.IsRunningOnMono && System.Threading.Thread.CurrentThread.ManagedThreadId != creatorThread)
 				throw new InvalidOperationException("GapTextBufferStategy is not thread-safe!");
 		}
 		#endif

Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/Src/Gui/TextEditorControl.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/Src/Gui/TextEditorControl.cs	2012-11-06 10:00:45 UTC (rev 7194)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/Src/Gui/TextEditorControl.cs	2012-11-06 16:18:45 UTC (rev 7195)
@@ -73,9 +73,7 @@
 			
 			primaryTextArea  = new TextAreaControl(this);
 			activeTextAreaControl = primaryTextArea;
-			primaryTextArea.TextArea.GotFocus += delegate {
-				SetActiveTextAreaControl(primaryTextArea);
-			};
+            primaryTextArea.TextArea.GotFocus += OnTextAreaGotFocus;
 			primaryTextArea.Dock = DockStyle.Fill;
 			textAreaPanel.Controls.Add(primaryTextArea);
 			InitializeTextAreaControl(primaryTextArea);
@@ -84,6 +82,11 @@
 			Document.UpdateCommited += new EventHandler(CommitUpdateRequested);
 			OptionsChanged();
 		}
+
+        void OnTextAreaGotFocus(object sender, EventArgs e)
+        {
+            SetActiveTextAreaControl(primaryTextArea);
+        }
 		
 		protected virtual void InitializeTextAreaControl(TextAreaControl newControl)
 		{

Added: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/Src/PlatformUtil.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/Src/PlatformUtil.cs	                        (rev 0)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/Src/PlatformUtil.cs	2012-11-06 16:18:45 UTC (rev 7195)
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace ICSharpCode.TextEditor
+{
+    public static class PlatformUtil
+    {
+        static PlatformUtil()
+        {
+            _mrtType = Type.GetType("Mono.Runtime"); //NOXLATE
+        }
+
+        private static Type _mrtType;
+
+        /// <summary>
+        /// Gets whether this application is running under the Mono CLR
+        /// </summary>
+        public static bool IsRunningOnMono
+        {
+            get
+            {
+                return _mrtType != null;
+            }
+        }
+    }
+}



More information about the mapguide-commits mailing list