Skip to content

Commit

Permalink
#77: Include ProviderTemplate tool with the Maestro install. Add a pr…
Browse files Browse the repository at this point in the history
…eference UI to set this path and include a tools menu entry for it.
  • Loading branch information
jumpinjackie committed Aug 7, 2019
1 parent 583cbce commit c7c1868
Show file tree
Hide file tree
Showing 10 changed files with 243 additions and 32 deletions.
66 changes: 66 additions & 0 deletions Maestro.Base/Commands/ProviderTemplateToolCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#region Disclaimer / License

// Copyright (C) 2019, Jackie Ng
// https://github.com/jumpinjackie/mapguide-maestro
//
// 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 Disclaimer / License

using ICSharpCode.Core;
using Maestro.Base.UI.Preferences;
using Maestro.Shared.UI;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Maestro.Base.Commands
{
internal class ProviderTemplateToolCommand : AbstractMenuCommand
{
public override void Run()
{
RunTool();
}

internal static void RunTool()
{
string exe = PropertyService.Get(ConfigProperties.ProviderToolPath, string.Empty); //NOXLATE

if (!File.Exists(exe))
{
using (var dlg = DialogFactory.OpenFile())
{
dlg.Title = string.Format(Strings.LocateExecutable, "ProviderTemplate.exe"); //NOXLATE
dlg.Filter = string.Format(OSGeo.MapGuide.MaestroAPI.Strings.GenericFilter, OSGeo.MapGuide.MaestroAPI.Strings.PickExe, "exe"); //NOXLATE
if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
exe = dlg.FileName;
PropertyService.Set(ConfigProperties.ProviderToolPath, exe);
}
}
}

var procInfo = new ProcessStartInfo(exe);
procInfo.WorkingDirectory = Path.GetDirectoryName(exe);
var proc = Process.Start(procInfo);
}
}
}
3 changes: 3 additions & 0 deletions Maestro.Base/Maestro.Base.addin
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,9 @@
<MenuItem id="MgCooker"
label="${res:MgCooker}"
class="Maestro.Base.Commands.MgCookerCommand" />
<MenuItem id="ProviderTemplate"
label="${res:ProviderTemplate}"
class="Maestro.Base.Commands.ProviderTemplateToolCommand" />
<MenuItem id="LocalFsPreview"
label="${res:LocalFsPreview}"
class="Maestro.Base.Commands.LocalFeatureSourcePreviewCommand" />
Expand Down
1 change: 1 addition & 0 deletions Maestro.Base/Maestro.Base.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<Compile Include="Commands\CacheViewerCommand.cs" />
<Compile Include="Commands\CloseActiveDocumentCommand.cs" />
<Compile Include="Commands\CloseAllDocumentsCommand.cs" />
<Compile Include="Commands\ProviderTemplateToolCommand.cs" />
<Compile Include="Commands\SiteExplorer\CompareResourceCommand.cs" />
<Compile Include="Commands\SiteExplorer\CompileFullDependencyListCommand.cs" />
<Compile Include="Commands\Conditions\ActiveEditorConditionEvaluator.cs" />
Expand Down
11 changes: 10 additions & 1 deletion Maestro.Base/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Maestro.Base/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1010,4 +1010,7 @@ Error message: {0}</value>
<data name="EditorServiceInvalidState" xml:space="preserve">
<value>The editor service for this resource has entered an invalid state and cannot continue</value>
</data>
<data name="ProviderTemplate" xml:space="preserve">
<value>Maestro API Provider Template Tool</value>
</data>
</root>
5 changes: 5 additions & 0 deletions Maestro.Base/UI/Preferences/ConfigProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ public static class ConfigProperties
/// </summary>
public const string MgCookerPath = "General.MgCookerPath"; //NOXLATE

/// <summary>
/// The path to ProviderTemplate.exe
/// </summary>
public const string ProviderToolPath = "General.ProviderToolPath"; //NOXLATE

/// <summary>
/// The path to RtMapInspector.exe
/// </summary>
Expand Down
27 changes: 27 additions & 0 deletions Maestro.Base/UI/Preferences/GeneralPreferencesCtrl.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions Maestro.Base/UI/Preferences/GeneralPreferencesCtrl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,18 @@ private void btnBrowseLiveMapEditor_Click(object sender, EventArgs e)
}
}
}

private void btnProviderTemplate_Click(object sender, EventArgs e)
{
using (var dlg = DialogFactory.OpenFile())
{
dlg.Title = string.Format(Strings.LocateExecutable, "ProviderTemplate.exe"); //NOXLATE
dlg.Filter = string.Format(OSGeo.MapGuide.MaestroAPI.Strings.GenericFilter, OSGeo.MapGuide.MaestroAPI.Strings.PickExe, "exe"); //NOXLATE
if (dlg.ShowDialog() == DialogResult.OK)
{
txtProviderTemplateTool.Text = dlg.FileName;
}
}
}
}
}

0 comments on commit c7c1868

Please sign in to comment.