Skip to content

Commit

Permalink
Add inline extensions to all object types that support extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
caleblanchard committed Jan 2, 2020
1 parent 25edb0f commit 209bdc3
Show file tree
Hide file tree
Showing 13 changed files with 943 additions and 139 deletions.
63 changes: 63 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto

###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp

###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary

###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary

###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
225 changes: 182 additions & 43 deletions Metadata/AOTBrowser/AOTBrowser/AxClass/ARBAOTObjectTree.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<AxClass xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Name>ARBAOTObjectTreeBaseEnum</Name>
<SourceCode>
<Declaration><![CDATA[
using Xpp = Microsoft.Dynamics.Ax.Xpp;
using Microsoft.Dynamics.AX.Metadata.MetaModel;
/// <summary>
/// Override the Object Tree for Base Enums
/// </summary>
[ARBAOTObjectType(ARBAOTObjectType::BaseEnum)]
class ARBAOTObjectTreeBaseEnum extends ARBAOTObjectTree
{
}
]]></Declaration>
<Methods>
<Method>
<Name>addExtensionCollection</Name>
<Source><![CDATA[
/// <summary>
/// Adds a collection of extensions to the tree
/// </summary>
/// <param name = "_collection">The collection to add</param>
/// <param name = "_collectionName">The collection name</param>
/// <param name = "_extensionName">The extension name</param>
protected void addExtensionCollection(System.Collections.IEnumerable _collection, str _collectionName, str _extensionName)
{
switch (_collectionName)
{
case 'ValueModifications':
System.Collections.IEnumerator valueModsEnum = _collection.GetEnumerator();
if (collectionMap.exists('EnumValues'))
{
Map valuesMap = collectionMap.lookup('EnumValues');
while (valueModsEnum.MoveNext())
{
FormTreeItem control = treeControl.getItem(valuesMap.lookup(this.getObjectName(valueModsEnum.Current)));
this.addExtensionModification(control, valueModsEnum.Current, _extensionName);
}
}
break;
default:
super(_collection, _collectionName, _extensionName);
break;
}
}
]]></Source>
</Method>
</Methods>
</SourceCode>
</AxClass>
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,100 @@ using ArbelaXpp = Arbela.Dynamics.Ax.Xpp;
using Microsoft.Dynamics.AX.Metadata.MetaModel;
/// <summary>
/// Override the Object Tree for Data entities
/// Override the Object Tree for Views
/// </summary>
[ARBAOTObjectType(ARBAOTObjectType::DataEntity)]
class ARBAOTObjectTreeDataEntity extends ARBAOTObjectTree
{
Map dataSourceMap = new Map(Types::String, Types::Integer);
Map currentDsMap;
}
]]></Declaration>
<Methods>
<Method>
<Name>update</Name>
<Name>addExtensionCollection</Name>
<Source><![CDATA[
/// <summary>
/// Update the object tree
/// Adds a collection of extensions to the tree
/// </summary>
/// <param name = "_aotNodeName">The name of the AOT object</param>
public void update(TreeNodeName _aotNodeName)
/// <param name = "_collection">The collection to add</param>
/// <param name = "_collectionName">The collection name</param>
/// <param name = "_extensionName">The extension name</param>
protected void addExtensionCollection(System.Collections.IEnumerable _collection, str _collectionName, str _extensionName)
{
AxDataEntityView dataEntityView = Xpp.MetadataSupport::GetDataEntityView(_aotNodeName);
TreeItemIdx rootIdx = this.updateObjectTree(dataEntityView, dataEntityView.Name);
var aotObjectExtensions = ArbelaXpp.MetadataSupport::GetDataEntityViewExtensionsForDataEntityView(_aotNodeName);
System.Collections.IEnumerator enumerator = aotObjectExtensions.GetEnumerator();
System.Collections.IEnumerator modsEnum;
switch (_collectionName)
{
case 'DataSources':
modsEnum = _collection.GetEnumerator();
while (modsEnum.MoveNext())
{
AxQueryExtensionEmbeddedDataSource ds = modsEnum.Current;
this.addExtension(ds.DataSource, this.getNamedNode(dataSourceMap.lookup(ds.Parent), 'DataSources'), _extensionName);
}
break;
case 'FieldGroupExtensions':
System.Collections.IEnumerator fieldGroupEnum = _collection.GetEnumerator();
if (collectionMap.exists('FieldGroups'))
{
Map fieldGroupsMap = collectionMap.lookup('FieldGroups');
while (fieldGroupEnum.MoveNext())
{
AxTableFieldGroupExtension fieldGroupExtension = fieldGroupEnum.Current;
TreeItemIdx parentIdx = fieldGroupsMap.lookup(fieldGroupExtension.Name);
parentIdx = treeControl.getChild(parentIdx); // Get the index of the Fields node
var fieldsEnum = fieldGroupExtension.Fields.GetEnumerator();
while (fieldsEnum.MoveNext())
{
this.addExtension(fieldsEnum.Current, parentIdx, _extensionName);
}
}
}
break;
default:
super(_collection, _collectionName, _extensionName);
break;
}
}
TreeItemIdx extensionsIdx = SysFormTreeControl::addTreeItem(treeControl, 'Extensions', rootIdx, aotObjectExtensions, 0, true);
while (enumerator.moveNext())
]]></Source>
</Method>
<Method>
<Name>addTreeNode</Name>
<Source><![CDATA[
/// <summary>
/// Adds a new node to the tree
/// </summary>
/// <param name = "_object">The object to add</param>
/// <param name = "_idx">The tree index to add it under</param>
/// <param name = "_formTreeAdd">The order it should add the node</param>
/// <param name = "extensionName">The name of the extension it came from, if any</param>
/// <returns>The tree index of the new node</returns>
public TreeItemIdx addTreeNode(anytype _object, TreeItemIdx _idx, int _formTreeAdd = FormTreeAdd::Sort, boolean _skipAddHeader = false, str _extensionName = '')
{
str objectName = this.getObjectName(_object);
boolean insertIntoMap = false;
if (_object is AxQuerySimpleRootDataSource)
{
insertIntoMap = true;
currentDsMap = dataSourceMap;
}
TreeItemIdx parentIdx = super(_object, _idx, _formTreeAdd, _skipAddHeader, _extensionName);
if (currentDsMap != null
&& (_object is AxQuerySimpleDataSource))
{
this.addTreeNode(enumerator.Current, extensionsIdx);
currentDsMap.insert(objectName, parentIdx);
}
treeControl.select(rootIdx);
if (insertIntoMap)
{
currentDsMap = null;
}
return parentIdx;
}
]]></Source>
Expand Down
88 changes: 26 additions & 62 deletions Metadata/AOTBrowser/AOTBrowser/AxClass/ARBAOTObjectTreeForm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Xpp = Microsoft.Dynamics.Ax.Xpp;
using ArbelaXpp = Arbela.Dynamics.Ax.Xpp;
using Microsoft.Dynamics.AX.Metadata.MetaModel;
using CoreMetaModel = Microsoft.Dynamics.AX.Metadata.Core.MetaModel;
/// <summary>
/// Override the Object Tree for Forms
Expand All @@ -19,75 +20,37 @@ class ARBAOTObjectTreeForm extends ARBAOTObjectTree
]]></Declaration>
<Methods>
<Method>
<Name>update</Name>
<Name>addExtensionCollection</Name>
<Source><![CDATA[
/// <summary>
/// Update the object tree
/// Adds a collection of extensions to the tree
/// </summary>
/// <param name = "_aotNodeName">The name of the AOT object</param>
public void update(TreeNodeName _aotNodeName)
/// <param name = "_collection">The collection to add</param>
/// <param name = "_collectionName">The collection name</param>
/// <param name = "_extensionName">The extension name</param>
protected void addExtensionCollection(System.Collections.IEnumerable _collection, str _collectionName, str _extensionName)
{
AxForm form = Xpp.MetadataSupport::GetForm(_aotNodeName);
TreeItemIdx rootIdx = this.updateObjectTree(form, form.Name);
var aotObjectExtensions = ArbelaXpp.MetadataSupport::GetFormExtensionsForForm(_aotNodeName);
System.Collections.IEnumerator enumerator = aotObjectExtensions.GetEnumerator();
TreeItemIdx extensionsIdx;
if (!extensionsInline)
{
extensionsIdx = SysFormTreeControl::addTreeItem(treeControl, 'Extensions', rootIdx, aotObjectExtensions, 0, true);
}
while (enumerator.moveNext())
System.Collections.IEnumerator modsEnum;
switch (_collectionName)
{
AxFormExtension formExtension = enumerator.Current;
if (extensionsInline)
{
str extensionName = conPeek(list2Con(strSplit(formExtension.Name, '.')),2);
var controlsEnum = formExtension.Controls.GetEnumerator();
while (controlsEnum.moveNext())
{
this.addExtension(controlsEnum.Current, controlMap.lookup(controlsEnum.Current.Parent), extensionName);
}
var controlsModEnum = formExtension.ControlModifications.GetEnumerator();
while (controlsModEnum.moveNext())
{
FormTreeItem control = treeControl.getItem(controlMap.lookup(controlsModEnum.Current.Name));
this.addExtensionModification(control, controlsModEnum.Current, extensionName);
}
Map dataSourceMap = collectionMap.lookup('DataSources');
TreeItemIdx dataSourcesIdx = dataSourceMap.lookup('RootNode');
var datasourcesEnum = formExtension.DataSources.GetEnumerator();
while (datasourcesEnum.moveNext())
{
this.addExtension(datasourcesEnum.Current, dataSourcesIdx, extensionName);
}
var dataSourcesModEnum = formExtension.DataSourceModifications.GetEnumerator();
while (dataSourcesModEnum.moveNext())
{
FormTreeItem control = treeControl.getItem(datasourceMap.lookup(dataSourcesModEnum.Current.Name));
this.addExtensionModification(control, dataSourcesModEnum.Current, extensionName);
}
Map partsMap = collectionMap.lookup('Parts');
TreeItemIdx partsIdx = partsMap.lookup('RootNode');
var partsEnum = formExtension.Parts.GetEnumerator();
while (partsEnum.moveNext())
{
this.addExtension(partsEnum.Current, partsIdx, extensionName);
}
if (formExtension.PropertyModifications != null)
case 'Controls':
modsEnum = _collection.GetEnumerator();
while (modsEnum.moveNext())
{
FormTreeItem rootNode = treeControl.getItem(treeControl.getRoot());
AxExtensionModification extMod = new AxExtensionModification();
extMod.PropertyModifications = formExtension.PropertyModifications;
this.addExtensionModification(rootNode, extMod, extensionName);
AxFormExtensionControl controlExt = modsEnum.Current;
TreeItemIdx parentIdx = controlMap.lookup(controlExt.Parent);
TreeItemIdx afterIdx;
if (controlExt.PositionType == CoreMetaModel.ExtensionItemPositionType::AfterItem)
{
afterIdx = SysFormTreeControl::findInsertAfterIdx(treeControl, parentIdx, controlExt.PreviousSibling);
}
this.addExtension(controlExt.FormControl, parentIdx, _extensionName, controlExt.PositionType, afterIdx);
}
}
else
{
this.addTreeNode(formExtension, extensionsIdx);
}
break;
default:
super(_collection, _collectionName, _extensionName);
break;
}
treeControl.select(rootIdx);
}
]]></Source>
Expand All @@ -103,14 +66,15 @@ class ARBAOTObjectTreeForm extends ARBAOTObjectTree
/// <param name = "_formTreeAdd">The order it should add the node</param>
/// <param name = "extensionName">The name of the extension it came from, if any</param>
/// <returns>The tree index of the new node</returns>
public TreeItemIdx addTreeNode(anytype _object, TreeItemIdx _idx, FormTreeAdd _formTreeAdd = FormTreeAdd::Sort, boolean _skipAddHeader = false, str _extensionName = '')
public TreeItemIdx addTreeNode(anytype _object, TreeItemIdx _idx, int _formTreeAdd = FormTreeAdd::Sort, boolean _skipAddHeader = false, str _extensionName = '')
{
str objectName = this.getObjectName(_object);
boolean insertIntoMap = false;
if (_object is AxFormDesign)
{
insertIntoMap = true;
currentMap = controlMap;
collectionMap.insert('Controls', controlMap);
}
TreeItemIdx parentIdx = super(_object, _idx, _formTreeAdd, _skipAddHeader, _extensionName);
Expand Down
Loading

0 comments on commit 209bdc3

Please sign in to comment.