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/09/12 05:29:53 UTC

[isis] 02/04: ISIS-2846 UI clean up

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

joergrade pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 999d2e18ba694e9114fe88ce4315d9edbe5152c3
Author: Jörg Rade <jo...@kuehne-nagel.com>
AuthorDate: Fri Sep 10 13:52:25 2021 +0200

    ISIS-2846 UI clean up
---
 .../org/apache/isis/client/kroviz/ui/core/RoDialog.kt | 17 ++++++++++++++++-
 .../isis/client/kroviz/ui/dialog/DiagramDialog.kt     |  2 +-
 .../isis/client/kroviz/ui/dialog/EventLogDetail.kt    | 19 +++++++++++++------
 .../isis/client/kroviz/ui/panel/EventLogTable.kt      |  4 +++-
 4 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoDialog.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoDialog.kt
index 8b299c8..b977975 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoDialog.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoDialog.kt
@@ -44,7 +44,8 @@ class RoDialog(
         defaultAction: String = "OK",
         widthPerc: Int = 30,
         heightPerc: Int = 100,
-        menu: List<KvisionHtmlLink>? = null) :
+        menu: List<KvisionHtmlLink>? = null,
+        customButtons: List<FormItem> = emptyList() ) :
         Displayable, RoWindow(caption = caption, closeButton = true, menu = menu) {
 
     private val okButton = Button(
@@ -101,6 +102,10 @@ class RoDialog(
                     spacing = 10,
                     classes = setOf("button-bar"))
             buttonBar.add(okButton)
+            customButtons.forEach {
+                val b = createButton(it)
+                buttonBar.add(b)
+            }
             buttonBar.add(cancelButton)
             if (items.isNotEmpty() && hasScalableContent()) {
                 buttonBar.add(scaleUpButton)
@@ -148,4 +153,14 @@ class RoDialog(
         //TODO put Dialog to lower right message box
     }
 
+    private fun createButton(fi: FormItem): Button {
+        val item = Button(text = fi.label, icon = IconManager.find(fi.label))
+        val obj = fi.callBack!! as Command
+        val action = fi.callBackAction
+        item.onClick {
+            obj.execute(action)
+        }
+        return item
+    }
+
 }
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/dialog/DiagramDialog.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/dialog/DiagramDialog.kt
index 750c3b1..ed239bc 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/dialog/DiagramDialog.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/dialog/DiagramDialog.kt
@@ -48,7 +48,7 @@ class DiagramDialog(
         dialog = RoDialog(
                 widthPerc = 80,
                 heightPerc = 80,
-                caption = "Diagram",
+                caption = label,
                 items = formItems,
                 command = this,
                 defaultAction = "Pin",
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/dialog/EventLogDetail.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/dialog/EventLogDetail.kt
index e72da92..afd9e98 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/dialog/EventLogDetail.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/dialog/EventLogDetail.kt
@@ -58,15 +58,18 @@ class EventLogDetail(val logEntryFromTabulator: LogEntry) : Command() {
         formItems.add(FormItem("Url", ValueType.TEXT, logEntry.title))
         formItems.add(FormItem("Response", ValueType.TEXT_AREA, responseStr, 10))
         formItems.add(FormItem("Aggregators", ValueType.TEXT, content = logEntry.aggregators))
-        formItems.add(FormItem("Link Tree Diagram", ValueType.BUTTON, null, callBack = this, callBackAction = LNK))
-        formItems.add(FormItem("Console", ValueType.BUTTON, null, callBack = this, callBackAction = LOG))
+
+        val customButtons = mutableListOf<FormItem>()
+        customButtons.add(FormItem("Link Tree Diagram", ValueType.BUTTON, null, callBack = this, callBackAction = LNK))
+        customButtons.add(FormItem("Console", ValueType.BUTTON, null, callBack = this, callBackAction = LOG))
 
         dialog = RoDialog(
                 caption = "Details :" + logEntry.title,
                 items = formItems,
                 command = this,
-                defaultAction = "Diagram",
-                widthPerc = 60)
+                defaultAction = "Response Diagram",
+                widthPerc = 60,
+                customButtons = customButtons)
         dialog.open()
     }
 
@@ -96,16 +99,20 @@ class EventLogDetail(val logEntryFromTabulator: LogEntry) : Command() {
 
     private fun defaultAction() {
         val str = logEntry.response
+        var label = "Diagram"
         val pumlCode = when {
             str.startsWith("<") -> {
                 val grid = logEntry.obj as Grid
+                label = "Layout Diagram"
                 LayoutDiagram.build(grid)
             }
-            str.startsWith("{") ->
+            str.startsWith("{") -> {
+                label = "JSON / XML Diagram"
                 JsonDiagram.build(str)
+            }
             else -> "{}"
         }
-        DiagramDialog("Layout Diagram", pumlCode).open()
+        DiagramDialog(label, pumlCode).open()
     }
 
 }
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/panel/EventLogTable.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/panel/EventLogTable.kt
index 9108c93..12885e8 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/panel/EventLogTable.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/panel/EventLogTable.kt
@@ -44,6 +44,7 @@ class EventLogTable(val model: List<LogEntry>) : VPanel() {
                     width = "50",
                     headerMenu = DynamicMenuBuilder().buildTableMenu(this),
                     hozAlign = Align.CENTER,
+                    vertAlign = VAlign.MIDDLE,
                     formatterComponentFunction = { _, _, data -> buildActionButton(data) }
             ),
             ColumnDefinition(
@@ -129,9 +130,10 @@ class EventLogTable(val model: List<LogEntry>) : VPanel() {
         val b = Button(
                 text = "",
                 icon = "fa fa-info-circle",
-                style = data.state.style)
+                style = data.state.style        )
         b.onClick { EventLogDetail(data).open() }
         b.margin = CssSize(-10, UNIT.px)
+        b.addCssClass("btn-sm")
         return b
     }