Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/java-17'
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanseter committed Nov 4, 2024
2 parents 51d9810 + 3e7ff6d commit dc1d8a1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
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>2.0.3</version>
<version>2.0.4</version>

<packaging>bundle</packaging>
<name>JSON Properties Editor Fx</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class JsonPropertiesEditor @JvmOverloads constructor(
callback: OnEditCallback
) {
if (idsToPanes.contains(objId)) {
updateObject(objId, obj)
updateObject(objId, obj, schema)
return
}

Expand Down Expand Up @@ -155,17 +155,17 @@ class JsonPropertiesEditor @JvmOverloads constructor(

fun updateObject(
objId: String,
obj: JSONObject
obj: JSONObject,
schema: JSONObject
) {
val pane = idsToPanes[objId] ?: return
pane.fillData(obj)
pane.updateSchemaIfChanged(schema)
}

fun removeObject(objId: String) {
(idsToPanes.remove(objId)?.treeItem)?.also {
(treeTableView.root as FilterableTreeItem).remove(
it
)
(treeTableView.root as FilterableTreeItem).remove(it)
}
rebindValidProperty()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,23 @@ class JsonPropertiesPane(
contentHandler.updateData(data)
}

fun updateSchemaIfChanged(new: JSONObject) {
if (new.similar(rawSchema)) return
val data = contentHandler.data
updateSchema(new)
fillData(data)
}

private fun updateSchema(new: JSONObject) {
rawSchema = new

val parsedSchema = SchemaNormalizer.parseSchema(new, resolutionScope, readOnly)

schema = SimpleEffectiveSchema(null, parsedSchema, title)

rebuildControlTree()
}

private fun fillSheet(data: JSONObject) {
val type = RootBindableType(data)
objectControl?.bindTo(type)
Expand All @@ -171,18 +188,7 @@ class JsonPropertiesPane(
val newData = changeListener(PropertiesEditInput(type.getValue()!!, rawSchema))

if (newData.schema != null) {

rawSchema = newData.schema

val parsedSchema = SchemaNormalizer.parseSchema(
newData.schema,
resolutionScope,
readOnly,
)

schema = SimpleEffectiveSchema(null, parsedSchema, title)

rebuildControlTree()
updateSchema(newData.schema)
}

fillData(newData.data)
Expand Down

0 comments on commit dc1d8a1

Please sign in to comment.