File tree Expand file tree Collapse file tree
src/main/kotlin/com/github/hanseter/json/editor Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66 <modelVersion >4.0.0</modelVersion >
77 <groupId >com.github.hanseter</groupId >
88 <artifactId >json-properties-fx</artifactId >
9- <version >2.0.3 </version >
9+ <version >2.0.4 </version >
1010
1111 <packaging >bundle</packaging >
1212 <name >JSON Properties Editor Fx</name >
Original file line number Diff line number Diff line change @@ -122,7 +122,7 @@ class JsonPropertiesEditor @JvmOverloads constructor(
122122 callback : OnEditCallback
123123 ) {
124124 if (idsToPanes.contains(objId)) {
125- updateObject(objId, obj)
125+ updateObject(objId, obj, schema )
126126 return
127127 }
128128
@@ -155,17 +155,17 @@ class JsonPropertiesEditor @JvmOverloads constructor(
155155
156156 fun updateObject (
157157 objId : String ,
158- obj : JSONObject
158+ obj : JSONObject ,
159+ schema : JSONObject
159160 ) {
160161 val pane = idsToPanes[objId] ? : return
161162 pane.fillData(obj)
163+ pane.updateSchemaIfChanged(schema)
162164 }
163165
164166 fun removeObject (objId : String ) {
165167 (idsToPanes.remove(objId)?.treeItem)?.also {
166- (treeTableView.root as FilterableTreeItem ).remove(
167- it
168- )
168+ (treeTableView.root as FilterableTreeItem ).remove(it)
169169 }
170170 rebindValidProperty()
171171 }
Original file line number Diff line number Diff line change @@ -161,6 +161,23 @@ class JsonPropertiesPane(
161161 contentHandler.updateData(data)
162162 }
163163
164+ fun updateSchemaIfChanged (new : JSONObject ) {
165+ if (new.similar(rawSchema)) return
166+ val data = contentHandler.data
167+ updateSchema(new)
168+ fillData(data)
169+ }
170+
171+ private fun updateSchema (new : JSONObject ) {
172+ rawSchema = new
173+
174+ val parsedSchema = SchemaNormalizer .parseSchema(new, resolutionScope, readOnly)
175+
176+ schema = SimpleEffectiveSchema (null , parsedSchema, title)
177+
178+ rebuildControlTree()
179+ }
180+
164181 private fun fillSheet (data : JSONObject ) {
165182 val type = RootBindableType (data)
166183 objectControl?.bindTo(type)
@@ -171,18 +188,7 @@ class JsonPropertiesPane(
171188 val newData = changeListener(PropertiesEditInput (type.getValue()!! , rawSchema))
172189
173190 if (newData.schema != null ) {
174-
175- rawSchema = newData.schema
176-
177- val parsedSchema = SchemaNormalizer .parseSchema(
178- newData.schema,
179- resolutionScope,
180- readOnly,
181- )
182-
183- schema = SimpleEffectiveSchema (null , parsedSchema, title)
184-
185- rebuildControlTree()
191+ updateSchema(newData.schema)
186192 }
187193
188194 fillData(newData.data)
You can’t perform that action at this time.
0 commit comments