diff --git a/src/AasxPackageLogic/DispEditHelperMiniModules.cs b/src/AasxPackageLogic/DispEditHelperMiniModules.cs index 049d4fbee..16ea47faf 100644 --- a/src/AasxPackageLogic/DispEditHelperMiniModules.cs +++ b/src/AasxPackageLogic/DispEditHelperMiniModules.cs @@ -1874,7 +1874,7 @@ public void DispSmeListAddNewHelper( }); } - public static Aas.ISubmodel DispEditHelperCreateSubmodelFromSmtSamm( + public static Tuple DispEditHelperCreateSubmodelFromSmtSamm( PackageCentral.PackageCentral packages, Aas.IEnvironment env, Aas.IConceptDescription rootCd, @@ -1893,8 +1893,12 @@ public static Aas.ISubmodel DispEditHelperCreateSubmodelFromSmtSamm( env.Submodels.Add(submodel); var aas1 = env?.AssetAdministrationShells?.FirstOrDefault(); + Aas.IReference smres = null; if (aas1 != null) - aas1.Submodels.Add(submodel.GetReference()); + { + smres = submodel.GetReference(); + aas1.Submodels.Add(smres); + } // lambda to recurse int numAdded = 0; @@ -1956,7 +1960,7 @@ public static Aas.ISubmodel DispEditHelperCreateSubmodelFromSmtSamm( Log.Singleton.Info($"Added {numAdded}. {numErrors} errors."); // ok - return submodel; + return new Tuple(submodel, smres); } } diff --git a/src/AasxPackageLogic/DispEditHelperSammModules.cs b/src/AasxPackageLogic/DispEditHelperSammModules.cs index 05b992866..f911a0899 100644 --- a/src/AasxPackageLogic/DispEditHelperSammModules.cs +++ b/src/AasxPackageLogic/DispEditHelperSammModules.cs @@ -2590,6 +2590,21 @@ public static IEnumerable // possible childs? var childs = new List(); + + // lambda for going deeper (Property) -> Characteristics -> Entity -> Property + Func lambdaTryProp2Entity = (propTest) => + { + var propCharCd = packages.QuickLookupFirstIdent(propTest.Characteristic?.Value); + var propCharMe = DispEditHelperSammModules.CheckReferableForSammElements(propCharCd)?.FirstOrDefault(); + if (propCharMe is Samm.Characteristic propChar) + { + var propEntCd = packages.QuickLookupFirstIdent(propChar.DataType?.Value); + var propEntMe = DispEditHelperSammModules.CheckReferableForSammElements(propEntCd)?.FirstOrDefault(); + if (propEntMe is Samm.Entity ent) + return ent; + } + return null; + }; // Aspect if (me is Samm.Aspect asp) @@ -2602,9 +2617,10 @@ public static IEnumerable childs.AddRange(asp.Events); } - // Property -> Charasteristics -> Enitity -> Property + // Property if (me is Samm.Property prop) { +#if old var propCharCd = packages.QuickLookupFirstIdent(prop.Characteristic?.Value); var propCharMe = DispEditHelperSammModules.CheckReferableForSammElements(propCharCd)?.FirstOrDefault(); if (propCharMe is Samm.Characteristic propChar) @@ -2615,7 +2631,13 @@ public static IEnumerable foreach (var p in ent.Properties) childs.Add(p); } - } +#endif + + var propEnt = lambdaTryProp2Entity(prop); + if (propEnt?.Properties != null) + foreach (var p in propEnt.Properties) + childs.Add(p); + } // try lookup childs foreach (var child in childs) @@ -2638,7 +2660,11 @@ public static IEnumerable smtRec.ExampleValue = childProp.ExampleValue; // poor mens SME type - smtRec.SubmodelElements = new List() { AasSubmodelElements.Property }; + var childSmeType = AasSubmodelElements.Property; + var childEntTest = lambdaTryProp2Entity(childProp); + if (childEntTest != null) + childSmeType = AasSubmodelElements.SubmodelElementCollection; + smtRec.SubmodelElements = new List() { childSmeType }; // put into item yield return new DispEditHelperMiniModules.ConceptOrganizedChildItem() diff --git a/src/AasxPackageLogic/MainWindowAnyUiDialogs.cs b/src/AasxPackageLogic/MainWindowAnyUiDialogs.cs index 1b0013c4d..95e8c41bf 100644 --- a/src/AasxPackageLogic/MainWindowAnyUiDialogs.cs +++ b/src/AasxPackageLogic/MainWindowAnyUiDialogs.cs @@ -1532,10 +1532,28 @@ await DisplayContextPlus.CheckIfDownloadAndStart( MainWindow.RedrawAllElementsAndFocus(); } - if (cmd == "submodelinstancefromsammaspect" + if (cmd == "submodelinstancefromsmtconcepts") + { + // simply pass on + try + { + // delegate futher + await CommandBinding_GeneralDispatchHeadless(cmd, menuItem, ticket); + } + catch (Exception ex) + { + LogErrorToTicket(ticket, ex, + $"When executing command {cmd}, an error occurred"); + } + + // redisplay + if (ticket.Success) + MainWindow.RedrawAllElementsAndFocus(nextFocus: ticket?.SetNextFocus); + } + + if (cmd == "submodelinstancefromsammaspect" || cmd == "smtextensionfromqualifiers" - || cmd == "smtorganizesfromSubmodel" - || cmd == "submodelinstancefromsmtconcepts") + || cmd == "smtorganizesfromSubmodel") { // simply pass on try diff --git a/src/AasxPackageLogic/MainWindowHeadless.cs b/src/AasxPackageLogic/MainWindowHeadless.cs index 27f0c0906..bb691edfb 100644 --- a/src/AasxPackageLogic/MainWindowHeadless.cs +++ b/src/AasxPackageLogic/MainWindowHeadless.cs @@ -1445,7 +1445,7 @@ record = rec; } // perfom dialogue - if (!DisplayContext.StartFlyoverModal(uc) + if (!(await DisplayContext.StartFlyoverModalAsync(uc)) || !uc.Result || uc.ResultItem == null) return; @@ -1465,8 +1465,8 @@ record = rec; Log.Singleton.Error("Error creating new Submodel from accessible ConceptDescriptions."); else { - Log.Singleton.Info($"Submodel {sm.IdShort} created"); - ticket.SetNextFocus = sm; + Log.Singleton.Info($"Submodel {sm.Item1.IdShort} created"); + ticket.SetNextFocus = sm.Item2; } } catch (Exception ex) diff --git a/src/BlazorExplorer/Data/BlazorSession.CommandBindings.cs b/src/BlazorExplorer/Data/BlazorSession.CommandBindings.cs index a3f20d313..51cc3bed3 100644 --- a/src/BlazorExplorer/Data/BlazorSession.CommandBindings.cs +++ b/src/BlazorExplorer/Data/BlazorSession.CommandBindings.cs @@ -84,6 +84,9 @@ public async Task CommandBinding_GeneralDispatch( MainMenu?.SetChecked("HintsMenu", hintsMode); } + // trigger re-indexing + TriggerPendingReIndexElements(); + // try to remember current selected data object object currMdo = null; if (DisplayElements.SelectedItem != null) diff --git a/src/BlazorExplorer/Data/BlazorSession.cs b/src/BlazorExplorer/Data/BlazorSession.cs index bb49339c9..6a6dd6e68 100644 --- a/src/BlazorExplorer/Data/BlazorSession.cs +++ b/src/BlazorExplorer/Data/BlazorSession.cs @@ -634,6 +634,8 @@ public bool PrepareDisplayDataAndElementPanel( return true; } + private bool _mainTimer_PendingReIndexElements = true; + private DateTime _mainTimer_LastCheckForReIndexElements = DateTime.Now; /// /// This is the main session timer callback. It is either activated by the session itself @@ -641,7 +643,25 @@ public bool PrepareDisplayDataAndElementPanel( /// public void MainTimerTick() { + // do re-index? + var deltaSecs2 = (DateTime.Now - _mainTimer_LastCheckForReIndexElements).TotalSeconds; + if (deltaSecs2 >= 1.0 && _mainTimer_PendingReIndexElements) + { + // dis-engage + _mainTimer_PendingReIndexElements = false; + + // be modest for the time being + PackageCentral?.MainItem?.Container?.ReIndexIdentifiables(); + + // Info + Log.Singleton.Info("Re-indexing Identifiables for faster access."); + } + } + public void TriggerPendingReIndexElements() + { + _mainTimer_LastCheckForReIndexElements = DateTime.Now; + _mainTimer_PendingReIndexElements = true; } /// diff --git a/src/BlazorExplorer/Pages/AnyUiFlyoutSelectFromDataGrid.razor b/src/BlazorExplorer/Pages/AnyUiFlyoutSelectFromDataGrid.razor index 1fca3569a..3beabc7c9 100644 --- a/src/BlazorExplorer/Pages/AnyUiFlyoutSelectFromDataGrid.razor +++ b/src/BlazorExplorer/Pages/AnyUiFlyoutSelectFromDataGrid.razor @@ -1,67 +1,55 @@ -@page "/AnyUiFlyoutSelectFromDatGrid" -@using AasxIntegrationBase +@page "/AnyUiFlyoutSelectFromDataGrid" @using AnyUi -@using AasxPredefinedConcepts -@using AasxPackageLogic @using BlazorUI.Data @inject BlazorUI.Data.AASService SubmodelService @inject BlazorUI.Data.BlazorSession bi -@if (EventSession != null && DialogueData is AnyUiDialogueDataSelectReferableFromPool ddsfl) +@if (EventSession != null && DialogueData is AnyUiDialogueDataSelectFromDataGrid ddsfl) { @* see Modal.razor: Bootstrap inner dialog classes *@ + int numItems = 2; + if (ddsfl.Rows != null && ddsfl.Rows.Count >= 2) + numItems = (150 * ddsfl.Rows.Count) / 100; + } @@ -73,102 +61,38 @@ [Parameter] public AnyUiDialogueDataBase DialogueData { get; set; } - [Parameter] - public AasxPredefinedConcepts.DefinitionsPool DataSourcePools { get; set; } - - protected List _domainNames = new List(); - protected string _domainCurrent = ""; - - protected DefinitionsPoolEntityBase _selectedEntity = null; - protected List _domainEntities = new List(); - - protected override void OnInitialized() + void OnSelect(ChangeEventArgs e) { - // pass thru - base.OnInitialized(); - - // access - if (!(DialogueData is AnyUiDialogueDataSelectReferableFromPool ddsrp)) - return; - - // domains - _domainNames.Clear(); - if (DataSourcePools != null) + if (DialogueData is AnyUiDialogueDataSelectFromDataGrid ddsfl + && e.Value is string[] varr + && varr.Length > 0 + && int.TryParse(varr[0], out int i) + && ddsfl.Rows != null + && i >= 0 && i < ddsfl.Rows.Count) { - var domains = DataSourcePools.GetDomains().ToList(); - domains.Sort(); - foreach (var d in domains) - _domainNames.Add(d); - } - - // no domain entities, yet - _domainEntities.Clear(); - - // first? - if (_domainNames.Count > 0) - { - _domainCurrent = _domainNames[0]; - ShowDomain(_domainCurrent); + ddsfl.Result = true; + ddsfl.ResultIndex = i; + ddsfl.ResultItem = ddsfl.Rows[i]; } } - protected void ShowDomain(string domain) + void DblHandler(MouseEventArgs e) { - // access - if (domain?.HasContent() != true) + if (DialogueData is AnyUiDialogueDataSelectFromDataGrid ddsfl + && ddsfl.AlternativeSelectButtons != null + && ddsfl.AlternativeSelectButtons.Length > 0) return; - // nothing selected, yet - _selectedEntity = null; - - // display - var ld = this.DataSourcePools?.GetEntitiesForDomain(domain)?.ToList(); - if (ld != null) - { - ld.Sort((x1, x2) => x1.DisplayName.CompareTo(x2.DisplayName)); - _domainEntities.Clear(); - foreach (var ent in ld) - _domainEntities.Add(ent); - StateHasChanged(); - } + LeaveResult(true, 0); } - void OnSelectDomain(ChangeEventArgs e) + public void LeaveResult(bool result, int buttonIndex) { - if (DialogueData is AnyUiDialogueDataSelectReferableFromPool ddsrp - && e.Value is string valstr - && int.TryParse(valstr, out int i) - && i >= 0 && i < _domainNames.Count) + if (DialogueData is AnyUiDialogueDataSelectFromDataGrid ddsfl) { - ShowDomain(_domainNames[i]); + ddsfl.ButtonIndex = buttonIndex; } + + EventSession?.EndModal(result); } - - protected void OnSelectRow(DefinitionsPoolEntityBase de) - { - _selectedEntity = de; - StateHasChanged(); - } - - void DblHandler(MouseEventArgs e) - { - LeaveResult(true); - } - - public void LeaveResult(bool result) - { - if (DialogueData is AnyUiDialogueDataSelectReferableFromPool ddsrp - && _domainEntities != null - && _selectedEntity != null) - { - ddsrp.ResultItem = _selectedEntity; - ddsrp.ResultIndex = _domainEntities.IndexOf(_selectedEntity); - EventSession?.EndModal(true); - } - else - { - // no - EventSession?.EndModal(false); - } - } -} \ No newline at end of file +} diff --git a/src/BlazorExplorer/Pages/Index.razor b/src/BlazorExplorer/Pages/Index.razor index b31a3d3c7..c8e7a76d8 100644 --- a/src/BlazorExplorer/Pages/Index.razor +++ b/src/BlazorExplorer/Pages/Index.razor @@ -87,6 +87,12 @@ DialogueData="evs.DialogueData" /> } + @if (evs.DialogueData is AnyUiDialogueDataSelectFromDataGrid) + { + + } + @if (evs.DialogueData is AnyUiDialogueDataOpenFile) {