Skip to content

Commit 583542b

Browse files
release: VisuStruct 1.2.4
Fix the code-generator Generate button, element-editor Apply text, and over-escaped hints. Make the code dialog resizable and document the output concatenation example. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent c186aba commit 583542b

36 files changed

Lines changed: 1257 additions & 418 deletions

‎README.md‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
**VisuStruct** is a **structure-chart editor** for **Nassi–Shneiderman** diagrams (desktop, Kotlin / Swing).
1212

13-
Under **Settings → Languages** the **user interface** can be set to any of **21 languages** aligned with **VisuStruct-swift** (English, German, Spanish, French, Italian, Polish, Turkish, Korean, Japanese, Greek, Ukrainian, Arabic, Russian, Hebrew, Dutch, Swedish, Danish, Norwegian Bokmål, Chinese Simplified/Traditional, European Portuguese). Stored as `uilanguage` in `visustruct.properties` (e.g. `zh_Hans`, `pt_PT`). UI strings are synced from the Swift app where keys overlap: `python3 tools/sync_java_messages_from_swift.py` (map: `VisuStruct-swift/tools/java_swift_i18n_map.json`). Desktop-only labels may still fall back to English.
13+
Under **Settings → Languages** the **user interface** can be set to any of **21 languages** aligned with **VisuStruct-swift** (English, German, Spanish, French, Italian, Polish, Turkish, Korean, Japanese, Greek, Ukrainian, Arabic, Russian, Hebrew, Dutch, Swedish, Danish, Norwegian Bokmål, Chinese Simplified/Traditional, European Portuguese). Stored as `uilanguage` in `visustruct.properties` (e.g. `zh_Hans`, `pt_PT`). UI strings are synced from the Swift app where keys overlap: `python3 tools/sync_java_messages_from_swift.py` (map: `tools/java_swift_i18n_map.json`, or `VisuStruct-swift/tools/java_swift_i18n_map.json` if that sibling clone exists). Desktop-only labels may still fall back to English.
1414

1515
*Lineage:* Based on the open-source project [kekru/struktogrammeditor](https://github.com/kekru/struktogrammeditor) (Kevin Krummenauer, MIT). Copyright and terms: [LICENSE](LICENSE).
1616

@@ -22,6 +22,13 @@ git clone https://github.com/code4teaching/VisuStruct.git
2222

2323
---
2424

25+
## Changes in 1.2.4 (summary)
26+
27+
- **Fixes:** code generator **Generate** button (invalid number-field regex); element editor **Apply text** (`split` limit); over-escaped editor hints; palette generate applies pending editor text.
28+
- **UI:** resizable code-generator dialog; output hint with `"Result: " + result` / `"Ergebnis: " + ergebnis`.
29+
30+
Full notes: [`release-notes/v1.2.4.md`](release-notes/v1.2.4.md).
31+
2532
## Changes in 1.2.3 (summary)
2633

2734
- **Kotlin:** full migration of production code; Java reference under `src/main/java-reference/`; tests still Java.
@@ -156,7 +163,7 @@ This release aligns **branding and technical identity** with **VisuStruct**. **`
156163
- **Java 17** target (build and run with JDK 17+).
157164
- **FlatLaf** light/dark themes; **JDOM2**; no legacy AppleJavaExtensions.
158165
- **Motif** look-and-feel removed; **Metal** and FlatLaf available.
159-
- Current fat JAR name follows **`pom.xml`** **`version`** (e.g. **`visustruct-1.2.3.jar`**).
166+
- Current fat JAR name follows **`pom.xml`** **`version`** (e.g. **`visustruct-1.2.4.jar`**).
160167

161168
---
162169

@@ -231,13 +238,13 @@ chmod +x mvnw
231238
Output (version from `pom.xml`):
232239

233240
```text
234-
target/visustruct-1.2.3.jar
241+
target/visustruct-1.2.4.jar
235242
```
236243

237244
## Run
238245

239246
```bash
240-
java -jar target/visustruct-1.2.3.jar
247+
java -jar target/visustruct-1.2.4.jar
241248
```
242249

243250
Double-click may work if `.jar` is associated with Java.

‎pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>de.visustruct</groupId>
66
<artifactId>visustruct</artifactId>
7-
<version>1.2.3</version>
7+
<version>1.2.4</version>
88
<name>VisuStruct</name>
99

1010
<properties>

‎release-notes/v1.2.4.md‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# VisuStruct 1.2.4
2+
3+
Patch release **after** **1.2.3**.
4+
5+
## Fixes
6+
7+
- **Code generator:** **Generate** did nothing after the Kotlin port because `JNumberField.isNumeric()` compiled an invalid regex (`PatternSyntaxException`). Indent fields now parse numbers with `toDoubleOrNull()`.
8+
- **Element editor:** **Apply text** crashed on `Regex.split(…, -1)` (Java’s “keep empties” limit is not valid in Kotlin).
9+
- **Hints:** editor example strings showed long backslash runs after i18n sync doubled `.properties` escapes. Sync/resync now unescape before rewriting.
10+
- **Palette → Generate code** applies pending editor text first (same as **File → Generate code**).
11+
12+
## UI
13+
14+
- **Code generator** dialog is **resizable**; the old fixed 498×458 absolute layout no longer clips buttons on HiDPI or with long translations.
15+
- **Output** hint includes a concatenation example (`output: "Ergebnis: " + ergebnis` / `output: "Result: " + result`).
16+
17+
## Internationalization
18+
19+
- Further **Swift** string sync for editor/dialog keys; `tools/java_swift_i18n_map.json` is kept in this repo as a fallback map.
20+
21+
## Tests
22+
23+
- `CodeGenRulesJavaTest`: Java input/output lines and numeric indent fields.
24+
25+
## Build
26+
27+
- Maven: **`de.visustruct:visustruct:1.2.4`**
28+
- Fat JAR: **`visustruct-1.2.4.jar`** (`./mvnw package` → `target/`)
29+
- Release also ships **`visustruct.jar`**.

‎src/main/kotlin/de/visustruct/control/Controlling.kt‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,7 @@ class Controlling(params: Array<String>?) : Konstanten, ActionListener, WindowLi
349349
XActionCommands.bildInZwischenAblage ->
350350
copyImagetoClipBoard(gibAktuellesStruktogramm()!!.generateImage(false))
351351

352-
XActionCommands.quellcodeErzeugen -> {
353-
flushPendingDiagramEdits()
354-
CodeErzeuger(gui, I18n.tr("menu.file.generateCode"), true, gibAktuellesStruktogramm()!!)
355-
}
352+
XActionCommands.quellcodeErzeugen -> openCodeGenerator()
356353

357354
XActionCommands.struktogrammSchliessen -> gui.gibTabbedpane().aktuellesStruktogrammschliessen()
358355
XActionCommands.programmBeenden -> programmBeendenGeklickt()
@@ -519,6 +516,14 @@ class Controlling(params: Array<String>?) : Konstanten, ActionListener, WindowLi
519516
onSimulationToggle()
520517
}
521518

519+
/** Menü „Quellcode erzeugen“ und Paletten-Button: Editortext übernehmen, dann Dialog. */
520+
fun openCodeGenerator() {
521+
if (gui.gibTabbedpane().tabCount <= 0) return
522+
flushPendingDiagramEdits()
523+
val str = gibAktuellesStruktogramm() ?: return
524+
CodeErzeuger(gui, I18n.tr("menu.file.generateCode"), true, str)
525+
}
526+
522527
private fun onSimulationToggle() {
523528
if (simulationMode) {
524529
endSimulationInternal()

‎src/main/kotlin/de/visustruct/other/JNumberField.kt‎

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,7 @@ class JNumberField @JvmOverloads constructor() : JTextField() {
2121

2222
fun getLong(): Long = getDouble().toLong()
2323

24-
fun isNumeric(): Boolean {
25-
val digits = "(\\p{Digit}+)"
26-
val hexDigits = "(\\p{XDigit}+)"
27-
val exp = "[eE][+-]?$digits"
28-
val fpRegex = (
29-
"[\\x00-\\x20]*" +
30-
"[+-]?(" +
31-
"NaN|" +
32-
"Infinity|" +
33-
"(($digits(\\.)?($digits?)(($exp)?))|" +
34-
"(\\.($digits)($exp)?)|" +
35-
"((0[xX]$hexDigits(\\.)?)|(0[xX]$hexDigits?(\\.)$hexDigits))[pP][+-]?$digits)" +
36-
"[fFdD]?))" +
37-
"[\\x00-\\x20]*"
38-
)
39-
return fpRegex.toRegex().matches(text)
40-
}
24+
fun isNumeric(): Boolean = text.trim().toDoubleOrNull() != null
4125

4226
fun setDouble(d: Double) {
4327
text = d.toString()

‎src/main/kotlin/de/visustruct/struktogrammelemente/CodeGenRules.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ object CodeGenRules {
373373
@JvmStatic
374374
fun javaScriptForLoopHeader(lines: Array<String>?): String {
375375
val header = cStyleForLoopHeader(lines)
376-
val parts = ";".toRegex().split(header, -1).toMutableList()
376+
val parts = header.split(";").toMutableList()
377377
if (parts.isNotEmpty()) {
378378
val init = javaScriptForInitializerFromJavaTypedDeclaration(parts[0])
379379
if (init != null) {

‎src/main/kotlin/de/visustruct/view/AuswahlPanel.kt‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,7 @@ class AuswahlPanel(private val controlling: Controlling) :
132132
wendePaletteAktionsIconAn(this, "code")
133133
toolTipText = I18n.tr("menu.file.generateCode")
134134
accessibleContext.accessibleName = I18n.tr("palette.generateCode")
135-
addActionListener {
136-
val str = controlling.gibAktuellesStruktogramm() ?: return@addActionListener
137-
CodeErzeuger(
138-
controlling.getGUI(),
139-
I18n.tr("menu.file.generateCode"),
140-
true,
141-
str,
142-
)
143-
}
135+
addActionListener { controlling.openCodeGenerator() }
144136
}
145137
add(paletteCodeGenButton, c)
146138

0 commit comments

Comments
 (0)