[mapguide-commits] r4336 - in trunk/Tools/Maestro: Maestro
Maestro/MaestroEditorInterface Maestro/ResourceBrowser
Maestro/ResourceEditors MaestroAPI/BinarySerializer
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Mon Nov 9 17:05:48 EST 2009
Author: ksgeograf
Date: 2009-11-09 17:05:47 -0500 (Mon, 09 Nov 2009)
New Revision: 4336
Modified:
trunk/Tools/Maestro/Maestro/EditorInterface.cs
trunk/Tools/Maestro/Maestro/FormMain.cs
trunk/Tools/Maestro/Maestro/MaestroEditorInterface/EditorInterface.cs
trunk/Tools/Maestro/Maestro/ResourceBrowser/BrowseResource.cs
trunk/Tools/Maestro/Maestro/ResourceEditors/MapEditor.cs
trunk/Tools/Maestro/MaestroAPI/BinarySerializer/Enums.cs
Log:
Maestro:
Fixes issue #1142, MultiSelect layers on add to map
Modified: trunk/Tools/Maestro/Maestro/EditorInterface.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/EditorInterface.cs 2009-11-09 18:26:32 UTC (rev 4335)
+++ trunk/Tools/Maestro/Maestro/EditorInterface.cs 2009-11-09 22:05:47 UTC (rev 4336)
@@ -97,14 +97,24 @@
get { return m_resourceID; }
}
- public string BrowseResource(string itemType)
+ public string BrowseResource(string itemType)
+ {
+ return BrowseResource(new string[] { itemType }, false);
+ }
+
+ public string BrowseResource(string itemType, bool multiSelect)
{
- return BrowseResource(new string[] { itemType } );
+ return BrowseResource(new string[] { itemType }, multiSelect );
}
- public string BrowseResource(string[] itemTypes)
+ public string BrowseResource(string[] itemTypes)
+ {
+ return BrowseResource(itemTypes, false);
+ }
+
+ public string BrowseResource(string[] itemTypes, bool multiSelect)
{
- ResourceBrowser.BrowseResource dlg = new ResourceBrowser.BrowseResource(m_editor.RepositoryCache, m_editor, true, itemTypes);
+ ResourceBrowser.BrowseResource dlg = new ResourceBrowser.BrowseResource(m_editor.RepositoryCache, m_editor, true, multiSelect, itemTypes);
dlg.SelectedResource = m_editor.LastSelectedNode;
if (dlg.ShowDialog() == DialogResult.OK)
@@ -223,7 +233,7 @@
string resourceType = m_editor.ResourceEditorMap.GetResourceTypeNameFromResourceID(m_resourceID);
if (!m_existing || resid == null)
{
- ResourceBrowser.BrowseResource dlg = new ResourceBrowser.BrowseResource(m_editor.RepositoryCache, m_editor, false, new string[] { resourceType });
+ ResourceBrowser.BrowseResource dlg = new ResourceBrowser.BrowseResource(m_editor.RepositoryCache, m_editor, false, false, new string[] { resourceType });
dlg.SelectedResource = m_editor.LastSelectedNode;
if (dlg.ShowDialog() != DialogResult.OK)
return false;
Modified: trunk/Tools/Maestro/Maestro/FormMain.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/FormMain.cs 2009-11-09 18:26:32 UTC (rev 4335)
+++ trunk/Tools/Maestro/Maestro/FormMain.cs 2009-11-09 22:05:47 UTC (rev 4336)
@@ -2161,9 +2161,10 @@
{
try
{
- ResourceBrowser.BrowseResource dlg = new ResourceBrowser.BrowseResource(this.RepositoryCache, this, true, null);
- if (dlg.ShowDialog(this) == DialogResult.OK)
- this.OpenResource(dlg.SelectedResource);
+ ResourceBrowser.BrowseResource dlg = new ResourceBrowser.BrowseResource(this.RepositoryCache, this, true, true, null);
+ if (dlg.ShowDialog(this) == DialogResult.OK)
+ foreach (string s in dlg.SelectedResource.Split(';'))
+ this.OpenResource(s);
}
catch(Exception ex)
{
Modified: trunk/Tools/Maestro/Maestro/MaestroEditorInterface/EditorInterface.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/MaestroEditorInterface/EditorInterface.cs 2009-11-09 18:26:32 UTC (rev 4335)
+++ trunk/Tools/Maestro/Maestro/MaestroEditorInterface/EditorInterface.cs 2009-11-09 22:05:47 UTC (rev 4336)
@@ -76,7 +76,23 @@
/// <returns>The name of the selected resource, or null if the user cancelled</returns>
string BrowseResource(string[] itemTypes);
- /// <summary>
+ /// <summary>
+ /// Request a browse dialog for the specified resource type
+ /// </summary>
+ /// <param name="itemType">The resource to browse for</param>
+ /// <param name="multiSelect">True if the user may select multiple items</param>
+ /// <returns>The name of the selected resource, or null if the user cancelled</returns>
+ string BrowseResource(string itemType, bool multiSelect);
+
+ /// <summary>
+ /// Request a browse dialog for the specified resource type
+ /// </summary>
+ /// <param name="itemTypes">The resource types to browse for, null for all valid resource types</param>
+ /// <param name="multiSelect">True if the user may select multiple items</param>
+ /// <returns>The name of the selected resource, or null if the user cancelled</returns>
+ string BrowseResource(string[] itemTypes, bool multiSelect);
+
+ /// <summary>
/// Deletes the current item from the server and removes the current page from the display
/// </summary>
void Delete();
Modified: trunk/Tools/Maestro/Maestro/ResourceBrowser/BrowseResource.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/ResourceBrowser/BrowseResource.cs 2009-11-09 18:26:32 UTC (rev 4335)
+++ trunk/Tools/Maestro/Maestro/ResourceBrowser/BrowseResource.cs 2009-11-09 22:05:47 UTC (rev 4336)
@@ -60,7 +60,7 @@
/// </summary>
private System.ComponentModel.Container components = null;
- public BrowseResource(RepositoryCache cache, Form ownerform, bool openMode, string[] avalibleTypes)
+ public BrowseResource(RepositoryCache cache, Form ownerform, bool openMode, bool allowMulti, string[] avalibleTypes)
: this()
{
m_connection = cache.Connection;
@@ -89,6 +89,7 @@
ResourceType.Enabled = ResourceType.Items.Count > 1;
ItemView.SmallImageList = cache.EditorMap.SmallImageList;
+ ItemView.MultiSelect = allowMulti;
if (!m_openMode)
this.Text = m_globalizor.Translate("Save resource");
@@ -411,9 +412,13 @@
private void OKButton_Click(object sender, System.EventArgs e)
{
string fullpath = ResourceName.Text;
- int imageindex = m_editorMap.GetImageIndexFromResourceID(ResourceName.Text);
- string itemType = m_editorMap.GetResourceTypeNameFromResourceID(ResourceName.Text);
+ if (ItemView.SelectedItems.Count > 1)
+ fullpath = ((MaestroAPI.ResourceListResourceDocument)ItemView.SelectedItems[0].Tag).ResourceId;
+
+ int imageindex = m_editorMap.GetImageIndexFromResourceID(fullpath);
+ string itemType = m_editorMap.GetResourceTypeNameFromResourceID(fullpath);
+
if (imageindex == m_editorMap.BlankIcon || imageindex == m_editorMap.FolderIcon)
{
itemType = m_validTypes[ResourceType.SelectedIndex];
@@ -436,7 +441,7 @@
}
- if (!ResourceName.Text.ToLower().StartsWith("library://"))
+ if (!fullpath.ToLower().StartsWith("library://"))
{
TreeNode node = FolderView.SelectedNode;
string startPath = "Library://";
@@ -459,7 +464,28 @@
if (MessageBox.Show(this, m_globalizor.Translate("Overwrite existing resource?"), Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.Yes)
return;
- m_selectedResource = fullpath;
+ if (ItemView.MultiSelect && ItemView.SelectedItems.Count > 1)
+ {
+ string path = new MaestroAPI.ResourceIdentifier(fullpath).ParentFolder;
+
+ System.Text.StringBuilder sb = new System.Text.StringBuilder();
+
+ if (!path.EndsWith("/"))
+ path += "/";
+
+ foreach (ListViewItem lvi in ItemView.SelectedItems)
+ {
+ if (sb.Length != 0)
+ sb.Append(";");
+
+ sb.Append(((MaestroAPI.ResourceListResourceDocument)lvi.Tag).ResourceId);
+ }
+
+ m_selectedResource = sb.ToString();
+ }
+ else
+ m_selectedResource = fullpath;
+
this.DialogResult = DialogResult.OK;
this.Close();
return;
@@ -519,8 +545,10 @@
private void ItemView_Click(object sender, System.EventArgs e)
{
- if (ItemView.SelectedItems.Count == 1)
- ResourceName.Text = ((OSGeo.MapGuide.MaestroAPI.ResourceListResourceDocument)ItemView.SelectedItems[0].Tag).ResourceId;
+ if (ItemView.SelectedItems.Count == 1)
+ ResourceName.Text = ((OSGeo.MapGuide.MaestroAPI.ResourceListResourceDocument)ItemView.SelectedItems[0].Tag).ResourceId;
+ else if (ItemView.SelectedItems.Count > 1)
+ ResourceName.Text = "";
}
private void ItemView_DoubleClick(object sender, System.EventArgs e)
Modified: trunk/Tools/Maestro/Maestro/ResourceEditors/MapEditor.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/ResourceEditors/MapEditor.cs 2009-11-09 18:26:32 UTC (rev 4335)
+++ trunk/Tools/Maestro/Maestro/ResourceEditors/MapEditor.cs 2009-11-09 22:05:47 UTC (rev 4336)
@@ -1586,49 +1586,67 @@
private void AddLayer()
{
- string resource = m_editor.BrowseResource("LayerDefinition");
+ string resource = m_editor.BrowseResource("LayerDefinition", true);
if (resource != null)
{
+ OSGeo.MapGuide.MaestroAPI.MapLayerType lastItem = null;
- ArrayList layers = new ArrayList();
- layers.AddRange(m_map.Layers);
- if (m_map.BaseMapDefinition != null && m_map.BaseMapDefinition.BaseMapLayerGroup != null)
- foreach (MaestroAPI.BaseMapLayerGroupCommonType g in m_map.BaseMapDefinition.BaseMapLayerGroup)
- layers.AddRange(g.BaseMapLayer);
+ foreach (string layerid in resource.Split(';'))
+ {
+ ArrayList layers = new ArrayList();
+ layers.AddRange(m_map.Layers);
+ if (m_map.BaseMapDefinition != null && m_map.BaseMapDefinition.BaseMapLayerGroup != null)
+ foreach (MaestroAPI.BaseMapLayerGroupCommonType g in m_map.BaseMapDefinition.BaseMapLayerGroup)
+ layers.AddRange(g.BaseMapLayer);
- foreach (OSGeo.MapGuide.MaestroAPI.BaseMapLayerType layer in layers)
- if (layer.ResourceId == resource)
- {
- if (MessageBox.Show(this, m_globalizor.Translate("That layer is already in the map, do you want it to appear twice?"), Application.ProductName, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) != DialogResult.Yes)
- return;
- }
+ bool add = true;
+ foreach (OSGeo.MapGuide.MaestroAPI.BaseMapLayerType layer in layers)
+ if (layer.ResourceId == layerid)
+ {
+ if (MessageBox.Show(this, string.Format(m_globalizor.Translate("The layer {0} is already in the map, do you want it to appear twice?"), layerid), Application.ProductName, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) != DialogResult.Yes)
+ {
+ add = false;
+ break;
+ }
+ }
- OSGeo.MapGuide.MaestroAPI.MapLayerType maplayer = new OSGeo.MapGuide.MaestroAPI.MapLayerType();
- maplayer.ResourceId = resource;
- maplayer.Name = resource.Substring(resource.LastIndexOf("/") + 1, resource.LastIndexOf(".") - (resource.LastIndexOf("/") + 1));
- maplayer.Visible = true;
- maplayer.ShowInLegend = true;
- maplayer.ExpandInLegend = true;
- m_map.Layers.Add(maplayer);
- m_editor.HasChanged();
- UpdateDisplay();
- if (tabLayers.SelectedTab == tabLayerGroups)
- SelectItemByTag(trvLayerGroups.Nodes, maplayer);
- else
- foreach(ListViewItem lvi in lstDrawOrder.Items)
- if (lvi.Tag == maplayer)
- {
- lstDrawOrder.SelectedItems.Clear();
- lvi.Selected = true;
- lvi.EnsureVisible();
- break;
- }
- try
+ if (!add)
+ continue;
+
+ OSGeo.MapGuide.MaestroAPI.MapLayerType maplayer = new OSGeo.MapGuide.MaestroAPI.MapLayerType();
+ maplayer.ResourceId = layerid;
+ maplayer.Name = new MaestroAPI.ResourceIdentifier(layerid).Name;
+ maplayer.Visible = true;
+ maplayer.ShowInLegend = true;
+ maplayer.ExpandInLegend = true;
+ maplayer.Selectable = false; //Better for performance
+ m_map.Layers.Add(maplayer);
+
+ lastItem = maplayer;
+ }
+
+ if (lastItem != null)
{
- ctlLayerProperties.txtLayername.SelectAll();
- ctlLayerProperties.txtLayername.Focus();
+ m_editor.HasChanged();
+ UpdateDisplay();
+ if (tabLayers.SelectedTab == tabLayerGroups)
+ SelectItemByTag(trvLayerGroups.Nodes, lastItem);
+ else
+ foreach (ListViewItem lvi in lstDrawOrder.Items)
+ if (lvi.Tag == lastItem)
+ {
+ lstDrawOrder.SelectedItems.Clear();
+ lvi.Selected = true;
+ lvi.EnsureVisible();
+ break;
+ }
+ try
+ {
+ ctlLayerProperties.txtLayername.SelectAll();
+ ctlLayerProperties.txtLayername.Focus();
+ }
+ catch { }
}
- catch { }
}
}
@@ -2212,38 +2230,56 @@
if (g == null)
return;
- string resource = m_editor.BrowseResource("LayerDefinition");
+ string resource = m_editor.BrowseResource("LayerDefinition", true);
if (resource != null)
{
- ArrayList layers = new ArrayList();
- layers.AddRange(m_map.Layers);
- foreach (MaestroAPI.BaseMapLayerGroupCommonType gx in m_map.BaseMapDefinition.BaseMapLayerGroup)
- layers.AddRange(gx.BaseMapLayer);
+ OSGeo.MapGuide.MaestroAPI.BaseMapLayerType lastItem = null;
- foreach (OSGeo.MapGuide.MaestroAPI.BaseMapLayerType layer in layers)
- if (layer.ResourceId == resource)
- {
- if (MessageBox.Show(this, m_globalizor.Translate("That layer is already in the map, do you want it to appear twice?"), Application.ProductName, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) != DialogResult.Yes)
- return;
- }
+ foreach (string layerid in resource.Split(';'))
+ {
+ ArrayList layers = new ArrayList();
+ layers.AddRange(m_map.Layers);
+ foreach (MaestroAPI.BaseMapLayerGroupCommonType gx in m_map.BaseMapDefinition.BaseMapLayerGroup)
+ layers.AddRange(gx.BaseMapLayer);
- OSGeo.MapGuide.MaestroAPI.BaseMapLayerType maplayer = new OSGeo.MapGuide.MaestroAPI.BaseMapLayerType();
- maplayer.ResourceId = resource;
- maplayer.Name = resource.Substring(resource.LastIndexOf("/") + 1, resource.LastIndexOf(".") - (resource.LastIndexOf("/") + 1));
- maplayer.ShowInLegend = true;
- maplayer.ExpandInLegend = true;
- g.BaseMapLayer.Add(maplayer);
- m_editor.HasChanged();
- UpdateDisplay();
+ bool add = true;
+ foreach (OSGeo.MapGuide.MaestroAPI.BaseMapLayerType layer in layers)
+ if (layer.ResourceId == layerid)
+ {
+ if (MessageBox.Show(this, string.Format(m_globalizor.Translate("The layer {0} is already in the map, do you want it to appear twice?"), layerid), Application.ProductName, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) != DialogResult.Yes)
+ {
+ add = false;
+ break;
+ }
+ }
- SelectItemByTag(trvBaseLayerGroups.Nodes, maplayer);
+ if (!add)
+ continue;
- try
+ OSGeo.MapGuide.MaestroAPI.BaseMapLayerType maplayer = new OSGeo.MapGuide.MaestroAPI.BaseMapLayerType();
+ maplayer.ResourceId = layerid;
+ maplayer.Name = new MaestroAPI.ResourceIdentifier(layerid).Name;
+ maplayer.ShowInLegend = true;
+ maplayer.ExpandInLegend = true;
+ g.BaseMapLayer.Add(maplayer);
+
+ lastItem = maplayer;
+ }
+
+ if (lastItem != null)
{
- ctlLayerProperties.txtLayername.SelectAll();
- ctlLayerProperties.txtLayername.Focus();
+ m_editor.HasChanged();
+ UpdateDisplay();
+
+ SelectItemByTag(trvBaseLayerGroups.Nodes, lastItem);
+
+ try
+ {
+ ctlLayerProperties.txtLayername.SelectAll();
+ ctlLayerProperties.txtLayername.Focus();
+ }
+ catch { }
}
- catch { }
}
}
Modified: trunk/Tools/Maestro/MaestroAPI/BinarySerializer/Enums.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/BinarySerializer/Enums.cs 2009-11-09 18:26:32 UTC (rev 4335)
+++ trunk/Tools/Maestro/MaestroAPI/BinarySerializer/Enums.cs 2009-11-09 22:05:47 UTC (rev 4336)
@@ -19,8 +19,8 @@
#endregion
using System;
-///This file contains a copy/conversion of some of the internal MapGuide Header files
-///This file is prone to breaking if the MapGuide Server is changed
+//This file contains a copy/conversion of some of the internal MapGuide Header files
+//This file is prone to breaking if the MapGuide Server is changed
namespace OSGeo.MapGuide.MaestroAPI.BinarySerializer
{
More information about the mapguide-commits
mailing list