Uses 911K of libraries. Click here for Pure Java version (6794L/34K).
1 | !7 |
2 | |
3 | cmodule DialogEditor { |
4 | L<TypeAndText> entries = synchroList(); |
5 | S globalID = aGlobalID(); |
6 | |
7 | transient JPanel stack; |
8 | transient JTextArea taRaw; |
9 | transient ReliableSingleThread rstFromRaw; |
10 | |
11 | start { |
12 | rstFromRaw = dm_rstWithDelay(500, r { if (taRaw != null) fromRaw(getText(taRaw)) }); |
13 | onChangeAndNow(r { |
14 | if (taRaw != null) |
15 | setText(taRaw, toRaw()); |
16 | if (empty(entries) || nempty(last(entries).text)) { |
17 | new TypeAndText e; |
18 | entries.add(e); change(); |
19 | if (stack != null) addAndValidate(stack, makeLine(e)); |
20 | } |
21 | }); |
22 | } |
23 | |
24 | visualize { |
25 | stack = dynamicVStack2(); |
26 | fillStack(); |
27 | taRaw = jTypeWriterTextArea(toRaw()); |
28 | main.onChange(taRaw, rstFromRaw); |
29 | ret centerAndSouthWithMargins(jtabs( |
30 | "Dialog" := jscroll_trackWidth(withRightMargin(stack)), |
31 | "Raw" := withMargin(taRaw)), |
32 | centerAndEastWithMargin( |
33 | withLabel("Dialog ID:", dm_textField('globalID)), |
34 | jbutton("Save", r save)); |
35 | } |
36 | |
37 | void fillStack { |
38 | if (stack == null) ret; |
39 | removeAllComponents(stack); |
40 | for (TypeAndText e : cloneList(entries)) |
41 | addAndValidate(stack, makeLine(e)); |
42 | } |
43 | |
44 | JPanel makeLine(final TypeAndText e) { |
45 | final JComboBox cb = jcombobox(ai_lineTypes(), e.type); |
46 | final JTextField tf = jtextfield(e.text); |
47 | main.onChange(cb, r { e.type = selectedItem(cb); change(); }); |
48 | main.onChange(tf, r { e.text = gtt(tf); change(); }); |
49 | ret westAndCenterWithMargin(cb, tf); |
50 | } |
51 | |
52 | S toRaw() { |
53 | ret lines(nempties(map(entries, func(TypeAndText e) -> S { |
54 | bothEmpty(e.text, e.type) ? "" : or2(e.type, "?") + ": " + unnull(e.text) |
55 | }))); |
56 | } |
57 | |
58 | void fromRaw(S raw) { |
59 | L<TypeAndText> entries = asSynchroList(ai_parseTypedDialog(raw)); |
60 | if (empty(entries) || nempty(last(entries).text)) entries.add(new TypeAndText); |
61 | if (setField(+entries)) fillStack(); |
62 | } |
63 | |
64 | void save { |
65 | if (emptyAfterTrim(globalID)) setField(globalID := aGlobalID()); |
66 | dm_requireAndCallModule("#1021238/DialogsCRUD", 'saveDialog, globalID, toRaw()); |
67 | } |
68 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1021235 |
Snippet name: | Dialog Editor |
Eternal ID of this version: | #1021235/34 |
Text MD5: | cc70176fedf057473773b96c0caa5239 |
Transpilation MD5: | 7c693e2fdc923a636fac4c5800321f9f |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-02-05 14:23:59 |
Source code size: | 2128 bytes / 68 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 334 / 1041 |
Version history: | 33 change(s) |
Referenced in: | [show references] |