This is an automated email from the ASF dual-hosted git repository. joergrade pushed a commit to branch ISIS-3171 in repository https://gitbox.apache.org/repos/asf/isis.git
commit 49c32a3a1f9aaafdc8ae2e12f0fb86f8e745b8de Author: Jörg Rade <joerg.r...@kuehne-nagel.com> AuthorDate: Wed Aug 31 09:59:23 2022 +0200 ISIS-3171 remove some explicit casts; grid processing introduced --- .../kroviz/core/aggregator/AggregatorWithLayout.kt | 17 ++++++++++++ .../kroviz/core/model/CollectionProperties.kt | 10 ++++++++ .../kroviz/core/model/DisplayModelWithLayout.kt | 30 ++++++++++++++++++++-- .../isis/client/kroviz/layout/PropertyIfc.kt | 29 +++++++++++++++++++++ .../org/apache/isis/client/kroviz/to/bs/Action.kt | 18 ++++++------- .../org/apache/isis/client/kroviz/to/bs/Col.kt | 2 +- .../apache/isis/client/kroviz/to/bs/Collection.kt | 18 ++++++------- .../apache/isis/client/kroviz/to/bs/Property.kt | 10 ++++---- 8 files changed, 108 insertions(+), 26 deletions(-) diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/aggregator/AggregatorWithLayout.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/aggregator/AggregatorWithLayout.kt index da4f7b5ea9..4725f23003 100644 --- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/aggregator/AggregatorWithLayout.kt +++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/aggregator/AggregatorWithLayout.kt @@ -66,6 +66,23 @@ abstract class AggregatorWithLayout : BaseAggregator() { val link = it.link!! ResourceProxy().fetch(link, this, subType = Constants.subTypeJson, referrer = referrer) } + //FIXME + if (dm.grid == null) { + dm.addGrid(grid) + dm.properties.propertyLayoutList.forEach { p -> + val l = p.link + if (l == null) { + console.log(p.id + " link empty") // ISIS-2846 + console.log(p) + } else { + val isDn = l.href.contains("datanucleus") + if (!isDn) { + //invoking DN links leads to an error + invoke(l, this, referrer = referrer) + } + } + } + } } protected fun invokeLayoutLink(obj: TObject, aggregator: AggregatorWithLayout, referrer: String) { diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/model/CollectionProperties.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/model/CollectionProperties.kt index c113332fb9..b18eb0059b 100644 --- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/model/CollectionProperties.kt +++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/model/CollectionProperties.kt @@ -101,4 +101,14 @@ class ColumnProperties(val key: String) { } } + fun initGrid(property: Property) { + // this.layout = layout +//FIXME hidden = (property.hidden != null) + // properties without labelPosition will be hidden - is that correct? + // example: Demo -> Strings -> Description + // if (!hidden && property.labelPosition == null) { + // hidden = true + // } + } + } diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/model/DisplayModelWithLayout.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/model/DisplayModelWithLayout.kt index e0087b8117..1be742e138 100644 --- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/model/DisplayModelWithLayout.kt +++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/model/DisplayModelWithLayout.kt @@ -24,6 +24,7 @@ import org.apache.isis.client.kroviz.to.Icon import org.apache.isis.client.kroviz.to.Property import org.apache.isis.client.kroviz.to.TransferObject import org.apache.isis.client.kroviz.to.bs.Grid +import org.apache.isis.client.kroviz.to.bs.Row abstract class DisplayModelWithLayout : BaseDisplayModel() { @@ -35,8 +36,7 @@ abstract class DisplayModelWithLayout : BaseDisplayModel() { override fun canBeDisplayed(): Boolean { return when { isRendered -> false - layout == null -> false - grid == null -> false + layout == null && grid == null -> false else -> properties.readyForDisplay() } } @@ -46,6 +46,11 @@ abstract class DisplayModelWithLayout : BaseDisplayModel() { initPropertyLayoutList(layout) } + fun addGrid(grid: Grid) { + this.grid = grid + initPropertyGridList(grid) + } + fun addIcon(obj: TransferObject?) { icon = obj as Icon } @@ -56,6 +61,12 @@ abstract class DisplayModelWithLayout : BaseDisplayModel() { } } + private fun initPropertyGridList(grid: Grid) { + grid.rows.forEach { r -> + initGrid4Row(r) + } + } + private fun initLayout4Row(r: RowLt) { r.cols.forEach { cs -> val c = cs.getCol() @@ -72,6 +83,21 @@ abstract class DisplayModelWithLayout : BaseDisplayModel() { } } + private fun initGrid4Row(r: Row) { + r.colList.forEach { c -> + c.fieldSetList.forEach { fs -> + //FIXME properties.addAllPropertiesFromGrid(fs.propertyList) + } + c.tabGroupList.forEach { tg -> + tg.tabList.forEach { t -> + t.rowList.forEach { r2 -> + initGrid4Row(r2) + } + } + } + } + } + fun addPropertyDescription(p: Property) { properties.addPropertyDescription(p) } diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/layout/PropertyIfc.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/layout/PropertyIfc.kt new file mode 100644 index 0000000000..16b7e05c69 --- /dev/null +++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/layout/PropertyIfc.kt @@ -0,0 +1,29 @@ +/* + * 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. + */ +import org.apache.isis.client.kroviz.to.Link + +interface PropertyIfc { + var id: String? + var named: String? + var link: Link? + var hidden: String? + var typicalLength: Int + var multiLine: Int + var describedAs: String? +} \ No newline at end of file diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/bs/Action.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/bs/Action.kt index f8936117b4..e8080bb380 100644 --- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/bs/Action.kt +++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/bs/Action.kt @@ -35,15 +35,15 @@ class Action(node: Node) : XmlLayout() { init { val dyNode = node.asDynamic() - bookmarking = dyNode.getAttribute("bookmarking") as String - cssClass = dyNode.getAttribute("cssClass") as String - cssClassFa = dyNode.getAttribute("cssClassFa") as String - cssClassFaPosition = dyNode.getAttribute("cssClassFaPosition") as String - hidden = dyNode.getAttribute("hidden") as String - id = dyNode.getAttribute("id") as String - position = dyNode.getAttribute("position") as String - named = dyNode.getAttribute("named") as String - describedAs = dyNode.getAttribute("describedAs") as String + bookmarking = dyNode.getAttribute("bookmarking") // as String + cssClass = dyNode.getAttribute("cssClass") // as String + cssClassFa = dyNode.getAttribute("cssClassFa") // as String + cssClassFaPosition = dyNode.getAttribute("cssClassFaPosition") // as String + hidden = dyNode.getAttribute("hidden") // as String + id = dyNode.getAttribute("id") // as String + position = dyNode.getAttribute("position") // as String + named = dyNode.getAttribute("named") // as String + describedAs = dyNode.getAttribute("describedAs") // as String val nodeList = node.childNodes.asList() val namedList = nodeList.filter { it.nodeName == "$nsCpt:named" } diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/bs/Col.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/bs/Col.kt index bae7402449..933816d860 100644 --- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/bs/Col.kt +++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/bs/Col.kt @@ -32,7 +32,7 @@ class Col(node: Node) : XmlLayout() { init { val dyNode = node.asDynamic() - span = dyNode.getAttribute("span") as Int + span = dyNode.getAttribute("span") //as Int val nl = node.childNodes.asList() diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/bs/Collection.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/bs/Collection.kt index 370b8bcb10..d063b7a98b 100644 --- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/bs/Collection.kt +++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/bs/Collection.kt @@ -35,15 +35,15 @@ class Collection(node: Node) : XmlLayout() { init { val dyNode = node.asDynamic() - bookmarking = dyNode.getAttribute("bookmarking") as String - cssClass = dyNode.getAttribute("cssClass") as String - cssClassFa = dyNode.getAttribute("cssClassFa") as String - cssClassFaPosition = dyNode.getAttribute("cssClassFaPosition") as String - hidden = dyNode.getAttribute("hidden") as String - id = dyNode.getAttribute("id") as String - position = dyNode.getAttribute("position") as String - named = dyNode.getAttribute("named") as String - describedAs = dyNode.getAttribute("describedAs") as String + bookmarking = dyNode.getAttribute("bookmarking") // as String + cssClass = dyNode.getAttribute("cssClass") // as String + cssClassFa = dyNode.getAttribute("cssClassFa") // as String + cssClassFaPosition = dyNode.getAttribute("cssClassFaPosition") // as String + hidden = dyNode.getAttribute("hidden") // as String + id = dyNode.getAttribute("id") // as String + position = dyNode.getAttribute("position") // as String + named = dyNode.getAttribute("named") // as String + describedAs = dyNode.getAttribute("describedAs") // as String val nodeList = node.childNodes.asList() diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/bs/Property.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/bs/Property.kt index c57185c277..49d41630c1 100644 --- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/bs/Property.kt +++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/bs/Property.kt @@ -35,11 +35,11 @@ class Property(node: Node) : XmlLayout() { init { val dn = node.asDynamic() - hidden = dn.getAttribute("hidden") as String - id = dn.getAttribute("id") as String - typicalLength = dn.getAttribute("typicalLength") as Int - multiLine = dn.getAttribute("multiLine") as Int - describedAs = dn.getAttribute("describedAs") as String + hidden = dn.getAttribute("hidden") //as String + id = dn.getAttribute("id") //as String + typicalLength = dn.getAttribute("typicalLength") //as Int + multiLine = dn.getAttribute("multiLine") //as Int + describedAs = dn.getAttribute("describedAs") //as String val nodeList = node.childNodes.asList() val namedList = nodeList.filter { it.nodeName == "$nsCpt:named" }