From 8d39a3efa5bcecfd8e57f89f998057e3c6746f6c Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Tue, 24 Dec 2019 14:14:10 +0300 Subject: [PATCH] Demo structure change and fx update --- dataforge-vis-common/build.gradle.kts | 1 + .../hep/dataforge/vis/common/StyleSheet.kt | 13 +- .../jsMain/kotlin/hep/dataforge/js/jsExtra.kt | 3 +- .../hep/dataforge/vis/js}/editor/bootstrap.kt | 2 +- .../hep/dataforge/vis/js}/editor/jsTree.kt | 2 +- .../hep/dataforge/vis/js/editor/jsoneditor.kt | 185 ++++++++++++++++++ .../vis/js}/editor/propertyEditor.kt | 31 ++- .../{values => editor}/ColorValueChooser.kt | 5 +- .../ComboBoxValueChooser.kt | 5 +- .../vis/fx/{meta => editor}/ConfigEditor.kt | 6 +- .../vis/fx/{meta => editor}/FXMeta.kt | 2 +- .../vis/fx/{meta => editor}/MetaViewer.kt | 2 +- .../fx/{values => editor}/TextValueChooser.kt | 5 +- .../fx/{values => editor}/ValueCallback.kt | 2 +- .../vis/fx/{values => editor}/ValueChooser.kt | 16 +- .../fx/{values => editor}/ValueChooserBase.kt | 2 +- .../fx/editor/VisualObjectEditorFragment.kt | 59 ++++++ .../vis/fx/editor/VisualObjectTreeFragment.kt | 33 ++++ .../dataforge/vis/fx/demo/MetaEditorDemo.kt | 6 +- .../vis/spatial/gdml/GDMLTransformer.kt | 8 +- .../dataforge/vis/spatial/gdml/visualGDML.kt | 2 +- .../src/jsMain/web/css/jsoneditor.min.css | 6 - .../vis/spatial/gdml/visualGDMLJvm.kt | 11 +- dataforge-vis-spatial/build.gradle.kts | 2 +- .../spatial/{editor => three}/outputConfig.kt | 4 +- .../dataforge/vis/spatial/fx/FXCanvas3D.kt | 23 ++- demo/build.gradle.kts | 0 demo/gdml/build.gradle.kts | 39 ++++ .../vis/spatial/gdml/demo/GDMLDemoApp.kt | 25 ++- .../src/jsMain/web/css/jsoneditor.min.css | 6 + .../gdml}/src/jsMain/web/css/main.css | 0 .../src/jsMain/web}/img/jsoneditor-icons.svg | 0 .../gdml}/src/jsMain/web/index.html | 0 .../vis/spatial/gdml/demo/GDMLDemoApp.kt | 78 ++++++++ .../spatial-showcase}/build.gradle.kts | 0 .../hep/dataforge/vis/spatial/demo/demo.kt | 0 .../vis/spatial/demo/ThreeDemoApp.kt | 3 - .../vis/spatial/demo/ThreeDemoGrid.kt | 0 .../dataforge/vis/spatial/demo/VariableBox.kt | 0 .../src/jsMain/web/index.html | 0 .../dataforge/vis/spatial/demo/FXDemoApp.kt | 0 .../dataforge/vis/spatial/demo/FXDemoGrid.kt | 3 - settings.gradle.kts | 5 +- 43 files changed, 514 insertions(+), 81 deletions(-) rename {dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial => dataforge-vis-common/src/jsMain/kotlin/hep/dataforge/vis/js}/editor/bootstrap.kt (89%) rename {dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial => dataforge-vis-common/src/jsMain/kotlin/hep/dataforge/vis/js}/editor/jsTree.kt (98%) create mode 100644 dataforge-vis-common/src/jsMain/kotlin/hep/dataforge/vis/js/editor/jsoneditor.kt rename {dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial => dataforge-vis-common/src/jsMain/kotlin/hep/dataforge/vis/js}/editor/propertyEditor.kt (59%) rename dataforge-vis-common/src/jvmMain/kotlin/hep/dataforge/vis/fx/{values => editor}/ColorValueChooser.kt (91%) rename dataforge-vis-common/src/jvmMain/kotlin/hep/dataforge/vis/fx/{values => editor}/ComboBoxValueChooser.kt (92%) rename dataforge-vis-common/src/jvmMain/kotlin/hep/dataforge/vis/fx/{meta => editor}/ConfigEditor.kt (97%) rename dataforge-vis-common/src/jvmMain/kotlin/hep/dataforge/vis/fx/{meta => editor}/FXMeta.kt (99%) rename dataforge-vis-common/src/jvmMain/kotlin/hep/dataforge/vis/fx/{meta => editor}/MetaViewer.kt (98%) rename dataforge-vis-common/src/jvmMain/kotlin/hep/dataforge/vis/fx/{values => editor}/TextValueChooser.kt (96%) rename dataforge-vis-common/src/jvmMain/kotlin/hep/dataforge/vis/fx/{values => editor}/ValueCallback.kt (94%) rename dataforge-vis-common/src/jvmMain/kotlin/hep/dataforge/vis/fx/{values => editor}/ValueChooser.kt (89%) rename dataforge-vis-common/src/jvmMain/kotlin/hep/dataforge/vis/fx/{values => editor}/ValueChooserBase.kt (98%) create mode 100644 dataforge-vis-common/src/jvmMain/kotlin/hep/dataforge/vis/fx/editor/VisualObjectEditorFragment.kt create mode 100644 dataforge-vis-common/src/jvmMain/kotlin/hep/dataforge/vis/fx/editor/VisualObjectTreeFragment.kt rename dataforge-vis-common/src/{jvmMain => jvmTest}/kotlin/hep/dataforge/vis/fx/demo/MetaEditorDemo.kt (90%) delete mode 100644 dataforge-vis-spatial-gdml/src/jsMain/web/css/jsoneditor.min.css rename dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/{editor => three}/outputConfig.kt (92%) create mode 100644 demo/build.gradle.kts create mode 100644 demo/gdml/build.gradle.kts rename {dataforge-vis-spatial-gdml => demo/gdml}/src/jsMain/kotlin/hep/dataforge/vis/spatial/gdml/demo/GDMLDemoApp.kt (86%) create mode 100644 demo/gdml/src/jsMain/web/css/jsoneditor.min.css rename {dataforge-vis-spatial-gdml => demo/gdml}/src/jsMain/web/css/main.css (100%) rename {dataforge-vis-spatial-gdml/src/jsMain/web/css => demo/gdml/src/jsMain/web}/img/jsoneditor-icons.svg (100%) rename {dataforge-vis-spatial-gdml => demo/gdml}/src/jsMain/web/index.html (100%) create mode 100644 demo/gdml/src/jvmMain/kotlin/hep/dataforge/vis/spatial/gdml/demo/GDMLDemoApp.kt rename {spatial-demo => demo/spatial-showcase}/build.gradle.kts (100%) rename {spatial-demo => demo/spatial-showcase}/src/commonMain/kotlin/hep/dataforge/vis/spatial/demo/demo.kt (100%) rename {spatial-demo => demo/spatial-showcase}/src/jsMain/kotlin/hep/dataforge/vis/spatial/demo/ThreeDemoApp.kt (93%) rename {spatial-demo => demo/spatial-showcase}/src/jsMain/kotlin/hep/dataforge/vis/spatial/demo/ThreeDemoGrid.kt (100%) rename {spatial-demo => demo/spatial-showcase}/src/jsMain/kotlin/hep/dataforge/vis/spatial/demo/VariableBox.kt (100%) rename {spatial-demo => demo/spatial-showcase}/src/jsMain/web/index.html (100%) rename {spatial-demo => demo/spatial-showcase}/src/jvmMain/kotlin/hep/dataforge/vis/spatial/demo/FXDemoApp.kt (100%) rename {spatial-demo => demo/spatial-showcase}/src/jvmMain/kotlin/hep/dataforge/vis/spatial/demo/FXDemoGrid.kt (92%) diff --git a/dataforge-vis-common/build.gradle.kts b/dataforge-vis-common/build.gradle.kts index 767364de..87b03571 100644 --- a/dataforge-vis-common/build.gradle.kts +++ b/dataforge-vis-common/build.gradle.kts @@ -29,6 +29,7 @@ kotlin { dependencies { api("hep.dataforge:dataforge-output-html:$dataforgeVersion") api(npm("bootstrap","4.4.1")) + implementation(npm("jsoneditor")) } } } diff --git a/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/StyleSheet.kt b/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/StyleSheet.kt index 2fcc1bed..fce0b422 100644 --- a/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/StyleSheet.kt +++ b/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/StyleSheet.kt @@ -27,18 +27,21 @@ class StyleSheet() { return styleMap[key] ?: (owner?.parent as? VisualGroup)?.styleSheet?.get(key) } - operator fun set(key: String, style: Meta?) { - val oldStyle = styleMap[key] + /** + * Define a style without notifying + */ + fun define(key: String, style: Meta?) { if (style == null) { styleMap.remove(key) } else { styleMap[key] = style } - owner?.styleChanged(key, oldStyle, style) } - infix fun String.put(style: Meta?) { - set(this, style) + operator fun set(key: String, style: Meta?) { + val oldStyle = styleMap[key] + define(key, style) + owner?.styleChanged(key, oldStyle, style) } operator fun set(key: String, builder: MetaBuilder.() -> Unit) { diff --git a/dataforge-vis-common/src/jsMain/kotlin/hep/dataforge/js/jsExtra.kt b/dataforge-vis-common/src/jsMain/kotlin/hep/dataforge/js/jsExtra.kt index ad94873d..6354a61c 100644 --- a/dataforge-vis-common/src/jsMain/kotlin/hep/dataforge/js/jsExtra.kt +++ b/dataforge-vis-common/src/jsMain/kotlin/hep/dataforge/js/jsExtra.kt @@ -1,6 +1,7 @@ package hep.dataforge.js -external fun require(name: String): dynamic +@JsName("require") +external fun requireJS(name: String): dynamic inline fun jsObject(builder: T.() -> Unit): T { val obj: T = js("({})") as T diff --git a/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/editor/bootstrap.kt b/dataforge-vis-common/src/jsMain/kotlin/hep/dataforge/vis/js/editor/bootstrap.kt similarity index 89% rename from dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/editor/bootstrap.kt rename to dataforge-vis-common/src/jsMain/kotlin/hep/dataforge/vis/js/editor/bootstrap.kt index 7be121b1..2f1e4595 100644 --- a/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/editor/bootstrap.kt +++ b/dataforge-vis-common/src/jsMain/kotlin/hep/dataforge/vis/js/editor/bootstrap.kt @@ -1,4 +1,4 @@ -package hep.dataforge.vis.spatial.editor +package hep.dataforge.vis.js.editor import kotlinx.html.TagConsumer import kotlinx.html.js.div diff --git a/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/editor/jsTree.kt b/dataforge-vis-common/src/jsMain/kotlin/hep/dataforge/vis/js/editor/jsTree.kt similarity index 98% rename from dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/editor/jsTree.kt rename to dataforge-vis-common/src/jsMain/kotlin/hep/dataforge/vis/js/editor/jsTree.kt index a45c1861..ba9b7dd8 100644 --- a/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/editor/jsTree.kt +++ b/dataforge-vis-common/src/jsMain/kotlin/hep/dataforge/vis/js/editor/jsTree.kt @@ -4,7 +4,7 @@ import hep.dataforge.names.NameToken import hep.dataforge.vis.common.VisualGroup import hep.dataforge.vis.common.VisualObject import hep.dataforge.vis.common.isEmpty -import hep.dataforge.vis.spatial.editor.card +import hep.dataforge.vis.js.editor.card import kotlinx.html.TagConsumer import kotlinx.html.dom.append import kotlinx.html.js.* diff --git a/dataforge-vis-common/src/jsMain/kotlin/hep/dataforge/vis/js/editor/jsoneditor.kt b/dataforge-vis-common/src/jsMain/kotlin/hep/dataforge/vis/js/editor/jsoneditor.kt new file mode 100644 index 00000000..8bfaf93a --- /dev/null +++ b/dataforge-vis-common/src/jsMain/kotlin/hep/dataforge/vis/js/editor/jsoneditor.kt @@ -0,0 +1,185 @@ +@file:Suppress( + "INTERFACE_WITH_SUPERCLASS", + "OVERRIDING_FINAL_MEMBER", + "RETURN_TYPE_MISMATCH_ON_OVERRIDE", + "CONFLICTING_OVERLOADS", + "EXTERNAL_DELEGATION" +) + +package hep.dataforge.vis.js.editor + +import org.w3c.dom.HTMLElement + +external interface Node { + var field: String + var value: String? get() = definedExternally; set(value) = definedExternally + var path: dynamic +} + +external interface NodeName { + var path: Array + var type: dynamic /* 'object' | 'array' */ + var size: Number +} + +external interface ValidationError { + var path: dynamic + var message: String +} + +external interface Template { + var text: String + var title: String + var className: String? get() = definedExternally; set(value) = definedExternally + var field: String + var value: Any +} + +external interface `T$6` { + var startFrom: Number + var options: Array +} + +external interface AutoCompleteOptions { + var confirmKeys: Array? get() = definedExternally; set(value) = definedExternally + var caseSensitive: Boolean? get() = definedExternally; set(value) = definedExternally +// var getOptions: AutoCompleteOptionsGetter? get() = definedExternally; set(value) = definedExternally +} + +external interface SelectionPosition { + var row: Number + var column: Number +} + +external interface SerializableNode { + var value: Any + var path: dynamic +} + +external interface Color { + var rgba: Array + var hsla: Array + var rgbString: String + var rgbaString: String + var hslString: String + var hslaString: String + var hex: String +} + +//external interface `T$0` { +// var field: Boolean +// var value: Boolean +//} +// +//external interface `T$1` { +// @nativeGetter +// operator fun get(key: String): String? +// +// @nativeSetter +// operator fun set(key: String, value: String) +//} + +//external interface Languages { +// @nativeGetter +// operator fun get(lang: String): `T$1`? +// +// @nativeSetter +// operator fun set(lang: String, value: `T$1`) +//} + +external interface JSONEditorOptions { +// var ace: AceAjax.Ace? get() = definedExternally; set(value) = definedExternally +// var ajv: Ajv? get() = definedExternally; set(value) = definedExternally + var onChange: (() -> Unit)? get() = definedExternally; set(value) = definedExternally + var onChangeJSON: ((json: Any) -> Unit)? get() = definedExternally; set(value) = definedExternally + var onChangeText: ((jsonString: String) -> Unit)? get() = definedExternally; set(value) = definedExternally + var onEditable: ((node: Node) -> dynamic)? get() = definedExternally; set(value) = definedExternally + var onError: ((error: Error) -> Unit)? get() = definedExternally; set(value) = definedExternally + var onModeChange: ((newMode: dynamic /* 'tree' | 'view' | 'form' | 'code' | 'text' */, oldMode: dynamic /* 'tree' | 'view' | 'form' | 'code' | 'text' */) -> Unit)? get() = definedExternally; set(value) = definedExternally + var onNodeName: ((nodeName: NodeName) -> String?)? get() = definedExternally; set(value) = definedExternally + var onValidate: ((json: Any) -> dynamic)? get() = definedExternally; set(value) = definedExternally + var escapeUnicode: Boolean? get() = definedExternally; set(value) = definedExternally + var sortObjectKeys: Boolean? get() = definedExternally; set(value) = definedExternally + var history: Boolean? get() = definedExternally; set(value) = definedExternally + var mode: dynamic /* 'tree' | 'view' | 'form' | 'code' | 'text' */ + var modes: Array? get() = definedExternally; set(value) = definedExternally + var name: String? get() = definedExternally; set(value) = definedExternally + var schema: Any? get() = definedExternally; set(value) = definedExternally + var schemaRefs: Any? get() = definedExternally; set(value) = definedExternally + var search: Boolean? get() = definedExternally; set(value) = definedExternally + var indentation: Number? get() = definedExternally; set(value) = definedExternally + var theme: String? get() = definedExternally; set(value) = definedExternally + var templates: Array