1 | sS exportSnippetID; |
2 | |
3 | svoid swingExportConcepts(fS desc) { |
4 | thread "Exporting" { |
5 | pcall-messagebox { |
6 | loading { |
7 | try { |
8 | swingExportConcepts_impl(desc); |
9 | } catch e { |
10 | if (containsIC(str(e), "Not your snippet")) { |
11 | if (!confirmOKCancel("Snippet " + exportSnippetID + " does not seem to belong to you. Maybe you're not logged in. Do you want to export to a new snippet?")) ret; |
12 | exportSnippetID = null; |
13 | save("exportSnippetID"); |
14 | swingExportConcepts_impl(desc); |
15 | } else rethrow(e); |
16 | } |
17 | } |
18 | } |
19 | } |
20 | } |
21 | |
22 | svoid swingExportConcepts_impl(S desc) { |
23 | if (mainConcepts.countConcepts() == 0) fail("Nothing to export (concepts not loaded?)"); |
24 | S text = mainConcepts.xfullgrab(); |
25 | if (match("exportable=f", text)) fail("Non-exportable concepts found"); |
26 | //print(javaTokWordWrap(text)); |
27 | print("Size: " + l(utf8(text))); |
28 | print(); |
29 | load("exportSnippetID"); |
30 | if (empty(exportSnippetID)) { |
31 | infoBox("Creating a snippet for you..."); |
32 | exportSnippetID = createSnippet(text, desc + " from " + computerID(), 53); |
33 | infoBox("Your snippet ID: " + exportSnippetID); |
34 | save("exportSnippetID"); |
35 | } else { |
36 | S oldMD5 = getSnippetMD5(exportSnippetID); |
37 | S newMD5 = md5(text); |
38 | if (eq(oldMD5, newMD5)) |
39 | infoBox("Snippet " + exportSnippetID + " already up to date!"); |
40 | else { |
41 | infoBox("Updating snippet: " + exportSnippetID); |
42 | editSnippet(exportSnippetID, text); |
43 | S actualMD5 = getSnippetMD5(exportSnippetID); |
44 | if (eq(actualMD5, newMD5)) |
45 | infoBox("Export to " + exportSnippetID + " complete (" + n(lUtf8(text), "bytes") + ")."); |
46 | else if (eq(actualMD5, oldMD5)) |
47 | infoBox("Export failed for unknown reason"); |
48 | else |
49 | infoBox("Hm. Export did something, but MD5 mismatch occurred."); |
50 | } |
51 | } |
52 | } |
Began life as a copy of #1007207
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: | #1007474 |
Snippet name: | swingExportConcepts |
Eternal ID of this version: | #1007474/7 |
Text MD5: | 8e887ddb769523da815ec44d83b9e0fb |
Author: | stefan |
Category: | javax / a.i. / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-04-06 14:46:43 |
Source code size: | 1901 bytes / 52 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 454 / 477 |
Version history: | 6 change(s) |
Referenced in: | [show references] |