Libraryless. Click here for Pure Java version (3884L/27K/97K).
1 | !759 |
2 | |
3 | static JTable questionsTable; |
4 | |
5 | p-substance { |
6 | showFrame( |
7 | hgrid( |
8 | withTitle("Logic List", |
9 | centerAndSouth( |
10 | logicListTable(), |
11 | vgrid( |
12 | jbutton("Add care...", r { addCareDialog() }), |
13 | jbutton("Add statement...", r { addStatementDialog() })))), |
14 | withTitle("Questions", questionsTable = tableWithToolTips()))); |
15 | |
16 | onDoubleClickOrEnter(questionsTable, voidfunc(int row) { |
17 | answerQuestion(row); |
18 | }); |
19 | |
20 | tablePopupMenu(questionsTable, voidfunc(JPopupMenu menu, final int row) { |
21 | menu.add(jmenuitem("Answer question...", r { answerQuestion(row) })); |
22 | }); |
23 | |
24 | // TODO: thinker thread |
25 | swingEvery(questionsTable, 1000, 50, r { |
26 | if (tableShouldThink(questionsTable)) |
27 | dataToTable_uneditable(questionsTable, makeQuestions()); |
28 | }); |
29 | } |
30 | |
31 | static L<S> makeQuestions() { |
32 | long time = now(); |
33 | genLog_set(map(func(S s) { lastLine(s) }, gLogicList())); |
34 | new L<S> l; |
35 | for (S care : gCares()) { |
36 | if (gMatchStart(format("* is", care)) == null |
37 | && gMatchStart(format("a * is", care)) == null |
38 | && gMatchStart(format("the * is", care)) == null) |
39 | l.add(format("What is *?", toUpper(care))); |
40 | } |
41 | done(time, "Making Questions"); |
42 | ret l; |
43 | } |
44 | |
45 | static S presetAnswer(S s) { |
46 | new Matches m; |
47 | if "what is *" ret format("* is ...", m.unq(0)); |
48 | null; |
49 | } |
50 | |
51 | static void answerQuestion(int row) { |
52 | SS line = getTableLineAsMap(questionsTable, row); |
53 | final S q = firstValue(line); |
54 | if (empty(q)) ret; |
55 | final JTextField textField = new JTextField(unnull(presetAnswer(q))); |
56 | showForm( |
57 | "Question", q, |
58 | "Answer", textField, |
59 | r { |
60 | addToLogicList(fromLines(q, textField.getText())); |
61 | }); |
62 | } |
Began life as a copy of #1004394
download show line numbers debug dex old transpilations
Travelled to 31 computer(s): aoiabmzegqzx, ayokdxtdmvtg, bhatertpkbcr, bwoimkvrfqyu, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, etmzoiygucik, gwrvuhgaqvyk, iavmkmvmshxs, ishqpsrjomds, jmyaexzvplwz, jttmaavzamyx, lhdilzshxjzv, lpdgvwnxivlt, mqqgnosmbjvj, nbgitpuheiab, nzrhlmtlsyqh, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, sekmkcqzslie, tpsnldywmnmr, tslmcundralx, tvejysmllsmz, unoaxrwscvea, vouqrxazstgt, vpdwwinrgdga, wnvtyfxbogru, xfasiavlzxuf, xpvikbxxwzsu
No comments. add comment
Snippet ID: | #1004419 |
Snippet name: | A.I.'s Questions |
Eternal ID of this version: | #1004419/1 |
Text MD5: | 5a62633cdf72fe9134602c53ae342fc0 |
Transpilation MD5: | 84699dccd04d6bce2c7e2f2b98341dcf |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-08-28 17:35:10 |
Source code size: | 1743 bytes / 62 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 718 / 1537 |
Referenced in: | [show references] |