Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions BHoM_UI/Caller/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@
*/

using BH.Engine.Reflection;
using BH.Engine.Serialiser;
using BH.oM.Base;
using BH.oM.UI;
using BH.UI.Base.Menus;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using BH.Engine.Serialiser;
using System.Windows.Forms;
using BH.oM.Base;
using System.Collections;
using BH.UI.Base.Menus;

namespace BH.UI.Base
{
Expand Down Expand Up @@ -97,9 +98,13 @@ static Caller()
{
if (!m_Initialised)
{
BH.Engine.Base.Compute.RecordNote($"Caller initialising at {DateTime.UtcNow}");

m_Initialised = true;
Engine.UI.Compute.LoadAssemblies();
//Engine.UI.Compute.LoadAssemblies();
Global.Initialisation.Activate();

BH.Engine.Base.Compute.RecordNote($"Caller initialised at {DateTime.UtcNow}");
}
}

Expand All @@ -125,10 +130,10 @@ public virtual void SetDataAccessor(IDataAccessor accessor)

/*************************************/

protected void SetPossibleItems<T>(IEnumerable<T> items)
protected void SetPossibleItems(IEnumerable<SearchItem> items)
{
HasPossibleItems = true;
m_ItemSelector = new ItemSelector(items.Cast<object>(), Name);
m_ItemSelector = new ItemSelector(items, Name);
m_ItemSelector.ItemSelected += (sender, e) => SetItem(e);
}

Expand Down
10 changes: 7 additions & 3 deletions BHoM_UI/Components/Adapter/CreateAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using BH.Adapter;
using BH.oM.UI;
using BH.UI.Base.Global;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using BH.Adapter;

namespace BH.UI.Base.Components
{
Expand Down Expand Up @@ -55,7 +58,8 @@ public class CreateAdapterCaller : Caller

public CreateAdapterCaller() : base()
{
SetPossibleItems(Engine.UI.Query.AdapterConstructorItems());
IEnumerable<SearchItem> items = Initialisation.SearchItems.Where(x => x.CallerType == typeof(CreateAdapterCaller));
SetPossibleItems(items);
}

/*************************************/
Expand Down
13 changes: 6 additions & 7 deletions BHoM_UI/Components/Adapter/CreateRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using BH.Engine.Reflection;
using BH.oM.UI;
using BH.UI.Base.Global;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using BH.Engine.Reflection;

namespace BH.UI.Base.Components
{
Expand Down Expand Up @@ -55,11 +57,8 @@ public class CreateRequestCaller : Caller

public CreateRequestCaller() : base()
{
List<MemberInfo> possibleItems = new List<MemberInfo>();
possibleItems.AddRange(Engine.UI.Query.ConstructableRequestItems());
possibleItems.AddRange(Engine.UI.Query.CreateRequestItems());

SetPossibleItems(possibleItems);
IEnumerable<SearchItem> items = Initialisation.SearchItems.Where(x => x.CallerType == typeof(CreateRequestCaller));
SetPossibleItems(items);
}

/*************************************/
Expand Down
7 changes: 5 additions & 2 deletions BHoM_UI/Components/Engine/Compute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using BH.oM.UI;
using BH.UI.Base.Global;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;

namespace BH.UI.Base.Components
{
Expand All @@ -52,7 +54,8 @@ public class ComputeCaller : Caller

public ComputeCaller() : base()
{
SetPossibleItems(Engine.UI.Query.ComputeItems());
IEnumerable<SearchItem> items = Initialisation.SearchItems.Where(x => x.CallerType == typeof(ComputeCaller));
SetPossibleItems(items);
}

/*************************************/
Expand Down
7 changes: 5 additions & 2 deletions BHoM_UI/Components/Engine/Convert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using BH.oM.UI;
using BH.UI.Base.Global;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;

namespace BH.UI.Base.Components
{
Expand All @@ -52,7 +54,8 @@ public class ConvertCaller : Caller

public ConvertCaller() : base()
{
SetPossibleItems(Engine.UI.Query.ConvertItems());
IEnumerable<SearchItem> items = Initialisation.SearchItems.Where(x => x.CallerType == typeof(ConvertCaller));
SetPossibleItems(items);
}

/*************************************/
Expand Down
9 changes: 6 additions & 3 deletions BHoM_UI/Components/Engine/External.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using BH.Adapter;
using BH.oM.UI;
using BH.UI.Base.Global;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using BH.Adapter;

namespace BH.UI.Base.Components
{
Expand All @@ -53,7 +55,8 @@ public class ExternalCaller : Caller

public ExternalCaller() : base()
{
SetPossibleItems(Engine.UI.Query.ExternalItems());
IEnumerable<SearchItem> items = Initialisation.SearchItems.Where(x => x.CallerType == typeof(ExternalCaller));
SetPossibleItems(items);
}

/*************************************/
Expand Down
12 changes: 7 additions & 5 deletions BHoM_UI/Components/Engine/Modify.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using BH.Engine.Base;
using BH.Engine.Reflection;
using BH.oM.UI;
using BH.UI.Base.Global;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using BH.Engine.Base;
using BH.Engine.Reflection;
using BH.oM.UI;

namespace BH.UI.Base.Components
{
Expand Down Expand Up @@ -57,7 +58,8 @@ public class ModifyCaller : Caller

public ModifyCaller() : base()
{
SetPossibleItems(Engine.UI.Query.ModifyItems());
IEnumerable<SearchItem> items = Initialisation.SearchItems.Where(x => x.CallerType == typeof(ModifyCaller));
SetPossibleItems(items);
}


Expand Down
7 changes: 5 additions & 2 deletions BHoM_UI/Components/Engine/Query.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using BH.oM.UI;
using BH.UI.Base.Global;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;

namespace BH.UI.Base.Components
{
Expand All @@ -52,7 +54,8 @@ public class QueryCaller : Caller

public QueryCaller() : base()
{
SetPossibleItems(Engine.UI.Query.QueryItems());
IEnumerable<SearchItem> items = Initialisation.SearchItems.Where(x => x.CallerType == typeof(QueryCaller));
SetPossibleItems(items);
}

/*************************************/
Expand Down
20 changes: 11 additions & 9 deletions BHoM_UI/Components/UI/UnitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,21 @@
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using BH.Engine.Base;
using BH.Engine.Reflection;
using BH.oM.Base;
using BH.oM.Test.UnitTests;
using BH.oM.UI;
using BH.UI.Base.Global;
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using System.CodeDom.Compiler;
using BH.Engine.Reflection;
using System.Windows.Forms;
using System.Windows.Controls;
using BH.oM.Test.UnitTests;
using BH.oM.UI;
using BH.oM.Base;
using BH.Engine.Base;
using System.Windows.Forms;

namespace BH.UI.Base.Components
{
Expand All @@ -60,7 +61,8 @@ public class UnitTestCaller : Caller

public UnitTestCaller() : base()
{
SetPossibleItems(Engine.UI.Query.EngineItems());
IEnumerable<SearchItem> items = Initialisation.SearchItems.Where(x => x.Text.Contains('('));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not know the exact details of the UI, but should we not have a UnitTestCaller type filter here rather than checking whether text contains a parenthesis?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, all methods are candidate for unit testing as far as I understand. I could filter by looking at all callers that use a method but this is much simple and efficient.

SetPossibleItems(items);
}


Expand Down
22 changes: 12 additions & 10 deletions BHoM_UI/Components/oM/CreateData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,22 @@
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using BH.Engine.Data;
using BH.Engine.Reflection;
using BH.Engine.Serialiser;
using BH.oM.Base;
using BH.oM.Data.Collections;
using BH.oM.UI;
using BH.UI.Base.Global;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using System.ComponentModel;
using BH.oM.UI;
using BH.oM.Data.Collections;
using BH.Engine.Reflection;
using BH.Engine.Data;
using BH.Engine.Serialiser;
using System.Windows.Forms;
using BH.oM.Base;
using System.Windows;
using System.Windows.Forms;

namespace BH.UI.Base.Components
{
Expand Down Expand Up @@ -73,7 +74,8 @@ protected set

public CreateDataCaller() : base()
{
SetPossibleItems(Engine.UI.Query.LibraryItems());
IEnumerable<SearchItem> items = Initialisation.SearchItems.Where(x => x.CallerType == typeof(CreateDataCaller));
SetPossibleItems(items);

InputParams = new List<ParamInfo>() { new ParamInfo { DataType = typeof(int), Kind = ParamKind.Input, Name = "index", Description = "index of the data reference" } };
OutputParams = new List<ParamInfo>() { new ParamInfo { DataType = typeof(IObject), Kind = ParamKind.Output, Name = "data", Description = "selected reference data" } };
Expand Down
20 changes: 11 additions & 9 deletions BHoM_UI/Components/oM/CreateEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,21 @@
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using BH.Engine.Base;
using BH.Engine.Data;
using BH.Engine.Reflection;
using BH.Engine.Serialiser;
using BH.oM.Data.Collections;
using BH.oM.UI;
using BH.UI.Base.Global;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using System.ComponentModel;
using BH.oM.UI;
using BH.oM.Data.Collections;
using BH.Engine.Reflection;
using BH.Engine.Data;
using BH.Engine.Serialiser;
using System.Windows.Forms;
using BH.Engine.Base;

namespace BH.UI.Base.Components
{
Expand Down Expand Up @@ -72,7 +73,8 @@ protected set

public CreateEnumCaller() : base()
{
SetPossibleItems(Engine.UI.Query.EnumItems());
IEnumerable<SearchItem> items = Initialisation.SearchItems.Where(x => x.CallerType == typeof(CreateEnumCaller));
SetPossibleItems(items);

InputParams = new List<ParamInfo>() { new ParamInfo { DataType = typeof(int), Kind = ParamKind.Input, Name = "index", Description = "index of the enum value" } };
OutputParams = new List<ParamInfo>() { new ParamInfo { DataType = typeof(Enum), Kind = ParamKind.Output, Name = "enum", Description = "enum value" } };
Expand Down
Loading