You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by jo...@apache.org on 2021/07/08 07:04:25 UTC

[isis] 01/02: ISIS-2505 omit empty fieldset, amend IconManager, fix compiler warnings

This is an automated email from the ASF dual-hosted git repository.

joergrade pushed a commit to branch ISIS-2505_Catch_Up_With_Demo_Examples
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 1ba080ae403be09e95cccc97a761b3e515c752fd
Author: Jörg Rade <jo...@kuehne-nagel.com>
AuthorDate: Wed Jul 7 18:26:10 2021 +0200

    ISIS-2505 omit empty fieldset, amend IconManager, fix compiler warnings
---
 .../isis/client/kroviz/ui/builder/ColBuilder.kt    |  23 ++--
 .../isis/client/kroviz/ui/core/ColumnFactory.kt    |  14 ++-
 .../apache/isis/client/kroviz/ui/core/RoTable.kt   |   2 +-
 .../apache/isis/client/kroviz/utils/IconManager.kt | 133 +++++++++++----------
 .../org/apache/isis/client/kroviz/utils/Utils.kt   |   9 +-
 5 files changed, 97 insertions(+), 84 deletions(-)

diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/builder/ColBuilder.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/builder/ColBuilder.kt
index f746902..7afd9bc 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/builder/ColBuilder.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/builder/ColBuilder.kt
@@ -27,6 +27,7 @@ import org.apache.isis.client.kroviz.to.bs3.Col
 import org.apache.isis.client.kroviz.ui.core.MenuFactory
 import org.apache.isis.client.kroviz.ui.core.RoDisplay
 import org.apache.isis.client.kroviz.ui.core.RoTable
+import org.apache.isis.client.kroviz.utils.Utils
 
 class ColBuilder : UiBuilder() {
 
@@ -43,16 +44,18 @@ class ColBuilder : UiBuilder() {
             panel.add(tgCpt)
         }
         for (fs in col.fieldSetList) {
-            val fsCpt = FieldSetBuilder().create(fs, tObject, dsp)!!
-            var legend = fs.name
-            if (legend.trim().length == 0) {
-                legend = fs.id
+            if (fs.propertyList.size > 0) {
+                val fsCpt = FieldSetBuilder().create(fs, tObject, dsp)!!
+                var legend = fs.name
+                if (legend.trim().length == 0) {
+                    legend = fs.id
+                }
+                legend = Utils.capitalize(legend)
+                val fsPanel = FieldsetPanel(legend = legend).add(fsCpt)
+                val tto = TooltipOptions(title = fs.id)
+                fsPanel.enableTooltip(tto)
+                panel.add(fsPanel)
             }
-            legend = legend.capitalize()
-            val fsPanel = FieldsetPanel(legend = legend).add(fsCpt)
-            val tto = TooltipOptions(title = fs.id)
-            fsPanel.enableTooltip(tto)
-            panel.add(fsPanel)
         }
         for (row in col.rowList) {
             val rowCpt = RowBuilder().create(row, tObject, dsp)
@@ -63,7 +66,7 @@ class ColBuilder : UiBuilder() {
             val objectDM = dsp.displayModel
             val collectionDM = objectDM.collections.get(key)!!
             val tblCpt = RoTable(collectionDM)
-            val fsPanel = FieldsetPanel(legend = key.capitalize()).add(tblCpt)
+            val fsPanel = FieldsetPanel(legend = Utils.capitalize(key)).add(tblCpt)
             panel.add(fsPanel)
             collectionDM.isRendered = true
         }
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/ColumnFactory.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/ColumnFactory.kt
index 1294f22..03a841e 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/ColumnFactory.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/ColumnFactory.kt
@@ -64,7 +64,7 @@ class ColumnFactory {
             columns.add(menu)
 
             val icon = buildLinkIcon()
-           columns.add(icon)
+            columns.add(icon)
         }
 
         val propertyLabels = displayCollection.properties.list
@@ -98,7 +98,8 @@ class ColumnFactory {
                 width = "40",
 /*                formatterComponentFunction = { _, _, data ->
                     buildButton(data, data["iconName"] as? String)
-                }*/)
+                }*/
+        )
     }
 
     private fun buildButton(data: Exposer, iconName: String?): Button {
@@ -121,7 +122,8 @@ class ColumnFactory {
                     Button(text = data["object"].title as String, icon = "fas fa-star-o", style = ButtonStyle.LINK).onClick {
                         console.log(data)
                     }
-                }*/)
+                }*/
+        )
     }
 
     private fun buildCheckBox(): ColumnDefinition<Exposer> {
@@ -147,7 +149,8 @@ class ColumnFactory {
     }
 
     private fun buildMenu(): ColumnDefinition<Exposer> {
-        return ColumnDefinition("",
+        return ColumnDefinition(
+                "",
                 field = "iconName", // any existing field can be used
                 formatter = Formatter.TICKCROSS,
                 formatterParams = menuFormatterParams,
@@ -159,7 +162,8 @@ class ColumnFactory {
                     MenuFactory.buildForObject(
                             tObject,
                             false)
-                }*/)
+                }*/
+        )
     }
 
     private fun getData(cell: Tabulator.CellComponent): Exposer {
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoTable.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoTable.kt
index c2d20e3..355576d 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoTable.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoTable.kt
@@ -49,7 +49,7 @@ class RoTable(displayCollection: CollectionDM) : SimplePanel() {
         val options = TabulatorOptions(
                 movableColumns = true,
                 height = Constants.calcHeight,
-                layout = Layout.FITCOLUMNS,
+                layout = Layout.FITCOLUMNS, //FITDATA seems to be right
                 columns = columns,
                 persistenceMode = false,
                 //selectable = true
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/utils/IconManager.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/utils/IconManager.kt
index 079afcd..68f89bc 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/utils/IconManager.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/utils/IconManager.kt
@@ -30,72 +30,73 @@ object IconManager {
 
     /* Merge with configuration values*/
     private val word2Icon = mapOf(
-        "About" to "info",
-        "Actions" to "ellipsis-v",
-        "All" to "asterisk",
-        "Blobs" to "cloud",
-        "Burger" to "bars",
-        "Chart" to "magic",
-        "Close" to "times",
-        "Configuration" to "wrench",
-        "Connect" to "plug",
-        "Console" to "terminal",
-        "Create" to "plus",
-        "Debug" to "bug",
-        "Delete" to "trash",
-        "Details" to "info-circle",
-        "Diagram" to "project-diagram",
-        "Download" to "download",
-        "Factory" to "industry",
-        "Featured" to "keyboard",
-        "Featured Types" to "keyboard",
-        "Edit" to "pencil",
-        "Error Handling" to "bug",
-        "Error" to "bug",
-        "Event" to "road",
-        "Experimental" to "flask",
-        "Export" to "file-export",
-        "Facet" to "gem",
-        "Find" to "search",
-        "Hierarchy" to "sitemap",
-        "History" to "history",
-        "Hsql" to "database",
-        "Isis" to "ankh",
-        "JEE/CDI" to "jedi",
-        "List" to "list",
-        "Location" to "map-marker",
-        "Log" to "history",
-        "Manager" to "manager",
-        "Map" to "map",
-        "Me" to "user",
-        "Notification" to "bell",
-        "Notifications" to "bell",
-        "Object" to "cube",
-        "Objects" to "cubes",
-        "OK" to "check",
-        "Open" to "book",
-        "Other" to "asterisk",
-        "Pin" to "map-pin",
-        "Primitives" to "hashtag",
-        "Prototyping" to "object-group",
-        "Queen" to "chess-queen",
-        "Run" to "rocket",
-        "Save" to "file",
-        "Security" to "lock",
-        "Simple" to "cubes",
-        "Switch" to "power-off",
-        "Target" to "bullseye",
-        "Text" to "font",
-        "Toast" to "bread-slice", //comment-alt-plus/minus/exclamation
-        "Toolbar" to "step-backward",
-        "Tooltips" to "comment-alt",
-        "Temporals" to "clock",
-        "Trees" to "tree",
-        "Types" to "typewriter",
-        "Undo" to "undo",
-        "Unknown" to "question",
-        "Visualize" to "eye",
-        "Wikipedia" to "wikipedia-w"
+            "About" to "info",
+            "Actions" to "ellipsis-v",
+            "All" to "asterisk",
+            "Blobs" to "cloud",
+            "Burger" to "bars",
+            "Chart" to "magic",
+            "Close" to "times",
+            "Configuration" to "wrench",
+            "Connect" to "plug",
+            "Console" to "terminal",
+            "Create" to "plus",
+            "Debug" to "bug",
+            "Delete" to "trash",
+            "Details" to "info-circle",
+            "Diagram" to "project-diagram",
+            "Download" to "download",
+            "Factory" to "industry",
+            "Featured" to "keyboard",
+            "Featured Types" to "keyboard",
+            "Edit" to "pencil",
+            "Error Handling" to "bug",
+            "Error" to "bug",
+            "Event" to "road",
+            "Experimental" to "flask",
+            "Export" to "file-export",
+            "Facet" to "gem",
+            "Find" to "search",
+            "Hierarchy" to "sitemap",
+            "History" to "history",
+            "Hsql" to "database",
+            "Isis" to "ankh",
+            "JEE/CDI" to "jedi",
+            "List" to "list",
+            "Location" to "map-marker",
+            "Log" to "history",
+            "Manager" to "manager",
+            "Map" to "map",
+            "Me" to "user",
+            "Notification" to "bell",
+            "Notifications" to "bell",
+            "Object" to "cube",
+            "Objects" to "cubes",
+            "OK" to "check",
+            "Open" to "book",
+            "Other" to "asterisk",
+            "Pin" to "map-pin",
+            "Primitives" to "hashtag",
+            "Prototyping" to "object-group",
+            "Queen" to "chess-queen",
+            "Run" to "rocket",
+            "Save" to "file",
+            "Security" to "lock",
+            "Simple" to "cubes",
+            "Strings" to "font",
+            "Switch" to "power-off",
+            "Target" to "bullseye",
+            "Text" to "font",
+            "Toast" to "bread-slice", //comment-alt-plus/minus/exclamation
+            "Toolbar" to "step-backward",
+            "Tooltips" to "comment-alt",
+            "Temporals" to "clock",
+            "Trees" to "tree",
+            "Types" to "typewriter",
+            "Undo" to "undo",
+            "Unknown" to "question",
+            "Visualize" to "eye",
+            "Wikipedia" to "wikipedia-w"
     )
 
     @OptIn(ExperimentalStdlibApi::class)
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/utils/Utils.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/utils/Utils.kt
index 00861b2..3c08788 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/utils/Utils.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/utils/Utils.kt
@@ -24,17 +24,22 @@ import org.apache.isis.client.kroviz.to.TObject
 
 object Utils {
 
-    @OptIn(ExperimentalStdlibApi::class)
     fun enCamel(input: String): String {
         var output = ""
         val words = input.split(" ")
         for (w in words) {
-            output += w.capitalize()
+            output += capitalize(w)
         }
         return decapitalize(output)
     }
 
     @OptIn(ExperimentalStdlibApi::class)
+    fun capitalize(input: String): String {
+        val output = input.substring(1, input.length)
+        return input.first().uppercaseChar() + output
+    }
+
+    @OptIn(ExperimentalStdlibApi::class)
     private fun decapitalize(input: String): String {
         val output = input.substring(1, input.length)
         return input.first().lowercaseChar() + output