[mapguide-commits] r4204 - in trunk/Tools/Maestro/Maestro: . MaestroEditorInterface Properties ResourceEditors/LayerEditorControls ResourceEditors/LayoutControls Resources

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Sun Aug 30 12:03:07 EDT 2009


Author: ksgeograf
Date: 2009-08-30 12:03:06 -0400 (Sun, 30 Aug 2009)
New Revision: 4204

Added:
   trunk/Tools/Maestro/Maestro/Resources/bullet_go.png
Modified:
   trunk/Tools/Maestro/Maestro/EditorInterface.cs
   trunk/Tools/Maestro/Maestro/FormExpression.Designer.cs
   trunk/Tools/Maestro/Maestro/FormExpression.cs
   trunk/Tools/Maestro/Maestro/MaestroEditorInterface/EditorInterface.cs
   trunk/Tools/Maestro/Maestro/OSGeo.MapGuide.Maestro.csproj
   trunk/Tools/Maestro/Maestro/Properties/Resources.Designer.cs
   trunk/Tools/Maestro/Maestro/Properties/Resources.resx
   trunk/Tools/Maestro/Maestro/ResourceEditors/LayerEditorControls/VectorLayer.cs
   trunk/Tools/Maestro/Maestro/ResourceEditors/LayoutControls/SearchCommand.cs
Log:
Maestro: Fixed issue #1056

Modified: trunk/Tools/Maestro/Maestro/EditorInterface.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/EditorInterface.cs	2009-08-30 13:53:38 UTC (rev 4203)
+++ trunk/Tools/Maestro/Maestro/EditorInterface.cs	2009-08-30 16:03:06 UTC (rev 4204)
@@ -312,10 +312,10 @@
 			return lo.ShowDialog(m_editor);
 		}
 
-        public string EditExpression(string current, OSGeo.MapGuide.MaestroAPI.FeatureSourceDescription.FeatureSourceSchema schema, string providername)
+        public string EditExpression(string current, OSGeo.MapGuide.MaestroAPI.FeatureSourceDescription.FeatureSourceSchema schema, string providername, string featuresSourceId)
         {
             FormExpression dlg = new FormExpression();
-            dlg.SetupForm(m_editor.CurrentConnection, schema, providername);
+            dlg.SetupForm(m_editor.CurrentConnection, schema, providername, featuresSourceId);
             dlg.Expression = current;
             if (dlg.ShowDialog() == DialogResult.OK)
                 return dlg.Expression;

Modified: trunk/Tools/Maestro/Maestro/FormExpression.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/FormExpression.Designer.cs	2009-08-30 13:53:38 UTC (rev 4203)
+++ trunk/Tools/Maestro/Maestro/FormExpression.Designer.cs	2009-08-30 16:03:06 UTC (rev 4204)
@@ -40,6 +40,10 @@
             this.btnCondition = new System.Windows.Forms.ToolStripMenuItem();
             this.btnSpatial = new System.Windows.Forms.ToolStripMenuItem();
             this.btnDistance = new System.Windows.Forms.ToolStripMenuItem();
+            this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
+            this.ColumnValue = new System.Windows.Forms.ToolStripComboBox();
+            this.LookupValues = new System.Windows.Forms.ToolStripButton();
+            this.ColumnName = new System.Windows.Forms.ToolStripComboBox();
             this.ExpressionText = new System.Windows.Forms.TextBox();
             this._autoCompleteTooltip = new System.Windows.Forms.ToolTip(this.components);
             this.panel1.SuspendLayout();
@@ -94,7 +98,11 @@
             this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
             this.btnProperties,
             this.btnFunctions,
-            this.btnFilter});
+            this.btnFilter,
+            this.toolStripSeparator1,
+            this.ColumnValue,
+            this.LookupValues,
+            this.ColumnName});
             this.toolStrip1.Location = new System.Drawing.Point(0, 0);
             this.toolStrip1.Name = "toolStrip1";
             this.toolStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.System;
@@ -148,10 +156,46 @@
             this.btnDistance.Size = new System.Drawing.Size(130, 22);
             this.btnDistance.Text = "Distance";
             // 
+            // toolStripSeparator1
+            // 
+            this.toolStripSeparator1.Name = "toolStripSeparator1";
+            this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25);
+            // 
+            // ColumnValue
+            // 
+            this.ColumnValue.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
+            this.ColumnValue.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.ColumnValue.Enabled = false;
+            this.ColumnValue.Name = "ColumnValue";
+            this.ColumnValue.Size = new System.Drawing.Size(90, 25);
+            this.ColumnValue.SelectedIndexChanged += new System.EventHandler(this.ColumnValue_SelectedIndexChanged);
+            // 
+            // LookupValues
+            // 
+            this.LookupValues.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
+            this.LookupValues.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
+            this.LookupValues.Enabled = false;
+            this.LookupValues.Image = global::OSGeo.MapGuide.Maestro.Properties.Resources.bullet_go;
+            this.LookupValues.ImageTransparentColor = System.Drawing.Color.Magenta;
+            this.LookupValues.Name = "LookupValues";
+            this.LookupValues.Size = new System.Drawing.Size(23, 22);
+            this.LookupValues.ToolTipText = "Click to lookup values from the selected column";
+            this.LookupValues.Click += new System.EventHandler(this.LookupValues_Click);
+            // 
+            // ColumnName
+            // 
+            this.ColumnName.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
+            this.ColumnName.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.ColumnName.Name = "ColumnName";
+            this.ColumnName.Size = new System.Drawing.Size(90, 25);
+            this.ColumnName.ToolTipText = "Select the column to read values from";
+            this.ColumnName.SelectedIndexChanged += new System.EventHandler(this.ColumnName_SelectedIndexChanged);
+            this.ColumnName.Click += new System.EventHandler(this.ColumnName_Click);
+            // 
             // ExpressionText
             // 
             this.ExpressionText.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.ExpressionText.Font = new System.Drawing.Font("Courier New", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+            this.ExpressionText.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
             this.ExpressionText.HideSelection = false;
             this.ExpressionText.Location = new System.Drawing.Point(0, 25);
             this.ExpressionText.Multiline = true;
@@ -196,5 +240,9 @@
         private System.Windows.Forms.ToolStripMenuItem btnDistance;
         private System.Windows.Forms.ToolTip _autoCompleteTooltip;
         private System.Windows.Forms.Label lblHint;
+        private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
+        private System.Windows.Forms.ToolStripComboBox ColumnName;
+        private System.Windows.Forms.ToolStripButton LookupValues;
+        private System.Windows.Forms.ToolStripComboBox ColumnValue;
     }
 }
\ No newline at end of file

Modified: trunk/Tools/Maestro/Maestro/FormExpression.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/FormExpression.cs	2009-08-30 13:53:38 UTC (rev 4203)
+++ trunk/Tools/Maestro/Maestro/FormExpression.cs	2009-08-30 16:03:06 UTC (rev 4204)
@@ -72,6 +72,7 @@
         private string m_providername;
         private ServerConnectionI m_connection;
         private Globalizator.Globalizator m_globalizor = null;
+        private string m_featureSource = null;
 
         public FormExpression()
         {
@@ -86,13 +87,14 @@
             set { ExpressionText.Text = value; }
         }
 
-        public void SetupForm(ServerConnectionI connection, FeatureSourceDescription.FeatureSourceSchema schema, string provider)
+        public void SetupForm(ServerConnectionI connection, FeatureSourceDescription.FeatureSourceSchema schema, string provider, string featuresSourceId)
         {
             try
             {
                 m_schema = schema;
                 m_providername = provider;
                 m_connection = connection;
+                m_featureSource = featuresSourceId;
 
                 FdoProviderCapabilities caps = m_connection.GetProviderCapabilities(provider);
 
@@ -103,6 +105,9 @@
                     sortedCols.Add(col.Name, col);
                 }
 
+                ColumnName.Items.Clear();
+                ColumnName.Tag = sortedCols;
+
                 foreach (FeatureSetColumn col in sortedCols.Values)
                 {
                     string name = col.Name;
@@ -114,7 +119,13 @@
                         InsertText(name);
                     };
                     btnProperties.DropDown.Items.Add(btn);
+
+                    ColumnName.Items.Add(name);
                 }
+
+                if (ColumnName.Items.Count > 0)
+                    ColumnName.SelectedIndex = 0;
+
                 LoadCompletableProperties(m_schema.Columns);
 
                 //TODO: Figure out how to translate the enums into something usefull
@@ -708,6 +719,94 @@
         {
             HandleKeyUp(e);
         }
+
+        private void ColumnName_Click(object sender, EventArgs e)
+        {
+
+        }
+
+        private void ColumnName_SelectedIndexChanged(object sender, EventArgs e)
+        {
+            ColumnValue.Enabled = false;
+
+            if (ColumnName.SelectedIndex < 0)
+                LookupValues.Enabled = ColumnName.SelectedIndex >= 0;
+        }
+
+        private void LookupValues_Click(object sender, EventArgs e)
+        {
+            using(new WaitCursor(this))
+                try
+                {
+                    SortedList<string, FeatureSetColumn> cols = (SortedList<string, FeatureSetColumn>)ColumnName.Tag;
+                    FeatureSetColumn col = cols[ColumnName.Text];
+
+                    bool retry = true;
+                    Exception rawEx = null;
+                    string filter = null;
+
+                    SortedList<string, string> values = new SortedList<string,string>();
+                    bool hasNull = false;
+
+                    while (retry)
+                        try
+                        {
+                            retry = false;
+                            using (FeatureSetReader rd = m_connection.QueryFeatureSource(m_featureSource, m_schema.FullnameDecoded, null, new string[] { ColumnName.Text }))
+                                while (rd.Read())
+                                    if (rd.Row.IsValueNull(ColumnName.Text))
+                                        hasNull = true;
+                                    else
+                                        values[Convert.ToString(rd.Row[ColumnName.Text], System.Globalization.CultureInfo.InvariantCulture)] = null;
+                        }
+                        catch (Exception ex)
+                        {
+                            if (filter == null && ex.Message.IndexOf("MgNullPropertyValueException") >= 0)
+                            {
+                                rawEx = ex;
+                                retry = true;
+                                filter = ColumnName.Text + " != NULL";
+                            }
+                            else if (rawEx != null)
+                                throw rawEx;
+                            else
+                                throw;
+                        }
+
+                    ColumnValue.Items.Clear();
+                    if (hasNull)
+                        ColumnValue.Items.Add("NULL");
+
+                    foreach (string s in values.Keys)
+                        ColumnValue.Items.Add(s);
+
+                    ColumnValue.Tag = col.Type;
+
+                    if (ColumnValue.Items.Count == 0)
+                        MessageBox.Show(this, "No values found in selected column", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
+                    else
+                    {
+                        ColumnValue.Enabled = true;
+                        ColumnValue.SelectedIndex = -1;
+                        ColumnValue.DroppedDown = true;
+                    }
+                }
+                catch (Exception ex)
+                {
+                    MessageBox.Show(this, string.Format("An error occured while reading column values: {0}", ex.Message), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
+                }
+        }
+
+        private void ColumnValue_SelectedIndexChanged(object sender, EventArgs e)
+        {
+            if (ColumnValue.SelectedIndex >= 0 && ColumnValue.Tag as Type != null)
+            {
+                if (ColumnValue.Tag == typeof(string) && (ColumnValue.SelectedIndex != 0 || ColumnValue.Text != "NULL"))
+                    ExpressionText.SelectedText = " '" + ColumnValue.Text + "' ";
+                else
+                    ExpressionText.SelectedText = " " + ColumnValue.Text + " ";
+            }
+        }
     }
 
     // ImageListBoxItem class 

Modified: trunk/Tools/Maestro/Maestro/MaestroEditorInterface/EditorInterface.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/MaestroEditorInterface/EditorInterface.cs	2009-08-30 13:53:38 UTC (rev 4203)
+++ trunk/Tools/Maestro/Maestro/MaestroEditorInterface/EditorInterface.cs	2009-08-30 16:03:06 UTC (rev 4204)
@@ -121,7 +121,7 @@
         /// <param name="current">The current text</param>
         /// <param name="featureSource">The featureSource this expression is executed against</param>
         /// <returns>Null if the user cancelled, otherwise the new expression</returns>
-        string EditExpression(string current, OSGeo.MapGuide.MaestroAPI.FeatureSourceDescription.FeatureSourceSchema schema, string providername);
+        string EditExpression(string current, OSGeo.MapGuide.MaestroAPI.FeatureSourceDescription.FeatureSourceSchema schema, string providername, string featureSourceId);
 
         /// <summary>
         /// Opens the system default browser and displays the given Url

Modified: trunk/Tools/Maestro/Maestro/OSGeo.MapGuide.Maestro.csproj
===================================================================
--- trunk/Tools/Maestro/Maestro/OSGeo.MapGuide.Maestro.csproj	2009-08-30 13:53:38 UTC (rev 4203)
+++ trunk/Tools/Maestro/Maestro/OSGeo.MapGuide.Maestro.csproj	2009-08-30 16:03:06 UTC (rev 4204)
@@ -349,6 +349,7 @@
     <Content Include="Icons\App.ico" />
     <EmbeddedResource Include="Icons\MapGuide Maestro.ico" />
     <Content Include="ProviderMap.xml" />
+    <None Include="Resources\bullet_go.png" />
     <None Include="app.config" />
     <None Include="Resources\bricks.png" />
     <None Include="Resources\sum.png" />

Modified: trunk/Tools/Maestro/Maestro/Properties/Resources.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/Properties/Resources.Designer.cs	2009-08-30 13:53:38 UTC (rev 4203)
+++ trunk/Tools/Maestro/Maestro/Properties/Resources.Designer.cs	2009-08-30 16:03:06 UTC (rev 4204)
@@ -67,6 +67,13 @@
             }
         }
         
+        internal static System.Drawing.Bitmap bullet_go {
+            get {
+                object obj = ResourceManager.GetObject("bullet_go", resourceCulture);
+                return ((System.Drawing.Bitmap)(obj));
+            }
+        }
+        
         internal static System.Drawing.Bitmap sum {
             get {
                 object obj = ResourceManager.GetObject("sum", resourceCulture);

Modified: trunk/Tools/Maestro/Maestro/Properties/Resources.resx
===================================================================
--- trunk/Tools/Maestro/Maestro/Properties/Resources.resx	2009-08-30 13:53:38 UTC (rev 4203)
+++ trunk/Tools/Maestro/Maestro/Properties/Resources.resx	2009-08-30 16:03:06 UTC (rev 4204)
@@ -127,4 +127,7 @@
   <data name="bricks" type="System.Resources.ResXFileRef, System.Windows.Forms">
     <value>..\Resources\bricks.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
   </data>
+  <data name="bullet_go" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\Resources\bullet_go.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+  </data>
 </root>
\ No newline at end of file

Modified: trunk/Tools/Maestro/Maestro/ResourceEditors/LayerEditorControls/VectorLayer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/ResourceEditors/LayerEditorControls/VectorLayer.cs	2009-08-30 13:53:38 UTC (rev 4203)
+++ trunk/Tools/Maestro/Maestro/ResourceEditors/LayerEditorControls/VectorLayer.cs	2009-08-30 16:03:06 UTC (rev 4204)
@@ -909,7 +909,7 @@
                 return null;
             }
 
-            return m_editor.EditExpression(entry, m_selectedSchema, fs.Provider);
+            return m_editor.EditExpression(entry, m_selectedSchema, fs.Provider, fs.ResourceId);
         }
 
 		private void EditFilterBtn_Click(object sender, System.EventArgs e)

Modified: trunk/Tools/Maestro/Maestro/ResourceEditors/LayoutControls/SearchCommand.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/ResourceEditors/LayoutControls/SearchCommand.cs	2009-08-30 13:53:38 UTC (rev 4203)
+++ trunk/Tools/Maestro/Maestro/ResourceEditors/LayoutControls/SearchCommand.cs	2009-08-30 16:03:06 UTC (rev 4204)
@@ -501,7 +501,7 @@
                 MaestroAPI.FeatureSourceDescription.FeatureSourceSchema schema = m_editor.CurrentConnection.GetFeatureSourceSchema(vldef.ResourceId, vldef.FeatureName);
 
 
-                string exp = m_editor.EditExpression(Filter.Text, schema, fs.Provider);
+                string exp = m_editor.EditExpression(Filter.Text, schema, fs.Provider, fs.ResourceId);
                 if (exp != null)
                     Filter.Text = exp;
             }

Added: trunk/Tools/Maestro/Maestro/Resources/bullet_go.png
===================================================================
(Binary files differ)


Property changes on: trunk/Tools/Maestro/Maestro/Resources/bullet_go.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream



More information about the mapguide-commits mailing list