Skip to content

Commit 642ea94

Browse files
author
Hanseter
committed
Keep view options for popped out editor
1 parent 836b35c commit 642ea94

9 files changed

Lines changed: 20 additions & 57 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<modelVersion>4.0.0</modelVersion>
77
<groupId>com.github.hanseter</groupId>
88
<artifactId>json-properties-fx</artifactId>
9-
<version>2.0.4</version>
9+
<version>2.0.5</version>
1010

1111
<packaging>bundle</packaging>
1212
<name>JSON Properties Editor Fx</name>

src/main/kotlin/com/github/hanseter/json/editor/JsonPropertiesEditor.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ class JsonPropertiesEditor @JvmOverloads constructor(
6666

6767
private val actions =
6868
actions + PreviewAction(
69+
viewOptions,
6970
{ referenceProposalProvider },
70-
{ resolutionScopeProvider }) + arrayActions
71+
{ resolutionScopeProvider }
72+
) + arrayActions
7173

7274
private val idsToPanes = mutableMapOf<String, JsonPropertiesPane>()
7375
private val rootItem: FilterableTreeItem<TreeItemData> =

src/main/kotlin/com/github/hanseter/json/editor/actions/PreviewAction.kt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ package com.github.hanseter.json.editor.actions
33
import com.github.hanseter.json.editor.*
44
import com.github.hanseter.json.editor.controls.IdReferenceControl
55
import com.github.hanseter.json.editor.i18n.JsonPropertiesMl
6+
import com.github.hanseter.json.editor.types.IdReferenceModel
67
import com.github.hanseter.json.editor.types.SupportedType
78
import com.github.hanseter.json.editor.types.TypeModel
9+
import com.github.hanseter.json.editor.util.ViewOptions
810
import javafx.event.Event
911
import javafx.geometry.Pos
1012
import javafx.scene.Node
@@ -22,11 +24,13 @@ import org.everit.json.schema.StringSchema
2224
import java.util.function.Supplier
2325

2426
class PreviewAction(
27+
private val viewOptions: ViewOptions,
2528
private val idReferenceProposalProvider: Supplier<IdReferenceProposalProvider>,
2629
private val resolutionScopeProvider: Supplier<ResolutionScopeProvider>
2730
) : EditorAction {
2831
override val text: String = ""
29-
override val description: String = JsonPropertiesMl.bundle.getString("jsonEditor.actions.preview")
32+
override val description: String =
33+
JsonPropertiesMl.bundle.getString("jsonEditor.actions.preview")
3034
override val selector: TargetSelector =
3135
TargetSelector.SchemaType(SupportedType.SimpleType.IdReferenceType)
3236

@@ -35,12 +39,11 @@ class PreviewAction(
3539
model: TypeModel<*, *>,
3640
mouseEvent: Event?
3741
): PropertiesEditResult? {
38-
val value = (model as TypeModel<String?, SupportedType.SimpleType.IdReferenceType>).value
39-
if (value != null) {
40-
val dataAndSchema = idReferenceProposalProvider.get().getDataAndSchema(value)
41-
if (dataAndSchema != null && mouseEvent != null) {
42-
showPreviewPopup(dataAndSchema, value, mouseEvent?.target as? Node)
43-
}
42+
val value = model.value as? String ?: return null
43+
44+
val dataAndSchema = idReferenceProposalProvider.get().getDataAndSchema(value)
45+
if (dataAndSchema != null && mouseEvent != null) {
46+
showPreviewPopup(dataAndSchema, value, mouseEvent.target as? Node)
4447
}
4548
return null
4649
}
@@ -55,12 +58,13 @@ class PreviewAction(
5558
private fun showPreviewPopup(
5659
dataAndSchema: IdReferenceProposalProvider.DataWithSchema,
5760
value: String,
58-
parent: Node?
61+
parent: Node?,
5962
) {
6063
val (data, previewSchema) = dataAndSchema
6164
val preview = JsonPropertiesEditor(true)
6265
preview.referenceProposalProvider = idReferenceProposalProvider.get()
6366
preview.resolutionScopeProvider = resolutionScopeProvider.get()
67+
preview.viewOptions = viewOptions
6468
preview.display(value, value, data, previewSchema) { it }
6569
val scrollPane = ScrollPane(preview)
6670
scrollPane.maxHeight = 500.0

src/main/kotlin/com/github/hanseter/json/editor/schemaExtensions/MultiLineFormat.kt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
/*
2-
*
3-
* * SWEETS - Software Engineering Tooling Suite
4-
* *
5-
* * Copyright (c) Siemens Mobility GmbH 2024, All Rights Reserved, Confidential.
6-
* *
7-
*
8-
*/
9-
101
package com.github.hanseter.json.editor.schemaExtensions
112

123
import java.util.*

src/main/kotlin/com/github/hanseter/json/editor/types/FormattedIntegerModel.kt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
/*
2-
* SWEETS - Software Engineering Tooling Suite
3-
*
4-
* Copyright (c) Siemens Mobility GmbH 2022, All Rights Reserved, Confidential.
5-
*/
61
package com.github.hanseter.json.editor.types
72

83
import com.github.hanseter.json.editor.controls.DoubleControl
@@ -15,10 +10,6 @@ import java.text.ParsePosition
1510
import kotlin.math.pow
1611
import kotlin.math.roundToInt
1712

18-
/**
19-
*
20-
* @author Henrik Frühling (henrik.fruehling@siemens.com)
21-
*/
2213
class FormattedIntegerModel(
2314
schema: EffectiveSchema<NumberSchema>,
2415
decimalFormatSymbols: DecimalFormatSymbols

src/main/kotlin/com/github/hanseter/json/editor/types/IdReferenceModel.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import com.github.hanseter.json.editor.extensions.EffectiveSchema
44
import com.github.hanseter.json.editor.util.BindableJsonType
55
import com.github.hanseter.json.editor.util.EditorContext
66
import com.github.hanseter.json.editor.util.IdRefDisplayMode
7+
import com.github.hanseter.json.editor.util.PropertyGrouping
8+
import com.github.hanseter.json.editor.util.ViewOptions
79
import org.everit.json.schema.StringSchema
810

911
class IdReferenceModel(
@@ -51,8 +53,8 @@ class IdReferenceModel(
5153

5254
override val previewString: PreviewString
5355
get() = PreviewString.create(
54-
idToString(value,context,schema),
55-
idToString(defaultValue,context,schema),
56+
idToString(value, context, schema),
57+
idToString(defaultValue, context, schema),
5658
rawValue
5759
)
5860

src/main/kotlin/com/github/hanseter/json/editor/types/PreviewString.kt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
1-
/*
2-
* SWEETS - Software Engineering Tooling Suite
3-
*
4-
* Copyright (c) Siemens Mobility GmbH 2022, All Rights Reserved, Confidential.
5-
*/
61
package com.github.hanseter.json.editor.types
72

83
import com.github.hanseter.json.editor.i18n.JsonPropertiesMl
94
import org.json.JSONObject
105

11-
/**
12-
*
13-
* @author Henrik Frühling (henrik.fruehling@siemens.com)
14-
*/
156
class PreviewString private constructor(
167
val string: String,
178
val isDefaultValue: Boolean = false,

src/main/kotlin/com/github/hanseter/json/editor/ui/TreeTableNavigation.kt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
1-
/*
2-
* SWEETS - Software Engineering Tooling Suite
3-
*
4-
* Copyright (c) Siemens Mobility GmbH 2022, All Rights Reserved, Confidential.
5-
*/
61
package com.github.hanseter.json.editor.ui
72

83
import javafx.scene.control.TreeItem
94
import javafx.scene.control.TreeTableView
105
import javafx.scene.input.KeyCode
116
import javafx.scene.input.KeyEvent
127

13-
/**
14-
*
15-
* @author Henrik Frühling (henrik.fruehling@siemens.com)
16-
*/
178
object TreeTableNavigation {
189

1910
fun addNavigationToTreeTableView(treeTableView: TreeTableView<TreeItemData>) {

src/test/kotlin/com/github/hanseter/json/editor/app/ControlsPreviewTestApp.kt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
/*
2-
* SWEETS - Software Engineering Tooling Suite
3-
*
4-
* Copyright (c) Siemens Mobility GmbH 2022, All Rights Reserved, Confidential.
5-
*/
61
package com.github.hanseter.json.editor.app
72

83
import com.github.hanseter.json.editor.ControlFactory
@@ -25,10 +20,6 @@ import javafx.stage.Stage
2520
import org.json.JSONObject
2621

2722

28-
/**
29-
*
30-
* @author Henrik Frühling (henrik.fruehling@siemens.com)
31-
*/
3223
class ControlsPreviewTestApp : Application() {
3324

3425
companion object {

0 commit comments

Comments
 (0)