[mapguide-commits] r5084 - in sandbox/maestro-3.0: Maestro.Base
Maestro.Base/Commands Maestro.Base/Editor
Maestro.Base/Services Maestro.Base/UI Maestro.Editors
OSGeo.MapGuide.MaestroAPI.Http
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Aug 11 22:14:26 EDT 2010
Author: jng
Date: 2010-08-12 02:14:26 +0000 (Thu, 12 Aug 2010)
New Revision: 5084
Added:
sandbox/maestro-3.0/Maestro.Base/Services/UrlLauncherService.cs
Removed:
sandbox/maestro-3.0/Maestro.Base/Services/UrlLauncher.cs
Modified:
sandbox/maestro-3.0/Maestro.Base/Commands/PreviewResourceCommand.cs
sandbox/maestro-3.0/Maestro.Base/Editor/EditorContentBase.cs
sandbox/maestro-3.0/Maestro.Base/Editor/FeatureSourceEditor.cs
sandbox/maestro-3.0/Maestro.Base/Editor/IEditorViewContent.cs
sandbox/maestro-3.0/Maestro.Base/Editor/ResourceEditorService.cs
sandbox/maestro-3.0/Maestro.Base/Maestro.Base.addin
sandbox/maestro-3.0/Maestro.Base/Maestro.Base.csproj
sandbox/maestro-3.0/Maestro.Base/Services/OpenResourceManager.cs
sandbox/maestro-3.0/Maestro.Base/UI/AboutDialog.cs
sandbox/maestro-3.0/Maestro.Editors/IEditorService.cs
sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs
Log:
This submission includes the following changes:
- Enable resource previews. Currently this only applies to feature sources. This will eventually cover all previewable resources.
- Rename UrlLauncher to UrlLauncherService
- Expose session id in IEditorService
- Add SetupPreviewUrl() API to IEditorViewContent. Currently only implemented by the Feature Source editor.
Modified: sandbox/maestro-3.0/Maestro.Base/Commands/PreviewResourceCommand.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Commands/PreviewResourceCommand.cs 2010-08-11 11:10:29 UTC (rev 5083)
+++ sandbox/maestro-3.0/Maestro.Base/Commands/PreviewResourceCommand.cs 2010-08-12 02:14:26 UTC (rev 5084)
@@ -20,10 +20,37 @@
using System;
using System.Collections.Generic;
using System.Text;
+using ICSharpCode.Core;
+using Maestro.Base.Services;
namespace Maestro.Base.Commands
{
- internal class PreviewResourceCommand : NotImplementedCommand
+ internal class PreviewResourceCommand : AbstractMenuCommand
{
+ public override void Run()
+ {
+ var wb = Workbench.Instance;
+ var ed = wb.ActiveEditor;
+
+ if (ed != null && ed.CanBePreviewed)
+ {
+ //TODO: This needs to be reviewed when we decide to support
+ //multiple site connections from the same session
+
+ var exp = wb.ActiveSiteExplorer;
+ if (exp != null)
+ {
+ var connMgr = ServiceRegistry.GetService<ServerConnectionManager>();
+ var conn = connMgr.GetConnection(exp.ConnectionName);
+ var launcher = ServiceRegistry.GetService<UrlLauncherService>();
+
+ //HACK: This is a bit dodgy as we assume we're dealing with the http
+ //impl of the IServerConnection
+ string url = ed.SetupPreviewUrl((string)conn.GetCustomProperty("BaseUrl"));
+
+ launcher.OpenUrl(url);
+ }
+ }
+ }
}
}
Modified: sandbox/maestro-3.0/Maestro.Base/Editor/EditorContentBase.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Editor/EditorContentBase.cs 2010-08-11 11:10:29 UTC (rev 5083)
+++ sandbox/maestro-3.0/Maestro.Base/Editor/EditorContentBase.cs 2010-08-12 02:14:26 UTC (rev 5084)
@@ -118,5 +118,10 @@
{
get { return true; }
}
+
+ public virtual string SetupPreviewUrl(string mapguideRootUrl)
+ {
+ throw new NotImplementedException();
+ }
}
}
Modified: sandbox/maestro-3.0/Maestro.Base/Editor/FeatureSourceEditor.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Editor/FeatureSourceEditor.cs 2010-08-11 11:10:29 UTC (rev 5083)
+++ sandbox/maestro-3.0/Maestro.Base/Editor/FeatureSourceEditor.cs 2010-08-12 02:14:26 UTC (rev 5084)
@@ -64,5 +64,18 @@
e.Cancel = true;
}
}
+
+ public override string SetupPreviewUrl(string mapguideRootUrl)
+ {
+ string url = mapguideRootUrl;
+ if (!url.EndsWith("/"))
+ url += "/";
+
+ var resId = this.EditorService.GetEditedResource().ResourceID;
+ var sessionId = this.EditorService.SessionID;
+ url += "schemareport/describeschema.php?viewer=basic&resId=" + resId + "&sessionId=" + sessionId;
+
+ return url;
+ }
}
}
Modified: sandbox/maestro-3.0/Maestro.Base/Editor/IEditorViewContent.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Editor/IEditorViewContent.cs 2010-08-11 11:10:29 UTC (rev 5083)
+++ sandbox/maestro-3.0/Maestro.Base/Editor/IEditorViewContent.cs 2010-08-12 02:14:26 UTC (rev 5084)
@@ -67,5 +67,14 @@
/// Indicates whether the resource being edited has unsaved changes
/// </summary>
bool IsDirty { get; }
+
+ /// <summary>
+ /// Returns a URL that can be opened to preview this resource. If the
+ /// <see cref="CanBePreviewed"/> property is false, this method should
+ /// throw a <see cref="NotSupportedException"/>
+ /// </summary>
+ /// <param name="mapguideRootUrl"></param>
+ /// <returns></returns>
+ string SetupPreviewUrl(string mapguideRootUrl);
}
}
Modified: sandbox/maestro-3.0/Maestro.Base/Editor/ResourceEditorService.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Editor/ResourceEditorService.cs 2010-08-11 11:10:29 UTC (rev 5083)
+++ sandbox/maestro-3.0/Maestro.Base/Editor/ResourceEditorService.cs 2010-08-12 02:14:26 UTC (rev 5084)
@@ -270,5 +270,10 @@
this.IsDirty = true;
OnDirtyStateChanged();
}
+
+ public string SessionID
+ {
+ get { return _conn.SessionID; }
+ }
}
}
Modified: sandbox/maestro-3.0/Maestro.Base/Maestro.Base.addin
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Maestro.Base.addin 2010-08-11 11:10:29 UTC (rev 5083)
+++ sandbox/maestro-3.0/Maestro.Base/Maestro.Base.addin 2010-08-12 02:14:26 UTC (rev 5084)
@@ -203,7 +203,7 @@
<ToolbarItem id="Preview"
icon="document_search_result"
tooltip="${res:Menu_File_PreviewResource}"
- class="Maestro.Base.Commands.NotImplementedCommand" />
+ class="Maestro.Base.Commands.PreviewResourceCommand" />
</Condition>
<Condition action="Disable" name="EditorFunction" property="CanEditAsXml">
<ToolbarItem id="XmlEdit"
Modified: sandbox/maestro-3.0/Maestro.Base/Maestro.Base.csproj
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Maestro.Base.csproj 2010-08-11 11:10:29 UTC (rev 5083)
+++ sandbox/maestro-3.0/Maestro.Base/Maestro.Base.csproj 2010-08-12 02:14:26 UTC (rev 5084)
@@ -157,7 +157,7 @@
<Compile Include="Services\ServerConnectionManager.cs" />
<Compile Include="Services\ServiceBase.cs" />
<Compile Include="Services\ServiceRegistry.cs" />
- <Compile Include="Services\UrlLauncher.cs" />
+ <Compile Include="Services\UrlLauncherService.cs" />
<Compile Include="Services\ViewContentManager.cs" />
<Compile Include="Templates\ApplicationDefinitionItemTemplate.cs" />
<Compile Include="Templates\DrawingSourceItemTemplate.cs" />
Modified: sandbox/maestro-3.0/Maestro.Base/Services/OpenResourceManager.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Services/OpenResourceManager.cs 2010-08-11 11:10:29 UTC (rev 5083)
+++ sandbox/maestro-3.0/Maestro.Base/Services/OpenResourceManager.cs 2010-08-12 02:14:26 UTC (rev 5084)
@@ -95,7 +95,7 @@
{
ed = FindEditor(svc, res.GetResourceTypeDescriptor());
}
- var launcher = ServiceRegistry.GetService<UrlLauncher>();
+ var launcher = ServiceRegistry.GetService<UrlLauncherService>();
var editorSvc = new ResourceEditorService(resourceId, conn, launcher);
ed.EditorService = editorSvc;
_openItems[resourceId] = ed;
Deleted: sandbox/maestro-3.0/Maestro.Base/Services/UrlLauncher.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Services/UrlLauncher.cs 2010-08-11 11:10:29 UTC (rev 5083)
+++ sandbox/maestro-3.0/Maestro.Base/Services/UrlLauncher.cs 2010-08-12 02:14:26 UTC (rev 5084)
@@ -1,82 +0,0 @@
-#region Disclaimer / License
-// Copyright (C) 2010, Jackie Ng
-// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
-//
-// 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 System;
-using System.Collections.Generic;
-using System.Text;
-using ICSharpCode.Core;
-using System.Diagnostics;
-using Maestro.Base.UI;
-using OSGeo.MapGuide.MaestroAPI;
-
-namespace Maestro.Base.Services
-{
- public interface IUrlLauncherService
- {
- bool CanUseEmbeddedWebBrowser { get; }
- void OpenUrl(string url);
- void OpenUrlEmbedded(string url, bool locked);
- }
-
- public class UrlLauncher : ServiceBase, IUrlLauncherService
- {
- public override void Initialize()
- {
- base.Initialize();
- LoggingService.Info(Properties.Resources.Service_Init_Url_Launcher);
- }
-
- public bool CanUseEmbeddedWebBrowser
- {
- //Mono's web browser is too unwieldy
- get { return Platform.IsWindows; }
- }
-
- /// <summary>
- /// Opens the specified url using the system default web browser
- /// </summary>
- /// <param name="url">The url to open</param>
- public void OpenUrl(string url)
- {
- Process.Start(url);
- }
-
- /// <summary>
- /// Opens the specified url using the embedded web browser. If embedded browsers are not supported,
- /// it will open it in the default system web browser.
- /// </summary>
- /// <param name="url">the url to open</param>
- /// <param name="locked">If true, the navigation toolbar will be disabled</param>
- public void OpenUrlEmbedded(string url, bool locked)
- {
- if (CanUseEmbeddedWebBrowser)
- {
- var mgr = ServiceRegistry.GetService<ViewContentManager>();
- var browser = mgr.OpenContent<EmbeddedWebBrowser>(ViewRegion.Document);
-
- browser.IsLockedDown = locked;
- browser.NavigateToUrl(url);
- }
- else
- {
- OpenUrl(url);
- }
- }
- }
-}
Copied: sandbox/maestro-3.0/Maestro.Base/Services/UrlLauncherService.cs (from rev 5077, sandbox/maestro-3.0/Maestro.Base/Services/UrlLauncher.cs)
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Services/UrlLauncherService.cs (rev 0)
+++ sandbox/maestro-3.0/Maestro.Base/Services/UrlLauncherService.cs 2010-08-12 02:14:26 UTC (rev 5084)
@@ -0,0 +1,82 @@
+#region Disclaimer / License
+// Copyright (C) 2010, Jackie Ng
+// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
+//
+// 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 System;
+using System.Collections.Generic;
+using System.Text;
+using ICSharpCode.Core;
+using System.Diagnostics;
+using Maestro.Base.UI;
+using OSGeo.MapGuide.MaestroAPI;
+
+namespace Maestro.Base.Services
+{
+ public interface IUrlLauncherService
+ {
+ bool CanUseEmbeddedWebBrowser { get; }
+ void OpenUrl(string url);
+ void OpenUrlEmbedded(string url, bool locked);
+ }
+
+ public class UrlLauncherService : ServiceBase, IUrlLauncherService
+ {
+ public override void Initialize()
+ {
+ base.Initialize();
+ LoggingService.Info(Properties.Resources.Service_Init_Url_Launcher);
+ }
+
+ public bool CanUseEmbeddedWebBrowser
+ {
+ //Mono's web browser is too unwieldy
+ get { return Platform.IsWindows; }
+ }
+
+ /// <summary>
+ /// Opens the specified url using the system default web browser
+ /// </summary>
+ /// <param name="url">The url to open</param>
+ public void OpenUrl(string url)
+ {
+ Process.Start(url);
+ }
+
+ /// <summary>
+ /// Opens the specified url using the embedded web browser. If embedded browsers are not supported,
+ /// it will open it in the default system web browser.
+ /// </summary>
+ /// <param name="url">the url to open</param>
+ /// <param name="locked">If true, the navigation toolbar will be disabled</param>
+ public void OpenUrlEmbedded(string url, bool locked)
+ {
+ if (CanUseEmbeddedWebBrowser)
+ {
+ var mgr = ServiceRegistry.GetService<ViewContentManager>();
+ var browser = mgr.OpenContent<EmbeddedWebBrowser>(ViewRegion.Document);
+
+ browser.IsLockedDown = locked;
+ browser.NavigateToUrl(url);
+ }
+ else
+ {
+ OpenUrl(url);
+ }
+ }
+ }
+}
Modified: sandbox/maestro-3.0/Maestro.Base/UI/AboutDialog.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/UI/AboutDialog.cs 2010-08-11 11:10:29 UTC (rev 5083)
+++ sandbox/maestro-3.0/Maestro.Base/UI/AboutDialog.cs 2010-08-12 02:14:26 UTC (rev 5084)
@@ -299,13 +299,13 @@
/// </summary>
private void dummy_function() { }
- private UrlLauncher _launcher;
+ private UrlLauncherService _launcher;
private void FormAbout_Load(object sender, System.EventArgs e)
{
System.Threading.Thread tmp = new System.Threading.Thread(new System.Threading.ThreadStart(dummy_function));
- _launcher = ServiceRegistry.GetService<UrlLauncher>();
+ _launcher = ServiceRegistry.GetService<UrlLauncherService>();
Debug.Assert(_launcher != null);
Version.Text = string.Format(Properties.Resources.About_VersionLabel, Application.ProductVersion);
Modified: sandbox/maestro-3.0/Maestro.Editors/IEditorService.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/IEditorService.cs 2010-08-11 11:10:29 UTC (rev 5083)
+++ sandbox/maestro-3.0/Maestro.Editors/IEditorService.cs 2010-08-12 02:14:26 UTC (rev 5084)
@@ -47,29 +47,11 @@
/// Gets the associated drawing service
/// </summary>
IDrawingService DrawingService { get; }
- /*
/// <summary>
- /// Adds the specified resource data. Do not use the identical method exposed by the
- /// <see cref="ResourceService"/> property as this one has dirty state notification hooks
+ /// Gets the session id
/// </summary>
- /// <param name="dataName"></param>
- /// <param name="type"></param>
- /// <param name="stream"></param>
- void AddResourceData(string dataName, ResourceDataType type, Stream stream);
+ string SessionID { get; }
/// <summary>
- /// Gets the specified resource data.
- /// </summary>
- /// <param name="dataName"></param>
- /// <returns></returns>
- MemoryStream GetResourceData(string dataName);
- /// <summary>
- /// Removes the specified resource data. Do not use the identical method exposed by the
- /// <see cref="ResourceService"/> property as this one has dirty state notification hooks
- /// </summary>
- /// <param name="dataName"></param>
- void RemoveResourceData(string dataName);
- */
- /// <summary>
/// Registers a custom notifier
/// </summary>
/// <param name="irc"></param>
Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs 2010-08-11 11:10:29 UTC (rev 5083)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs 2010-08-12 02:14:26 UTC (rev 5084)
@@ -1627,17 +1627,20 @@
throw new UnsupportedServiceTypeException(st);
}
- const string PROP_USER_AGENT = "UserAgent";
+ public const string PROP_USER_AGENT = "UserAgent";
+ public const string PROP_BASE_URL = "BaseUrl";
public override string[] GetCustomPropertyNames()
{
- return new string[] { PROP_USER_AGENT };
+ return new string[] { PROP_USER_AGENT, PROP_BASE_URL };
}
public override Type GetCustomPropertyType(string name)
{
if (name == PROP_USER_AGENT)
return typeof(string);
+ else if (name == PROP_BASE_URL)
+ return typeof(string);
else
throw new CustomPropertyNotFoundException();
}
@@ -1654,6 +1657,8 @@
{
if (name == PROP_USER_AGENT)
return this.UserAgent;
+ else if (name == PROP_BASE_URL)
+ return this.BaseURL;
else
throw new CustomPropertyNotFoundException();
}
More information about the mapguide-commits
mailing list