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 2020/06/08 10:45:14 UTC

[isis] branch master updated: ISIS-2350 Tool panel introduced

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


The following commit(s) were added to refs/heads/master by this push:
     new 72b262b  ISIS-2350 Tool panel introduced
72b262b is described below

commit 72b262ba0e3ab0f9814fe93a86e717d9c56bc6ed
Author: Jörg Rade <jo...@kuehne-nagel.com>
AuthorDate: Mon Jun 8 12:44:40 2020 +0200

    ISIS-2350 Tool panel introduced
---
 .../org/apache/isis/client/kroviz/to/TypeMapper.kt |  3 +-
 .../apache/isis/client/kroviz/ui/BrowserWindow.kt  | 17 ++++++
 .../apache/isis/client/kroviz/ui/IconManager.kt    |  4 ++
 .../isis/client/kroviz/ui/kv/FormPanelFactory.kt   | 20 ++++++-
 .../org/apache/isis/client/kroviz/ui/kv/RoApp.kt   | 11 ++--
 .../apache/isis/client/kroviz/ui/kv/RoMenuBar.kt   |  7 +++
 .../apache/isis/client/kroviz/ui/kv/RoStatusBar.kt | 13 +----
 .../apache/isis/client/kroviz/ui/kv/RoToolPanel.kt | 68 +++++++++++++++++++---
 8 files changed, 116 insertions(+), 27 deletions(-)

diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/TypeMapper.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/TypeMapper.kt
index 94cd7d6..e0de44e 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/TypeMapper.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/TypeMapper.kt
@@ -13,7 +13,8 @@ enum class ValueType(val type: String) {
     TEXT_AREA("TextArea"),
     TIME("Time"),
     SIMPLE_SELECT("SimpleSelect"),
-    SLIDER("Slider")
+    SLIDER("Slider"),
+    IFRAME("IFrame")
 }
 
 class TypeMapper {
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/BrowserWindow.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/BrowserWindow.kt
new file mode 100644
index 0000000..07900d5
--- /dev/null
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/BrowserWindow.kt
@@ -0,0 +1,17 @@
+package org.apache.isis.client.kroviz.ui
+
+import org.apache.isis.client.kroviz.ui.kv.RoDialog
+
+class BrowserWindow(val url: String) : Command() {
+
+    fun open() {
+        val formItems = mutableListOf<FormItem>()
+        formItems.add(FormItem("URL", "IFrame", url))
+        RoDialog(
+                caption = url,
+                items = formItems,
+                command = this,
+                defaultAction = "Visualize").open()
+    }
+
+}
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/IconManager.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/IconManager.kt
index 63ac6dd..3ba2f0b 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/IconManager.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/IconManager.kt
@@ -45,19 +45,23 @@ object IconManager {
             "Me" to "user",
             "Notification" to "bell",
             "Notifications" to "bell",
+            "Object" to "cube",
             "Objects" to "cubes",
             "OK" to "check",
             "Open" to "book",
             "Other" to "asterisk",
             "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
+            "Toolbox" to "magic",
             "Tooltips" to "comment-alt",
             "Temporals" to "clock",
             "Trees" to "tree",
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/FormPanelFactory.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/FormPanelFactory.kt
index f7f4792..d04df81 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/FormPanelFactory.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/FormPanelFactory.kt
@@ -4,6 +4,7 @@ import org.apache.isis.client.kroviz.to.ValueType
 import org.apache.isis.client.kroviz.ui.FormItem
 import org.apache.isis.client.kroviz.utils.DateHelper
 import pl.treksoft.kvision.core.Component
+import pl.treksoft.kvision.core.Overflow
 import pl.treksoft.kvision.core.StringPair
 import pl.treksoft.kvision.core.onEvent
 import pl.treksoft.kvision.form.FormPanel
@@ -18,6 +19,7 @@ import pl.treksoft.kvision.form.text.TextArea
 import pl.treksoft.kvision.form.time.DateTime
 import pl.treksoft.kvision.form.time.dateTime
 import pl.treksoft.kvision.html.Div
+import pl.treksoft.kvision.html.Iframe
 import pl.treksoft.kvision.panel.VPanel
 import pl.treksoft.kvision.panel.vPanel
 import pl.treksoft.kvision.utils.auto
@@ -30,7 +32,7 @@ class FormPanelFactory(items: List<FormItem>) : VPanel() {
 
     init {
         panel = formPanel {
-            height = 100.perc
+            height = auto
             margin = 10.px
             for (fi: FormItem in items) {
                 when (fi.type) {
@@ -45,6 +47,7 @@ class FormPanelFactory(items: List<FormItem>) : VPanel() {
                     ValueType.BOOLEAN.type -> add(createBoolean(fi))
                     ValueType.IMAGE.type -> add(createImage(fi))
                     ValueType.SLIDER.type -> add(createSlider(fi))
+                    ValueType.IFRAME.type -> add(createIFrame(fi))
                 }
             }
         }
@@ -150,4 +153,19 @@ class FormPanelFactory(items: List<FormItem>) : VPanel() {
         return item
     }
 
+    private fun createIFrame(fi: FormItem): VPanel {
+        val item = VPanel {
+            val url = fi.content as String
+            val iframe = Iframe(url)
+            iframe.height = 100.perc
+            iframe.width = 100.perc
+            iframe.overflow = Overflow.INHERIT
+            add(iframe)
+        }
+        item.height = 100.perc
+        item.width = 100.perc
+        item.overflow = Overflow.INHERIT
+        return item
+    }
+
 }
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/RoApp.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/RoApp.kt
index 5fd1e52..5625c95 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/RoApp.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/RoApp.kt
@@ -1,14 +1,17 @@
 package org.apache.isis.client.kroviz.ui.kv
 
+import pl.treksoft.kvision.panel.HPanel
 import pl.treksoft.kvision.panel.SimplePanel
 
 object RoApp : SimplePanel() {
     init {
         this.add(RoMenuBar.navbar)
-//        val view = HPanel()
-//        view.add(RoToolPanel().panel)
-//        view.add(RoView.tabPanel)
-        this.add(RoView.tabPanel)
+
+        val view = HPanel()
+        view.add(RoToolPanel.panel)
+        view.add(RoView.tabPanel)
+        this.add(view)
+
         this.add(RoStatusBar.navbar)
     }
 }
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/RoMenuBar.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/RoMenuBar.kt
index 2a2ea72..48a77b3 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/RoMenuBar.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/RoMenuBar.kt
@@ -51,6 +51,13 @@ object RoMenuBar : SimplePanel() {
                 LoginPrompt().open(at)
             }
 
+            val toolTitle = "Toolbox"
+            ddLink(toolTitle,
+                    icon = IconManager.find(toolTitle)
+            ).onClick {
+                RoToolPanel.toggle()
+            }
+
             val sampleTitle = "History"
             ddLink(sampleTitle,
                     icon = IconManager.find(sampleTitle)
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/RoStatusBar.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/RoStatusBar.kt
index c493aff..4002bb6 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/RoStatusBar.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/RoStatusBar.kt
@@ -25,9 +25,7 @@ object RoStatusBar {
     private val userBtn: Button = buildButton("", "Me", ButtonStyle.OUTLINEWARNING)
     private val umlDiagram = buildButton("", "Diagram", ButtonStyle.OUTLINEWARNING)
     private val lastError = buildButton("OK", "OK", ButtonStyle.OUTLINESUCCESS)
-    private val alert = buildButton("", "Notification", ButtonStyle.OUTLINEINFO)
-    private val drag = buildButton("", "Objects", ButtonStyle.OUTLINEINFO)
-    private val drop = buildButton("", "Wikipedia", ButtonStyle.OUTLINEINFO)
+    private val alert = buildButton("", "Notification", ButtonStyle.OUTLINESUCCESS)
 
     private fun buildButton(text: String, iconName: String, style: ButtonStyle): Button {
         return Button(
@@ -45,15 +43,6 @@ object RoStatusBar {
         nav.add(umlDiagram)
         nav.add(userBtn)
         nav.add(alert)
-        drag.setDragDropData("text/plain", "element")
-        nav.add(drag)
-        drop.setDropTarget("text/plain") { data ->
-            console.log("[RoStatsbar.drop]" )
-            if (data.target.asDynamic().textContent == "element") {
-                console.log("[RoStatsbar.drop]" )
-            }
-        }
-        nav.add(drop)
     }
 
     fun updateDiagram(dd: DiagramDM) {
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/RoToolPanel.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/RoToolPanel.kt
index 370d5fb..7f1fdf4 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/RoToolPanel.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/RoToolPanel.kt
@@ -1,26 +1,76 @@
 package org.apache.isis.client.kroviz.ui.kv
 
-import pl.treksoft.kvision.core.Background
-import pl.treksoft.kvision.core.Col
-import pl.treksoft.kvision.core.Color
-import pl.treksoft.kvision.core.CssSize
-import pl.treksoft.kvision.core.UNIT
+import org.apache.isis.client.kroviz.to.TObject
+import org.apache.isis.client.kroviz.ui.BrowserWindow
+import org.apache.isis.client.kroviz.ui.IconManager
+import pl.treksoft.kvision.core.*
 import pl.treksoft.kvision.html.Button
 import pl.treksoft.kvision.html.ButtonStyle
 import pl.treksoft.kvision.panel.SimplePanel
 import pl.treksoft.kvision.panel.VPanel
 
-class RoToolPanel : SimplePanel() {
+object RoToolPanel : SimplePanel() {
 
     val panel = VPanel()
+    val buttons = mutableListOf<Button>()
 
     init {
+        panel.marginTop = CssSize(40, UNIT.px)
         panel.width = CssSize(40, UNIT.px)
-        panel.background = Background(Color.name(Col.GREEN))
-        val wButton: Button = Button(text = "Wikipedia", style = ButtonStyle.SUCCESS).apply {
+        panel.height = CssSize(100, UNIT.perc)
+        panel.background = Background(color = Color.name(Col.LIGHTBLUE))
+        panel.setDragDropData("text/plain", "element")
+        initButtons()
+        panel.addAll(buttons)
+    }
+
+    private fun initButtons() {
+        val drop: Button = Button(
+                text = "",
+                icon = IconManager.find("Toolbox"),
+                style = ButtonStyle.LIGHT).apply {
+            padding = CssSize(-16, UNIT.px)
+            margin = CssSize(0, UNIT.px)
+            title = "Sample drop target"
+            setDropTarget("text/plain") { data ->
+                console.log("[RoToolPanel]")
+                console.log(data)
+                val obj = data.dataTransfer?.getData("text/plain")!!
+                BrowserWindow("http://isis.apache.org").open()
+            }
+        }
+        buttons.add(drop)
+        //
+        val drag = Button(
+                text = "",
+                icon = IconManager.find("Object"),
+                style = ButtonStyle.LIGHT).apply {
             padding = CssSize(-16, UNIT.px)
             margin = CssSize(0, UNIT.px)
+            title = "Sample drag object"
+            setDragDropData("text/plain", "element")
         }
-        panel.add(wButton)
+        buttons.add(drag)
+    }
+
+    fun toggle() {
+        if (panel.width?.first == 0) show() else hide()
+    }
+
+    override fun hide(): Widget {
+        panel.width = CssSize(0, UNIT.px)
+        panel.removeAll()
+        return super.hide()
+    }
+
+    override fun show(): Widget {
+        panel.width = CssSize(40, UNIT.px)
+        buttons.forEach { it -> panel.add(it) }
+        return super.show()
     }
+
+    fun addButton(obj: TObject) {
+
+    }
+
 }