Skip to content

Commit 09eaabc

Browse files
committed
* work on empty list
for CDs * find statistics fixed
1 parent 7a1de31 commit 09eaabc

11 files changed

+459
-203
lines changed

src/AasxCsharpLibrary/Extensions/ExtendILangStringDefinitionTypeIec61360.cs

+28-15
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,42 @@ namespace Extensions
1313
{
1414
public static class ExtendILangStringDefinitionTypeIec61360
1515
{
16-
public static List<ILangStringDefinitionTypeIec61360> CreateLangStringDefinitionType(string language, string text)
16+
public static string GetDefaultString(this List<ILangStringDefinitionTypeIec61360> langStringSet, string defaultLang = null)
1717
{
18-
return new List<ILangStringDefinitionTypeIec61360> { new LangStringDefinitionTypeIec61360(language, text) };
18+
return ExtendLangString.GetDefaultStringGen(langStringSet, defaultLang);
1919
}
20-
public static string GetDefaultString(this List<ILangStringDefinitionTypeIec61360> langStringSet, string defaultLang = null)
20+
21+
public static List<ILangStringDefinitionTypeIec61360> CreateFrom(string text, string lang = "en")
2122
{
22-
// start
23-
if (defaultLang == null)
24-
defaultLang = "en"; //Default Lang in old implementation is en
23+
if (text == null)
24+
return null;
2525

26-
string res = null;
26+
var res = new List<ILangStringDefinitionTypeIec61360>();
27+
res.Add(new LangStringDefinitionTypeIec61360(lang, text));
28+
return res;
29+
}
2730

28-
// search
29-
foreach (var langString in langStringSet)
30-
if (langString.Language.Equals(defaultLang, StringComparison.OrdinalIgnoreCase))
31-
res = langString.Text;
31+
public static bool IsEmpty(this List<ILangStringDefinitionTypeIec61360> langStringSet)
32+
{
33+
if (langStringSet == null || langStringSet.Count == 0)
34+
{
35+
return true;
36+
}
3237

33-
if (res == null && langStringSet.Count > 0)
34-
res = langStringSet[0].Text;
38+
return false;
39+
}
3540

36-
// found?
37-
return res;
41+
public static bool IsValid(this List<ILangStringDefinitionTypeIec61360> elems)
42+
{
43+
if (elems == null || elems.Count < 1)
44+
return false;
45+
foreach (var ls in elems)
46+
if (ls?.Language == null || ls.Language.Trim().Length < 1
47+
|| ls.Text == null || ls.Text.Trim().Length < 1)
48+
return false;
49+
return true;
3850
}
51+
3952
public static List<ILangStringDefinitionTypeIec61360> ConvertFromV20(
4053
this List<ILangStringDefinitionTypeIec61360> lss,
4154
AasxCompatibilityModels.AdminShellV20.LangStringSetIEC61360 src)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
Copyright (c) 2018-2023 Festo SE & Co. KG <https://www.festo.com/net/de_de/Forms/web/contact_international>
3+
Author: Michael Hoffmeister
4+
5+
This source code is licensed under the Apache License 2.0 (see LICENSE.txt).
6+
7+
This source code may use other Open Source software components (see LICENSE.txt).
8+
*/
9+
using Extensions;
10+
using System.Collections.Generic;
11+
using System.Linq;
12+
using AdminShellNS;
13+
using Aas = AasCore.Aas3_0;
14+
15+
namespace Extensions
16+
{
17+
public static class ExtendILevelType
18+
{
19+
public static bool IsEmpty(this ILevelType level)
20+
{
21+
return !(level.Nom || level.Typ || level.Min || level.Max);
22+
}
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
Copyright (c) 2018-2023 Festo SE & Co. KG <https://www.festo.com/net/de_de/Forms/web/contact_international>
3+
Author: Michael Hoffmeister
4+
5+
This source code is licensed under the Apache License 2.0 (see LICENSE.txt).
6+
7+
This source code may use other Open Source software components (see LICENSE.txt).
8+
*/
9+
using Extensions;
10+
using System.Collections.Generic;
11+
using System.Linq;
12+
using AdminShellNS;
13+
using Aas = AasCore.Aas3_0;
14+
15+
namespace Extensions
16+
{
17+
public static class ExtendIValueList
18+
{
19+
public static bool IsEmpty(this IValueList list)
20+
{
21+
return list.ValueReferencePairs == null
22+
|| list.ValueReferencePairs.Count < 1;
23+
}
24+
25+
public static bool IsValid(this IValueList list)
26+
{
27+
if (IsEmpty(list))
28+
return false;
29+
30+
foreach (var vp in list.ValueReferencePairs)
31+
if (vp.Value?.HasContent() != true
32+
|| vp.ValueId?.IsValid() != true)
33+
return false;
34+
35+
return true;
36+
}
37+
}
38+
}

src/AasxPackageLogic/DispEditHelperBasics.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1997,8 +1997,8 @@ uc.ResultItem is AasxPredefinedConcepts.DefinitionsPoolReferableEntity pe
19971997
if (topContextMenu)
19981998
{
19991999
List<string> contextHeaders = new();
2000-
contextHeaders.AddRange(new[] { "\u2205", "Set all \u2192 blank" });
2001-
contextHeaders.AddRange(new[] { "\u2702", "Delete completely" });
2000+
contextHeaders.AddRange(new[] { "\u2205", "Set all keys \u2192 1 blank" });
2001+
contextHeaders.AddRange(new[] { "\u2702", "Delete keys completely" });
20022002

20032003
if (addEclassIrdi)
20042004
contextHeaders.AddRange(new[] { "\U0001f517", "Add ECLASS" });

src/AasxPackageLogic/DispEditHelperMiniModules.cs

+13-8
Original file line numberDiff line numberDiff line change
@@ -1478,6 +1478,7 @@ public void ValueListHelper(
14781478
Aas.IEnvironment env,
14791479
AnyUiStackPanel stack, ModifyRepo repo, string key,
14801480
List<Aas.IValueReferencePair> valuePairs,
1481+
Action<IValueList> setValueList = null,
14811482
Aas.IReferable relatedReferable = null,
14821483
AasxMenu superMenu = null)
14831484
{
@@ -1493,10 +1494,7 @@ public void ValueListHelper(
14931494
if (buttonNdx == 0)
14941495
{
14951496
valuePairs.Add(new Aas.ValueReferencePair(
1496-
"",
1497-
new Aas.Reference(Aas.ReferenceTypes.ExternalReference, new List<Aas.IKey> {
1498-
new Aas.Key(Aas.KeyTypes.GlobalReference, "")
1499-
})));
1497+
"", Options.Curr.GetDefaultEmptyReference()));
15001498
this.AddDiaryEntry(relatedReferable, new DiaryEntryStructChange());
15011499
}
15021500

@@ -1535,8 +1533,13 @@ public void ValueListHelper(
15351533
}
15361534
}
15371535

1538-
if (buttonNdx == 3 && valuePairs.Count > 0)
1539-
valuePairs.RemoveAt(valuePairs.Count - 1);
1536+
if (buttonNdx == 3)
1537+
{
1538+
if (valuePairs.Count > 0)
1539+
valuePairs.RemoveAt(valuePairs.Count - 1);
1540+
if (valuePairs.Count < 1)
1541+
setValueList?.Invoke(null);
1542+
}
15401543

15411544
return new AnyUiLambdaActionRedrawEntity();
15421545
});
@@ -1573,8 +1576,8 @@ public void ValueListHelper(
15731576
.CreateFrom(
15741577
AdminShellUtil.GetDefaultLngIso639(), "" + valuePairs[i].Value),
15751578
definition: ExtendILangStringDefinitionTypeIec61360
1576-
.CreateLangStringDefinitionType(
1577-
AdminShellUtil.GetDefaultLngIso639(), "" + valuePairs[i].Value),
1579+
.CreateFrom("" + valuePairs[i].Value,
1580+
lang: AdminShellUtil.GetDefaultLngIso639()),
15781581
dataType: Aas.DataTypeIec61360.StringTranslatable));
15791582

15801583
var cd = new Aas.ConceptDescription(
@@ -1622,6 +1625,8 @@ public void ValueListHelper(
16221625
{
16231626
case 0:
16241627
valuePairs.Remove(vp);
1628+
if (valuePairs.Count < 1)
1629+
setValueList?.Invoke(null);
16251630
action = true;
16261631
break;
16271632
case 1:

0 commit comments

Comments
 (0)