Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

Commit

Permalink
* update sources
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaHofft committed Nov 19, 2023
1 parent df8f058 commit 93b7737
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/AasxPackageExplorer/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 5 additions & 3 deletions src/AasxPackageExplorer/options-debug.MIHO.json
Original file line number Diff line number Diff line change
Expand Up @@ -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", */
Expand All @@ -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,
Expand Down Expand Up @@ -61,7 +63,7 @@
"ShowIdAsIri": false,
"VerboseConnect": true,
"WorkDir": ".\\work",
"CdSortOrder" : "Structured",
"CdSortOrder": "Structured",
"ObserveEvents": true,
"CompressEvents": true,
"CheckSmtElements": false,
Expand Down
45 changes: 34 additions & 11 deletions src/AasxPackageLogic/DispEditHelperBasics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -667,14 +667,15 @@ public void AddActionPanel(
AasxMenu superMenu = null,
AasxMenu ticketMenu = null,
Func<int, AasxMenuActionTicket, AnyUiLambdaActionBase> ticketAction = null,
FirstColumnWidth firstColumnWidth = FirstColumnWidth.Standard)
Func<int, AasxMenuActionTicket, Task<AnyUiLambdaActionBase>> 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;
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -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]);
Expand Down
4 changes: 2 additions & 2 deletions src/AasxPackageLogic/DispEditHelperMiniModules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1738,7 +1738,7 @@ public void DispSmeListAddNewHelper<T>(
stack, key,
repo: repo, superMenu: superMenu,
ticketMenu: menu,
ticketAction: (buttonNdx, ticket) =>
ticketActionAsync: async (buttonNdx, ticket) =>
{
if (buttonNdx >= 0 && buttonNdx <= 3)
{
Expand Down Expand Up @@ -1823,7 +1823,7 @@ public void DispSmeListAddNewHelper<T>(
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)
Expand Down
48 changes: 43 additions & 5 deletions src/AasxPackageLogic/MainWindowAnyUiDialogs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -1810,11 +1814,45 @@ public PackageContainerListBase UiLoadFileRepository(string fn)
return null;
}

/// <summary>
/// Using the currently loaded AASX, will check if a CD_AasxLoadedNavigateTo elements can be
/// found to be activated
/// </summary>
public bool UiCheckIfActivateLoadedNavTo()
public async Task<PackageContainerListBase> 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;
}

/// <summary>
/// Using the currently loaded AASX, will check if a CD_AasxLoadedNavigateTo elements can be
/// found to be activated
/// </summary>
public bool UiCheckIfActivateLoadedNavTo()
{
// access
if (PackageCentral.Main?.AasEnv == null || MainWindow.GetDisplayElements() == null)
Expand Down
79 changes: 66 additions & 13 deletions src/BlazorExplorer/Pages/AnyUiFlyoutSelectFromDataGrid.razor
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
<div class="modal-header">
<h3 class="modal-title" id="exampleModalLongTitle">@ddsfl.Caption</h3>
<button type="button" class="close btn btn-backdrop" aria-label="Close"
@onclick="() => LeaveResult(false)">
@onclick="() => LeaveResult(false, 0)">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form>

@*
<span @ondblclick="@DblHandler">
<select class="form-control selectpicker" multiple data-max-options="2"
style="height:@(numItems)rem; max-height: 60vh;"
Expand All @@ -34,6 +36,39 @@
</select>
</span>
*@

<span @ondblclick="@DblHandler">
<table class="table table-primary table-hover table-bordered border-primary" id="tableIds">
<thead>
<tr>
@if (ddsfl.ColumnHeaders != null)
foreach (var ch in ddsfl.ColumnHeaders)
{
<th scope="col">@ch</th>
}
</tr>
</thead>
<tbody>
@if (ddsfl.Rows != null)
foreach (var row in ddsfl.Rows)
{
var currRow = row;
var active = (row == _selectedRow) ? "table-active " : "";
<tr class="clickable @(active)" @onclick="() => OnSelectRow(currRow)">

@if (ddsfl.ColumnHeaders != null)
for (int ci=0; ci < ddsfl.ColumnHeaders.Length; ci++)
if (currRow.Cells != null && currRow.Cells.Count() >= ci)
{
<th scope="col">@currRow.Cells[ci]</th>
}
</tr>
}
</tbody>
</table>
</span>

</form>
</div>
<div class="modal-footer">
Expand All @@ -46,8 +81,9 @@
{
for (int bi = 0; bi < ddsfl.AlternativeSelectButtons.Length; bi++)
{
var currBi = bi;
var title = ddsfl.AlternativeSelectButtons[bi];
<button type="button" class="btn btn-primary-light btn-lg" @onclick="() => LeaveResult(true, bi)">@title</button>
<button type="button" class="btn btn-primary-light btn-lg" @onclick="() => LeaveResult(true, currBi)">@title</button>
}
}

Expand All @@ -61,21 +97,36 @@
[Parameter]
public AnyUiDialogueDataBase DialogueData { get; set; }

void OnSelect(ChangeEventArgs e)
AnyUiDialogueDataGridRow _selectedRow = null;

void PrepareResult(AnyUiDialogueDataGridRow row)
{
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)
if (DialogueData is AnyUiDialogueDataSelectFromDataGrid ddsfdg)
{
ddsfl.Result = true;
ddsfl.ResultIndex = i;
ddsfl.ResultItem = ddsfl.Rows[i];
if (row != null
&& ddsfdg.Rows != null
&& ddsfdg.Rows.Contains(row))
{
ddsfdg.Result = true;
ddsfdg.ResultIndex = ddsfdg.Rows.IndexOf(row);
ddsfdg.ResultItem = row;
ddsfdg.ResultItems = new List<AnyUiDialogueDataGridRow>() { row };
}
else
{
ddsfdg.Result = false;
ddsfdg.ResultIndex = -1;
ddsfdg.ResultItem = null;
}
}
}

protected void OnSelectRow(AnyUiDialogueDataGridRow de)
{
_selectedRow = de;
StateHasChanged();
}

void DblHandler(MouseEventArgs e)
{
if (DialogueData is AnyUiDialogueDataSelectFromDataGrid ddsfl
Expand All @@ -92,7 +143,9 @@
{
ddsfl.ButtonIndex = buttonIndex;
}


PrepareResult(_selectedRow);

EventSession?.EndModal(result);
}
}

0 comments on commit 93b7737

Please sign in to comment.