Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.hanseter</groupId>
<artifactId>json-properties-fx</artifactId>
<version>1.0.19</version>
<version>1.0.20</version>

<packaging>bundle</packaging>
<name>JSON Properties Editor Fx</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package com.github.hanseter.json.editor.actions
import com.github.hanseter.json.editor.*
import com.github.hanseter.json.editor.controls.IdReferenceControl
import com.github.hanseter.json.editor.i18n.JsonPropertiesMl
import com.github.hanseter.json.editor.types.IdReferenceModel
import com.github.hanseter.json.editor.types.SupportedType
import com.github.hanseter.json.editor.types.TypeModel
import com.github.hanseter.json.editor.util.ViewOptions
import javafx.event.Event
import javafx.geometry.Pos
import javafx.scene.Node
Expand Down Expand Up @@ -36,10 +38,11 @@ class PreviewAction(
mouseEvent: Event?
): PropertiesEditResult? {
val value = (model as TypeModel<String?, SupportedType.SimpleType.IdReferenceType>).value
val viewOptions = (model as IdReferenceModel).viewOptions
if (value != null) {
val dataAndSchema = idReferenceProposalProvider.get().getDataAndSchema(value)
if (dataAndSchema != null && mouseEvent != null) {
showPreviewPopup(dataAndSchema, value, mouseEvent?.target as? Node)
showPreviewPopup(dataAndSchema, value, mouseEvent?.target as? Node,viewOptions)
}
}
return null
Expand All @@ -55,12 +58,14 @@ class PreviewAction(
private fun showPreviewPopup(
dataAndSchema: IdReferenceProposalProvider.DataWithSchema,
value: String,
parent: Node?
parent: Node?,
viewOptions: ViewOptions
) {
val (data, previewSchema) = dataAndSchema
val preview = JsonPropertiesEditor(true)
preview.referenceProposalProvider = idReferenceProposalProvider.get()
preview.resolutionScopeProvider = resolutionScopeProvider.get()
preview.viewOptions= viewOptions
preview.display(value, value, data, previewSchema) { it }
val scrollPane = ScrollPane(preview)
scrollPane.maxHeight = 500.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.github.hanseter.json.editor.types

import com.github.hanseter.json.editor.extensions.EffectiveSchema
import com.github.hanseter.json.editor.util.BindableJsonType
import com.github.hanseter.json.editor.util.EditorContext
import com.github.hanseter.json.editor.util.IdRefDisplayMode
import com.github.hanseter.json.editor.util.*
import org.everit.json.schema.StringSchema

class IdReferenceModel(
Expand All @@ -23,6 +21,13 @@ class IdReferenceModel(
bound?.setValue(schema, value)
}

val viewOptions: ViewOptions
get() = ViewOptions(
idRefDisplayMode = context.idRefDisplayMode,
decimalFormatSymbols = context.decimalFormatSymbols,
groupBy = PropertyGrouping.NONE
)

companion object {
val CONVERTER: (Any) -> String = { it as? String ?: it.toString() }
private fun idToString(
Expand Down Expand Up @@ -51,8 +56,8 @@ class IdReferenceModel(

override val previewString: PreviewString
get() = PreviewString.create(
idToString(value,context,schema),
idToString(defaultValue,context,schema),
idToString(value, context, schema),
idToString(defaultValue, context, schema),
rawValue
)

Expand Down