Skip to content

Commit

Permalink
Feature to show data in FXB
Browse files Browse the repository at this point in the history
  • Loading branch information
rappen committed Dec 31, 2023
1 parent dadec2c commit 3a6d6a2
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 121 deletions.
23 changes: 21 additions & 2 deletions LCG-UDG/LCG.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

namespace Rappen.XTB.LCG
{
public partial class LCG : PluginControlBase, IGitHubPlugin, IPayPalPlugin, IAboutPlugin, IHelpPlugin
public partial class LCG : PluginControlBase, IGitHubPlugin, IPayPalPlugin, IAboutPlugin, IHelpPlugin, IMessageBusHost
{
#region Private Fields

Expand Down Expand Up @@ -58,6 +58,8 @@ public partial class LCG : PluginControlBase, IGitHubPlugin, IPayPalPlugin, IAbo

public string HelpUrl => isUML ? "https://jonasr.app/UML" : "https://github.com/rappen/LCG-UDG/blob/master/README.md";

public event EventHandler<MessageBusEventArgs> OnOutgoingMessage;

public void ShowAboutDialog()
{
tslAbout_Click(null, null);
Expand Down Expand Up @@ -1223,7 +1225,6 @@ private void LoadCommonSettings()
commonsettings.MigrateFromOldConfig(isUML);
commonsettings.SetFixedValues(isUML);
toolTip1.SetToolTip(chkEntExclMS, $"Will not include with prefix:\r\n {string.Join($"\r\n ", commonsettings.MicrosoftPrefixes)}");

}

private void LoadEntities()
Expand Down Expand Up @@ -1776,5 +1777,23 @@ private void btnCancel_Click(object sender, EventArgs e)
btnCancel.Enabled = false;
CancelWorker();
}

private void linkShowDataInFXB_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
if (selectedEntity == null)
{
MessageBox.Show("An entity has to be selected to retrieve the data.", "Show in FXB", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
var fetch = $"<fetch top='1000'><entity name='{selectedEntity.LogicalName}'>";
fetch += string.Join("\n", selectedEntity.Attributes.Where(a => a.Selected).Select(a => $"<attribute name='{a.LogicalName}'/>"));
fetch += "</entity></fetch>";
OnOutgoingMessage(this, new MessageBusEventArgs("FetchXML Builder", true) { TargetArgument = fetch });
}

public void OnIncomingMessage(MessageBusEventArgs message)
{
MessageBox.Show("Sorry, we can't handle incoming from other tools.\n\nWhat features would you like to see?\nClick on the Help button to add your requests there!", "Incoming", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1, 0, "https://github.com/rappen/LCG-UDG/issues/new");
}
}
}
61 changes: 43 additions & 18 deletions LCG-UDG/LCG.designer.cs

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

Loading

0 comments on commit 3a6d6a2

Please sign in to comment.