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 2022/02/11 09:01:03 UTC

[isis] branch ISIS-2957 created (now 39736ff)

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

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


      at 39736ff  ISIS-2949 catch NPE's

This branch includes the following new commits:

     new 39736ff  ISIS-2949 catch NPE's

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[isis] 01/01: ISIS-2949 catch NPE's

Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 39736ff33c7efa992bf74c82f46d40ed6928c754
Author: Jörg Rade <jo...@kuehne-nagel.com>
AuthorDate: Fri Feb 11 10:00:04 2022 +0100

    ISIS-2949 catch NPE's
---
 incubator/clients/kroviz/build.gradle.kts          |  5 ++
 .../kotlin/org/apache/isis/client/kroviz/App.kt    |  5 +-
 .../apache/isis/client/kroviz/ui/core/FormItem.kt  |  2 +-
 .../apache/isis/client/kroviz/ui/core/RoDialog.kt  |  2 +-
 .../apache/isis/client/kroviz/ui/core/RoMenuBar.kt | 37 +++++----
 .../isis/client/kroviz/ui/dialog/ChartDialog.kt    | 95 ++++++++++++++++++++++
 6 files changed, 126 insertions(+), 20 deletions(-)

diff --git a/incubator/clients/kroviz/build.gradle.kts b/incubator/clients/kroviz/build.gradle.kts
index 546e7f8..1d4eff1 100644
--- a/incubator/clients/kroviz/build.gradle.kts
+++ b/incubator/clients/kroviz/build.gradle.kts
@@ -100,6 +100,11 @@ kotlin {
         implementation("io.kvision:kvision-rest:$kvisionVersion")
         implementation("io.kvision:kvision-moment:$kvisionVersion")
         implementation("io.kvision:kvision-maps:$kvisionVersion")
+        implementation("io.data2viz.d2v:d2v-core-js:0.9.1")
+        implementation("io.data2viz.d2v:d2v-color-js:0.9.1")
+        implementation("io.data2viz.d2v:d2v-scale-js:0.9.1")
+        implementation("io.data2viz.d2v:d2v-viz-js:0.9.1")
+
         implementation(npm("xmltojson", "1.3.5", false))
         implementation(npm("flatted", "3.2.2", false))
         implementation(npm("diff", "5.0.0", false))
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/App.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/App.kt
index f690d74..da3d549 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/App.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/App.kt
@@ -26,17 +26,18 @@ import org.apache.isis.client.kroviz.ui.core.RoApp
 import org.apache.isis.client.kroviz.ui.core.ViewManager
 
 class App : Application() {
+    private val appName = "kroviz"
 
     var roApp : RoApp? = null
 
     init {
         Pace.init()
-        require("css/kroviz.css")
+        require("css/$appName.css")
         initRoApp()
     }
 
     override fun start() {
-        val r = root("kroviz", addRow = true)
+        val r = root(appName, addRow = true)
         val v = VPanel()
         v.add(roApp!!)
         r.add(v)
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/FormItem.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/FormItem.kt
index 5644605..00c16e9 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/FormItem.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/FormItem.kt
@@ -32,7 +32,7 @@ class FormItem(
         var callBack: Any? = null,
         var callBackAction: String? = null) {
 
-    private var originalContent: Any? = content
+    private val originalContent: Any? = content
     var readOnly = false
 
     init {
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 e118e8e..584d87e 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
@@ -37,7 +37,7 @@ import io.kvision.html.Link as KvisionHtmlLink
 
 class RoDialog(
     caption: String,
-    val items: List<FormItem>,
+    val items: List<FormItem> = mutableListOf(),
     val controller: Controller,
     defaultAction: String = "OK",
     widthPerc: Int = 30,
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoMenuBar.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoMenuBar.kt
index 299b7a7..185564a 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoMenuBar.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoMenuBar.kt
@@ -34,10 +34,7 @@ import org.apache.isis.client.kroviz.core.Session
 import org.apache.isis.client.kroviz.core.event.ResourceProxy
 import org.apache.isis.client.kroviz.to.mb.Menubars
 import org.apache.isis.client.kroviz.ui.chart.SampleChartModel
-import org.apache.isis.client.kroviz.ui.dialog.About
-import org.apache.isis.client.kroviz.ui.dialog.EventDialog
-import org.apache.isis.client.kroviz.ui.dialog.LoginPrompt
-import org.apache.isis.client.kroviz.ui.dialog.SvgInline
+import org.apache.isis.client.kroviz.ui.dialog.*
 import org.apache.isis.client.kroviz.ui.panel.EventChart
 import org.apache.isis.client.kroviz.ui.panel.GeoMap
 import org.apache.isis.client.kroviz.ui.panel.ImageSample
@@ -198,19 +195,27 @@ class RoMenuBar : SimplePanel() {
             buildMenuEntry(testTitle, "Test", { this.executeAllMenuBarActions() })
         )
 
+        val d3Title = "BarchartExample"
+        mainMenu.add(
+            buildMenuEntry(
+                d3Title,
+                "Test",
+                { ChartDialog(SessionManager.getEventStore().log, "barchartExample").open() })
+        )
+
         /*
-              val testTitle = "Test"
-                mainMenu.add(
-                    buildMenuEntry(testTitle, "Test", { this.testFirstSession() })
-                )
-
-         mainMenu.add(
-             buildMenuEntry("Browser in IFrame", "Wikipedia", { BrowserWindow("https://isis.apache.org/").open() })
-         )
-
-         mainMenu.add(
-             buildMenuEntry("SSH", "Terminal", { ShellWindow("localhost:8080").open() })
-         )*/
+               val testTitle = "Test"
+                 mainMenu.add(
+                     buildMenuEntry(testTitle, "Test", { this.testFirstSession() })
+                 )
+
+          mainMenu.add(
+              buildMenuEntry("Browser in IFrame", "Wikipedia", { BrowserWindow("https://isis.apache.org/").open() })
+          )
+
+          mainMenu.add(
+              buildMenuEntry("SSH", "Terminal", { ShellWindow("localhost:8080").open() })
+          )*/
 
         return mainMenu
     }
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/dialog/ChartDialog.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/dialog/ChartDialog.kt
new file mode 100644
index 0000000..0cceb52
--- /dev/null
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/dialog/ChartDialog.kt
@@ -0,0 +1,95 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.isis.client.kroviz.ui.dialog
+
+import io.data2viz.color.Colors
+import io.data2viz.geom.size
+import io.data2viz.scale.Scales
+import io.data2viz.viz.*
+import io.kvision.html.Canvas
+import org.apache.isis.client.kroviz.core.event.LogEntry
+import org.apache.isis.client.kroviz.ui.core.RoDialog
+import org.w3c.dom.HTMLCanvasElement
+
+class ChartDialog(
+    private val expectedEvents: List<LogEntry>,
+    canvasId: String
+) : Controller() {
+
+    init {
+        dialog = RoDialog(
+            caption = canvasId,
+            items = mutableListOf(),
+            controller = this,
+            defaultAction = "OK",
+            widthPerc = 50,
+            heightPerc = 50,
+            customButtons = mutableListOf()
+        )
+        val canvas = Canvas(200, 200)
+        canvas.addAfterInsertHook {
+            val htmlCanvas = canvas.unsafeCast<HTMLCanvasElement>()
+            viz().bindRendererOn(htmlCanvas)
+        }
+        dialog.add(canvas)
+    }
+
+    private fun viz(): Viz {
+        val vizSize = 500.0
+        val barHeight = 14.0
+        val cPadding = 2.0
+        val data = listOf(4, 8, 15, 16, 23, 42)
+
+        val xScale = Scales.Continuous.linear {
+            domain = listOf(.0, data.maxOrNull()!!.toDouble())
+            range = listOf(.0, vizSize - 2 * cPadding)
+        }
+
+        val viz = viz {
+            size = size(vizSize, vizSize)
+            data.forEachIndexed { index, datum ->
+                group {
+                    transform {
+                        translate(
+                            x = cPadding,
+                            y = cPadding + index * (cPadding + barHeight)
+                        )
+                    }
+                    rect {
+                        width = xScale(datum.toDouble())
+                        height = barHeight
+                        fill = Colors.Web.steelblue
+                    }
+                    text {
+                        textContent = datum.toString()
+                        hAlign = TextHAlign.RIGHT
+                        vAlign = TextVAlign.HANGING
+                        x = xScale(datum.toDouble()) - 2.0
+                        y = 1.5
+                        textColor = Colors.Web.white
+                        fontSize = 10.0
+                    }
+                }
+            }
+        }
+        return viz
+    }
+
+}
+