From 93b7737695871430e14db852c4ddab42469be9e6 Mon Sep 17 00:00:00 2001 From: MichaelHoffmeisterFesto Date: Sun, 19 Nov 2023 15:17:46 +0100 Subject: [PATCH] * update sources --- src/AasxPackageExplorer/MainWindow.xaml.cs | 2 +- .../options-debug.MIHO.json | 8 +- src/AasxPackageLogic/DispEditHelperBasics.cs | 45 ++++++++--- .../DispEditHelperMiniModules.cs | 4 +- .../MainWindowAnyUiDialogs.cs | 48 +++++++++-- .../Pages/AnyUiFlyoutSelectFromDataGrid.razor | 79 ++++++++++++++++--- 6 files changed, 151 insertions(+), 35 deletions(-) diff --git a/src/AasxPackageExplorer/MainWindow.xaml.cs b/src/AasxPackageExplorer/MainWindow.xaml.cs index d88457e3..4fe72338 100644 --- a/src/AasxPackageExplorer/MainWindow.xaml.cs +++ b/src/AasxPackageExplorer/MainWindow.xaml.cs @@ -929,7 +929,7 @@ private async void Window_Loaded(object sender, RoutedEventArgs e) // Repository pointed by the Options if (Options.Curr.AasxRepositoryFn.HasContent()) { - var fr2 = Logic.UiLoadFileRepository(Options.Curr.AasxRepositoryFn); + var fr2 = await Logic.UiLoadFileRepositoryAsync(Options.Curr.AasxRepositoryFn, tryLoadResident: true); if (fr2 != null) { this.UiShowRepositories(visible: true); diff --git a/src/AasxPackageExplorer/options-debug.MIHO.json b/src/AasxPackageExplorer/options-debug.MIHO.json index 23e174ee..e86ae3c6 100644 --- a/src/AasxPackageExplorer/options-debug.MIHO.json +++ b/src/AasxPackageExplorer/options-debug.MIHO.json @@ -10,7 +10,8 @@ // "AasxRepositoryFn": "C:\\Users\\miho\\Desktop\\201112_Festo_AAS_Demo_Koffer\\repo3\\Festo-DemoBox-repo-local.json", /* "AasxRepositoryFn": "C:\\Users\\miho\\Desktop\\201112_Festo_AAS_Demo_Koffer\\Festo_Demo_Box\\Festo-DemoBox-repo-CPX_E.json", */ /* "AasxRepositoryFn": "C:\\Users\\miho\\Desktop\\new-aasx-repo.json", */ - "AasxRepositoryFn": "C:\\HOMI\\Develop\\Aasx\\repo_demo_case\\Festo-DemoCase-repo-local.json", + // "AasxRepositoryFn": "C:\\HOMI\\Develop\\Aasx\\repo_demo_case\\Festo-DemoCase-repo-local.json", + "AasxRepositoryFn": "C:\\HOMI\\Develop\\Aasx\\repo\\samm-smt-templates.json", /* "AasxToLoad": "C:\\Users\\miho\\Desktop\\200806_Sample_Repo_with_Fluidic_Plan\\MTPsample.aasx", */ /* "AasxToLoad": "http://localhost:51310/server/getaasx/0", */ /* "AasxToLoad": "C:\\MIHO\\Develop\\Aasx\\AasxFesto\\AasxFesto\\AasxFctTool\\bin\\Debug\\net472\\test.aasx", */ @@ -26,7 +27,8 @@ // "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\SMT_Sample_B.aasx", // "AuxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\SMT_Sample_A.aasx", // "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\00_FestoDemoBox-Module-2-Kopie2.aasx", - "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\SMT_and_SAMM_Showcase_v01.aasx", + // "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\SMT_and_SAMM_Showcase_v01.aasx", + "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\Test1.aasx", "WindowLeft": 200, "WindowTop": -1, "WindowWidth": 900, @@ -61,7 +63,7 @@ "ShowIdAsIri": false, "VerboseConnect": true, "WorkDir": ".\\work", - "CdSortOrder" : "Structured", + "CdSortOrder": "Structured", "ObserveEvents": true, "CompressEvents": true, "CheckSmtElements": false, diff --git a/src/AasxPackageLogic/DispEditHelperBasics.cs b/src/AasxPackageLogic/DispEditHelperBasics.cs index ed0de5fe..83355d9a 100644 --- a/src/AasxPackageLogic/DispEditHelperBasics.cs +++ b/src/AasxPackageLogic/DispEditHelperBasics.cs @@ -667,14 +667,15 @@ public void AddActionPanel( AasxMenu superMenu = null, AasxMenu ticketMenu = null, Func ticketAction = null, - FirstColumnWidth firstColumnWidth = FirstColumnWidth.Standard) + Func> ticketActionAsync = null, + FirstColumnWidth firstColumnWidth = FirstColumnWidth.Standard) { // generate actionStr from ticketMenu if (actionStr == null && ticketMenu != null) actionStr = ticketMenu.Select((tmi) => (tmi is AasxMenuItem mi) ? mi.Header : "").ToArray(); // access - if ((action == null && ticketAction == null) || actionStr == null) + if ((action == null && ticketAction == null && ticketActionAsync == null) || actionStr == null) return; if (repo == null && addWoEdit == null) return; @@ -693,7 +694,14 @@ public void AddActionPanel( if (ticket != null) ticket.UiLambdaAction = ticketAction(currentI, ticket); }; - superMenu.Add(tmi); + + tmi.ActionAsync = async (name, item, ticket) => + { + if (ticket != null) + ticket.UiLambdaAction = await ticketActionAsync(currentI, ticket); + }; + + superMenu.Add(tmi); } } @@ -746,14 +754,29 @@ public void AddActionPanel( wp.Children.Add(b); // register callback - AnyUiUIElement.RegisterControl(b, - (o) => - { - // button # as argument! - return (ticketAction != null) - ? ticketAction(currentI, null) - : action?.Invoke(currentI); - }); + if (ticketActionAsync == null) + AnyUiUIElement.RegisterControl(b, + setValue: (o) => + { + // button # as argument! + if (ticketAction != null) + return ticketAction.Invoke(currentI, null); + else + return action?.Invoke(currentI); + }); + else + AnyUiUIElement.RegisterControl(b, + setValueAsync: async (o) => + { + // button # as argument! + if (ticketAction != null) + return ticketAction.Invoke(currentI, null); + else + if (ticketActionAsync != null) + return await ticketActionAsync.Invoke(currentI, null); + else + return action?.Invoke(currentI); + }); if (actionTags != null && i < actionTags.Length) AnyUiUIElement.NameControl(b, actionTags[i]); diff --git a/src/AasxPackageLogic/DispEditHelperMiniModules.cs b/src/AasxPackageLogic/DispEditHelperMiniModules.cs index 16ea47fa..792bae44 100644 --- a/src/AasxPackageLogic/DispEditHelperMiniModules.cs +++ b/src/AasxPackageLogic/DispEditHelperMiniModules.cs @@ -1738,7 +1738,7 @@ public void DispSmeListAddNewHelper( stack, key, repo: repo, superMenu: superMenu, ticketMenu: menu, - ticketAction: (buttonNdx, ticket) => + ticketActionAsync: async (buttonNdx, ticket) => { if (buttonNdx >= 0 && buttonNdx <= 3) { @@ -1823,7 +1823,7 @@ public void DispSmeListAddNewHelper( uc.ColumnHeaders = new[] { "Present", "Card.", "Type", "IdShort", "Id" }; uc.Rows = smtElemItem; - this.context.StartFlyoverModal(uc); + await this.context.StartFlyoverModalAsync(uc); var itemsAdded = 0; ISubmodelElement lastSme = null; if (uc.ResultItems != null) diff --git a/src/AasxPackageLogic/MainWindowAnyUiDialogs.cs b/src/AasxPackageLogic/MainWindowAnyUiDialogs.cs index 95e8c41b..a631bfae 100644 --- a/src/AasxPackageLogic/MainWindowAnyUiDialogs.cs +++ b/src/AasxPackageLogic/MainWindowAnyUiDialogs.cs @@ -1786,15 +1786,19 @@ await DisplayContext.MessageBoxFlyoutShowAsync( // some functions in close relation to UI menu functions // + // TODO (MIHO, 2023-11-19): join the two functions + public PackageContainerListBase UiLoadFileRepository(string fn) { try { + // load the list Log.Singleton.Info( $"Loading aasx file repository {fn} .."); var fr = PackageContainerListFactory.GuessAndCreateNew(fn); + // finalize if (fr != null) return fr; else @@ -1810,11 +1814,45 @@ public PackageContainerListBase UiLoadFileRepository(string fn) return null; } - /// - /// Using the currently loaded AASX, will check if a CD_AasxLoadedNavigateTo elements can be - /// found to be activated - /// - public bool UiCheckIfActivateLoadedNavTo() + public async Task UiLoadFileRepositoryAsync(string fn, bool tryLoadResident) + { + try + { + // load the list + Log.Singleton.Info( + $"Loading aasx file repository {fn} .."); + + var fr = PackageContainerListFactory.GuessAndCreateNew(fn); + + // try load resident? + if (fr != null && tryLoadResident) + foreach (var fi in fr.EnumerateItems()) + { + if (fi.ContainerOptions?.LoadResident == true) + await fi.LoadResidentIfPossible(fr.GetFullItemLocation(fi.Location)); + } + + // finalize + if (fr != null) + return fr; + else + Log.Singleton.Info( + $"File not found when loading aasx file repository {fn}"); + } + catch (Exception ex) + { + Log.Singleton.Error( + ex, $"When loading aasx file repository {Options.Curr.AasxRepositoryFn}"); + } + + return null; + } + + /// + /// Using the currently loaded AASX, will check if a CD_AasxLoadedNavigateTo elements can be + /// found to be activated + /// + public bool UiCheckIfActivateLoadedNavTo() { // access if (PackageCentral.Main?.AasEnv == null || MainWindow.GetDisplayElements() == null) diff --git a/src/BlazorExplorer/Pages/AnyUiFlyoutSelectFromDataGrid.razor b/src/BlazorExplorer/Pages/AnyUiFlyoutSelectFromDataGrid.razor index 3beabc7c..ff6291b6 100644 --- a/src/BlazorExplorer/Pages/AnyUiFlyoutSelectFromDataGrid.razor +++ b/src/BlazorExplorer/Pages/AnyUiFlyoutSelectFromDataGrid.razor @@ -15,12 +15,14 @@