Skip to content

Commit 55b07e2

Browse files
committed
Java-Standard: Palette mit Schlüsselwörtern (if, switch, while, …)
Neue Blöcke unverändert (condition, selector, For-Kopf, …); nur Button-Text über javaStandardPaletteButtonLabel + gibPaletteButtonBeschriftung. Made-with: Cursor
1 parent a17beef commit 55b07e2

3 files changed

Lines changed: 44 additions & 4 deletions

File tree

src/main/java/de/visustruct/control/GlobalSettings.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,17 @@ public static String gibElementBeschriftung(int typNummer){
416416
return StruktogrammPalette.getDefaultTextForNewElement(typNummer);
417417
}
418418

419+
/**
420+
* Text auf der linken Palette: bei Java-Standard Schlüsselwörter ({@code if}, {@code while}, …),
421+
* sonst wie {@link #gibElementBeschriftung(int)}.
422+
*/
423+
public static String gibPaletteButtonBeschriftung(int typNummer) {
424+
if (elementBeschriftungPresetIndex == ElementBeschriftungPresets.PRESET_ENGLISH_JAVA) {
425+
return ElementBeschriftungPresets.javaStandardPaletteButtonLabel(typNummer);
426+
}
427+
return gibElementBeschriftung(typNummer);
428+
}
429+
419430
public static int getElementBeschriftungPresetIndex() {
420431
return elementBeschriftungPresetIndex;
421432
}

src/main/java/de/visustruct/view/AuswahlPanelElement.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ public void mouseReleased(MouseEvent e) {
4040
}
4141

4242
public void aktualisiereBeschriftung() {
43-
setFont(new Font(Font.SANS_SERIF, Font.BOLD, textFontSizeFuerZeile(GlobalSettings.gibElementBeschriftung(typ))));
44-
// Kurztext = Vorgabe des gewählten Text-Presets (z. B. Java: Statement, condition, …); Tooltip = didaktischer Name in der UI-Sprache.
45-
setText(GlobalSettings.gibElementBeschriftung(typ));
43+
String kurz = GlobalSettings.gibPaletteButtonBeschriftung(typ);
44+
setFont(new Font(Font.SANS_SERIF, Font.BOLD, textFontSizeFuerZeile(kurz)));
45+
setText(kurz);
46+
// Didaktischer Blockname in der UI-Sprache (z. B. Kopf- vs. fußgesteuerte Schleife trotz gleichem Java-Wort auf zwei Buttons).
4647
setToolTipText(StructureElementI18n.paletteTooltip(typ));
4748
invalidate();
4849
revalidate();

src/main/java/de/visustruct/view/ElementBeschriftungPresets.java

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public final class ElementBeschriftungPresets {
1414
public static final int PRESET_KLASSISCH = 0;
1515
public static final int PRESET_FORMAL = 1;
1616
public static final int PRESET_JAVA_NA = 2;
17-
/** Syntaxnahe Java-Vorgaben ({@code if}, {@code condition}, …) — Programm-Standard; UI z. B. „Java (Standard)“ / „Java (Default)“. */
17+
/** Syntaxnahe Java-Vorgaben — Programm-Standard; neue Blöcke mit Platzhaltertext, Palette mit {@link #javaStandardPaletteButtonLabel(int)}. */
1818
public static final int PRESET_ENGLISH_JAVA = 3;
1919
/** Didaktische Begriffe gemäß UI-Sprache ({@link StructureElementI18n}). */
2020
public static final int PRESET_DIDACTIC_I18N = 4;
@@ -44,13 +44,33 @@ public final class ElementBeschriftungPresets {
4444
"condition", "condition", "\u221e", "break", "method()", "\u00f8"},
4545
};
4646

47+
/**
48+
* Nur Palette bei {@link #PRESET_ENGLISH_JAVA}: echte Java-Schlüsselwörter / übliche Kurzformen (nicht {@code condition} für alles).
49+
* Reihenfolge = Elementtypen 0–9 wie {@link #PRESETS}.
50+
*/
51+
private static final String[] JAVA_STANDARD_PALETTE_LABELS = {
52+
"Statement",
53+
"if",
54+
"switch",
55+
"for",
56+
"while",
57+
"do",
58+
"while(true)",
59+
"break",
60+
"method()",
61+
"\u00f8",
62+
};
63+
4764
static {
4865
if (PRESETS.length != ANZAHL_PRESETS - 1) {
4966
throw new IllegalStateException("Preset-Anzahl");
5067
}
5168
if (PRESET_DIALOG_REIHENFOLGE.length != ANZAHL_PRESETS) {
5269
throw new IllegalStateException("Preset-Dialog-Reihenfolge");
5370
}
71+
if (JAVA_STANDARD_PALETTE_LABELS.length != N) {
72+
throw new IllegalStateException("Java-Palette-L\u00e4nge");
73+
}
5474
for (String[] row : PRESETS) {
5575
if (row.length != N) {
5676
throw new IllegalStateException("Preset-L\u00e4nge");
@@ -79,6 +99,14 @@ public static int presetIndexAtDialogPlatz(int dialogPlatz) {
7999
return PRESET_DIALOG_REIHENFOLGE[dialogPlatz];
80100
}
81101

102+
/** Paletten-Button bei gewähltem Java-Standard-Preset ({@link #PRESET_ENGLISH_JAVA}). */
103+
public static String javaStandardPaletteButtonLabel(int typ) {
104+
if (typ < 0 || typ >= JAVA_STANDARD_PALETTE_LABELS.length) {
105+
return "";
106+
}
107+
return JAVA_STANDARD_PALETTE_LABELS[typ];
108+
}
109+
82110
public static String getPresetAnzeigename(int index) {
83111
switch (index) {
84112
case PRESET_KLASSISCH:

0 commit comments

Comments
 (0)