From 0b92de8515668903b6aaa4e4becb648778f4a492 Mon Sep 17 00:00:00 2001 From: Norbert Csaba Herczeg Date: Mon, 22 Jul 2024 20:06:30 +0200 Subject: [PATCH] JNG-5853 refactors and additional tests --- .../operations/jsl/actor/actorDeclaration.eol | 7 ---- .../epsilon/operations/ui/namedElement.eol | 3 -- .../epsilon/transformations/ui/jslToUi.etl | 13 +++++-- .../application/JslModel2UiWidgetsTest.java | 36 ++++++++++++++----- 4 files changed, 37 insertions(+), 22 deletions(-) diff --git a/judo-tatami-jsl-jsl2ui/src/main/epsilon/operations/jsl/actor/actorDeclaration.eol b/judo-tatami-jsl-jsl2ui/src/main/epsilon/operations/jsl/actor/actorDeclaration.eol index 7a9e30b7..9c9c457f 100644 --- a/judo-tatami-jsl-jsl2ui/src/main/epsilon/operations/jsl/actor/actorDeclaration.eol +++ b/judo-tatami-jsl-jsl2ui/src/main/epsilon/operations/jsl/actor/actorDeclaration.eol @@ -89,10 +89,3 @@ operation JSL!ActorDeclaration getExposedTransferObjects() : Set { return collected; } - -@cached -operation JSL!ActorDeclaration getExposedVisibleDeclarations() : Set { - var transfers = self.getExposedTransferObjects(); - - return transfers.select(t | t.isTypeOf(JSL!ViewDeclaration) or t.isTypeOf(JSL!RowDeclaration)).asSet(); -} diff --git a/judo-tatami-jsl-jsl2ui/src/main/epsilon/operations/ui/namedElement.eol b/judo-tatami-jsl-jsl2ui/src/main/epsilon/operations/ui/namedElement.eol index af86f4d2..b25937ac 100644 --- a/judo-tatami-jsl-jsl2ui/src/main/epsilon/operations/ui/namedElement.eol +++ b/judo-tatami-jsl-jsl2ui/src/main/epsilon/operations/ui/namedElement.eol @@ -3,9 +3,6 @@ operation UI!ui::NamedElement getRootApplication() : UI!ui::Application { if (self.eContainer.isTypeOf(UI!ui::Application)) { return self.eContainer; } else { - if (self.eContainer.isUndefined()) { - log.info("AAAAA >>>>>>>>>> " + self.getFqName()); - } return self.eContainer.getRootApplication(); } } diff --git a/judo-tatami-jsl-jsl2ui/src/main/epsilon/transformations/ui/jslToUi.etl b/judo-tatami-jsl-jsl2ui/src/main/epsilon/transformations/ui/jslToUi.etl index d2835312..a9d760ae 100644 --- a/judo-tatami-jsl-jsl2ui/src/main/epsilon/transformations/ui/jslToUi.etl +++ b/judo-tatami-jsl-jsl2ui/src/main/epsilon/transformations/ui/jslToUi.etl @@ -35,6 +35,13 @@ pre { } } } + for (visible : JSL!VisibleDeclaration in JSL!VisibleDeclaration.all()) { + if (visible.isTypeOf(JSL!ViewDeclaration) or visible.isTypeOf(JSL!RowDeclaration)) { + for (member in visible.members) { + member.~pos = visible.members.indexOf(member) + 1; + } + } + } } post { @@ -48,7 +55,7 @@ post { group.items = group.items.sortBy(e | e.~pos); } - /*for (container : UI!ui::Container in UI!ui::Container.all().select(a | a.getRootApplication() == application)) { + for (container : UI!ui::Container in UI!ui::Container.all().select(a | a.getRootApplication() == application)) { var missingPos = false; for (child in container.children) { if (child.~pos.isUndefined()) { @@ -57,8 +64,8 @@ post { } } if (missingPos) { - throw "Missing position parameter(s) under Container: " + container; + throw "Missing position parameter(s) under Container: " + container.name; } container.children = container.children.sortBy(e | e.~pos); - }*/ + } } diff --git a/judo-tatami-jsl-jsl2ui/src/test/java/hu/blackbelt/judo/tatami/jsl/jsl2ui/application/JslModel2UiWidgetsTest.java b/judo-tatami-jsl-jsl2ui/src/test/java/hu/blackbelt/judo/tatami/jsl/jsl2ui/application/JslModel2UiWidgetsTest.java index b435e8f9..1e387765 100644 --- a/judo-tatami-jsl-jsl2ui/src/test/java/hu/blackbelt/judo/tatami/jsl/jsl2ui/application/JslModel2UiWidgetsTest.java +++ b/judo-tatami-jsl-jsl2ui/src/test/java/hu/blackbelt/judo/tatami/jsl/jsl2ui/application/JslModel2UiWidgetsTest.java @@ -75,25 +75,25 @@ enum MyEnum { view UserView(User u) { group level1 label:"Yo" icon:"text" { group level2 width:12 frame:true icon:"unicorn" label:"Level 2" stretch:true { - field String email <= u.email bind required; - field Binary binaryDerived <= u.binary; - field String stringDerived <= u.string; + field String email <= u.email bind required icon:"text" label: "My Email"; + field Binary binaryDerived <= u.binary icon:"binary" label:"Binary Derived"; + field String stringDerived <= u.string icon:"string" label:"String Derived"; } group level22 width:6 frame:true icon:"dog" label:"Level 2 - 2" orientation:horizontal { - field Boolean booleanDerived <= u.boolean; - field Date dateDerived <= u.date; - field Numeric numericDerived <= u.numeric; + field Boolean booleanDerived <= u.boolean icon:"boolean" label:"Boolean Derived"; + field Date dateDerived <= u.date icon:"date" label:"Date Derived"; + field Numeric numericDerived <= u.numeric icon:"numeric" label:"Numeric Derived"; } tabs tabs0 orientation:horizontal width:6 { group tab1 label:"Tab1" icon:"numbers" h-align:left { - field Time timeDerived <= u.time; + field Time timeDerived <= u.time icon:"time" label:"Time Derived"; } group tab2 label:"Tab2" icon:"numbers" h-align:right { - field Timestamp timestampDerived <= u.timestamp; - field MyEnum mappedEnum <= u.`enum` bind default:MyEnum#Crazy; + field Timestamp timestampDerived <= u.timestamp icon:"timestamp" label:"Timestamp Derived"; + field MyEnum mappedEnum <= u.`enum` bind default:MyEnum#Crazy icon:"enum" label:"Mapped Enum"; } } } @@ -164,6 +164,8 @@ view UserView(User u) { TextInput email = (TextInput) level2.getChildren().stream().filter(c -> c.getName().equals("email")).findFirst().orElseThrow(); assertEquals("email", email.getName()); + assertEquals("My Email", email.getLabel()); + assertEquals("text", email.getIcon().getIconName()); assertEquals("String", email.getAttributeType().getDataType().getName()); assertTrue(email.getAttributeType().isIsRequired()); assertFalse(email.getAttributeType().isIsReadOnly()); @@ -171,6 +173,8 @@ view UserView(User u) { BinaryTypeInput binaryDerived = (BinaryTypeInput) level2.getChildren().stream().filter(c -> c.getName().equals("binaryDerived")).findFirst().orElseThrow(); assertEquals("binaryDerived", binaryDerived.getName()); + assertEquals("Binary Derived", binaryDerived.getLabel()); + assertEquals("binary", binaryDerived.getIcon().getIconName()); assertEquals("Binary", binaryDerived.getAttributeType().getDataType().getName()); assertFalse(binaryDerived.getAttributeType().isIsRequired()); assertTrue(binaryDerived.getAttributeType().isIsReadOnly()); @@ -178,6 +182,8 @@ view UserView(User u) { TextInput stringDerived = (TextInput) level2.getChildren().stream().filter(c -> c.getName().equals("stringDerived")).findFirst().orElseThrow(); assertEquals("stringDerived", stringDerived.getName()); + assertEquals("String Derived", stringDerived.getLabel()); + assertEquals("string", stringDerived.getIcon().getIconName()); assertEquals("String", stringDerived.getAttributeType().getDataType().getName()); assertFalse(stringDerived.getAttributeType().isIsRequired()); assertTrue(stringDerived.getAttributeType().isIsReadOnly()); @@ -198,6 +204,8 @@ view UserView(User u) { TrinaryLogicCombo booleanDerived = (TrinaryLogicCombo) level22.getChildren().stream().filter(c -> c.getName().equals("booleanDerived")).findFirst().orElseThrow(); assertEquals("booleanDerived", booleanDerived.getName()); + assertEquals("Boolean Derived", booleanDerived.getLabel()); + assertEquals("boolean", booleanDerived.getIcon().getIconName()); assertEquals("Boolean", booleanDerived.getAttributeType().getDataType().getName()); assertFalse(booleanDerived.getAttributeType().isIsRequired()); assertTrue(booleanDerived.getAttributeType().isIsReadOnly()); @@ -205,6 +213,8 @@ view UserView(User u) { DateInput dateDerived = (DateInput) level22.getChildren().stream().filter(c -> c.getName().equals("dateDerived")).findFirst().orElseThrow(); assertEquals("dateDerived", dateDerived.getName()); + assertEquals("Date Derived", dateDerived.getLabel()); + assertEquals("date", dateDerived.getIcon().getIconName()); assertEquals("Date", dateDerived.getAttributeType().getDataType().getName()); assertFalse(dateDerived.getAttributeType().isIsRequired()); assertTrue(dateDerived.getAttributeType().isIsReadOnly()); @@ -212,6 +222,8 @@ view UserView(User u) { NumericInput numericDerived = (NumericInput) level22.getChildren().stream().filter(c -> c.getName().equals("numericDerived")).findFirst().orElseThrow(); assertEquals("numericDerived", numericDerived.getName()); + assertEquals("Numeric Derived", numericDerived.getLabel()); + assertEquals("numeric", numericDerived.getIcon().getIconName()); assertEquals("Numeric", numericDerived.getAttributeType().getDataType().getName()); assertFalse(numericDerived.getAttributeType().isIsRequired()); assertTrue(numericDerived.getAttributeType().isIsReadOnly()); @@ -243,6 +255,8 @@ view UserView(User u) { TimeInput timeDerived = (TimeInput) tab1Element.getChildren().stream().filter(c -> c.getName().equals("timeDerived")).findFirst().orElseThrow(); assertEquals("timeDerived", timeDerived.getName()); + assertEquals("Time Derived", timeDerived.getLabel()); + assertEquals("time", timeDerived.getIcon().getIconName()); assertEquals("Time", timeDerived.getAttributeType().getDataType().getName()); assertFalse(timeDerived.getAttributeType().isIsRequired()); assertTrue(timeDerived.getAttributeType().isIsReadOnly()); @@ -265,6 +279,8 @@ view UserView(User u) { DateTimeInput timestampDerived = (DateTimeInput) tab2Element.getChildren().stream().filter(c -> c.getName().equals("timestampDerived")).findFirst().orElseThrow(); assertEquals("timestampDerived", timestampDerived.getName()); + assertEquals("Timestamp Derived", timestampDerived.getLabel()); + assertEquals("timestamp", timestampDerived.getIcon().getIconName()); assertEquals("Timestamp", timestampDerived.getAttributeType().getDataType().getName()); assertFalse(timestampDerived.getAttributeType().isIsRequired()); assertTrue(timestampDerived.getAttributeType().isIsReadOnly()); @@ -272,6 +288,8 @@ view UserView(User u) { EnumerationCombo mappedEnum = (EnumerationCombo) tab2Element.getChildren().stream().filter(c -> c.getName().equals("mappedEnum")).findFirst().orElseThrow(); assertEquals("mappedEnum", mappedEnum.getName()); + assertEquals("Mapped Enum", mappedEnum.getLabel()); + assertEquals("enum", mappedEnum.getIcon().getIconName()); assertEquals("MyEnum", mappedEnum.getAttributeType().getDataType().getName()); assertFalse(mappedEnum.getAttributeType().isIsRequired()); assertFalse(mappedEnum.getAttributeType().isIsReadOnly());