-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat(tekla): plugin structure and bind UI (#282)
* Fun 101 * Update package.lock for tekla project * Align tekla with new DI * More alignment * Add launch setting * Message for init * Move project to connectors folder * Show, activate, focus * Post build action * NOT_DEPENDENT for inputs on slides said that it useful on imports and exports and faster around 20x * Add doc for InputObjectDependency.NOT_DEPENDENT * Disable conditions on post build action * Make it work! * Move packages to Directory.Packages.props * Bump tekla package.json to sdk 3.1.0-dev.146 * Add tekla project to Local.sln too * Update packages.lock
- Loading branch information
1 parent
9f402e8
commit b086d16
Showing
14 changed files
with
774 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
Connectors/Tekla/Speckle.Connector.Tekla2024/Bindings/TeklaBasicConnectorBinding.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using Speckle.Connectors.DUI.Bindings; | ||
using Speckle.Connectors.DUI.Bridge; | ||
using Speckle.Connectors.DUI.Models; | ||
using Speckle.Connectors.DUI.Models.Card; | ||
using Speckle.Sdk; | ||
|
||
namespace Speckle.Connector.Tekla2024.Bindings; | ||
|
||
public class TeklaBasicConnectorBinding : IBasicConnectorBinding | ||
{ | ||
private readonly ISpeckleApplication _speckleApplication; | ||
private readonly DocumentModelStore _store; | ||
public string Name => "baseBinding"; | ||
public IBrowserBridge Parent { get; } | ||
|
||
public TeklaBasicConnectorBinding( | ||
IBrowserBridge parent, | ||
ISpeckleApplication speckleApplication, | ||
DocumentModelStore store | ||
) | ||
{ | ||
_speckleApplication = speckleApplication; | ||
_store = store; | ||
Parent = parent; | ||
} | ||
|
||
public string GetSourceApplicationName() => _speckleApplication.Slug; | ||
|
||
public string GetSourceApplicationVersion() => _speckleApplication.HostApplicationVersion; | ||
|
||
public string GetConnectorVersion() => _speckleApplication.SpeckleVersion; | ||
|
||
public DocumentInfo? GetDocumentInfo() => new DocumentInfo("Test", "Test", "Test"); | ||
|
||
public DocumentModelStore GetDocumentState() => _store; | ||
|
||
public void AddModel(ModelCard model) => throw new NotImplementedException(); | ||
|
||
public void UpdateModel(ModelCard model) => throw new NotImplementedException(); | ||
|
||
public void RemoveModel(ModelCard model) => throw new NotImplementedException(); | ||
|
||
public void HighlightModel(string modelCardId) => throw new NotImplementedException(); | ||
|
||
public void HighlightObjects(List<string> objectIds) => throw new NotImplementedException(); | ||
|
||
public BasicConnectorBindingCommands Commands { get; } | ||
} |
27 changes: 27 additions & 0 deletions
27
Connectors/Tekla/Speckle.Connector.Tekla2024/Bindings/TeklaSendBinding.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Speckle.Connectors.DUI.Bindings; | ||
using Speckle.Connectors.DUI.Bridge; | ||
using Speckle.Connectors.DUI.Models.Card.SendFilter; | ||
using Speckle.Connectors.DUI.Settings; | ||
|
||
namespace Speckle.Connector.Tekla2024.Bindings; | ||
|
||
public class TeklaSendBinding : ISendBinding | ||
{ | ||
public string Name => "sendBinding"; | ||
public IBrowserBridge Parent { get; } | ||
|
||
public TeklaSendBinding(IBrowserBridge parent) | ||
{ | ||
Parent = parent; | ||
} | ||
|
||
public List<ISendFilter> GetSendFilters() => []; | ||
|
||
public List<ICardSetting> GetSendSettings() => []; | ||
|
||
public Task Send(string modelCardId) => throw new NotImplementedException(); | ||
|
||
public void CancelSend(string modelCardId) => throw new NotImplementedException(); | ||
|
||
public SendBindingUICommands Commands { get; } | ||
} |
Binary file added
BIN
+149 KB
...kla/Speckle.Connector.Tekla2024/DevDocs/InputObjectDependency.NOT_DEPENDENT.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions
17
Connectors/Tekla/Speckle.Connector.Tekla2024/HostApp/TeklaDocumentModelStore.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Speckle.Connectors.DUI.Models; | ||
using Speckle.Newtonsoft.Json; | ||
|
||
namespace Speckle.Connector.Tekla2024.HostApp; | ||
|
||
public class TeklaDocumentModelStore : DocumentModelStore | ||
{ | ||
public TeklaDocumentModelStore( | ||
JsonSerializerSettings jsonSerializerSettings | ||
// ITopLevelExceptionHandler topLevelExceptionHandler | ||
) | ||
: base(jsonSerializerSettings, true) { } | ||
|
||
public override void WriteToFile() { } | ||
|
||
public override void ReadFromFile() { } | ||
} |
18 changes: 18 additions & 0 deletions
18
Connectors/Tekla/Speckle.Connector.Tekla2024/Plugin/TeklaPlugin.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Tekla.Structures.Plugins; | ||
|
||
namespace Speckle.Connector.Tekla2024.Plugin; | ||
|
||
[Plugin("Speckle.Connectors.Tekla")] | ||
[PluginUserInterface("Speckle.Connector.Tekla2024.SpeckleTeklaPanelHost")] | ||
[InputObjectDependency(InputObjectDependency.NOT_DEPENDENT)] // See DevDocs/InputObjectDependency.NOT_DEPENDENT.png | ||
public class TeklaPlugin : PluginBase | ||
{ | ||
#pragma warning disable IDE1006 | ||
public override bool Run(List<InputDefinition> Input) | ||
{ | ||
return true; | ||
} | ||
#pragma warning restore IDE1006 | ||
|
||
public override List<InputDefinition> DefineInput() => new(); | ||
} |
8 changes: 8 additions & 0 deletions
8
Connectors/Tekla/Speckle.Connector.Tekla2024/Properties/launchSettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"profiles": { | ||
"Tekla2024": { | ||
"commandName": "Executable", | ||
"executablePath": "C:\\Program Files\\Tekla Structures\\2024.0\\bin\\TeklaStructures.exe" | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
Connectors/Tekla/Speckle.Connector.Tekla2024/ServiceRegistration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Speckle.Connector.Tekla2024.Bindings; | ||
using Speckle.Connector.Tekla2024.HostApp; | ||
using Speckle.Connectors.Common; | ||
using Speckle.Connectors.DUI; | ||
using Speckle.Connectors.DUI.Bindings; | ||
using Speckle.Connectors.DUI.Models; | ||
using Speckle.Connectors.DUI.WebView; | ||
|
||
namespace Speckle.Connector.Tekla2024; | ||
|
||
public static class ServiceRegistration | ||
{ | ||
public static void AddTekla(this IServiceCollection serviceCollection) | ||
{ | ||
serviceCollection.AddConnectorUtils(); | ||
serviceCollection.AddDUI(); | ||
serviceCollection.AddDUIView(); | ||
|
||
serviceCollection.AddSingleton<IBinding, TestBinding>(); | ||
serviceCollection.AddSingleton<IBinding, ConfigBinding>(); | ||
serviceCollection.AddSingleton<IBinding, AccountBinding>(); | ||
|
||
serviceCollection.AddSingleton<DocumentModelStore, TeklaDocumentModelStore>(); | ||
|
||
serviceCollection.RegisterTopLevelExceptionHandler(); | ||
|
||
serviceCollection.AddSingleton<IBinding>(sp => sp.GetRequiredService<IBasicConnectorBinding>()); | ||
serviceCollection.AddSingleton<IBasicConnectorBinding, TeklaBasicConnectorBinding>(); | ||
|
||
serviceCollection.AddSingleton<IBinding, TeklaSendBinding>(); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
Connectors/Tekla/Speckle.Connector.Tekla2024/Speckle.Connector.Tekla2024.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net48</TargetFramework> | ||
<UseWpf>true</UseWpf> | ||
<DefineConstants>$(DefineConstants);TEKLA2024</DefineConstants> | ||
<PostBuildEvent>RD /S /Q "$(TargetDir)arm64\" | ||
if EXIST "C:\Program Files\Tekla Structures\2024.0\" ( | ||
xcopy "$(TargetDir)*.*" "C:\ProgramData\Trimble\Tekla Structures\2024.0\Environments\common\extensions\Speckle3TeklaStructures" /Y /I /E | ||
) | ||
if EXIST "C:\TeklaStructures\2024.0\" ( | ||
xcopy "$(TargetDir)*.*" "C:\TeklaStructures\2024.0\Environments\common\extensions\Speckle3TeklaStructures" /Y /I /E | ||
) | ||
</PostBuildEvent> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Tekla.Structures.Dialog" IncludeAssets="compile; build" PrivateAssets="all" /> | ||
<PackageReference Include="Tekla.Structures.Model" IncludeAssets="compile; build" PrivateAssets="all" /> | ||
<PackageReference Include="Tekla.Structures.Plugins" IncludeAssets="compile; build" PrivateAssets="all" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\DUI3\Speckle.Connectors.DUI.WebView\Speckle.Connectors.DUI.WebView.csproj" /> | ||
<ProjectReference Include="..\..\..\DUI3\Speckle.Connectors.DUI\Speckle.Connectors.DUI.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Reference Include="WindowsFormsIntegration" /> | ||
</ItemGroup> | ||
|
||
</Project> |
62 changes: 62 additions & 0 deletions
62
Connectors/Tekla/Speckle.Connector.Tekla2024/SpeckleTeklaPanelHost.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using System.Windows.Forms; | ||
using System.Windows.Forms.Integration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Speckle.Connectors.Common; | ||
using Speckle.Connectors.DUI; | ||
using Speckle.Connectors.DUI.WebView; | ||
using Speckle.Sdk.Host; | ||
using Tekla.Structures.Dialog; | ||
using Tekla.Structures.Model; | ||
using Tekla.Structures.Model.Operations; | ||
|
||
namespace Speckle.Connector.Tekla2024; | ||
|
||
public class SpeckleTeklaPanelHost : PluginFormBase | ||
{ | ||
private ElementHost Host { get; } | ||
public Model Model { get; private set; } | ||
|
||
public static new ServiceProvider? Container { get; private set; } | ||
|
||
// TODO: private IDisposable? _disposableLogger; | ||
|
||
public SpeckleTeklaPanelHost() | ||
{ | ||
var services = new ServiceCollection(); | ||
services.Initialize(HostApplications.TeklaStructures, GetVersion()); | ||
services.AddTekla(); | ||
|
||
// TODO: Add Tekla converters | ||
|
||
Container = services.BuildServiceProvider(); | ||
Container.UseDUI(); // TODO: this might not needed? ISyncToThread? | ||
|
||
Model = new Model(); // don't know what is this.. | ||
if (!Model.GetConnectionStatus()) | ||
{ | ||
MessageBox.Show( | ||
"Speckle connector connection failed. Please try again.", | ||
"Error", | ||
MessageBoxButtons.OK, | ||
MessageBoxIcon.Error | ||
); | ||
} | ||
var webview = Container.GetRequiredService<DUI3ControlWebView>(); | ||
Host = new() { Child = webview, Dock = DockStyle.Fill }; | ||
Controls.Add(Host); | ||
Operation.DisplayPrompt("Speckle connector initialized."); | ||
|
||
Show(); | ||
Activate(); | ||
Focus(); | ||
} | ||
|
||
private HostAppVersion GetVersion() | ||
{ | ||
#if TEKLA2024 | ||
return HostAppVersion.v2024; | ||
#else | ||
throw new NotImplementedException(); | ||
#endif | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<runtime> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/> | ||
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0"/> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="DotNetZip" publicKeyToken="6583c7c814667745" culture="neutral"/> | ||
<bindingRedirect oldVersion="0.0.0.0-1.16.0.0" newVersion="1.16.0.0"/> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
</runtime> | ||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration> |
Oops, something went wrong.