!759 concepts. concept Line { S text; *() {} *(S *text) { change(); } } concept UserLine { new Ref<Line> line; } concept Action { S code; } concept Line2Action { new Ref<Line> line; new Ref<Action> action; } static JTextField tf; static SingleComponentPanel scp; static UserLine userLine; static SystemAnswer systemAnswer; static JTable table; static L<Map> tableData; p-awt { //mistAqua(); // GREAT, with rounded buttons/scrollbars //emeraldDusk(); // wellll... magellan(); // funny, but not that readable loadAndAutoSaveConcepts(); showFrameHidingConsole(jtabs( "Console", northAndCenter( centerAndEast(tf = jCenteredTextField("What is love?"), jbutton("Answer...", "answerQ")), scp = new SingleComponentPanel(centeredHtmlLabel("Yo!"))), "Questions & Answers", table = sexyTable())); tf.selectAll(); tf.requestFocus(); setFrameIconLater(tf, "#1005372"); onEnter(tf, r { S s = tf.getText().trim(); userLine = userLine(s); processUserLine(); }); tablePopupMenu(table, voidfunc(JPopupMenu menu, final int row) { final S q = first(getTableLine(table, row)); Map map = _get(tableData, row); final UserAnswer ua = cast _get(map, "[hidden] ua"); menu.add(jmenuItem("Answer...", r { userLine = uniq(UserLine, text := q); answerQ2(); })); menu.add(jmenuItem("Mark solvable", r { cset(ua, "solvable", true); })); menu.add(jmenuItem("Un-mark solvable", r { cset(ua, "solvable", false); })); }); /*registerCtrlKey(table, KeyEvent.VK_PAGE_UP, "Tab Left", r { print("lalala"); });*/ awtOnConceptChanges(table, 500, "updateTable"); } svoid answerQ { final S s = tf.getText().trim(); if (userLine == null || neq(userLine.text, s)) userLine = new UserLine(s); answerQ2(); } svoid answerQ2 { final UserLine _userLine = userLine; final new JTextField tfA; final JCheckBox cbSolvable = jCheckBox(uniq(SCDefaults).solvable); showTitledForm("Answer question", "Question", _userLine.text, "Answer", tfA, "Solvable", cbSolvable, r { S a = tfA.getText().trim(); cnew(UserAnswer, userLine := _userLine, text := a, solvable := (uniq(SCDefaults).solvable = isChecked(cbSolvable))); print("Answer recorded! " + _userLine.text + " => " + a); processUserLine(); }); } svoid processUserLine { try { scp.setComponent(makeComponent()); } catch e { scp.setComponent(typeWriterTextArea(getStackTrace(e))); } } static Component makeComponent() { S ua = findUserAnswer(userLine.text); if (nempty(ua)) ret centeredHtmlLabel(htmlencode(ua)); ret yeahDummyAnswer(); } static JComponent yeahDummyAnswer() { S answer = "Yeah. " + userLine.text; systemAnswer = cnew(SystemAnswer, +userLine, "text", answer); ret centeredHtmlLabel(htmlencode(answer)); } svoid updateTable() { print("Updating table (c=" + changes + ")"); new L<Map> l; dataToTable_uneditable(table, tableData = reversedList(l)); } static UserLine userLine(S text) { ret cnew(UserLine, line := uniq(Line, +text)); }
Began life as a copy of #1005320
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1005444 |
Snippet name: | Action Console [dev.] |
Eternal ID of this version: | #1005444/1 |
Text MD5: | f51d15c39b57d6152131f71b8ad0f5ab |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-11-19 13:51:59 |
Source code size: | 3286 bytes / 135 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 518 / 510 |
Referenced in: | [show references] |